Michael Wang 3 anos atrás
pai
commit
ae3cca1ec2

+ 1 - 0
.eslintrc.js

@@ -63,6 +63,7 @@ module.exports = {
         project: ["tsconfig.json"],
       },
       globals: {
+        $: true,
         $ref: true,
         $computed: true,
         $$: true,

+ 2 - 2
src/App.vue

@@ -11,7 +11,7 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, ref, watch, watchEffect } from "vue";
+import { defineComponent, watch, watchEffect } from "vue";
 import { useMainStore } from "@/store";
 import { useTimers } from "./setups/useTimers";
 import { getToken } from "./auth/auth";
@@ -24,7 +24,7 @@ export default defineComponent({
     const { addInterval } = useTimers();
     addInterval(() => {
       if (getToken()) {
-        httpApp.post("/api/ess/user/online/signal");
+        void httpApp.post("/api/ess/user/online/signal");
       }
     }, 60 * 1000);
 

+ 1 - 1
src/api/loginPage.ts

@@ -22,7 +22,7 @@ export async function logout() {
           retries: 0,
         },
       })
-      .catch(() => {})
+      .catch((e) => console.log(e))
       .finally(() => removeToken());
   } else {
     return;

+ 1 - 1
src/components/CourseSelect.vue

@@ -47,7 +47,7 @@ async function fetchData(searchStr = "") {
   }
 }
 async function handleSearch(searchStr: string) {
-  fetchData(searchStr);
+  await fetchData(searchStr);
 }
 let valueStr = computed(() => {
   let res: undefined | number | string = props.value ?? undefined;

+ 3 - 1
src/components/Layout.vue

@@ -104,7 +104,9 @@ import { message } from "ant-design-vue";
 const store = useMainStore();
 
 async function doLogout() {
-  logout().then(() => routeLogout({ cause: "主动退出", redirectTo: "/" }));
+  await logout().then(() =>
+    routeLogout({ cause: "主动退出", redirectTo: "/" })
+  );
 }
 
 let visible = $ref(false);

+ 1 - 1
src/components/ProjectCourseSelect.vue

@@ -46,7 +46,7 @@ async function fetchData(searchStr = "") {
   optionList = res.data.content;
 }
 async function handleSearch(searchStr: string) {
-  fetchData(searchStr);
+  await fetchData(searchStr);
 }
 
 let valueStr = computed(() => {

+ 0 - 6
src/directives/numberToPercent.ts

@@ -7,10 +7,4 @@ export default {
       el.innerText = (Math.round(ft * 10000) / 100).toFixed(2) + "%";
     }
   }, // new
-  beforeMount() {},
-  mounted() {},
-  beforeUpdate() {}, // new
-  updated() {},
-  beforeUnmount() {}, // new
-  unmounted() {},
 };

+ 0 - 6
src/directives/roundNumber.ts

@@ -7,10 +7,4 @@ export default {
       el.innerText = Math.round(ft * 100) / 100 + "";
     }
   }, // new
-  beforeMount() {},
-  mounted() {},
-  beforeUpdate() {}, // new
-  updated() {},
-  beforeUnmount() {}, // new
-  unmounted() {},
 };

+ 2 - 2
src/features/login/Login.vue

@@ -44,7 +44,7 @@ let password = $ref("");
 let rootOrgId = $(useRouteQuery("rootOrgId"));
 const router = useRouter();
 if (!rootOrgId) {
-  router.push("/?rootOrgId=1");
+  void router.push("/?rootOrgId=1");
 }
 
 let errorInfo = $ref("");
@@ -58,7 +58,7 @@ async function login() {
     });
     console.log(res);
     store.setUserInfo(res.data);
-    router.push("/project/projectManagement");
+    void router.push("/project/projectManagement");
   } catch (error) {
     console.log(error);
     errorInfo = (<any>error).response.data.desc;

+ 8 - 8
src/features/projectPapersManagement/ProjectPapersManagement.vue

@@ -26,11 +26,11 @@
           pageSize: pageSize,
           current: pageNo,
           total: totalElements,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
-            pageNo = pageNoChanged; 
+          showTotal: () => ``,
+          onChange: (pageNoChanged, pageSizeChanged) => {
+            pageNo = pageNoChanged;
             pageSize = pageSizeChanged;
-          }
+          },
         }"
       >
         <template #course="{ record }">
