|
|
@ -1,23 +1,7 @@
|
|
|
|
import { getUserInfo, getPermission } from '@/api/auth';
|
|
|
|
import { getUserInfo, getPermission, sendSmsCode, login } from '@/api/auth';
|
|
|
|
import { ElMessage } from '@/plugins/element-plus';
|
|
|
|
import { ElMessage } from '@/plugins/element-plus';
|
|
|
|
const sms = () => {
|
|
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
resolve(true);
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const login = () => {
|
|
|
|
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
resolve({
|
|
|
|
|
|
|
|
token: 'eyJhbGciOiJSUzI1NiJ9.eyJ1aWQiOjEzMjI1LCJwaG9uZSI6IjEzMjAyMDkwNjAxIiwibG9naW5UeXBlIjo1LCJ1c2VyTm8iOiIxMzIyNSIsIm5pY2tuYW1lIjoi5b-D5LmL5omA5ZCRIiwiZGVwdElkIjpudWxsLCJleHAiOjE2Nzg5NzI5NjksInVzZXJuYW1lIjoiTUNBLTMzYTkifQ.bDgxrGWUYW1iGLQidoj3q4lBXTlI0zKMBslIjN5LuvyLE4O8LPfFFYh33nAlevKuey_tqYQSWn0Cvm81Ywuksn70lGyy5-BEBbLUQCXaFKaWXujc2FzWFIvPHzAXfF16aUzyKkCppR5tfLDQz5cimLHAQBw24Ar69UCMiYJjN8E',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
import router, { reset as resetRoutes } from '@/router';
|
|
|
|
import router, { reset as resetRoutes } from '@/router';
|
|
|
|
const modules = import.meta.glob('../views/*/*.vue');
|
|
|
|
const viewComponents = import.meta.glob('../../views/**/*.vue');
|
|
|
|
const state = () => ({
|
|
|
|
const state = () => ({
|
|
|
|
userInfo: null,
|
|
|
|
userInfo: null,
|
|
|
|
permission: [],
|
|
|
|
permission: [],
|
|
|
@ -40,7 +24,7 @@ const mutations = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (!route.path.startsWith('/')) {
|
|
|
|
if (!route.path.startsWith('/')) {
|
|
|
|
route.path = parent.path + route.path;
|
|
|
|
route.path = parent.path + '/' + route.path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
route.meta.menu = route.path.replaceAll(/\/:[^?]+\?/g, '');
|
|
|
|
route.meta.menu = route.path.replaceAll(/\/:[^?]+\?/g, '');
|
|
|
|
let activeMenu = route.meta.activeMenu;
|
|
|
|
let activeMenu = route.meta.activeMenu;
|
|
|
@ -52,12 +36,15 @@ const mutations = {
|
|
|
|
if (route.component === 'Layout') {
|
|
|
|
if (route.component === 'Layout') {
|
|
|
|
route.component = () => import('@/layouts/default.vue');
|
|
|
|
route.component = () => import('@/layouts/default.vue');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let path = `../views/${route.component}`;
|
|
|
|
let path = `../../views/${route.component}`;
|
|
|
|
if (!path.endsWith('.vue')) {
|
|
|
|
if (!path.endsWith('.vue')) {
|
|
|
|
path += '.vue';
|
|
|
|
path += '.vue';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let alias = path.replace(/\.vue$/, '/index.vue');
|
|
|
|
let alias = path.replace(/\.vue$/, '/index.vue');
|
|
|
|
route.component = modules[path] || modules[alias];
|
|
|
|
route.component = viewComponents[path] || viewComponents[alias];
|
|
|
|
|
|
|
|
if (!route.component) {
|
|
|
|
|
|
|
|
route.component = () => import('@/views/global/404.vue');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
route.children = convert(item.children || [], route);
|
|
|
|
route.children = convert(item.children || [], route);
|
|
|
@ -66,12 +53,12 @@ const mutations = {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
state.permission = convert(data);
|
|
|
|
state.permission = convert(data);
|
|
|
|
// resetRoutes(state.permission);
|
|
|
|
resetRoutes(state.permission);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const actions = {
|
|
|
|
const actions = {
|
|
|
|
sms: async ({ commit }, data) => {
|
|
|
|
sms: async ({ commit }, data) => {
|
|
|
|
let res = await sms(data);
|
|
|
|
let res = await sendSmsCode(data);
|
|
|
|
if (res) {
|
|
|
|
if (res) {
|
|
|
|
ElMessage.success('验证码已发送');
|
|
|
|
ElMessage.success('验证码已发送');
|
|
|
|
commit('local/sendMessage', {}, { root: true });
|
|
|
|
commit('local/sendMessage', {}, { root: true });
|
|
|
@ -96,7 +83,7 @@ const actions = {
|
|
|
|
router.push({ name: 'Login' });
|
|
|
|
router.push({ name: 'Login' });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getPermission: async ({ commit }) => {
|
|
|
|
getPermission: async ({ commit }) => {
|
|
|
|
let res = await getPermission();
|
|
|
|
let res = await getPermission({ systemCode: 'msb_shop_admin' });
|
|
|
|
if (res) {
|
|
|
|
if (res) {
|
|
|
|
commit('setPermission', res);
|
|
|
|
commit('setPermission', res);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|