- 介绍多角色的页面权限控制方法
- 面包屑的封装和使用
Vuex
Vuex入口
@/store/index.js:
1 | import Vue from 'vue'; |
全局的store
@/store/modules/app.js:
1 | import { getHomeRoute, getBreadCrumbList } from '@/utils'; // 获取主页、面包屑 |
权限
@/store/modules/permission.js:
1 | import { asyncRouterMap, constantRouterMap } from '@/router/modules/smart-assistant-jgpt'; // 引入所有的路由 |
用户信息
@/store/modules/user.js:
1 | import api from '@/plugins/api'; |
getRolePermission
接口给的返回数据格式:
getters
@/store/getters.js:
1 | const getters = { |
router
入口
@/router/idnex.js:
1 | import Vue from 'vue'; |
模块
@/router/modules/smart-assistant-jgpt/idnex.js:
1 | import Main from '@/views/smart-assistant-jgpt/main'; // 进入平台后的默认首页 |
列举其中一个模块写法:
@/router/modules/smart-assistant-jgpt/school-count.js:
1 | import Main from '@/views/smart-assistant-jgpt/main'; |
路由拦截器
@/config/interceptor/router.js:
1 | import router from '@/router'; |
Vuex和router配置
默认配置
@/config/idnex.js:
1 | // 面包屑的 主页是dashboard |
注册
@/idnex.js:
1 | import Vue from 'vue'; |
面包屑使用方法
mixins
@/views/mixins/bread-crumb.js:
1 | import { constantRouterMap } from '@/router/modules/smart-assistant-jgpt'; // 不需要验证用户权限的路由 |
@/views/mixins/index.js:
1 | import BreadCrumb from './bread-crumb'; |
组件
@/components/custom-bread-crumb/custom-bread-crumb.vue:
1 | <template> |
@/components/custom-bread-crumb/custom-bread-crumb.less:
1 | .custom-bread-crumb{ |
@/components/custom-bread-crumb/index.js:
1 | import customBreadCrumb from './custom-bread-crumb.vue'; |
@/components/common-icon/common-icon.vue:
1 | <template> |
@/components/common-icon/index.js:
1 | import CommonIcon from './common-icon.vue'; |
无扩展项目时
1 | <div class="navigation"> |
1 | import { BreadCrumb } from '@/views/mixins'; |
有扩展项目时
1 | <CustomBreadCrumb :list="breadCrumbList" :breadCrumbTitle="breadCrumbTitle"></CustomBreadCrumb> |
1 | import { BreadCrumb } from '@/views/mixins'; |
工具函数
@/utils/index.js:
1 | /** |
@/utils/auth.js:
1 | import Cookies from 'js-cookie'; |