yanghao 3 minggu lalu
induk
melakukan
dfaa4f274b
1 mengubah file dengan 22 tambahan dan 3 penghapusan
  1. 22 3
      src/permission.ts

+ 22 - 3
src/permission.ts

@@ -49,6 +49,25 @@ const parseURL = (
   return { basePath, paramsObject }
   return { basePath, paramsObject }
 }
 }
 
 
+const loginData = reactive({
+  isShowPassword: false,
+  captchaEnable: import.meta.env.VITE_APP_CAPTCHA_ENABLE !== 'false',
+  tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false',
+  loginForm: {
+    tenantName: '芋道源码',
+    username: '',
+    password: '',
+    captchaVerification: '',
+    rememberMe: false
+  }
+})
+const getTenantId = async () => {
+  if (loginData.tenantEnable) {
+    const res = await LoginApi.getTenantIdByName(loginData.loginForm.tenantName)
+    authUtil.setTenantId(res)
+  }
+}
+
 // 路由不重定向白名单
 // 路由不重定向白名单
 const whiteList = [
 const whiteList = [
   '/login',
   '/login',
@@ -69,7 +88,7 @@ router.beforeEach(async (to, from, next) => {
     } else if (to.fullPath.includes('portalLogin')) {
     } else if (to.fullPath.includes('portalLogin')) {
       const userStore = useUserStoreWithOut()
       const userStore = useUserStoreWithOut()
       await userStore.loginOut()
       await userStore.loginOut()
-      // await getTenantId()
+      await getTenantId()
       const res = await LoginApi.portalLogin({
       const res = await LoginApi.portalLogin({
         username: to.query.username
         username: to.query.username
       })
       })
@@ -110,7 +129,7 @@ router.beforeEach(async (to, from, next) => {
     deleteUserCache()
     deleteUserCache()
     useUserStoreWithOut().resetState()
     useUserStoreWithOut().resetState()
     if (to.query.username) {
     if (to.query.username) {
-      // await getTenantId()
+      await getTenantId()
       const res = await LoginApi.portalLogin({
       const res = await LoginApi.portalLogin({
         username: to.query.username
         username: to.query.username
       })
       })
@@ -121,7 +140,7 @@ router.beforeEach(async (to, from, next) => {
     } else if (whiteList.indexOf(to.path) !== -1) {
     } else if (whiteList.indexOf(to.path) !== -1) {
       const code = to.query.code
       const code = to.query.code
       if (code) {
       if (code) {
-        // await getTenantId()
+        await getTenantId()
         const res = await LoginApi.socialLogin('20', typeof code === 'string' ? code : '', '22')
         const res = await LoginApi.socialLogin('20', typeof code === 'string' ? code : '', '22')
         authUtil.setToken(res)
         authUtil.setToken(res)
         next({ path: 'index' })
         next({ path: 'index' })