瀏覽代碼

Update router-guards.ts

lex-xin 9 月之前
父節點
當前提交
7f8768216e
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      src/router/router-guards.ts

+ 10 - 4
src/router/router-guards.ts

@@ -3,6 +3,7 @@ import { useUserStore } from '@/store/modules/users';
 import { storage } from '@/utils/storage';
 import { PageEnum } from '@/enums/pageEnum';
 import { ACCESS_TOKEN, ACCESS_TOKEN_ADMIN } from '@/store/mutation-types';
+import { getAuthForAdmin } from '../utils';
 
 const LOGIN_PATH = PageEnum.BASE_LOGIN;
 
@@ -63,10 +64,15 @@ export function createRouterGuards(router: Router) {
       return;
     }
 
-    let token = storage.get(ACCESS_TOKEN);
-    const authSource = sessionStorage.getItem('authSource');
-    if (authSource === 'admin' && storage.get(ACCESS_TOKEN_ADMIN)) {
-      token = storage.get(ACCESS_TOKEN_ADMIN);
+
+    // 为了处理课堂乐器后台预览课件的功能
+    // const authSource = sessionStorage.getItem('authSource');
+    const userAuth = getAuthForAdmin()
+    let token = "";
+    if (userAuth.authSource === 'admin') {
+      token = userAuth.Authorization;
+    } else {
+      token = storage.get(ACCESS_TOKEN)
     }
     // console.log(token, 'access token');
     if (!token) {