This repository was archived by the owner on Nov 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +30
-38
lines changed
Expand file tree Collapse file tree 4 files changed +30
-38
lines changed Original file line number Diff line number Diff line change @@ -79,30 +79,17 @@ export default {
7979 methods: {
8080 toAside () {
8181 this .drawer = ! this .drawer ;
82- },
83- nav () {
84- // 若用户地址本身不为根目录,则不管
85- console .log (" 路由地址:" , this .$route .path );
86- if (this .$route .path != " /" ) return ;
87- // 根据不同的用户类型进行跳转
88- const userInfo = this .$store .state .userInfo ;
89- if (userInfo && userInfo .permission >= 10 ) {
90- console .log (" 导航至管理界面" );
91- router .push ({ path: " /overview" });
92- } else {
93- console .log (" 导航至普通界面" );
94- router .push ({ path: " /home" });
95- }
9682 }
9783 },
9884 async beforeCreate () {
85+ // 第一次刷新后,尝试获取一次用户数据
86+ // 如果失败,则导航至 / 视图进一步决定跳转路由
9987 try {
100- console .log (" 正在初始化用户信息,执行: await setupUserInfo()" );
10188 await setupUserInfo ();
102- this .nav ();
89+ const userInfo = this .$store .state .userInfo ;
90+ if (! userInfo || ! userInfo .uuid ) throw new Error (" userInfo.uuid is null" );
10391 } catch (error) {
104- console .log (" App.vue setupUserInfo():" , error);
105- router .push ({ path: " /login" });
92+ router .push ({ path: " /" });
10693 }
10794 },
10895 async mounted () {
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export async function requestUserInfo(advanced = null) {
9191 } ) ;
9292 store . commit ( "setUserInfo" , info ) ;
9393 store . commit ( "setToken" , info . token ) ;
94- console . log ( "用户身份 " , store . state . userInfo ) ;
94+ console . log ( "用户身份信息: " , store . state . userInfo ) ;
9595 return info ;
9696}
9797
Original file line number Diff line number Diff line change @@ -214,18 +214,15 @@ export default {
214214 duration: 0
215215 });
216216 }
217+ // 等待动画效果完毕
217218 await sleep (1500 );
218- // router.push({ path: `/` });
219- // window.location.href = "/" ;
219+ // 无缝切换,不采用刷新方法登录系统
220+ this . $router . push ({ path : ` / ` }) ;
220221 },
221222 async requestLoginInfo () {
222223 const res = await request ({
223224 method: " POST" ,
224- url: API_USER_LOGIN_INFO ,
225- data: {
226- username: this .form .username ,
227- password: this .form .password
228- }
225+ url: API_USER_LOGIN_INFO
229226 });
230227 this .loginInfo = res? .loginInfo ?? " " ;
231228 }
Original file line number Diff line number Diff line change 2121
2222<template >
2323 <Panel v-loading =" true" >
24- <template #title >板块 </template >
24+ <template #title >处理中... </template >
2525 <template #default >
2626 <el-skeleton :rows =" 12" />
2727 </template >
2828 </Panel >
2929</template >
3030<script >
3131import Panel from " ../../components/Panel" ;
32- // import router from "../router";
32+ import router from " ../router" ;
33+ import { setupUserInfo } from " ../service/protocol" ;
3334export default {
3435 components: { Panel },
3536 data : function () {
3637 return {};
3738 },
3839 methods: {},
3940 async mounted () {
40- // const userInfo = this.$store.state.userInfo;
41- // if (userInfo.uuid) {
42- // if (userInfo.permission >= 10) {
43- // console.log("辅助链接 - 导航跳转至高权限界面");
44- // router.push({ path: "/overview" });
45- // } else {
46- // console.log("辅助链接 - 导航跳转至普通界面");
47- // router.push({ path: "/home" });
48- // }
49- // }
41+ try {
42+ // 为了适配无缝登录,这里必须还需要再请求一次数据
43+ await setupUserInfo ();
44+ const userInfo = this .$store .state .userInfo ;
45+ if (! userInfo || ! userInfo .uuid ) throw new Error (` userInfo status error: ${ userInfo} ` );
46+ if (userInfo .permission >= 10 ) {
47+ console .log (" 辅助链接 - 导航跳转至高权限界面" );
48+ router .push ({ path: " /overview" });
49+ } else {
50+ console .log (" 辅助链接 - 导航跳转至普通界面" );
51+ router .push ({ path: " /home" });
52+ }
53+ return ;
54+ } catch (error) {
55+ console .log (" App.vue setupUserInfo() ERROR:" , error);
56+ router .push ({ path: " /login" });
57+ }
5058 }
5159};
5260 </script >
You can’t perform that action at this time.
0 commit comments