File tree Expand file tree Collapse file tree 2 files changed +8
-16
lines changed
Expand file tree Collapse file tree 2 files changed +8
-16
lines changed Original file line number Diff line number Diff line change 1717 }
1818 },
1919 mounted : function () {
20- // 如果有token则加载首页,如果没有则加载登录页
21- var UserData = window .localStorage .getItem (" SQBlog" );
22-
23- if (! UserData) {
24- this .$router .push ({
25- name: ' LoginPage' ,
26- });
27- this .TopbarShow = false ;
28- }
20+ // SQAjax方法体内,会取本地token,如果没有直接路由到登录页;如果有token,携带token请求传入的Url地址。
21+ // 且如果返回失败会路由到登录页,如果返回成功不做操作,路由还是正常展示首页不变
22+ this .SQAjax ({
23+ Url: ' /api/checkToken' ,
24+ Success : function (data ) {}
25+ });
2926 },
3027 /* 监听每次路由变化,如果是登录页则隐藏导航栏*/
3128 watch: {
Original file line number Diff line number Diff line change @@ -28,18 +28,13 @@ CommonFunction.install = function (Vue) {
2828 Para [ 'Success' ] ( response . data . data ) ;
2929 } else if ( response . data . status == '1' ) {
3030 that . $message ( {
31- message : '令牌超时或失效,需重新登录' ,
31+ message : response . data . data . message ,
3232 type : 'success'
3333 } ) ;
3434 that . $router . push ( {
3535 name :'LoginPage' ,
3636 } ) ;
37- } else if ( response . data . status == '1' ) {
38- that . $message ( {
39- message : response . data . data . message ,
40- type : 'success'
41- } ) ;
42- } else {
37+ } else {
4338 that . $message . error ( response . data . data . message ) ;
4439 }
4540 } ) . catch ( function ( error ) {
You can’t perform that action at this time.
0 commit comments