@@ -49,7 +49,7 @@
 <script setup lang="ts">
 import { useMainStore } from "@/store";
 import { goBack } from "@/utils/utils";
-import { watch, onMounted, ref, toRaw } from "vue";
+import { watch, onMounted } from "vue";
 import { useRoute } from "vue-router";
 import ProjectSelect from "@/components/ProjectSelect.vue";
 import { Course_Type } from "@/types";
@@ -57,7 +57,7 @@ import { getPaperList } from "@/api/paperManagementPage";
 import router from "@/router";
 
 const store = useMainStore();
-store.currentLocation = "项目管理 / 项目列表 / 试卷列表";
+store.currentLocation = "项目管理 / 项目列表 / 试卷列表";
 
 let rootOrgId = $ref(undefined as unknown as number);
 let courseId = $ref(undefined as undefined | number);
@@ -124,10 +124,10 @@ onMounted(async () => {
 });
 
 async function goAllAnalysis() {
-  router.push(`/project/allAnalysis/${projectId}`);
+  await router.push(`/project/allAnalysis/${projectId}`);
 }
 
 async function goPaperAnalysis(record: any) {
-  router.push(`/project/${projectId}/paperAnalysis/${record.id}`);
+  await router.push(`/project/${projectId}/paperAnalysis/${record.id}`);
 }
 </script>

+ 1 - 1
src/features/roleManagement/RoleManagement.vue

@@ -22,7 +22,7 @@
 <script setup lang="ts">
 import { getRoleList } from "@/api/roleManagementPage";
 import { useMainStore } from "@/store";
-import { watch, onMounted, ref, reactive, toRaw } from "vue";
+import { watch, onMounted } from "vue";
 
 const store = useMainStore();
 store.currentLocation = "基础管理 / 角色管理";

+ 6 - 6
src/features/rootOrg/RootOrg.vue

@@ -32,11 +32,11 @@
           pageSize: pageSize,
           current: pageNo,
           total: totalElements,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
-            pageNo = pageNoChanged; 
+          showTotal: () => ``,
+          onChange: (pageNoChanged, pageSizeChanged) => {
+            pageNo = pageNoChanged;
             pageSize = pageSizeChanged;
-          }
+          },
         }"
       >
         <template #enable="{ text }">
@@ -156,10 +156,10 @@ const showModal = (record: any) => {
 };
 
 const editRootOrgSettings = (orgId: number) => {
-  router.push("/basic/rootOrg/edit/" + orgId);
+  void router.push("/basic/rootOrg/edit/" + orgId);
 };
 
-const handleOk = async (e: MouseEvent) => {
+const handleOk = async () => {
   await updateRootOrg({ domainName: rootOrgObj.domainName });
   visible.value = false;
   await search();

+ 3 - 3
src/features/rootOrg/RootOrgEdit.vue

@@ -54,7 +54,7 @@ async function handleOrgPorps() {
 function codeToName(item: any): any {
   return ORG_GLOSSARY[item as keyof typeof ORG_GLOSSARY];
 }
-function codeToValue(item: any): any {
-  return orgPorps[item as keyof typeof ORG_GLOSSARY];
-}
+// function codeToValue(item: any): any {
+//   return orgPorps[item as keyof typeof ORG_GLOSSARY];
+// }
 </script>

+ 16 - 16
src/features/userManagement/UserPrivilegeCourse.vue

@@ -18,12 +18,12 @@
           pageSize: pageSize,
           current: pageNo,
           total: totalElements,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
+          showTotal: () => ``,
+          onChange: (pageNoChanged, pageSizeChanged) => {
             selectIds = [];
-            pageNo = pageNoChanged; 
+            pageNo = pageNoChanged;
             pageSize = pageSizeChanged;
-          }
+          },
         }"
       >
       </a-table>
@@ -56,16 +56,16 @@
           :data-source="data2"
           :rowSelection="rowSelection2"
           :pagination="{
-          pageSize: pageSize2,
-          current: pageNo2,
-          total: totalElements2,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
-            selectIds2 = [];
-            pageNo2 = pageNoChanged; 
-            pageSize2 = pageSizeChanged;
-          }
-        }"
+            pageSize: pageSize2,
+            current: pageNo2,
+            total: totalElements2,
+            showTotal: () => ``,
+            onChange: (pageNoChanged, pageSizeChanged) => {
+              selectIds2 = [];
+              pageNo2 = pageNoChanged;
+              pageSize2 = pageSizeChanged;
+            },
+          }"
         >
           <template #enable="{ text }">
             <a>{{ $filters.booleanEnableDisableFilter(text) }}</a>
