libushang 9 月之前
父节点
当前提交
aec443052d
共有 5 个文件被更改,包括 56 次插入47 次删除
  1. 3 3
      .env.development
  2. 2 2
      .env.production
  3. 38 39
      src/permission.ts
  4. 10 2
      src/types/components.d.ts
  5. 3 1
      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://127.0.0.1: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

+ 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(() => {

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

@@ -22,8 +22,11 @@ declare module 'vue' {
     ElCard: typeof import('element-plus/es')['ElCard']
     ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
     ElCol: typeof import('element-plus/es')['ElCol']
+    ElCollapse: typeof import('element-plus/es')['ElCollapse']
+    ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
     ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
+    ElContainer: typeof import('element-plus/es')['ElContainer']
     ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDivider: typeof import('element-plus/es')['ElDivider']
@@ -34,25 +37,32 @@ declare module 'vue' {
     ElEmpty: typeof import('element-plus/es')['ElEmpty']
     ElForm: typeof import('element-plus/es')['ElForm']
     ElFormItem: typeof import('element-plus/es')['ElFormItem']
+    ElHeader: typeof import('element-plus/es')['ElHeader']
     ElIcon: typeof import('element-plus/es')['ElIcon']
     ElInput: typeof import('element-plus/es')['ElInput']
     ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
     ElLink: typeof import('element-plus/es')['ElLink']
+    ElMain: typeof import('element-plus/es')['ElMain']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
     ElOption: typeof import('element-plus/es')['ElOption']
     ElPagination: typeof import('element-plus/es')['ElPagination']
     ElPopover: typeof import('element-plus/es')['ElPopover']
     ElRadio: typeof import('element-plus/es')['ElRadio']
+    ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
     ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElSelect: typeof import('element-plus/es')['ElSelect']
+    ElSpace: typeof import('element-plus/es')['ElSpace']
     ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
     ElSwitch: typeof import('element-plus/es')['ElSwitch']
     ElTable: typeof import('element-plus/es')['ElTable']
     ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
+    ElTabPane: typeof import('element-plus/es')['ElTabPane']
+    ElTabs: typeof import('element-plus/es')['ElTabs']
     ElTag: typeof import('element-plus/es')['ElTag']
+    ElText: typeof import('element-plus/es')['ElText']
     ElTooltip: typeof import('element-plus/es')['ElTooltip']
     ElTree: typeof import('element-plus/es')['ElTree']
     ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
@@ -61,8 +71,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']

+ 3 - 1
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,7 +58,7 @@
     </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>