Преглед на файлове

Merge branch 'sso_pms' of shuzhihua/pms-iot-vue into master

yanghao преди 1 ден
родител
ревизия
25c559136c
променени са 1 файла, в които са добавени 13 реда и са изтрити 2 реда
  1. 13 2
      src/permission.ts

+ 13 - 2
src/permission.ts

@@ -10,7 +10,6 @@ import { useUserStoreWithOut } from '@/store/modules/user'
 import { usePermissionStoreWithOut } from '@/store/modules/permission'
 import * as LoginApi from '@/api/login'
 import * as authUtil from '@/utils/auth'
-import { he } from 'element-plus/es/locale'
 
 const { start, done } = useNProgress()
 
@@ -87,6 +86,18 @@ router.beforeEach(async (to, from, next) => {
   if (getAccessToken()) {
     if (to.path === '/login') {
       next({ path: '/' })
+    } else if (to.fullPath.includes('portalLogin')) {
+      // authUtil.removeToken()
+      // deleteUserCache()
+      const userStore = useUserStoreWithOut()
+      await userStore.loginOut()
+      await getTenantId()
+      const res = await LoginApi.portalLogin({
+        username: to.query.username
+      })
+
+      authUtil.setToken(res)
+      next({ path: '/' })
     } else {
       // 获取所有字典
       const dictStore = useDictStoreWithOut()
@@ -124,7 +135,7 @@ router.beforeEach(async (to, from, next) => {
 
       authUtil.setToken(res)
 
-      next({ path: '/' })
+      next({ path: '/index' })
     } else if (whiteList.indexOf(to.path) !== -1) {
       const code = to.query.code
       if (code) {