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

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

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