提交 2a78f8d8 authored 作者: 王鹏飞's avatar 王鹏飞

feat: 修改菜单通过接口控制显示隐藏

上级 db1cfddf
......@@ -151,3 +151,8 @@ export function getCategoryList(params?: { name?: string }) {
export function getProductList(params?: { name?: string }) {
return httpRequest.get('/api/lab/v1/experiment/live-commodity/list', { params })
}
// 获取当前实验下的所有权限 (实验营销配置)
export function getAuth() {
return httpRequest.get('/api/lab/v1/experiment/auth/all')
}
......@@ -15,6 +15,11 @@ const routes: RouteRecordRaw[] = [
{ path: 'view', component: () => import('./views/Demo.vue'), props: { isView: true } },
],
},
{
path: '/one/live/test/view',
component: () => import('./views/Demo.vue'),
props: { isView: true },
},
]
export { routes }
......@@ -3,11 +3,11 @@ import { useUserStore } from '@/stores/user'
const router = createRouter({
history: createWebHistory(),
routes: [{ path: '/:pathMatch(.*)*', redirect: '/' }]
routes: [{ path: '/:pathMatch(.*)*', redirect: '/' }],
})
router.beforeEach(async (to, from, next) => {
const whiteList = ['/401']
const whiteList = ['/401', '/one/live/test/view']
const user = useUserStore()
if (!user.isLogin && !whiteList.includes(to.path)) {
try {
......@@ -27,8 +27,8 @@ router.beforeEach(async (to, from, next) => {
...to.query,
experiment_id: from.query.experiment_id || '7028276368903241728',
student_id: from.query.student_id,
force_tgc: from.query.force_tgc
}
force_tgc: from.query.force_tgc,
},
})
} else {
next()
......
差异被折叠。
import type { UserType, ProjectType, OrganizationType, RoleType, PermissionType } from '@/types'
import { defineStore } from 'pinia'
import { getUser, logout, checkDataStatus } from '@/api/base'
import { getUser, logout, checkDataStatus, getAuth } from '@/api/base'
import { useMapStore } from '@/stores/map'
// 角色信息(1学员;5教师; 6管理员)
......@@ -16,6 +16,13 @@ interface State {
roles: RoleType[]
permissions: PermissionType[]
status: any
menus: Menu[]
}
interface Menu {
id: number
name: string
pid: number
}
export const useUserStore = defineStore({
......@@ -27,10 +34,11 @@ export const useUserStore = defineStore({
project: null,
roles: [],
permissions: [],
status: {}
status: {},
menus: [],
}),
getters: {
isLogin: state => !!state.user
isLogin: (state) => !!state.user,
},
actions: {
async getUser() {
......@@ -44,13 +52,16 @@ export const useUserStore = defineStore({
this.roles = roles
this.permissions = permissions
await useMapStore().getMapList()
await checkDataStatus().then(res => {
await checkDataStatus().then((res) => {
this.status = res.data
})
await getAuth().then((res) => {
this.menus = res.data.items || []
})
},
async logout() {
await logout()
this.user = null
}
}
},
},
})
import type { Component } from 'vue'
export interface IMenuItem {
id?: number
tag?: string | string[]
name: string
path: string
studentPath?: string
icon?: Component
children?: IMenuItem[]
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论