init:修复一些bug
This commit is contained in:
parent
64ee8a76c9
commit
d31b2388aa
|
|
@ -39,23 +39,9 @@ export default [
|
||||||
url: `/mock/user/info`,
|
url: `/mock/user/info`,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
response: ({ body }) => {
|
response: ({ body }) => {
|
||||||
const { token } = body
|
return {
|
||||||
const info = users.find(user => {
|
code: 200,
|
||||||
return user.token === token
|
data: users[0],
|
||||||
}).info
|
|
||||||
if (info) {
|
|
||||||
return {
|
|
||||||
code: 200,
|
|
||||||
data: {
|
|
||||||
info: info
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
code: 403,
|
|
||||||
data: {},
|
|
||||||
msg: '无访问权限'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { createApp,App as Vue } from 'vue'
|
import { createApp,App as Vue } from 'vue'
|
||||||
import ElementPlus from 'element-plus'
|
import ElementPlus from 'element-plus'
|
||||||
console.log(store.state.user.token)
|
|
||||||
// import 'virtual:svg-icons-register'
|
// import 'virtual:svg-icons-register'
|
||||||
import 'element-plus/lib/theme-chalk/index.css'
|
import 'element-plus/lib/theme-chalk/index.css'
|
||||||
import 'element-plus/lib/theme-chalk/display.css' // 引入基于断点的隐藏类
|
import 'element-plus/lib/theme-chalk/display.css' // 引入基于断点的隐藏类
|
||||||
|
|
@ -9,17 +8,13 @@ import './assets/style/common.scss' // 公共css
|
||||||
import './theme/modules/chinese/index.scss'
|
import './theme/modules/chinese/index.scss'
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
console.log(store.state.user.token)
|
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
import md5 from 'js-md5';
|
import md5 from 'js-md5';
|
||||||
import i18n from './locale'
|
import i18n from './locale'
|
||||||
console.log(store.state.user.token)
|
|
||||||
import SvgIcon from './components/svgIcon.vue'
|
import SvgIcon from './components/svgIcon.vue'
|
||||||
import draggable from 'vuedraggable'
|
import draggable from 'vuedraggable'
|
||||||
import {renderWithQiankun,qiankunWindow,QiankunProps} from "vite-plugin-qiankun/dist/helper"
|
import {renderWithQiankun,qiankunWindow,QiankunProps} from "vite-plugin-qiankun/dist/helper"
|
||||||
import app from "@/store/modules/app";
|
|
||||||
console.log(store.state.user.token)
|
|
||||||
let instance:any = null
|
let instance:any = null
|
||||||
const render = (props:QiankunProps={})=>{
|
const render = (props:QiankunProps={})=>{
|
||||||
const {container} = props
|
const {container} = props
|
||||||
|
|
@ -58,7 +53,7 @@ const initQianKun = ()=>{
|
||||||
|
|
||||||
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQianKun() : render()
|
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQianKun() : render()
|
||||||
console.log('__POWERED_BY_QIANKUN__:',qiankunWindow.__POWERED_BY_QIANKUN__);
|
console.log('__POWERED_BY_QIANKUN__:',qiankunWindow.__POWERED_BY_QIANKUN__);
|
||||||
export function mount(props){
|
export function mount(props:any){
|
||||||
console.log('基座下发的能力:', props);
|
console.log('基座下发的能力:', props);
|
||||||
render(props)
|
render(props)
|
||||||
// return new Promise(((resolve, reject) => {
|
// return new Promise(((resolve, reject) => {
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,7 @@ const asyncRoutes: RouteRecordRaw[] = [
|
||||||
...Component,
|
...Component,
|
||||||
...Pages,
|
...Pages,
|
||||||
...SystemManage,
|
...SystemManage,
|
||||||
...Print,
|
...Print
|
||||||
...routess
|
|
||||||
];
|
];
|
||||||
// 动态路由的权限新增,供登录后调用
|
// 动态路由的权限新增,供登录后调用
|
||||||
export async function addRoutes() {
|
export async function addRoutes() {
|
||||||
|
|
|
||||||
|
|
@ -27,14 +27,14 @@ const route = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// path: "/login",
|
||||||
|
// component: createNameComponent(() => import("@/views/system/login.vue")),
|
||||||
|
// hideMenu: true,
|
||||||
|
// meta: { title: "message.system.login", hideTabs: true },
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
path: "/login",
|
path: "/login",
|
||||||
component: createNameComponent(() => import("@/views/system/login.vue")),
|
|
||||||
hideMenu: true,
|
|
||||||
meta: { title: "message.system.login", hideTabs: true },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/userlogin",
|
|
||||||
component: createNameComponent(() => import("@/views/system/userLogin.vue")),
|
component: createNameComponent(() => import("@/views/system/userLogin.vue")),
|
||||||
hideMenu: true,
|
hideMenu: true,
|
||||||
meta: { title: "message.system.login", hideTabs: true },
|
meta: { title: "message.system.login", hideTabs: true },
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ Object.keys(files).forEach((c: string) => {
|
||||||
const moduleName: string = c.replace(/^\.\/(.*)\/(.*)\.\w+$/, "$2");
|
const moduleName: string = c.replace(/^\.\/(.*)\/(.*)\.\w+$/, "$2");
|
||||||
modules[moduleName] = module;
|
modules[moduleName] = module;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 这是一个vuex本地存储插件,默认把vuex所有数据都做存储了
|
// 这是一个vuex本地存储插件,默认把vuex所有数据都做存储了
|
||||||
// local代表存储在localStorage里面,进行永久存储
|
// local代表存储在localStorage里面,进行永久存储
|
||||||
// session代表存储在sessionStorage里面,进行临时存储
|
// session代表存储在sessionStorage里面,进行临时存储
|
||||||
|
|
@ -32,7 +31,6 @@ const persistent = Persistent({
|
||||||
session: [],
|
session: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default createStore<RootState>({
|
export default createStore<RootState>({
|
||||||
modules: {
|
modules: {
|
||||||
...modules,
|
...modules,
|
||||||
|
|
@ -40,3 +38,4 @@ export default createStore<RootState>({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
plugins: debug ? [createLogger(), persistent] : [persistent],
|
plugins: debug ? [createLogger(), persistent] : [persistent],
|
||||||
});
|
});
|
||||||
|
console.log(modules.user.token)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { loginApi, getInfoApi, loginOutApi } from "@/api/user";
|
import {loginApi, getInfoApi, loginOutApi, login} from "@/api/user";
|
||||||
import { ActionContext } from "vuex";
|
import { ActionContext } from "vuex";
|
||||||
|
|
||||||
export interface userState {
|
export interface userState {
|
||||||
|
|
@ -21,7 +21,6 @@ const getters = {
|
||||||
// mutations
|
// mutations
|
||||||
const mutations = {
|
const mutations = {
|
||||||
tokenChange(state: userState, token: string) {
|
tokenChange(state: userState, token: string) {
|
||||||
debugger
|
|
||||||
state.token = token;
|
state.token = token;
|
||||||
},
|
},
|
||||||
infoChange(state: userState, info: object) {
|
infoChange(state: userState, info: object) {
|
||||||
|
|
@ -37,8 +36,7 @@ const actions = {
|
||||||
params: any
|
params: any
|
||||||
) {
|
) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
debugger
|
login(params)
|
||||||
loginApi(params)
|
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
commit("tokenChange", res.data.token);
|
commit("tokenChange", res.data.token);
|
||||||
|
|
@ -53,7 +51,6 @@ const actions = {
|
||||||
},
|
},
|
||||||
// get user info after user logined
|
// get user info after user logined
|
||||||
getInfo({ commit }: ActionContext<userState, userState>, params: any) {
|
getInfo({ commit }: ActionContext<userState, userState>, params: any) {
|
||||||
debugger
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
getInfoApi(params).then((res) => {
|
getInfoApi(params).then((res) => {
|
||||||
commit("infoChange", res.data.info);
|
commit("infoChange", res.data.info);
|
||||||
|
|
|
||||||
|
|
@ -235,6 +235,8 @@ import banner from "@/assets/images/banner.png";
|
||||||
import {login} from "@/api/user";
|
import {login} from "@/api/user";
|
||||||
import router, {addRoutes} from "@/router";
|
import router, {addRoutes} from "@/router";
|
||||||
import {RouteLocationRaw, useRoute} from "vue-router";
|
import {RouteLocationRaw, useRoute} from "vue-router";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
import store from "@/store";
|
||||||
// import verify from './verify.png'
|
// import verify from './verify.png'
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -353,7 +355,6 @@ export default defineComponent({
|
||||||
const isMssages: any = ref(false)
|
const isMssages: any = ref(false)
|
||||||
const setState = (state: Boolean) => {
|
const setState = (state: Boolean) => {
|
||||||
isLogin.value = state
|
isLogin.value = state
|
||||||
console.log(isLogin)
|
|
||||||
}
|
}
|
||||||
const setMssages = (state: Boolean) => {
|
const setMssages = (state: Boolean) => {
|
||||||
isMssages.value = state
|
isMssages.value = state
|
||||||
|
|
@ -365,21 +366,27 @@ export default defineComponent({
|
||||||
formWrap.validate((valid: boolean) => {
|
formWrap.validate((valid: boolean) => {
|
||||||
console.log(valid)
|
console.log(valid)
|
||||||
if (valid) {
|
if (valid) {
|
||||||
login({
|
store
|
||||||
type: "user",
|
.dispatch("user/login", {
|
||||||
password: formSubmit.form.password,
|
type: "user",
|
||||||
name: formSubmit.form.name,
|
password: formSubmit.form.password,
|
||||||
// code: formSubmit.register.code
|
name: formSubmit.form.name,
|
||||||
}).then(async (res: any) => {
|
// code: formSubmit.register.code
|
||||||
console.log(res)
|
})
|
||||||
await addRoutes();
|
.then(async () => {
|
||||||
await router.push(
|
ElMessage.success({
|
||||||
(route.query.redirect as RouteLocationRaw) || "/"
|
message: "登录成功",
|
||||||
);
|
type: "success",
|
||||||
})
|
showClose: true,
|
||||||
|
duration: 1000,
|
||||||
|
});
|
||||||
|
await addRoutes();
|
||||||
|
await router.push(
|
||||||
|
(route.query.redirect as RouteLocationRaw) || "/"
|
||||||
|
);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log(11111111)
|
|
||||||
}
|
}
|
||||||
const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => {
|
const submitForm = (formEl: InstanceType<typeof ElForm> | undefined) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue