- 角色模型改为 permissions 字段,移除 methods/includeUri/excludeUri - 角色管理页面支持权限树选择,保存时只传最上级权限 - /common/verifyToken 返回 permissions,存入 vuex - 新增 v-permission 指令,所有操作按钮和菜单均按权限控制显示 - 菜单按 list 权限过滤 - 各业务页面按钮加权限指令 - 角色管理列表只显示名称/描述/时间,不显示权限列,权限必选
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { createApp } from 'vue'
|
|
import App from './App.vue'
|
|
import { router, filterExclude } from './router'
|
|
import store from './store'
|
|
import type { RouteLocationNormalized, NavigationGuardNext } from 'vue-router'
|
|
|
|
import { ElLoading } from 'element-plus'
|
|
import 'element-plus/theme-chalk/el-message.css'
|
|
import 'element-plus/theme-chalk/el-message-box.css'
|
|
import 'element-plus/theme-chalk/el-image-viewer.css'
|
|
import 'element-plus/theme-chalk/dark/css-vars.css'
|
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|
import { permissionDirective } from '@/utils/permission'
|
|
|
|
// 全局路由导航前置守卫
|
|
router.beforeEach(function (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) {
|
|
if (to.meta?.title) {
|
|
store.commit('addTab', { title: to.meta.title, path: to.path, name: to.name })
|
|
}
|
|
store.state.activeTab = to.path
|
|
if(filterExclude.indexOf(to.path) !== -1 || store.state.loginInfo.token) {
|
|
next()
|
|
} else {
|
|
next('/login')
|
|
}
|
|
})
|
|
|
|
const app = createApp(App)
|
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|
app.component(key, component)
|
|
}
|
|
|
|
app.use(router)
|
|
.use(store)
|
|
.directive('loading', ElLoading.directive)
|
|
.directive('permission', permissionDirective)
|
|
.mount('#app')
|