Преглед изворни кода

Merge branch 'dev' of https://gogs.tjp.com.cn/maoming/yjhtgl-web into feature/knowledge-base

愿你天天开心 пре 11 месеци
родитељ
комит
4fc0bb1b17
6 измењених фајлова са 52 додато и 54 уклоњено
  1. 3 3
      .env.development
  2. 2 2
      .env.production
  3. 2 2
      src/api/login.ts
  4. 38 39
      src/permission.ts
  5. 0 2
      src/types/components.d.ts
  6. 7 6
      src/views/login.vue

+ 3 - 3
.env.development

@@ -5,7 +5,7 @@ VITE_APP_TITLE = 智慧应急工作台
 VITE_APP_ENV = 'development'
 
 # 开发环境
-VITE_APP_BASE_API = 'http://10.181.7.236:9988'
+VITE_APP_BASE_API = 'http://10.181.7.236:9988/prod_api'
 
 # 应用访问路径 例如使用前缀 /admin/
 VITE_APP_CONTEXT_PATH = '/'
@@ -19,7 +19,7 @@ VITE_APP_SNAILJOB_ADMIN = 'http://localhost:8800/snail-job'
 VITE_APP_PORT = 80
 
 # 接口加密功能开关(如需关闭 后端也必须对应关闭)
-VITE_APP_ENCRYPT = true
+VITE_APP_ENCRYPT = false
 # 接口加密传输 RSA 公钥与后端解密私钥对应 如更换需前后端一同更换
 VITE_APP_RSA_PUBLIC_KEY = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
 # 接口响应解密 RSA 私钥与后端加密公钥对应 如更换需前后端一同更换
@@ -29,4 +29,4 @@ VITE_APP_RSA_PRIVATE_KEY = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3C
 VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e'
 
 # websocket 开关
-VITE_APP_WEBSOCKET = true
+VITE_APP_WEBSOCKET = false

+ 2 - 2
.env.production

@@ -22,7 +22,7 @@ VITE_BUILD_COMPRESS = gzip
 VITE_APP_PORT = 80
 
 # 接口加密功能开关(如需关闭 后端也必须对应关闭)
-VITE_APP_ENCRYPT = true
+VITE_APP_ENCRYPT = false
 # 接口加密传输 RSA 公钥与后端解密私钥对应 如更换需前后端一同更换
 VITE_APP_RSA_PUBLIC_KEY = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoR8mX0rGKLqzcWmOzbfj64K8ZIgOdHnzkXSOVOZbFu/TJhZ7rFAN+eaGkl3C4buccQd/EjEsj9ir7ijT7h96MCAwEAAQ=='
 # 接口响应解密 RSA 私钥与后端加密公钥对应 如更换需前后端一同更换
@@ -32,4 +32,4 @@ VITE_APP_RSA_PRIVATE_KEY = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3C
 VITE_APP_CLIENT_ID = 'e5cd7e4891bf95d1d19206ce24a7b32e'
 
 # websocket 开关
-VITE_APP_WEBSOCKET = true
+VITE_APP_WEBSOCKET = false

+ 2 - 2
src/api/login.ts

@@ -96,7 +96,7 @@ export function getInfo(): AxiosPromise<UserInfo> {
 }
 
 // 获取租户列表
-/*export function getTenantList(): AxiosPromise<TenantInfo> {
+export function getTenantList(): AxiosPromise<TenantInfo> {
   return request({
     url: '/auth/tenant/list',
     headers: {
@@ -104,4 +104,4 @@ export function getInfo(): AxiosPromise<UserInfo> {
     },
     method: 'get'
   });
-}*/
+}

+ 38 - 39
src/permission.ts

