Ver Fonte

前端优化

skyline há 1 dia atrás
pai
commit
73a7ee4236

+ 8 - 5
admin-web-new/src/store/modules/multiTags.ts

@@ -51,11 +51,14 @@ export const useMultiTagsStore = defineStore("pure-multiTags", {
       }
     },
     tagsCache(multiTags) {
-      this.getMultiTagsCache &&
-        storageLocal().setItem(
-          `${responsiveStorageNameSpace()}tags`,
-          multiTags
-        );
+      if (this.getMultiTagsCache) {
+        setTimeout(() => {
+          storageLocal().setItem(
+            `${responsiveStorageNameSpace()}tags`,
+            this.multiTags
+          );
+        }, 0);
+      }
     },
     handleTags<T>(
       mode: string,

+ 1 - 1
admin-web-new/src/store/modules/permission.ts

@@ -54,7 +54,7 @@ export const usePermissionStore = defineStore("pure-permission", {
           this.clearCache();
           break;
         case "add":
-          this.cachePageList.push(name);
+          delIndex === -1 && this.cachePageList.push(name);
           break;
         case "delete":
           delIndex !== -1 && this.cachePageList.splice(delIndex, 1);

+ 6 - 0
admin-web-new/src/style/element-plus.scss

@@ -29,6 +29,12 @@
   margin-left: 2px !important;
 }
 
+/* el-button 内图标继承按钮文字色(而非按钮背景色) */
+.el-button .el-icon,
+.el-button .el-icon svg {
+  color: var(--el-button-text-color) !important;
+}
+
 /* 自定义 popover 的类名 */
 .pure-popper {
   padding: 0 !important;

+ 1 - 1
admin-web-new/src/style/transition.scss

@@ -12,7 +12,7 @@
 /* fade-transform */
 .fade-transform-leave-active,
 .fade-transform-enter-active {
-  transition: all 0.5s;
+  transition: all 0.2s;
 }
 
 .fade-transform-enter-from {

+ 15 - 4
admin-web-new/src/utils/http/index.ts

@@ -10,9 +10,9 @@ import type {
   PureHttpRequestConfig
 } from "./types.d";
 import { stringify } from "qs";
-import { getToken } from "@/utils/auth";
-import { useUserStoreHook } from "@/store/modules/user";
+import { getToken, removeToken } from "@/utils/auth";
 import { ElMessage, ElMessageBox } from "element-plus";
+import router from "@/router";
 
 // API 基础 URL
 const baseUrl = import.meta.env.VITE_API_URL || `${location.origin}/admin/`;
@@ -65,6 +65,9 @@ class PureHttp {
   /** 防止重复刷新`token` */
   private static isRefreshing = false;
 
+  /** 防止重复跳转登录页 */
+  private static isRedirecting = false;
+
   /** 初始化配置对象 */
   private static initConfig: PureHttpRequestConfig = {};
 
@@ -129,12 +132,20 @@ class PureHttp {
         if (res.code !== undefined && res.code !== 0 && res.code !== 200) {
           // token 过期或未登录
           if (res.code === 401) {
+            if (PureHttp.isRedirecting) {
+              return Promise.reject(new Error(res.msg || '未授权'));
+            }
+            PureHttp.isRedirecting = true;
+            removeToken();
             ElMessageBox.alert('你已被登出,请重新登录', '提示', {})
               .then(() => {
-                window.location.href = '/#/login';
+                router.push('/login');
               })
               .catch(() => {
-                window.location.href = '/#/login';
+                router.push('/login');
+              })
+              .finally(() => {
+                PureHttp.isRedirecting = false;
               });
             return Promise.reject(new Error(res.msg || '未授权'));
           }

+ 3 - 35
admin-web-new/src/views/admin/station/list.vue

@@ -4,7 +4,7 @@ import { useRouter } from "vue-router";
 import { getStationList, removeStation } from "@/api/station";
 import { useRenderIcon } from "@/components/ReIcon/src/hooks";
 import { ElMessage, ElMessageBox } from "element-plus";
-import { ExtDLabel, ExtDSelect } from "@/components/ExtForm";
+import { ExtDLabel } from "@/components/ExtForm";
 import StationDialog from "./dialog.vue";
 import StationUploadDialog from "./upload.vue";
 
@@ -23,10 +23,7 @@ const currentStationName = ref("");
 
 const state = reactive({
   formQuery: {
-    stationName: "",
-    stationStatus: "",
-    stationType: "",
-    address: ""
+    stationName: ""
   },
   pageQuery: {
     pageNum: 1,
@@ -97,12 +94,7 @@ const handleSearch = () => {
 };
 
 const handleReset = () => {
-  state.formQuery = {
-    stationName: "",
-    stationStatus: "",
-    stationType: "",
-    address: ""
-  };
+  state.formQuery.stationName = "";
   loadData(true);
 };
 
@@ -170,30 +162,6 @@ const handleGotoDevice = (row: any) => {
             @keyup.enter="handleSearch"
           />
         </el-form-item>
-        <el-form-item label="站点状态">
-          <ExtDSelect
-            v-model="state.formQuery.stationStatus"
-            type="Station.status"
-            placeholder="请选择站点状态"
-            @on-change="handleSearch"
-          />
-        </el-form-item>
-        <el-form-item label="站点类型">
-          <ExtDSelect
-            v-model="state.formQuery.stationType"
-            type="Station.type"
-            placeholder="请选择站点类型"
-            @on-change="handleSearch"
-          />
-        </el-form-item>
-        <el-form-item label="地址">
-          <el-input
-            v-model="state.formQuery.address"
-            placeholder="请输入地址"
-            clearable
-            @keyup.enter="handleSearch"
-          />
-        </el-form-item>
         <el-form-item>
           <el-button
             type="primary"