@@ -251,7 +251,7 @@ const rowSelection2 = {
   },
 };
 
-function checkEmpty2(selectIds: number[]): boolean {
+function checkEmpty2(): boolean {
   if (selectIds2 && selectIds2.length > 0) {
     return false;
   } else {
@@ -260,7 +260,7 @@ function checkEmpty2(selectIds: number[]): boolean {
   }
 }
 async function handleOk() {
-  if (checkEmpty2(selectIds2)) return;
+  if (checkEmpty2()) return;
   await addListForUserPrivilege({
     type: PRIVI_TYPE,
     userId,

+ 16 - 16
src/features/userManagement/UserPrivilegeOrg.vue

@@ -18,12 +18,12 @@
           pageSize: pageSize,
           current: pageNo,
           total: totalElements,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
+          showTotal: () => ``,
+          onChange: (pageNoChanged, pageSizeChanged) => {
             selectIds = [];
-            pageNo = pageNoChanged; 
+            pageNo = pageNoChanged;
             pageSize = pageSizeChanged;
-          }
+          },
         }"
       >
       </a-table>
@@ -56,16 +56,16 @@
           :data-source="data2"
           :rowSelection="rowSelection2"
           :pagination="{
-          pageSize: pageSize2,
-          current: pageNo2,
-          total: totalElements2,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
-            selectIds2 = [];
-            pageNo2 = pageNoChanged; 
-            pageSize2 = pageSizeChanged;
-          }
-        }"
+            pageSize: pageSize2,
+            current: pageNo2,
+            total: totalElements2,
+            showTotal: () => ``,
+            onChange: (pageNoChanged, pageSizeChanged) => {
+              selectIds2 = [];
+              pageNo2 = pageNoChanged;
+              pageSize2 = pageSizeChanged;
+            },
+          }"
         >
           <template #enable="{ text }">
             <a>{{ $filters.booleanEnableDisableFilter(text) }}</a>
@@ -251,7 +251,7 @@ const rowSelection2 = {
   },
 };
 
