Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

xt_permission.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import router from './router'
  2. import store from './store'
  3. import NProgress from 'nprogress' // progress bar
  4. import 'nprogress/nprogress.css' // progress bar style
  5. NProgress.configure({
  6. showSpinner: false
  7. }) // NProgress Configuration
  8. const loginWhiteList = ['/token/verify', '/401', '/404'] // 登录验证白名单
  9. const permissionWhiteList = loginWhiteList.concat(['/']) // 权限验证白名单
  10. router.beforeEach((to, from, next) => {
  11. // 线上注释
  12. if (!store.getters.configlist || store.getters.configlist === undefined || store.getters.configlist.length <= 0) {
  13. store.dispatch('VerifyConfigList', []).then(() => {
  14. next()
  15. })
  16. }
  17. if (store.getters.permission_routers === undefined) {
  18. store.dispatch('xt_GenerateRoutes', []).then(() => {
  19. next()
  20. })
  21. } else {
  22. next()
  23. }
  24. return
  25. // 线上注释
  26. NProgress.start()
  27. // console.log(store.getters.current_role_urls.indexOf(to.path))
  28. // alert('path:' + to.path)
  29. // 如果 url 带有 lt (login_token)参数,则跳转到验证 token 时等待的页面
  30. if (to.query.lt != null && to.query.lt.length > 0) {
  31. // alert('will go to verify token: ' + to.query.lt)
  32. next({
  33. path: '/token/verify',
  34. query: {
  35. token: to.query.lt
  36. }
  37. })
  38. // 否则 如果没有 user 信息,则前往 sso 登录
  39. } else if (store.getters.xt_user.user.id === 0) {
  40. if (loginWhiteList.indexOf(to.path) !== -1) {
  41. // alert('登录白名单内,跳过登录')
  42. next()
  43. } else {
  44. // alert('前往登录')
  45. window.location.href = process.env.BASE_API + '/login' // sso 地址
  46. }
  47. // 否则 如果当前 url 不需要验证访问权限,则通过
  48. } else if (permissionWhiteList.indexOf(to.path) !== -1) {
  49. // alert('权限验证白名单内,直接进入')
  50. next()
  51. // 否则 如果拥有当前 url 的权限,则通过
  52. // } else if (store.getters.current_role_urls.indexOf(to.path) !== -1) {
  53. // // alert('权限验证通过')
  54. // next()
  55. // 否则 跳转401 (未经授权)
  56. } else {
  57. // console.log(store.getters.current_role_urls)
  58. // console.log(store.getters.current_role_urls.indexOf(to.path))
  59. // alert('401')
  60. next()
  61. // next({ path: '/404' })
  62. }
  63. })
  64. router.afterEach(() => {
  65. NProgress.done()
  66. })