Commit d5d453bf242166025529ff9a13c1931c58075f31
1 parent
30fb7566
m
Showing
4 changed files
with
54 additions
and
47 deletions
trash-admin/src/main/resources/application-dev.yml
| @@ -16,7 +16,7 @@ trash: | @@ -16,7 +16,7 @@ trash: | ||
| 16 | # 验证码类型 math 数组计算 char 字符验证 | 16 | # 验证码类型 math 数组计算 char 字符验证 |
| 17 | captchaType: math | 17 | captchaType: math |
| 18 | # 远程服务器地址 | 18 | # 远程服务器地址 |
| 19 | - remotePath: http://183.66.242.6:6001 | 19 | + remotePath: http://175.6.47.84:8008 |
| 20 | token: durable:auth:token:eyJhbGciOiJIUzUxMiJ9.eyJ5ZWEiOiJjc3poIiwiZXhwIjo0MTAyNDE1OTk5LCJjcmVhdGVkIjoxNjg0MzI3NzQ1ODkyfQ.4BrpgD9i_1TwjLRGqa3wo4Ikx8t8Gcl3FzHfjL_uolPnNMm2rd7fCvrUoBBN4Qp4cMGzg9h2Nt4NNx8PYThTaQ | 20 | token: durable:auth:token:eyJhbGciOiJIUzUxMiJ9.eyJ5ZWEiOiJjc3poIiwiZXhwIjo0MTAyNDE1OTk5LCJjcmVhdGVkIjoxNjg0MzI3NzQ1ODkyfQ.4BrpgD9i_1TwjLRGqa3wo4Ikx8t8Gcl3FzHfjL_uolPnNMm2rd7fCvrUoBBN4Qp4cMGzg9h2Nt4NNx8PYThTaQ |
| 21 | #remotePath: http://183.66.242.6:14601 | 21 | #remotePath: http://183.66.242.6:14601 |
| 22 | #token: durable:auth:token:eyJhbGciOiJIUzUxMiJ9.eyJ5ZWEiOiJjc3poIiwiZXhwIjo0MTAyNDE1OTk5LCJjcmVhdGVkIjoxNjg0NDU5MjEzNzQ2fQ.85oIrOnU7cz7L_-IGt4Bt1LXDTkFtyrdqNt05K0v9-4nsrrzzpbjbemK-yMlbnUpe4Fx2FFES-Wbw8Yr8ML69w | 22 | #token: durable:auth:token:eyJhbGciOiJIUzUxMiJ9.eyJ5ZWEiOiJjc3poIiwiZXhwIjo0MTAyNDE1OTk5LCJjcmVhdGVkIjoxNjg0NDU5MjEzNzQ2fQ.85oIrOnU7cz7L_-IGt4Bt1LXDTkFtyrdqNt05K0v9-4nsrrzzpbjbemK-yMlbnUpe4Fx2FFES-Wbw8Yr8ML69w |
trash-ui/src/layout/index.vue
| 1 | <template> | 1 | <template> |
| 2 | - <div :class="classObj" class="app-wrapper"> | ||
| 3 | - <sidebar class="sidebar-container" /> | ||
| 4 | - <div :class="{hasTagsView:needTagsView}" class="main-container"> | ||
| 5 | - <tags-view v-if="needTagsView" /> | ||
| 6 | <app-main /> | 2 | <app-main /> |
| 7 | - | ||
| 8 | - </div> | ||
| 9 | - </div> | ||
| 10 | </template> | 3 | </template> |
| 11 | 4 | ||
| 12 | <script> | 5 | <script> |
trash-ui/src/layout/index4.vue renamed to trash-ui/src/layout/index5.vue
| 1 | <template> | 1 | <template> |
| 2 | + <div :class="classObj" class="app-wrapper"> | ||
| 3 | + <sidebar class="sidebar-container" /> | ||
| 4 | + <div :class="{hasTagsView:needTagsView}" class="main-container"> | ||
| 5 | + <tags-view v-if="needTagsView" /> | ||
| 2 | <app-main /> | 6 | <app-main /> |
| 7 | + | ||
| 8 | + </div> | ||
| 9 | + </div> | ||
| 3 | </template> | 10 | </template> |
| 4 | 11 | ||
| 5 | <script> | 12 | <script> |
trash-ui/src/permission.js
| @@ -14,8 +14,15 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] | @@ -14,8 +14,15 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] | ||
| 14 | // const whiteList = ['/*'] | 14 | // const whiteList = ['/*'] |
| 15 | 15 | ||
| 16 | router.beforeEach((to, from, next) => { | 16 | router.beforeEach((to, from, next) => { |
| 17 | + debugger; | ||
| 17 | NProgress.start() | 18 | NProgress.start() |
| 18 | var token = getToken(); | 19 | var token = getToken(); |
| 20 | + | ||
| 21 | + if(token && to.query.token.indexOf(token) == -1){ | ||
| 22 | + removeToken(); | ||
| 23 | + token = null; | ||
| 24 | + } | ||
| 25 | + | ||
| 19 | if(!token){ | 26 | if(!token){ |
| 20 | if( to.query.token ){ | 27 | if( to.query.token ){ |
| 21 | loginByToken(to.query.token).then(res=>{ | 28 | loginByToken(to.query.token).then(res=>{ |
| @@ -58,49 +65,49 @@ router.beforeEach((to, from, next) => { | @@ -58,49 +65,49 @@ router.beforeEach((to, from, next) => { | ||
| 58 | } | 65 | } |
| 59 | } | 66 | } |
| 60 | }else{ | 67 | }else{ |
| 61 | - /* has token*/ | ||
| 62 | - if (to.path === '/login') { | ||
| 63 | - next({ path: '/' }) | ||
| 64 | - NProgress.done() | ||
| 65 | - } else { | ||
| 66 | - if (store.getters.roles.length === 0) { | ||
| 67 | - store.dispatch('GetInfo').then(res => { | ||
| 68 | - // 拉取user_info | ||
| 69 | - const roles = res.roles | 68 | + /* has token*/ |
| 69 | + if (to.path === '/login') { | ||
| 70 | + next({ path: '/' }) | ||
| 71 | + NProgress.done() | ||
| 72 | + } else { | ||
| 73 | + if (store.getters.roles.length === 0) { | ||
| 74 | + store.dispatch('GetInfo').then(res => { | ||
| 75 | + // 拉取user_info | ||
| 76 | + const roles = res.roles | ||
| 70 | 77 | ||
| 71 | - setToken(res.token) | 78 | + setToken(res.token) |
| 72 | 79 | ||
| 73 | - store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => { | ||
| 74 | - // 测试 默认静态页面 | ||
| 75 | - // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => { | ||
| 76 | - // 根据roles权限生成可访问的路由表 | ||
| 77 | - router.addRoutes(accessRoutes) // 动态添加可访问路由表 | ||
| 78 | - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 | ||
| 79 | - }) | ||
| 80 | - }).catch(err => { | ||
| 81 | - if( to.query.token ){ | ||
| 82 | - removeToken(); | ||
| 83 | - next({path:to }) | ||
| 84 | - }else{ | 80 | + store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => { |
| 81 | + // 测试 默认静态页面 | ||
| 82 | + // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => { | ||
| 83 | + // 根据roles权限生成可访问的路由表 | ||
| 84 | + router.addRoutes(accessRoutes) // 动态添加可访问路由表 | ||
| 85 | + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 | ||
| 86 | + }) | ||
| 87 | + }).catch(err => { | ||
| 88 | + if( to.query.token ){ | ||
| 89 | + removeToken(); | ||
| 90 | + next({path:to }) | ||
| 91 | + }else{ | ||
| 85 | 92 | ||
| 86 | 93 | ||
| 87 | - store.dispatch('FedLogOut').then(() => { | ||
| 88 | - Message.error(err) | ||
| 89 | - removeToken(); | ||
| 90 | - next({ path: '/' }) | ||
| 91 | - }) | ||
| 92 | - } | ||
| 93 | - }) | ||
| 94 | - } else { | ||
| 95 | - next() | ||
| 96 | - // 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓ | ||
| 97 | - // if (hasPermission(store.getters.roles, to.meta.roles)) { | ||
| 98 | - // next() | ||
| 99 | - // } else { | ||
| 100 | - // next({ path: '/401', replace: true, query: { noGoBack: true }}) | ||
| 101 | - // } | ||
| 102 | - // 可删 ↑ | ||
| 103 | - } | 94 | + store.dispatch('FedLogOut').then(() => { |
| 95 | + Message.error(err) | ||
| 96 | + removeToken(); | ||
| 97 | + next({ path: '/' }) | ||
| 98 | + }) | ||
| 99 | + } | ||
| 100 | + }) | ||
| 101 | + } else { | ||
| 102 | + next() | ||
| 103 | + // 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓ | ||
| 104 | + // if (hasPermission(store.getters.roles, to.meta.roles)) { | ||
| 105 | + // next() | ||
| 106 | + // } else { | ||
| 107 | + // next({ path: '/401', replace: true, query: { noGoBack: true }}) | ||
| 108 | + // } | ||
| 109 | + // 可删 ↑ | ||
| 110 | + } | ||
| 104 | } | 111 | } |
| 105 | } | 112 | } |
| 106 | }) | 113 | }) |