bill 5 月之前
父節點
當前提交
de1028a259
共有 4 個文件被更改,包括 38 次插入32 次删除
  1. 1 1
      src/api/constant.ts
  2. 2 1
      src/api/setting.ts
  3. 32 27
      src/env/index.ts
  4. 3 3
      src/sdk/association/fuseMode.ts

+ 1 - 1
src/api/constant.ts

@@ -109,6 +109,6 @@ export const UPLOAD_FILE = `${namespace}/upload/file`
 
 // 素材库分页
 export const MATERIAL_PAG = `${namespace}/dictFile/pageList/media-library`
-export const ADD_MATERIAL = `${namespace}/common/upload/fileNew`
+export const ADD_MATERIAL = `${namespace}/upload/fileNew`
 export const DEL_MATERIAL = `${namespace}/dictFile/del/media-library`
 export const MATERIAL_GROUP_LIST = `${namespace}/dict/getByKey/media-library`

+ 2 - 1
src/api/setting.ts

@@ -3,6 +3,7 @@ import defaultCover from "@/assets/cover.png";
 import { params } from "@/env";
 import axios from "./instance";
 
+
 type ServeSetting = {
   settingsId?: string;
   pose?: string;
@@ -33,7 +34,7 @@ export type Setting = {
 const toLocal = (serviceSetting: ServeSetting): Setting => ({
   id: serviceSetting.settingsId,
   pose: serviceSetting.pose && JSON.parse(serviceSetting.pose),
-  cover: serviceSetting.cover || defaultCover,
+  cover: serviceSetting.cover || (params.static +"/fusion/default/images/cover.png"),
   back: serviceSetting.back || "map",
   mapType: serviceSetting.mapType || 'satellite',
 });

+ 32 - 27
src/env/index.ts

@@ -63,7 +63,7 @@ export type Params = {
   laserRoot: string;
   panoOSSRoot: string;
   ossRoot: string;
-  root: string
+  root: string;
   laserOSSRoot: string;
   service: string;
   fileUrl?: string;
@@ -98,45 +98,50 @@ export const getResource = (uri: string) => {
 // /fusion
 
 if (import.meta.env.DEV) {
-  params.ip = 'http://192.168.0.62'
-  params.static = '/profile'
-  params.laserServicePort = '9008'
-  params.servicePort = '8808'
+  // params.ip = "http://192.168.0.62";
+  // params.static = "/profile";
+  // params.laserServicePort = "9008";
+  // params.servicePort = "8808";
 } else {
-  params.ip = params.ip || ''
-  params.static = params.static || ''
-  params.laserServicePort = params.laserServicePort || ''
-  params.servicePort = params.servicePort || ''
+  params.ip = params.ip || "";
+  params.static = params.static || "";
+  params.laserServicePort = params.laserServicePort || "";
+  params.servicePort = params.servicePort || "";
 }
 
-const ip = params.ip + ':';
-params.root = `${ip}${params.laserServicePort}`
-params.ossRoot = `${ip}${params.laserServicePort}/${params.static}/`
+const ip = params.ip + ":";
+params.root = `${ip}${params.laserServicePort}`;
+params.ossRoot = `${ip}${params.laserServicePort}/${params.static}/`;
 params.serviceUrl = `${ip}${params.servicePort}/fusion`;
-params.laserRoot = params.root
+params.laserRoot = params.root;
 
 // params.laserOSSRoot = 'asd/'
 
-params.serviceUrl = '/fusion'
+params.serviceUrl = "/fusion";
 export let namespace = params.serviceUrl;
 
-
 export const getResources = (uri: string) => {
+  uri = uri.replaceAll("\\", "/");
   if (
     !params.ossRoot ||
-    ~uri.indexOf('base64') ||
-    ~uri.indexOf('bolb') ||
-    ~uri.indexOf('//')
+    ~uri.indexOf("base64") ||
+    ~uri.indexOf("bolb") ||
+    ~uri.indexOf("//")
   )
-    return uri
+    return uri;
 
-  const root = uri.indexOf('/' + params.static) === 0 ? `${ip}${params.laserServicePort}` : params.ossRoot
-  const baseURL = new URL(root)
-  const url = new URL(uri, root)
+  const root =
+    uri.indexOf(params.static.substring(1)) === 0 ||
+    uri.indexOf(params.static) === 0
+      ? `${ip}${params.laserServicePort}`
+      : params.ossRoot;
+  const baseURL = new URL(root);
+  const url = new URL(uri, root);
+  console.log(root, uri);
   const basePath =
-    baseURL.pathname[baseURL.pathname.length - 1] === '/'
+    baseURL.pathname[baseURL.pathname.length - 1] === "/"
       ? baseURL.pathname.substring(0, baseURL.pathname.length - 1)
-      : baseURL.pathname
-  url.pathname = basePath + url.pathname
-  return url.href
-}
+      : baseURL.pathname;
+  url.pathname = basePath + url.pathname;
+  return url.href;
+};

+ 3 - 3
src/sdk/association/fuseMode.ts

@@ -1,6 +1,6 @@
 import { SDK, SceneModel, ModelAttrRange } from "../sdk";
 import { toRaw, watch, reactive, ref } from "vue";
-import { custom, getResource } from "@/env";
+import { custom, getResource, getResources } from "@/env";
 import {
   diffArrayChange,
   shallowWatchArray,
@@ -48,7 +48,6 @@ const setModels = (sdk: SDK, models: FuseModels, oldModels: FuseModels) => {
     if (getSceneModel(item)) {
       continue;
     }
-    console.error('addMode', item)
     if (item.status !== SceneStatus.SUCCESS) {
       item.error = true;
       item.loaded = true;
@@ -59,6 +58,7 @@ const setModels = (sdk: SDK, models: FuseModels, oldModels: FuseModels) => {
     let sceneModel: SceneModel;
     try {
       
+    console.error('addMode', item.url, item.url.map(getResources))
       sceneModel = sdk.addModel({
         ...itemRaw,
         ...modelRange,
@@ -71,7 +71,7 @@ const setModels = (sdk: SDK, models: FuseModels, oldModels: FuseModels) => {
           : item.modelType,
         url: [SceneType.SWSS, SceneType.SWYDSS].includes(item.type)
           ? item.url
-          : item.url && item.url.map(getResource),
+          : item.url && item.url.map(getResources),
         fromType: item.type,
       });
     } catch (e) {