@@ -13,51 +13,50 @@ NProgress.configure({ showSpinner: false });
 const whiteList = ['/login', '/register', '/social-callback'];
 
 router.beforeEach(async (to, from, next) => {
-  // NProgress.start();
-  // if (getToken()) {
-  //   to.meta.title && useSettingsStore().setTitle(to.meta.title);
-  //   /* has token*/
-  //   if (to.path === '/login') {
-  //     next({ path: '/' });
-  //     NProgress.done();
-  //   } else if (whiteList.indexOf(to.path as string) !== -1) {
-  //     next();
-  //   } else {
-  if (useUserStore().roles.length === 0) {
-    isRelogin.show = true;
-    // 判断当前用户是否已拉取完user_info信息
-    const [err] = await tos(useUserStore().getInfo());
-    if (err) {
-      await useUserStore().logout();
-      ElMessage.error(err);
+  NProgress.start();
+  if (getToken()) {
+    to.meta.title && useSettingsStore().setTitle(to.meta.title);
+    /* has token*/
+    if (to.path === '/login') {
       next({ path: '/' });
+      NProgress.done();
+    } else if (whiteList.indexOf(to.path as string) !== -1) {
+      next();
     } else {
-      isRelogin.show = false;
-      const accessRoutes = await usePermissionStore().generateRoutes();
-      // 根据roles权限生成可访问的路由表
-      accessRoutes.forEach((route) => {
-        if (!isHttp(route.path)) {
-          router.addRoute(route); // 动态添加可访问路由表
+      if (useUserStore().roles.length === 0) {
+        isRelogin.show = true;
+        // 判断当前用户是否已拉取完user_info信息
+        const [err] = await tos(useUserStore().getInfo());
+        if (err) {
+          await useUserStore().logout();
+          ElMessage.error(err);
+          next({ path: '/' });
+        } else {
+          isRelogin.show = false;
+          const accessRoutes = await usePermissionStore().generateRoutes();
+          // 根据roles权限生成可访问的路由表
+          accessRoutes.forEach((route) => {
+            if (!isHttp(route.path)) {
+              router.addRoute(route); // 动态添加可访问路由表
+            }
+          });
+          next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
         }
-      });
-      next({ path: to.path, replace: true, params: to.params, query: to.query, hash: to.hash, name: to.name as string }); // hack方法 确保addRoutes已完成
+      } else {
+        next();
+      }
     }
   } else {
-    next();
+    // 没有token
+    if (whiteList.indexOf(to.path as string) !== -1) {
+      // 在免登录白名单,直接进入
+      next();
+    } else {
+      const redirect = encodeURIComponent(to.fullPath || '/');
+      next(`/login?redirect=${redirect}`); // 否则全部重定向到登录页
+      NProgress.done();
+    }
   }
-  // }
-  // } else {
-  //   // 没有token
-  //   if (whiteList.indexOf(to.path as string) !== -1) {
-  //     // 在免登录白名单,直接进入
-  //     next();
-  //   } else {
-  //     const redirect = encodeURIComponent(to.fullPath || '/');
-  //     next(`/login?redirect=${redirect}`); // 否则全部重定向到登录页
-  //     NProgress.done();
-  //   }
-  // }
-  // next();
 });
 
 router.afterEach(() => {

+ 0 - 2
src/types/components.d.ts

@@ -75,8 +75,6 @@ declare module 'vue' {
     Hamburger: typeof import('./../components/Hamburger/index.vue')['default']
     HeaderSearch: typeof import('./../components/HeaderSearch/index.vue')['default']
     IconSelect: typeof import('./../components/IconSelect/index.vue')['default']
-    IEpCaretBottom: typeof import('~icons/ep/caret-bottom')['default']
-    IEpCaretTop: typeof import('~icons/ep/caret-top')['default']
     IEpUploadFilled: typeof import('~icons/ep/upload-filled')['default']
     IFrame: typeof import('./../components/iFrame/index.vue')['default']
     ImagePreview: typeof import('./../components/ImagePreview/index.vue')['default']

+ 7 - 6
src/views/login.vue

@@ -27,6 +27,7 @@
         </div>
       </el-form-item>
       <el-checkbox v-model="loginForm.rememberMe" style="margin: 0 0 25px 0">记住密码</el-checkbox>
+      <!--
       <el-form-item style="float: right">
         <el-button circle title="微信登录" @click="doSocialLogin('wechat')">
           <svg-icon icon-class="wechat" />
@@ -44,6 +45,7 @@
           <svg-icon icon-class="github" />
         </el-button>
       </el-form-item>
+      -->
       <el-form-item style="width: 100%">
         <el-button :loading="loading" size="large" type="primary" style="width: 100%" @click.prevent="handleLogin">
           <span v-if="!loading">登 录</span>
@@ -56,14 +58,13 @@
     </el-form>
     <!--  底部  -->
     <div class="el-login-footer">
-      <span>Copyright © 2018-2024 疯狂的狮子Li All Rights Reserved.</span>
+      <span v-if="false">Copyright © 2018-2024 疯狂的狮子Li All Rights Reserved.</span>
     </div>
   </div>
 </template>
 
 <script setup lang="ts">
-// import { getCodeImg, getTenantList } from '@/api/login';
-import { getCodeImg } from '@/api/login';
+import { getCodeImg, getTenantList } from '@/api/login';
 import { authBinding } from '@/api/system/social/auth';
 import { useUserStore } from '@/store/modules/user';
 import { LoginData, TenantVO } from '@/api/types';
@@ -176,7 +177,7 @@ const getLoginData = () => {
 /**
  * 获取租户列表
  */
-/*const initTenantList = async () => {
+const initTenantList = async () => {
   const { data } = await getTenantList();
   tenantEnabled.value = data.tenantEnabled === undefined ? true : data.tenantEnabled;
   if (tenantEnabled.value) {
@@ -185,7 +186,7 @@ const getLoginData = () => {
       loginForm.value.tenantId = tenantList.value[0].tenantId;
     }
   }
-};*/
+};
 
 /**
  * 第三方登录
@@ -204,7 +205,7 @@ const doSocialLogin = (type: string) => {
 
 onMounted(() => {
   getCode();
-  // initTenantList();
+  initTenantList();
   getLoginData();
 });
 </script>