管理端
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {ref} from "vue";
|
||||
import mockRoutes from './mock.js';
|
||||
import {mockRoutes1, mockRoutes2} from './mock.js';
|
||||
import router from "../../router/index.js";
|
||||
import generateRouter from "../../router/generateRouter.js";
|
||||
|
||||
@@ -21,19 +21,36 @@ export const useSystemStore = defineStore("SystemStore", () => {
|
||||
await router.replace(router.currentRoute.value.fullPath);
|
||||
}
|
||||
|
||||
const setRouter = async () => {
|
||||
const setRouter = async (_isRoot) => {
|
||||
isRoot.value = _isRoot;
|
||||
|
||||
RoutesTemp.value.length = 0;
|
||||
// 请求资源 mockRoutes
|
||||
const routes = generateRouter(mockRoutes);
|
||||
RoutesTemp.value.push(...mockRoutes);
|
||||
const routes = generateRouter(isRoot.value ? mockRoutes2 : mockRoutes1);
|
||||
RoutesTemp.value.push(...(isRoot.value ? mockRoutes2 : mockRoutes1));
|
||||
await installRoute();
|
||||
}
|
||||
|
||||
const clearRouter = async () => {
|
||||
const routes = generateRouter(RoutesTemp.value);
|
||||
RoutesTemp.value.length = 0;
|
||||
router.removeRoute('home');
|
||||
router.addRoute({
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: () => import('../../pages/layout/index.vue'),
|
||||
redirect: `/home/${routes[0].path}`,
|
||||
children: []
|
||||
});
|
||||
await router.replace(router.currentRoute.value.fullPath);
|
||||
}
|
||||
|
||||
return {
|
||||
isRoot,
|
||||
RoutesTemp,
|
||||
setRouter,
|
||||
installRoute,
|
||||
clearRouter,
|
||||
}
|
||||
}, {
|
||||
persist: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const mockRoutes = [
|
||||
const mockRoutes1 = [
|
||||
{
|
||||
path: 'task-center',
|
||||
name: 'task-center',
|
||||
@@ -102,7 +102,8 @@ const mockRoutes = [
|
||||
title: '数据看板',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '数据看板'
|
||||
name: '数据看板',
|
||||
hidden: true,
|
||||
},
|
||||
component: 'data-board',
|
||||
},
|
||||
@@ -204,4 +205,240 @@ const mockRoutes = [
|
||||
}
|
||||
];
|
||||
|
||||
export default mockRoutes;
|
||||
const mockRoutes2 = [
|
||||
{
|
||||
path: 'manage-reward-mission',
|
||||
name: 'manage-reward-mission',
|
||||
title: '悬赏任务',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '悬赏任务'
|
||||
},
|
||||
component: 'manage-reward-mission',
|
||||
children: [
|
||||
{
|
||||
path: 'task-review',
|
||||
name: 'task-review',
|
||||
title: '任务审核',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '任务审核'
|
||||
},
|
||||
component: 'task-review',
|
||||
},
|
||||
{
|
||||
path: 'subtask-review',
|
||||
name: 'subtask-review',
|
||||
title: '子任务审核',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '子任务审核'
|
||||
},
|
||||
component: 'subtask-review',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'message-center',
|
||||
name: 'message-center',
|
||||
title: '消息中心',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '消息中心'
|
||||
},
|
||||
component: 'message-center',
|
||||
children: [
|
||||
{
|
||||
path: 'message-review',
|
||||
name: 'message-review',
|
||||
title: '消息审核',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '消息审核'
|
||||
},
|
||||
component: 'message-review',
|
||||
},
|
||||
{
|
||||
path: 'exemption-from-audit-review',
|
||||
name: 'exemption-from-audit-review',
|
||||
title: '免审审核',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '免审审核'
|
||||
},
|
||||
component: 'subtask-review',
|
||||
},
|
||||
{
|
||||
path: 'platform-intervention',
|
||||
name: 'platform-intervention',
|
||||
title: '平台介入',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '平台介入'
|
||||
},
|
||||
component: 'platform-intervention',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'fund',
|
||||
name: 'fund',
|
||||
title: '资金',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '资金'
|
||||
},
|
||||
component: 'fund',
|
||||
children: [
|
||||
{
|
||||
path: 'fund-management-business',
|
||||
name: 'fund-management-business',
|
||||
title: '资金管理(商)',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '资金管理(商)'
|
||||
},
|
||||
component: 'fund-management-business',
|
||||
},
|
||||
{
|
||||
path: 'fund-management-expert',
|
||||
name: 'fund-management-expert',
|
||||
title: '资金管理(达)',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '资金管理(达)'
|
||||
},
|
||||
component: 'fund-management-expert',
|
||||
},
|
||||
{
|
||||
path: 'withdrawal-information',
|
||||
name: 'withdrawal-information',
|
||||
title: '提现信息',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '提现信息'
|
||||
},
|
||||
component: 'withdrawal-information',
|
||||
},
|
||||
{
|
||||
path: 'financial-overview',
|
||||
name: 'financial-overview',
|
||||
title: '资金概览',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '资金概览'
|
||||
},
|
||||
component: 'financial-overview',
|
||||
},
|
||||
{
|
||||
path: 'payment-management',
|
||||
name: 'payment-management',
|
||||
title: '打款管理',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '打款管理'
|
||||
},
|
||||
component: 'payment-management',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'account-management',
|
||||
name: 'account-management',
|
||||
title: '账号管理',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '账号管理'
|
||||
},
|
||||
component: 'account-management',
|
||||
children: [
|
||||
{
|
||||
path: 'merchant-account',
|
||||
name: 'merchant-account',
|
||||
title: '商家账号',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '商家账号'
|
||||
},
|
||||
component: 'merchant-account',
|
||||
},
|
||||
{
|
||||
path: 'expert-account',
|
||||
name: 'expert-account',
|
||||
title: '达人账号',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '达人账号'
|
||||
},
|
||||
component: 'expert-account',
|
||||
},
|
||||
{
|
||||
path: 'promoted-accounts',
|
||||
name: 'promoted-accounts',
|
||||
title: '推广账号',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '推广账号'
|
||||
},
|
||||
component: 'promoted-accounts',
|
||||
},
|
||||
{
|
||||
path: 'blackout-records',
|
||||
name: 'blackout-records',
|
||||
title: '拉黑记录',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '拉黑记录'
|
||||
},
|
||||
component: 'blackout-records',
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'manage-expert-management',
|
||||
name: 'manage-expert-management',
|
||||
title: '资金',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '达人端管理'
|
||||
},
|
||||
component: 'manage-expert-management',
|
||||
children: [
|
||||
{
|
||||
path: 'expert-end-materials',
|
||||
name: 'expert-end-materials',
|
||||
title: '达人端物料',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '达人端物料'
|
||||
},
|
||||
component: 'expert-end-materials',
|
||||
},
|
||||
{
|
||||
path: 'task-sorting',
|
||||
name: 'task-sorting',
|
||||
title: '任务排序',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '任务排序'
|
||||
},
|
||||
component: 'task-sorting',
|
||||
},
|
||||
{
|
||||
path: 'team-complaints',
|
||||
name: 'team-complaints',
|
||||
title: '团队投诉',
|
||||
icon: '',
|
||||
meta: {
|
||||
name: '团队投诉'
|
||||
},
|
||||
component: 'team-complaints',
|
||||
},
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export {
|
||||
mockRoutes1,
|
||||
mockRoutes2
|
||||
};
|
||||
|
||||
@@ -7,19 +7,26 @@ export const useUserStore = defineStore("UserStore", () => {
|
||||
const isLogin = ref(false);
|
||||
const userInfo = ref(null);
|
||||
|
||||
const login = async (from) => {
|
||||
const login = async (isRoot = false) => {
|
||||
// 请求
|
||||
isLogin.value = true;
|
||||
// 获取并安装路由
|
||||
const { setRouter } = useSystemStore();
|
||||
await setRouter();
|
||||
await setRouter(isRoot);
|
||||
// 跳转
|
||||
await router.push('/home');
|
||||
}
|
||||
|
||||
const logout = async () => {
|
||||
isLogin.value = false;
|
||||
const { clearRouter } = useSystemStore();
|
||||
await clearRouter();
|
||||
}
|
||||
return {
|
||||
isLogin,
|
||||
userInfo,
|
||||
login,
|
||||
logout,
|
||||
}
|
||||
}, {
|
||||
persist: {
|
||||
|
||||
Reference in New Issue
Block a user