-function checkEmpty2(selectIds: number[]): boolean {
+function checkEmpty2(): boolean {
   if (selectIds2 && selectIds2.length > 0) {
     return false;
   } else {
@@ -260,7 +260,7 @@ function checkEmpty2(selectIds: number[]): boolean {
   }
 }
 async function handleOk() {
-  if (checkEmpty2(selectIds2)) return;
+  if (checkEmpty2()) return;
   await addListForUserPrivilege({
     type: PRIVI_TYPE,
     userId,

+ 0 - 32
src/plugins/axiosCache.ts

@@ -1,32 +0,0 @@
-import { AxiosInstance } from "axios";
-
-export default function (axios: AxiosInstance, regexes: [RegExp] | []) {
-  // cachingGet
-  const cache = new Map();
-
-  return function cachedGet(url: string) {
-    const key = url;
-
-    if (regexes.some((regex) => url.match(regex))) {
-      if (cache.has(key)) {
-        const request = cache.get(key);
-        // console.log("cache.get(key):" + request.then(v => console.log(v)));
-        return request;
-      } else {
-        // @ts-ignore
-        const request = axios.get(...arguments);
-        return request.then((v) => {
-          if (v.status === 200) {
-            // 如果能取到数据,才缓存
-            cache.set(key, request);
-          }
-          return request;
-        });
-      }
-    } else {
-      // @ts-ignore
-      const request = axios.get(...arguments);
-      return request;
-    }
-  };
-}

+ 1 - 4
src/plugins/axiosNoAuth.ts

@@ -1,15 +1,12 @@
-import Vue from "vue";
 import axios from "axios";
 // @ts-ignore
 import { loadProgressBar } from "axios-progress-bar";
-import cachingGet from "./axiosCache";
 import axiosRetry from "axios-retry";
 import { message } from "ant-design-vue";
 
 const config = {
   timeout: 60 * 1000, // Timeout
 };
-const cacheGetUrls: [RegExp] | [] = [];
 
 const _axiosNoAuth = axios.create(config);
 axiosRetry(_axiosNoAuth);
@@ -58,7 +55,7 @@ _axiosNoAuth.interceptors.response.use(
   }
 );
 
-_axiosNoAuth.get = cachingGet(_axiosNoAuth, cacheGetUrls);
+// eslint-disable-next-line @typescript-eslint/no-unsafe-call
 loadProgressBar(null, _axiosNoAuth);
 
 // Plugin.install = function (Vue) {

+ 6 - 6
src/plugins/axiosNotice.ts

@@ -1,4 +1,3 @@
-import Vue from "vue";
 import { throttle } from "lodash-es";
 import { message } from "ant-design-vue";
 import { logout } from "@/api/loginPage";
@@ -14,11 +13,12 @@ export const notifyInvalidTokenThrottled = throttle(
       duration: 10,
     });
     setTimeout(() => {
-      logout().finally(() =>
-        routeLogout({
-          cause: "登录失效",
-          redirectTo: router.currentRoute.value.fullPath,
-        })
+      logout().finally(
+        () =>
+          void routeLogout({
+            cause: "登录失效",
+            redirectTo: router.currentRoute.value.fullPath,
+          })
       );
     }, 1000);
     console.log("登录失效");

+ 3 - 3
src/router/index.ts

@@ -112,9 +112,9 @@ export async function routeLogout(params: {
 router.beforeEach((to, from, next) => {
   const token = getToken();
   if (isNil(token) && to.path.includes("/login") === false) {
-    routeLogout({ cause: "missingToken", redirectTo: to.fullPath }).then(() =>
-      next(false)
-    );
+    routeLogout({ cause: "missingToken", redirectTo: to.fullPath })
+      .then(() => next(false))
+      .catch((e) => console.log(e));
   } else {
     next();
   }

+ 2 - 0
src/setups/useTimers.ts

@@ -12,6 +12,7 @@ export function useTimers() {
    * @param {function} fn 要执行的函数
    * @param {number} interval 执行间隔ms
    */
+  // eslint-disable-next-line @typescript-eslint/ban-types
   function addInterval(fn: Function, interval: number) {
     const i = setInterval(fn, interval);
     mixin__intervals.push(i);
@@ -21,6 +22,7 @@ export function useTimers() {
    * @param {function} fn 要执行的函数
    * @param {number} timeout 触发时间ms
    */
+  // eslint-disable-next-line @typescript-eslint/ban-types
   function addTimeout(fn: Function, timeout: number) {
     const i = setTimeout(fn, timeout);
     mixin__timeouts.push(i);

+ 0 - 1
src/types/global.d.ts

@@ -1,4 +1,3 @@
-import { ComponentCustomProperties } from "vue";
 import filters from "@/filters";
 import { default as message } from "ant-design-vue/lib/message";
 // import { default as notification } from "ant-design-vue/lib/notification";

+ 3 - 3
src/utils/utils.ts

@@ -3,17 +3,17 @@ import router from "@/router";
 import { AxiosResponse } from "axios";
 
 // 下载文件
-export async function downloadFileURL(url: string, name?: string) {
+export async function downloadFileURL(url: string) {
   return httpApp
     .get(url, { responseType: "blob" })
     .then((res) => {
       return responseToFile(res);
     })
-    .catch((err) => {});
+    .catch((err) => console.log(err));
 }
 
 export async function responseToFile(response: AxiosResponse) {
-  return new Promise((resolve) => {
+  return new Promise(() => {
     const { data, headers } = response;
     const fileName = headers["content-disposition"].replace(
       /\w+;\s*filename=(.*)/,