Browse Source

对someData.json各字段处理,酌情改为从本地拿资源

任一存 2 years ago
parent
commit
b12bbac00f
3 changed files with 39 additions and 2 deletions
  1. BIN
      dist.zip
  2. 38 1
      src/apis/index.js
  3. 1 1
      src/pages/showMobile.js

BIN
dist.zip


+ 38 - 1
src/apis/index.js

@@ -13,6 +13,37 @@ const HDNumber = function () {
   return config.hengdaNum;
 };
 
+function changeSubStr(targetStr, subStr1, subStr2) {
+  return targetStr.replace(subStr1, subStr2)
+}
+
+function deepProcess(obj, detailWork, ...otherP) {
+  if(obj === null || obj === undefined) {
+    return
+  }
+
+  if (Array.isArray(obj)) {
+    for (let index = 0; index < obj.length; index++) {
+      const element = obj[index];
+      if (typeof element === 'string') {
+        obj[index] = detailWork(element, ...otherP)
+      } else if (typeof element === 'object') {
+        deepProcess(element, detailWork, ...otherP)
+      }
+    }
+  } else if (typeof obj === 'object') {
+    for (const key in obj) {
+      if (Object.hasOwnProperty.call(obj, key)) {
+        if (typeof obj[key] === 'string') {
+          obj[key] = detailWork(obj[key], ...otherP)
+        } else if (typeof obj[key] === 'object') {
+          deepProcess(obj[key], detailWork, ...otherP)
+        }
+      }
+    }
+  }
+}
+
 /**
  * 获取全景作品基本信息
  * @param {*} data
@@ -20,7 +51,13 @@ const HDNumber = function () {
  * @param {*} no
  */
 export function getPanoInfo(ok, no) {
-  return http.get(`${process.env.VUE_APP_CDN}/720yun_fd_manage/${number()}/someData.json?_=${Math.random()}`, {}, ok, no);
+  return http.get(`${process.env.VUE_APP_CDN}/720yun_fd_manage/${number()}/someData.json?_=${Math.random()}`, {}, ok, no).then((res) => {
+    if (process.env.VUE_APP_CLI_MODE === 'local') {
+      deepProcess(res, changeSubStr, 'https://4dkk.4dage.com/720yun_fd_manage/', '/720yun_fd_manage/')
+      deepProcess(res, changeSubStr, 'https://4dscene.4dage.com/culturalrelics/JSYSBW/Model.html?m=', '/JSYSBWModel/Model2.html?m=')
+    }
+    return res
+  })
 }
 
 /**

+ 1 - 1
src/pages/showMobile.js

@@ -11,7 +11,7 @@ import Deferred from "@/utils/Deferred";
 import store from '../store'
 import VueLazyLoad from 'vue3-lazyload'
 
-console.log('2023.06.28.11.09');
+console.log('2023.07.19');
 
 let App;
 if (