wangfumin 2 місяців тому
батько
коміт
37c0c75edf
4 змінених файлів з 64 додано та 10 видалено
  1. 2 2
      index.html
  2. 44 0
      offline.html
  3. 17 2
      src/api/floder.ts
  4. 1 6
      src/model/index.ts

+ 2 - 2
index.html

@@ -24,11 +24,11 @@
         console.log(appParam, basePath, 6666)
         if (appParam.app == '1') {
           faviconPath = basePath + 'fire.ico';
-        } else if (appParam.app == '2' && appParam.isSample == '0') {
+        } else if (appParam.app == '2' && appParam.isSample == '1') {
           faviconPath = basePath + 'police.ico';
         } else if (appParam.app == '3') {
           faviconPath = basePath + 'jmlogo.png';
-        } else if (appParam.app == '2' && appParam.isSample == '1') {
+        } else if (appParam.app == '2' && appParam.isSample == '0') {
           faviconPath = basePath + 'logo_big.ico';
         }
         

+ 44 - 0
offline.html

@@ -9,6 +9,50 @@
     <link rel="stylesheet" type="text/css" href="./lib/Cesium/Widgets/CesiumWidget/lighter.css">
     <script>window.offline = true</script>
   </head>
+  <script>
+    // 获取URL参数中的app值
+    function getAppParam() {
+      const urlParams = new URLSearchParams(window.location.search);
+      return {app: urlParams.get('app'), isSample: urlParams.get('isSample')};
+    }
+
+    // 根据app参数设置favicon
+    function setFavicon() {
+      const appParam = getAppParam();
+      // 获取基础路径
+      const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
+      let faviconPath = basePath + 'favicon.ico'; // 默认图标
+      console.log(appParam, basePath, 6666)
+      if (appParam.app == '1') {
+        faviconPath = basePath + 'fire.ico';
+      } else if (appParam.app == '2' && appParam.isSample == '1') {
+        faviconPath = basePath + 'police.ico';
+      } else if (appParam.app == '3') {
+        faviconPath = basePath + 'jmlogo.png';
+      } else if (appParam.app == '2' && appParam.isSample == '0') {
+        faviconPath = basePath + 'logo_big.ico';
+      }
+      
+      // 查找现有的favicon链接元素
+      let link = document.querySelector("link[rel~='icon']");
+      
+      // 如果没有找到,创建一个新的
+      if (!link) {
+        link = document.createElement('link');
+        link.rel = 'icon';
+        document.head.appendChild(link);
+      }
+      
+      // 设置favicon路径
+      link.href = faviconPath;
+    }
+
+    // 页面加载时设置favicon
+    window.addEventListener('load', setFavicon);
+    
+    // 当URL通过History API变化时也更新favicon
+    window.addEventListener('popstate', setFavicon);
+  </script>
   <body>
     <div id="app"></div>
     <script type="module" src="/src/main.ts"></script>

+ 17 - 2
src/api/floder.ts

@@ -42,6 +42,7 @@ export const fetchFloders = async () => {
       })
     })
   }
+  console.log('floders', floders)
   await Promise.all(otherFloders.map(async of => {
     const kybl = await axios.get(of.ex, { params: { caseId: params.caseId } })
     if (kybl) {
@@ -54,5 +55,19 @@ export const fetchFloders = async () => {
       })
     }
   }))
-  return floders
-}
+  const uniqueFloders = floders.reduce((acc: Floders, current) => {
+    const isDuplicate = acc.some(item => 
+      item.filesTitle === current.filesTitle && 
+      item.filesTypeId === current.filesTypeId && 
+      item.filesId === current.filesId
+    );
+    
+    if (!isDuplicate) {
+      acc.push(current);
+    }
+    
+    return acc;
+  }, []);
+  console.log('uniqueFloders', uniqueFloders)
+  return uniqueFloders
+}

+ 1 - 6
src/model/index.ts

@@ -14,9 +14,7 @@ export type { ModelExpose }
 
 export const fuseModel = Symbol('fuse')
 export const currentModel = ref<ModelType>(fuseModel)
-watchEffect(() => {
-  console.error(currentModel.value, 'currentModel')
-}, { flush: 'sync'  })
+
 export const modelProps: ModelProps = reactive({ type: currentModel, callback: null })
 export const getModelTypeDesc = (model: ModelType) => {
   if (model === fuseModel) {
@@ -39,8 +37,6 @@ const _loadModel = (() => {
   let oldResult: Promise<ModelExpose>
 
   return (modelType: ModelType) => {
-    console.log(oldModelType, modelType, 'oldModelType')
-    console.log(deepIsRevise(oldModelType, modelType), 'oldModelType')
     if (!deepIsRevise(oldModelType, modelType)) {
       return oldResult
     }
@@ -54,7 +50,6 @@ const _loadModel = (() => {
           resolve(data)
         }
       }
-      console.log(modelType, oldModelType, '不是吧')
       currentModel.value = modelType
     })
   }