Procházet zdrojové kódy

feat: 同步锁定

gemercheung před 9 měsíci
rodič
revize
a49cfc0250
3 změnil soubory, kde provedl 39 přidání a 11 odebrání
  1. 15 2
      src/request/config.ts
  2. 22 8
      src/request/index.ts
  3. 2 1
      src/view/case/photos/index.vue

+ 15 - 2
src/request/config.ts

@@ -10,6 +10,8 @@ import {
   getModelSceneList,
   getRoleList,
   getSceneList,
+  getSysSetting,
+  getTreeselect,
   insertCaseFile,
   saveCaseFileInfo,
   sendUserMsg,
@@ -21,6 +23,8 @@ import {
   uploadModel,
   userLogin,
   userReg,
+  getCaseHasDownloadProcess,
+  ffmpegMergeImage
 } from "./urls";
 
 // 不需要登录就能请求的接口
@@ -28,6 +32,8 @@ export const notLoginUrls = [
   userLogin,
   getCode,
   sendUserMsg,
+  getSysSetting,
+  getTreeselect,
   userReg,
   updatePsw,
   getCompanyList,
@@ -35,7 +41,9 @@ export const notLoginUrls = [
   getAttachListByPsw,
 ];
 // 需要用表单提交的数据
-export const fromUrls: string[] = [];
+export const fromUrls: string[] = [
+  // ffmpegMergeImage
+];
 // 带文件的请求
 export const fileUrls = [
   uploadAttachFile,
@@ -45,6 +53,7 @@ export const fileUrls = [
   uploadFile,
   insertCaseFile,
   saveCaseFileInfo,
+  ffmpegMergeImage
 ];
 // 需要限定卫GET请求方式的url
 export const GetUrls = [getRoleList, getCompanyList];
@@ -63,4 +72,8 @@ export const successCode = [0, "000000", 200];
 // baseURL
 export const baseURL = import.meta.env.DEV ? "/api" : "";
 
-export const notOpenUrls: string[] = [uploadModel, getDownloadProcess];
+export const notOpenUrls: string[] = [
+  uploadModel,
+  getDownloadProcess,
+  getCaseHasDownloadProcess,
+];

+ 22 - 8
src/request/index.ts

@@ -26,7 +26,7 @@ export type AuthHook = () => {
   clear: () => void;
 };
 export const setAuthHook = (hook: AuthHook) => (getAuth = hook);
-let getAuth: AuthHook = () => ({ token: "", userId: "0", clear: () => {} });
+let getAuth: AuthHook = () => ({ token: "", userId: "0", clear: () => { } });
 
 axios.defaults.baseURL = baseURL;
 
@@ -45,14 +45,17 @@ axios.interceptors.request.use(async (config) => {
   }
 
   const { token, userId } = getAuth();
-  if (!token && !~notLoginUrls.indexOf(config.url)) {
-    router.replace({ name: RouteName.login });
-    throw "用户未登录";
-  }
-
   config.headers.token = token;
   config.headers.userid = userId;
 
+  const hasIgnore = config.params ? "ingoreRes" in config.params : false;
+  if (!hasIgnore) {
+    if (!token && !~notLoginUrls.indexOf(config.url)) {
+      router.replace({ name: RouteName.login });
+      throw "用户未登录";
+    }
+  }
+
   if (~GetUrls.indexOf(config.url)) {
     config.method = "GET";
   } else if (~PostUrls.indexOf(config.url)) {
@@ -71,7 +74,15 @@ axios.interceptors.request.use(async (config) => {
     const fromData = new FormData();
 
     Object.keys(config.data).forEach((key) => {
-      fromData.append(key, config.data[key]);
+      if (key === 'files') {
+        Array.from(config.data[key]).forEach(file => {
+          fromData.append('files', file as any as File);
+        })
+      } else {
+        fromData.append(key, config.data[key]);
+      }
+
+
     });
     config.data = fromData;
     config.headers["Content-Type"] = "multipart/form-data";
@@ -83,7 +94,10 @@ axios.interceptors.request.use(async (config) => {
 
 const responseInterceptor = (res: AxiosResponse<any, any>) => {
   closeLoading();
-  if (!successCode.includes(res.data.code)) {
+  const hasIgnore = res.config.params
+    ? "ingoreRes" in res.config.params
+    : false;
+  if (!successCode.includes(res.data.code) && !hasIgnore) {
     let errMsg = res.data.msg || res.data.message;
     openErrorMsg(errMsg);
 

+ 2 - 1
src/view/case/photos/index.vue

@@ -247,15 +247,16 @@ const renderCanvas = () => {
   });
   scene.on("submitScreenshot", (save) => {
     if (window.scene) {
+
       const params = {
         files: window.scene.blobScreens.map(
           (b, index) => new File([b], `${Date.now()}-${index}.jpg`)
         ),
         caseId: caseId.value,
       };
-
       setTimeout(async () => {
         try {
+          console.log('参数',params)
           const res = await submitMergePhotos(params);
           console.log("res", res);
           const { data, code } = res;