feat: 产品菜单路由权限
This commit is contained in:
@ -21,7 +21,7 @@ export function configAutoImport() {
|
|||||||
'@vueuse/core',
|
'@vueuse/core',
|
||||||
{
|
{
|
||||||
dayjs: [['default', 'dayjs']],
|
dayjs: [['default', 'dayjs']],
|
||||||
'lodash-es': ['cloneDeep', 'omit', 'pick', 'union', 'isNumber'],
|
'lodash-es': ['cloneDeep', 'omit', 'pick', 'union', 'isNumber', 'uniqBy'],
|
||||||
'@/hooks': ['useModal'],
|
'@/hooks': ['useModal'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
13
src/App.vue
13
src/App.vue
@ -8,6 +8,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from '@/stores';
|
import { useUserStore } from '@/stores';
|
||||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
|
||||||
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
||||||
|
|
||||||
@ -20,14 +21,18 @@ const redTheme = {
|
|||||||
colorLink: '#f5222d', // 链接色
|
colorLink: '#f5222d', // 链接色
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
// 初始化企业信息
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
const { isLogin, fetchUserInfo } = userStore;
|
const { isLogin, getUserInfo } = userStore;
|
||||||
const { updateEnterpriseInfo } = enterpriseStore;
|
const { getUserEnterpriseInfo } = enterpriseStore;
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
|
||||||
if (isLogin) {
|
if (isLogin) {
|
||||||
await fetchUserInfo();
|
await getUserInfo(); // 初始化用户信息
|
||||||
await updateEnterpriseInfo();
|
await getUserEnterpriseInfo(); // 初始化企业信息
|
||||||
|
sidebarStore.getUserNavbarMenuList(); // 初始化navbar菜单
|
||||||
|
userStore.getUserAllowAccessRoutes(); // 初始化允许访问的路由
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* @Author: 田鑫
|
* @Author: 田鑫
|
||||||
* @Date: 2023-02-17 11:58:44
|
* @Date: 2023-02-17 11:58:44
|
||||||
* @LastEditors: Please set LastEditors
|
* @LastEditors: rd 1344903914@qq.com
|
||||||
* @LastEditTime: 2025-07-05 17:59:59
|
* @LastEditTime: 2025-07-08 14:50:57
|
||||||
* @Description:
|
* @Description:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -42,13 +42,12 @@ export class Request {
|
|||||||
this.instance.interceptors.request.use(
|
this.instance.interceptors.request.use(
|
||||||
(config: AxiosRequestConfig) => {
|
(config: AxiosRequestConfig) => {
|
||||||
const store = useEnterpriseStore(pinia);
|
const store = useEnterpriseStore(pinia);
|
||||||
const enterprise = store.getEnterpriseInfo();
|
|
||||||
|
|
||||||
const token = localStorage.getItem('accessToken') as string;
|
const token = localStorage.getItem('accessToken') as string;
|
||||||
config.headers!.Authorization = token;
|
config.headers!.Authorization = token;
|
||||||
|
|
||||||
if (enterprise) {
|
if (store.enterpriseInfo) {
|
||||||
config.headers!['enterprise-id'] = enterprise.id;
|
config.headers!['enterprise-id'] = store.enterpriseInfo.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
|||||||
@ -67,7 +67,8 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
listenerRouteChange((newRoute) => {
|
listenerRouteChange((newRoute) => {
|
||||||
const { requiresAuth, activeMenu, hideInMenu } = newRoute.meta;
|
const { requiresAuth, activeMenu, hideInMenu } = newRoute.meta;
|
||||||
if (requiresAuth && (!hideInMenu || activeMenu)) {
|
// if (requiresAuth && (!hideInMenu || activeMenu)) {
|
||||||
|
if (!hideInMenu || activeMenu) {
|
||||||
const menuOpenKeys = findMenuOpenKeys((activeMenu || newRoute.name) as string);
|
const menuOpenKeys = findMenuOpenKeys((activeMenu || newRoute.name) as string);
|
||||||
const keySet = new Set([...menuOpenKeys, ...openKeys.value]);
|
const keySet = new Set([...menuOpenKeys, ...openKeys.value]);
|
||||||
openKeys.value = [...keySet];
|
openKeys.value = [...keySet];
|
||||||
|
|||||||
@ -18,7 +18,6 @@ const sidebarStore = useSidebarStore();
|
|||||||
const exitAccountModalRef = ref(null);
|
const exitAccountModalRef = ref(null);
|
||||||
// const selectedKey = ref([]);
|
// const selectedKey = ref([]);
|
||||||
|
|
||||||
// const enterpriseInfo = enterpriseStore.getEnterpriseInfo();
|
|
||||||
const selectedKey = computed(() => {
|
const selectedKey = computed(() => {
|
||||||
return [String(sidebarStore.activeMenuId)];
|
return [String(sidebarStore.activeMenuId)];
|
||||||
});
|
});
|
||||||
|
|||||||
13
src/permission/permission.ts
Normal file
13
src/permission/permission.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { useUserStore } from '@/stores/modules/user';
|
||||||
|
|
||||||
|
export function checkRoutePermission(routeName: string) {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const allowAccessRoutes = userStore.allowAccessRoutes;
|
||||||
|
|
||||||
|
if (!routeName) return false;
|
||||||
|
|
||||||
|
// console.log({ routeName, allowAccessRoutes });
|
||||||
|
const route = allowAccessRoutes.find((route) => route.name === routeName);
|
||||||
|
console.log({ route });
|
||||||
|
return !!route;
|
||||||
|
}
|
||||||
@ -5,6 +5,8 @@
|
|||||||
import type { Router } from 'vue-router';
|
import type { Router } from 'vue-router';
|
||||||
import NProgress from 'nprogress';
|
import NProgress from 'nprogress';
|
||||||
import { goUserLogin } from '@/utils/user';
|
import { goUserLogin } from '@/utils/user';
|
||||||
|
// import router from '@/router';
|
||||||
|
import { checkRoutePermission } from '@/permission/permission';
|
||||||
|
|
||||||
import { useUserStore } from '@/stores/modules/user';
|
import { useUserStore } from '@/stores/modules/user';
|
||||||
|
|
||||||
@ -13,15 +15,25 @@ export default function setupUserLoginInfoGuard(router: Router) {
|
|||||||
NProgress.start();
|
NProgress.start();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
const routeName = to?.name as string;
|
||||||
const requiresAuth = to?.meta?.requiresAuth || false;
|
const requiresAuth = to?.meta?.requiresAuth || false;
|
||||||
const isLogin = !!userStore.isLogin;
|
const requireLogin = to?.meta?.requireLogin || false;
|
||||||
|
|
||||||
if (requiresAuth && !isLogin) {
|
if (requireLogin && !userStore.isLogin) {
|
||||||
goUserLogin();
|
goUserLogin();
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requiresAuth) {
|
||||||
|
const hasPermission = checkRoutePermission(routeName);
|
||||||
|
if (!hasPermission) {
|
||||||
|
AMessage.error('您没有权限访问该页面');
|
||||||
|
next('/');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
router.afterEach((to) => {
|
router.afterEach((to) => {
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { createRouter, createWebHistory } from 'vue-router';
|
import { createRouter, createWebHistory } from 'vue-router';
|
||||||
import { appRoutes } from './routes';
|
import { appRoutes } from './routes';
|
||||||
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './routes/base';
|
import { NOT_FOUND_ROUTE } from './routes/base';
|
||||||
import NProgress from 'nprogress';
|
import NProgress from 'nprogress';
|
||||||
import 'nprogress/nprogress.css';
|
import 'nprogress/nprogress.css';
|
||||||
import { MENU_GROUP_IDS } from './constants';
|
import { MENU_GROUP_IDS } from './constants';
|
||||||
@ -21,6 +21,7 @@ export const router = createRouter({
|
|||||||
component: () => import('@/views/components/login'),
|
component: () => import('@/views/components/login'),
|
||||||
meta: {
|
meta: {
|
||||||
requiresAuth: false,
|
requiresAuth: false,
|
||||||
|
requireLogin: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -29,7 +30,8 @@ export const router = createRouter({
|
|||||||
component: () => import('@/views/components/workplace'),
|
component: () => import('@/views/components/workplace'),
|
||||||
meta: {
|
meta: {
|
||||||
hideSidebar: true,
|
hideSidebar: true,
|
||||||
requiresAuth: true,
|
requiresAuth: false,
|
||||||
|
requireLogin: true,
|
||||||
id: MENU_GROUP_IDS.WORK_BENCH_ID,
|
id: MENU_GROUP_IDS.WORK_BENCH_ID,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -37,20 +39,22 @@ export const router = createRouter({
|
|||||||
path: '/permission',
|
path: '/permission',
|
||||||
name: 'permission',
|
name: 'permission',
|
||||||
component: () => import('@/views/components/permission/choose-enterprise.vue'),
|
component: () => import('@/views/components/permission/choose-enterprise.vue'),
|
||||||
meta: {
|
|
||||||
requiresAuth: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/auth',
|
|
||||||
name: 'auth',
|
|
||||||
component: () => import('@/views/components/permission/auth.vue'),
|
|
||||||
meta: {
|
meta: {
|
||||||
requiresAuth: false,
|
requiresAuth: false,
|
||||||
|
requireLogin: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// path: '/auth',
|
||||||
|
// name: 'auth',
|
||||||
|
// component: () => import('@/views/components/permission/auth.vue'),
|
||||||
|
// meta: {
|
||||||
|
// requiresAuth: false,
|
||||||
|
// requireLogin: true,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
...appRoutes,
|
...appRoutes,
|
||||||
REDIRECT_MAIN,
|
// REDIRECT_MAIN,
|
||||||
NOT_FOUND_ROUTE,
|
NOT_FOUND_ROUTE,
|
||||||
],
|
],
|
||||||
scrollBehavior() {
|
scrollBehavior() {
|
||||||
|
|||||||
@ -1,28 +1,35 @@
|
|||||||
import type { RouteRecordRaw } from 'vue-router';
|
import type { RouteRecordRaw } from 'vue-router';
|
||||||
import { REDIRECT_ROUTE_NAME } from '@/router/constants';
|
import { REDIRECT_ROUTE_NAME } from '@/router/constants';
|
||||||
|
|
||||||
export const REDIRECT_MAIN: RouteRecordRaw = {
|
// export const REDIRECT_MAIN: RouteRecordRaw = {
|
||||||
path: '/redirect',
|
// path: '/redirect',
|
||||||
name: 'redirect',
|
// name: 'redirect',
|
||||||
meta: {
|
// meta: {
|
||||||
requiresAuth: true,
|
// requiresAuth: false,
|
||||||
hideInMenu: true,
|
// requireLogin: false,
|
||||||
},
|
// hideInMenu: true,
|
||||||
children: [
|
// },
|
||||||
{
|
// children: [
|
||||||
path: '/redirect/:path',
|
// {
|
||||||
name: REDIRECT_ROUTE_NAME,
|
// path: '/redirect/:path',
|
||||||
component: () => import('@/layouts/Basic.vue'),
|
// name: REDIRECT_ROUTE_NAME,
|
||||||
meta: {
|
// component: () => import('@/layouts/Basic.vue'),
|
||||||
requiresAuth: true,
|
// meta: {
|
||||||
hideInMenu: true,
|
// requiresAuth: false,
|
||||||
},
|
// requireLogin: false,
|
||||||
},
|
// hideInMenu: true,
|
||||||
],
|
// },
|
||||||
};
|
// },
|
||||||
|
// ],
|
||||||
|
// };
|
||||||
|
|
||||||
export const NOT_FOUND_ROUTE: RouteRecordRaw = {
|
export const NOT_FOUND_ROUTE: RouteRecordRaw = {
|
||||||
path: '/:pathMatch(.*)*',
|
path: '/:pathMatch(.*)*',
|
||||||
name: 'notFound',
|
name: 'notFound',
|
||||||
component: () => import('@/layouts/NotFound.vue'),
|
component: () => import('@/layouts/NotFound.vue'),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: false,
|
||||||
|
hideInMenu: true,
|
||||||
|
hideSidebar: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import type { RouteRecordNormalized } from 'vue-router';
|
import type { RouteRecordNormalized } from 'vue-router';
|
||||||
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './base';
|
// import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from './base';
|
||||||
import { MENU_GROUP_IDS } from '@/router/constants';
|
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||||
|
|
||||||
const modules = import.meta.glob('./modules/*.ts', { eager: true });
|
const modules = import.meta.glob('./modules/*.ts', { eager: true });
|
||||||
@ -17,6 +17,6 @@ function formatModules(_modules: any, result: RouteRecordNormalized[]) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const appRoutes: any[] = formatModules(modules, []);
|
export const appRoutes: RouteRecordNormalized[] = formatModules(modules, []);
|
||||||
|
|
||||||
// export const appExternalRoutes: RouteRecordNormalized[] = formatModules(externalModules, []);
|
// export const appExternalRoutes: RouteRecordNormalized[] = formatModules(externalModules, []);
|
||||||
|
|||||||
@ -15,8 +15,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
locale: '全域数据引擎',
|
locale: '全域数据引擎',
|
||||||
icon: IconBookmark,
|
icon: IconBookmark,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
|
||||||
id: MENU_GROUP_IDS.DATA_ENGINE_ID,
|
id: MENU_GROUP_IDS.DATA_ENGINE_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -26,6 +26,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '行业热门话题洞察',
|
locale: '行业热门话题洞察',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/components/dataEngine/hotTranslation.vue'),
|
component: () => import('@/views/components/dataEngine/hotTranslation.vue'),
|
||||||
@ -36,6 +37,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '行业词云',
|
locale: '行业词云',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/components/dataEngine/hotCloud.vue'),
|
component: () => import('@/views/components/dataEngine/hotCloud.vue'),
|
||||||
@ -46,6 +48,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '行业关键词动向',
|
locale: '行业关键词动向',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/components/dataEngine/keyWord.vue'),
|
component: () => import('@/views/components/dataEngine/keyWord.vue'),
|
||||||
@ -56,6 +59,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '用户痛点观察',
|
locale: '用户痛点观察',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/components/dataEngine/userPainPoints.vue'),
|
component: () => import('@/views/components/dataEngine/userPainPoints.vue'),
|
||||||
@ -66,6 +70,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '重点品牌动向',
|
locale: '重点品牌动向',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/components/dataEngine/keyBrandMovement.vue'),
|
component: () => import('@/views/components/dataEngine/keyBrandMovement.vue'),
|
||||||
@ -76,6 +81,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '用户画像',
|
locale: '用户画像',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/components/dataEngine/userPersona.vue'),
|
component: () => import('@/views/components/dataEngine/userPersona.vue'),
|
||||||
|
|||||||
@ -15,8 +15,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
locale: '管理中心',
|
locale: '管理中心',
|
||||||
icon: IconBookmark,
|
icon: IconBookmark,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
|
||||||
id: MENU_GROUP_IDS.MANAGEMENT_ID,
|
id: MENU_GROUP_IDS.MANAGEMENT_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -27,6 +27,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '个人信息',
|
locale: '个人信息',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -37,6 +38,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '企业信息',
|
locale: '企业信息',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -47,6 +49,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '账号管理',
|
locale: '账号管理',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -19,8 +19,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
locale: '品牌资产管理',
|
locale: '品牌资产管理',
|
||||||
icon: IconRepository,
|
icon: IconRepository,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
|
||||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -30,6 +30,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '品牌信息',
|
locale: '品牌信息',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/brands/brand-materials/index.vue'),
|
component: () => import('@/views/property-marketing/brands/brand-materials/index.vue'),
|
||||||
@ -44,8 +45,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
locale: '账号资源中心',
|
locale: '账号资源中心',
|
||||||
icon: IconMediaAccount,
|
icon: IconMediaAccount,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
|
||||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -55,6 +56,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '账号管理',
|
locale: '账号管理',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/media-account/account-manage'),
|
component: () => import('@/views/property-marketing/media-account/account-manage'),
|
||||||
@ -65,6 +67,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '账号数据看板',
|
locale: '账号数据看板',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/media-account/account-dashboard'),
|
component: () => import('@/views/property-marketing/media-account/account-dashboard'),
|
||||||
@ -75,6 +78,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '账号详情',
|
locale: '账号详情',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
hideInMenu: true,
|
hideInMenu: true,
|
||||||
activeMenu: 'MediaAccountAccountDashboard',
|
activeMenu: 'MediaAccountAccountDashboard',
|
||||||
@ -91,8 +95,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
locale: '投放资源中心',
|
locale: '投放资源中心',
|
||||||
icon: IconPutAccount,
|
icon: IconPutAccount,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
|
||||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -102,6 +106,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '账户管理',
|
locale: '账户管理',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/put-account/account-manage'),
|
component: () => import('@/views/property-marketing/put-account/account-manage'),
|
||||||
@ -112,6 +117,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '账户数据',
|
locale: '账户数据',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/put-account/account-data'),
|
component: () => import('@/views/property-marketing/put-account/account-data'),
|
||||||
@ -122,6 +128,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '投放表现分析',
|
locale: '投放表现分析',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/put-account/account-dashboard'),
|
component: () => import('@/views/property-marketing/put-account/account-dashboard'),
|
||||||
@ -132,6 +139,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '平台投放指南',
|
locale: '平台投放指南',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/put-account/investment-guidelines'),
|
component: () => import('@/views/property-marketing/put-account/investment-guidelines'),
|
||||||
@ -146,8 +154,8 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
locale: '智能方案管理',
|
locale: '智能方案管理',
|
||||||
icon: IconIntelligentSolution,
|
icon: IconIntelligentSolution,
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
requiresSidebar: true,
|
|
||||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
@ -157,6 +165,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '业务洞察报告',
|
locale: '业务洞察报告',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/intelligent-solution/businessAnalysisReport'),
|
component: () => import('@/views/property-marketing/intelligent-solution/businessAnalysisReport'),
|
||||||
@ -167,6 +176,7 @@ const COMPONENTS: AppRouteRecordRaw[] = [
|
|||||||
meta: {
|
meta: {
|
||||||
locale: '竟品对比报告',
|
locale: '竟品对比报告',
|
||||||
requiresAuth: true,
|
requiresAuth: true,
|
||||||
|
requireLogin: true,
|
||||||
roles: ['*'],
|
roles: ['*'],
|
||||||
},
|
},
|
||||||
component: () => import('@/views/property-marketing/intelligent-solution/competitiveProductAnalysisReport'),
|
component: () => import('@/views/property-marketing/intelligent-solution/competitiveProductAnalysisReport'),
|
||||||
|
|||||||
1
src/router/typeings.d.ts
vendored
1
src/router/typeings.d.ts
vendored
@ -14,5 +14,6 @@ declare module 'vue-router' {
|
|||||||
noAffix?: boolean; // if set true, the tag will not affix in the tab-bar
|
noAffix?: boolean; // if set true, the tag will not affix in the tab-bar
|
||||||
ignoreCache?: boolean; // if set true, the page will not be cached
|
ignoreCache?: boolean; // if set true, the page will not be cached
|
||||||
hideSidebar?: boolean;
|
hideSidebar?: boolean;
|
||||||
|
requireLogin?: boolean; // 是否需要登陆才能访问
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { fetchEnterpriseInfo } from '@/api/all/login';
|
import { fetchEnterpriseInfo } from '@/api/all/login';
|
||||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
import { useUserStore } from '@/stores/modules/user';
|
||||||
|
import { glsWithCatch, slsWithCatch, rlsWithCatch } from '@/utils/stroage';
|
||||||
|
|
||||||
interface EnterpriseInfo {
|
interface EnterpriseInfo {
|
||||||
id: number;
|
id: number;
|
||||||
@ -17,24 +19,14 @@ interface EnterpriseState {
|
|||||||
|
|
||||||
export const useEnterpriseStore = defineStore('enterprise', {
|
export const useEnterpriseStore = defineStore('enterprise', {
|
||||||
state: (): EnterpriseState => ({
|
state: (): EnterpriseState => ({
|
||||||
enterpriseInfo: (() => {
|
enterpriseInfo: (glsWithCatch('enterpriseInfo') && JSON.parse(glsWithCatch('enterpriseInfo') as string)) || null,
|
||||||
const stored = localStorage.getItem('enterpriseInfo');
|
|
||||||
if (stored) {
|
|
||||||
try {
|
|
||||||
return JSON.parse(stored) as EnterpriseInfo;
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
})(),
|
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setEnterpriseInfo(enterpriseInfo: EnterpriseInfo) {
|
setEnterpriseInfo(enterpriseInfo: EnterpriseInfo) {
|
||||||
this.enterpriseInfo = enterpriseInfo;
|
this.enterpriseInfo = enterpriseInfo;
|
||||||
localStorage.setItem('enterpriseInfo', JSON.stringify(enterpriseInfo));
|
slsWithCatch('enterpriseInfo', JSON.stringify(enterpriseInfo));
|
||||||
},
|
},
|
||||||
clearEnterpriseInfo() {
|
clearUserEnterpriseInfo() {
|
||||||
this.enterpriseInfo = null;
|
this.enterpriseInfo = null;
|
||||||
localStorage.removeItem('enterpriseInfo');
|
localStorage.removeItem('enterpriseInfo');
|
||||||
},
|
},
|
||||||
@ -53,17 +45,12 @@ export const useEnterpriseStore = defineStore('enterprise', {
|
|||||||
this.enterpriseInfo.used_sub_account_count++;
|
this.enterpriseInfo.used_sub_account_count++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getEnterpriseInfo(): EnterpriseInfo | null {
|
async getUserEnterpriseInfo() {
|
||||||
return this.enterpriseInfo;
|
if (this.enterpriseInfo) {
|
||||||
},
|
const { code, data } = await fetchEnterpriseInfo(this.enterpriseInfo!.id);
|
||||||
async updateEnterpriseInfo() {
|
|
||||||
const sidebarStore = useSidebarStore();
|
|
||||||
|
|
||||||
const res = await fetchEnterpriseInfo(this.enterpriseInfo!.id);
|
|
||||||
const { code, data } = res;
|
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
this.setEnterpriseInfo(data);
|
this.setEnterpriseInfo(data);
|
||||||
sidebarStore.getNavbarMenuList();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,15 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* @Author: rd 1344903914@qq.com
|
||||||
|
* @Date: 2025-07-08 11:22:05
|
||||||
|
* @LastEditors: rd 1344903914@qq.com
|
||||||
|
* @LastEditTime: 2025-07-08 14:06:41
|
||||||
|
* @FilePath: /lingji-work-fe/src/stores/modules/side-bar/constants.ts
|
||||||
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||||
|
*/
|
||||||
import { MENU_GROUP_IDS } from '@/router/constants';
|
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||||
export const MENU_LIST = [
|
export const MENU_LIST = [
|
||||||
{
|
{
|
||||||
id: MENU_GROUP_IDS.WORK_BENCH_ID,
|
id: MENU_GROUP_IDS.WORK_BENCH_ID,
|
||||||
name: '工作台',
|
name: '工作台',
|
||||||
pathName: 'Home',
|
pathName: 'Home',
|
||||||
|
requiresAuth: false,
|
||||||
permissionKey: '', // 权限key,如果为空,则表示该菜单不需要权限,与后端约定
|
permissionKey: '', // 权限key,如果为空,则表示该菜单不需要权限,与后端约定
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: MENU_GROUP_IDS.DATA_ENGINE_ID,
|
id: MENU_GROUP_IDS.DATA_ENGINE_ID,
|
||||||
name: '全域数据分析',
|
name: '全域数据分析',
|
||||||
permissionKey: 'data_analysis',
|
permissionKey: 'data_analysis',
|
||||||
|
requiresAuth: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: '行业热门话题洞察',
|
name: '行业热门话题洞察',
|
||||||
@ -41,6 +51,7 @@ export const MENU_LIST = [
|
|||||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||||
name: '营销资产中台',
|
name: '营销资产中台',
|
||||||
permissionKey: 'marketing_asset',
|
permissionKey: 'marketing_asset',
|
||||||
|
requiresAuth: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
name: '品牌资产管理',
|
name: '品牌资产管理',
|
||||||
|
|||||||
@ -11,12 +11,15 @@ import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
|||||||
interface sidebarState {
|
interface sidebarState {
|
||||||
activeMenuId: number | null;
|
activeMenuId: number | null;
|
||||||
menuList: any[];
|
menuList: any[];
|
||||||
|
allowAccessRoutes: any[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSidebarStore = defineStore('sidebar', {
|
export const useSidebarStore = defineStore('sidebar', {
|
||||||
state: (): sidebarState => ({
|
state: (): sidebarState => ({
|
||||||
activeMenuId: null,
|
activeMenuId: null,
|
||||||
menuList: [],
|
menuList: [],
|
||||||
|
|
||||||
|
allowAccessRoutes: [], // 允许访问的路由列表
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
clearActiveMenuId() {
|
clearActiveMenuId() {
|
||||||
@ -25,12 +28,14 @@ export const useSidebarStore = defineStore('sidebar', {
|
|||||||
setActiveMenuId(id: number) {
|
setActiveMenuId(id: number) {
|
||||||
this.activeMenuId = id;
|
this.activeMenuId = id;
|
||||||
},
|
},
|
||||||
|
clearUserNavbarMenuList() {
|
||||||
|
this.menuList = [];
|
||||||
|
},
|
||||||
// navbar菜单列表由企业对应权限决定
|
// navbar菜单列表由企业对应权限决定
|
||||||
getNavbarMenuList() {
|
getUserNavbarMenuList() {
|
||||||
const enterpriseStore = useEnterpriseStore();
|
const enterpriseStore = useEnterpriseStore();
|
||||||
const enterpriseInfo = enterpriseStore.getEnterpriseInfo();
|
|
||||||
this.menuList = MENU_LIST.filter(
|
this.menuList = MENU_LIST.filter(
|
||||||
(item) => !item.permissionKey || enterpriseInfo?.permissions?.includes(item.permissionKey),
|
(item) => !item.permissionKey || enterpriseStore.enterpriseInfo?.permissions?.includes(item.permissionKey),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
// 根据当前路由自动设置 activeMenuId
|
// 根据当前路由自动设置 activeMenuId
|
||||||
@ -61,7 +66,7 @@ export const useSidebarStore = defineStore('sidebar', {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuId = findMenuGroup(appRoutes);
|
const menuId = findMenuGroup(appRoutes as any);
|
||||||
if (menuId !== null) {
|
if (menuId !== null) {
|
||||||
this.activeMenuId = menuId;
|
this.activeMenuId = menuId;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
|
import type { RouteRecordNormalized } from 'vue-router';
|
||||||
|
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { fetchProfileInfo } from '@/api/all/login';
|
import { fetchProfileInfo } from '@/api/all/login';
|
||||||
|
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||||
|
import router from '@/router';
|
||||||
|
import { glsWithCatch, slsWithCatch, rlsWithCatch } from '@/utils/stroage';
|
||||||
|
|
||||||
interface UserInfo {
|
interface UserInfo {
|
||||||
id: number;
|
id: number;
|
||||||
@ -10,16 +15,10 @@ interface UserInfo {
|
|||||||
// 添加其他用户属性...
|
// 添加其他用户属性...
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CompanyInfo {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
// 添加其他公司属性...
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UserState {
|
interface UserState {
|
||||||
token: string;
|
token: string;
|
||||||
userInfo: UserInfo | null;
|
userInfo: UserInfo | null;
|
||||||
companyInfo: CompanyInfo | null;
|
allowAccessRoutes: RouteRecordNormalized[];
|
||||||
// isLogin: boolean;
|
// isLogin: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,9 +30,10 @@ interface UserInfo {
|
|||||||
|
|
||||||
export const useUserStore = defineStore('user', {
|
export const useUserStore = defineStore('user', {
|
||||||
state: (): UserState => ({
|
state: (): UserState => ({
|
||||||
token: localStorage.getItem('accessToken') || '',
|
token: glsWithCatch('accessToken') || '',
|
||||||
userInfo: null,
|
userInfo: (glsWithCatch('userInfo') && JSON.parse(glsWithCatch('userInfo') as string)) || null,
|
||||||
companyInfo: null,
|
allowAccessRoutes:
|
||||||
|
(glsWithCatch('allowAccessRoutes') && JSON.parse(glsWithCatch('allowAccessRoutes') as string)) || [], // 允许访问的路由列表
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
isLogin(): boolean {
|
isLogin(): boolean {
|
||||||
@ -44,12 +44,12 @@ export const useUserStore = defineStore('user', {
|
|||||||
// 设置 Token
|
// 设置 Token
|
||||||
setToken(token: string) {
|
setToken(token: string) {
|
||||||
this.token = `Bearer ${token}`;
|
this.token = `Bearer ${token}`;
|
||||||
localStorage.setItem('accessToken', this.token);
|
slsWithCatch('accessToken', this.token);
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteToken() {
|
deleteToken() {
|
||||||
this.token = '';
|
this.token = '';
|
||||||
localStorage.removeItem('accessToken');
|
rlsWithCatch('accessToken');
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取 Token
|
// 获取 Token
|
||||||
@ -60,14 +60,54 @@ export const useUserStore = defineStore('user', {
|
|||||||
// 设置用户信息
|
// 设置用户信息
|
||||||
setUserInfo(userInfo: UserInfo | null) {
|
setUserInfo(userInfo: UserInfo | null) {
|
||||||
this.userInfo = userInfo;
|
this.userInfo = userInfo;
|
||||||
|
slsWithCatch('userInfo', JSON.stringify(userInfo));
|
||||||
|
},
|
||||||
|
clearUserInfo() {
|
||||||
|
this.userInfo = null;
|
||||||
|
rlsWithCatch('userInfo');
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
async fetchUserInfo() {
|
async getUserInfo() {
|
||||||
const { code, data } = await fetchProfileInfo();
|
const { code, data } = await fetchProfileInfo();
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
this.setUserInfo(data);
|
this.setUserInfo(data);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clearUserAllowAccessRoutes() {
|
||||||
|
this.allowAccessRoutes = [];
|
||||||
|
rlsWithCatch('allowAccessRoutes');
|
||||||
|
},
|
||||||
|
getUserAllowAccessRoutes() {
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
const menuList = sidebarStore.menuList;
|
||||||
|
|
||||||
|
const appRoutes = router.getRoutes();
|
||||||
|
|
||||||
|
appRoutes.forEach((route: any) => {
|
||||||
|
if (!route.meta?.requiresAuth) {
|
||||||
|
this.allowAccessRoutes.push(route);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
menuList.forEach((item) => {
|
||||||
|
if (item.children && item.children.length > 0) {
|
||||||
|
item.children.forEach((child: any) => {
|
||||||
|
const matchedRoute = appRoutes.find((route: any) => route.name === child.pathName);
|
||||||
|
if (matchedRoute) {
|
||||||
|
this.allowAccessRoutes.push(matchedRoute);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const matchedRoute = appRoutes.find((route: any) => route.name === item.pathName);
|
||||||
|
if (matchedRoute) {
|
||||||
|
this.allowAccessRoutes.push(matchedRoute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.allowAccessRoutes = uniqBy(this.allowAccessRoutes, 'name');
|
||||||
|
slsWithCatch('allowAccessRoutes', JSON.stringify(this.allowAccessRoutes));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
47
src/utils/stroage.ts
Normal file
47
src/utils/stroage.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
export const glsWithCatch = (key: string) => {
|
||||||
|
try {
|
||||||
|
return localStorage?.getItem(key);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const slsWithCatch = (key: string, value: any) => {
|
||||||
|
try {
|
||||||
|
localStorage?.setItem(key, value);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const rlsWithCatch = (key: string) => {
|
||||||
|
try {
|
||||||
|
localStorage?.removeItem(key);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const gssWithCatch = (key: string) => {
|
||||||
|
try {
|
||||||
|
return sessionStorage?.getItem(key);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const sssWithCatch = (key: string, value: any) => {
|
||||||
|
try {
|
||||||
|
sessionStorage?.setItem(key, value);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const rssWithCatch = (key: string) => {
|
||||||
|
try {
|
||||||
|
sessionStorage?.removeItem(key);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -15,6 +15,15 @@ export function goUserLogin(query?: any) {
|
|||||||
|
|
||||||
// 登录处理
|
// 登录处理
|
||||||
export async function handleUserLogin() {
|
export async function handleUserLogin() {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const enterpriseStore = useEnterpriseStore();
|
||||||
|
const sidebarStore = useSidebarStore();
|
||||||
|
|
||||||
|
await userStore.getUserInfo(); // 初始化用户信息
|
||||||
|
await enterpriseStore.getUserEnterpriseInfo(); // 初始化企业信息
|
||||||
|
sidebarStore.getUserNavbarMenuList(); // 初始化navbar菜单
|
||||||
|
userStore.getUserAllowAccessRoutes(); // 初始化允许访问的路由
|
||||||
|
|
||||||
handleUserHome();
|
handleUserHome();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,9 +37,13 @@ export function handleUserLogout() {
|
|||||||
const enterpriseStore = useEnterpriseStore();
|
const enterpriseStore = useEnterpriseStore();
|
||||||
const sidebarStore = useSidebarStore();
|
const sidebarStore = useSidebarStore();
|
||||||
|
|
||||||
userStore.deleteToken();
|
userStore.clearUserInfo();
|
||||||
enterpriseStore.clearEnterpriseInfo();
|
enterpriseStore.clearUserEnterpriseInfo();
|
||||||
|
sidebarStore.clearUserNavbarMenuList();
|
||||||
|
userStore.clearUserAllowAccessRoutes();
|
||||||
|
|
||||||
sidebarStore.clearActiveMenuId();
|
sidebarStore.clearActiveMenuId();
|
||||||
|
userStore.deleteToken();
|
||||||
|
|
||||||
goUserLogin();
|
goUserLogin();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -225,7 +225,6 @@ const clearError = (field: string) => {
|
|||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
|
|
||||||
await enterpriseStore.updateEnterpriseInfo();
|
|
||||||
handleUserLogin();
|
handleUserLogin();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -273,7 +272,6 @@ const getProfileInfo = async () => {
|
|||||||
|
|
||||||
if (enterprises.length > 0) {
|
if (enterprises.length > 0) {
|
||||||
if (enterprises.length === 1) {
|
if (enterprises.length === 1) {
|
||||||
await enterpriseStore.updateEnterpriseInfo();
|
|
||||||
handleUserLogin();
|
handleUserLogin();
|
||||||
} else {
|
} else {
|
||||||
// 多个企业时候需要弹窗让用户选择企业
|
// 多个企业时候需要弹窗让用户选择企业
|
||||||
|
|||||||
@ -99,7 +99,7 @@ const addAccountVisible = ref(false);
|
|||||||
const deleteVisible = ref(false);
|
const deleteVisible = ref(false);
|
||||||
const deleteTitle = ref('');
|
const deleteTitle = ref('');
|
||||||
|
|
||||||
const enterpriseInfo = store.getEnterpriseInfo();
|
const enterpriseInfo = store.enterpriseInfo;
|
||||||
|
|
||||||
const okText = computed(() => {
|
const okText = computed(() => {
|
||||||
if (!canAddAccount.value) {
|
if (!canAddAccount.value) {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ const form = reactive({
|
|||||||
name: '',
|
name: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const enterpriseInfo = store.getEnterpriseInfo();
|
const enterpriseInfo = store.enterpriseInfo;
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -102,7 +102,7 @@ const enterpriseStore = useEnterpriseStore();
|
|||||||
const handleTrial = async (id: any) => {
|
const handleTrial = async (id: any) => {
|
||||||
const { code } = await trialProduct(id);
|
const { code } = await trialProduct(id);
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
enterpriseStore.updateEnterpriseInfo();
|
enterpriseStore.getUserEnterpriseInfo();
|
||||||
AMessage.success('试用成功!');
|
AMessage.success('试用成功!');
|
||||||
emit('refresh');
|
emit('refresh');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -191,7 +191,6 @@ const getHealthData = async () => {
|
|||||||
const { code, data } = await getMediaAccountsHealth();
|
const { code, data } = await getMediaAccountsHealth();
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
healthData.value = data;
|
healthData.value = data;
|
||||||
console.log(healthData.value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const getAccountData = async () => {
|
const getAccountData = async () => {
|
||||||
|
|||||||
@ -40,7 +40,8 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
// 目标地址
|
// 目标地址
|
||||||
target: 'https://lingjiapi.lvfunai.com/api',
|
// target: 'https://lingjiapi.lvfunai.com/api',
|
||||||
|
target: 'http://192.168.40.12/api',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user