浏览代码

Merge branch 'v2.0.0-jm-local' of http://192.168.0.115:3000/bill/fuse-code into v2.0.0-jm-local

bill 1 月之前
父节点
当前提交
86fdaf863f

+ 1 - 1
src/api/material.ts

@@ -154,7 +154,7 @@ export const syncMaterialAll = async () => {
 };
 
 export const addMaterial = (file: File) => {
-  return axios<string>({
+  return axios<any>({
     method: "POST",
     url: ADD_MATERIAL,
     data: jsonToForm({ file }),

二进制
src/components/materials/image1.png


二进制
src/components/materials/image2.png


+ 105 - 0
src/components/materials/loc-upload.vue

@@ -0,0 +1,105 @@
+<template>
+  <Modal
+    width="600px"
+    :title="$t('fuse.localUpload')"
+    :open="visible"
+    @ok="okHandler"
+    :afterClose="afterClose"
+    @cancel="emit('update:visible', false)"
+    :okText="$t('sys.upload.name1')"
+    :cancelText="$t('sys.cancel')"
+    class="model-table"
+  >
+    <ui-input
+      width="200px"
+      style="display: none"
+      class="input"
+      ref="inputRef"
+      :accept="ft"
+      :maxSize="maxSize"
+      @update:modelValue="(file: File) => uploadHandler(file)"
+      type="file"
+    >
+      <template v-slot:replace>
+        <Button type="primary" ghost ref="btn" style="width: 100%">
+          <ui-icon type="add" class="icon" />{{ $t("sys.upload.place1") }}
+        </Button>
+      </template>
+    </ui-input>
+    <div class="bund">
+      <h4>{{ $t("fuse.modelUpload.title0") }}</h4>
+      <p>
+        {{ $t("fuse.modelUpload.desc0") }}
+      </p>
+      <img src="./image1.png" />
+    </div>
+    <div class="bund">
+      <h4>{{ $t("fuse.modelUpload.title1") }}</h4>
+      <p>
+        {{ $t("fuse.modelUpload.desc1") }}
+      </p>
+      <img src="./image2.png" />
+    </div>
+  </Modal>
+</template>
+
+<script lang="ts" setup>
+import { Modal, Table, Empty, Button } from "ant-design-vue";
+import { getSizeStr } from "@/utils";
+import { addMaterial, Material } from "@/api/material";
+import { computed, ref } from "vue";
+
+const props = defineProps<{
+  uploadFormat?: string[];
+  format?: string[];
+  maxSize?: number;
+  visible: boolean;
+  count?: number;
+  readonly?: boolean;
+  groupIds: number[];
+  useType?: string;
+  afterClose?: () => void;
+}>();
+
+const emit = defineEmits<{
+  (e: "update:visible", v: boolean): void;
+  (e: "selectMaterials", v: Material[]): void;
+}>();
+
+const ft = computed(() => {
+  const ft = props.uploadFormat || props.format;
+  if (!ft) return void 0;
+  return ft.map((t) => `.${t}`).join(",");
+});
+
+const inputRef = ref();
+const okHandler = () => {
+  console.log(inputRef.value.vmRef);
+  inputRef.value.vmRef.input.click();
+};
+
+const uploadHandler = async (file: File) => {
+  const m = await addMaterial(file);
+  emit("selectMaterials", [{ ...m, uploadId: m.id }]);
+};
+</script>
+
+<style lang="less" scoped>
+.bund {
+  &:not(:first-child) {
+    margin-top: 20px;
+  }
+  h4 {
+    margin-bottom: 4px;
+    color: #fff;
+  }
+  p {
+    margin-bottom: 10px;
+    color: #ccc;
+  }
+
+  img {
+    width: 200px;
+  }
+}
+</style>

+ 34 - 0
src/components/materials/quisk.ts

@@ -1,5 +1,6 @@
 import { mount } from "@/utils";
 import Materials from "./index.vue";
+import Materials1 from "./loc-upload.vue";
 import { Material } from "@/api/material";
 import { reactive } from "vue";
 
@@ -32,3 +33,36 @@ export const selectMaterials = async (props: {
     const umMount = mount(document.querySelector("#app")!, Materials, mprops);
   });
 };
+
+
+
+export const selectMaterials1 = async (props: {
+  uploadFormat?: string[],
+  format?: string[];
+  isSystem?: number,
+  maxSize?: number;
+  count?: number
+  readonly?: boolean;
+  groupIds?: number[]
+  useType?: string
+} = {}) => {
+  return new Promise<Material[] | null>((resolve) => {
+    const mprops = reactive({
+      ...props,
+      visible: true,
+      onSelectMaterials: (val: Material[]) => {
+        resolve(val);
+        mprops.visible = false
+      },
+      "onUpdate:visible": () => {
+        mprops.visible = false
+        resolve(null);
+      },
+      afterClose() {
+        umMount();
+      }
+    })
+    const umMount = mount(document.querySelector("#app")!, Materials1, mprops);
+  });
+};
+

+ 1 - 1
src/components/static-preview/resource.vue

@@ -51,7 +51,7 @@ const props = defineProps<{
 
 const url = computed(() =>
   typeof props.data === "string"
-    ? getResource(props.data)
+    ? getResources(props.data)
     : URL.createObjectURL(props.data)
 );
 

+ 2 - 2
src/components/static-preview/sign.vue

@@ -8,7 +8,7 @@
 
 <script lang="ts" setup>
 import { ref, watchEffect } from "vue";
-import { getResource } from "@/env";
+import { getResource, getResources } from "@/env";
 import ResourceView from "./resource.vue";
 import type { MediaItem } from "./index.vue";
 
@@ -18,7 +18,7 @@ defineEmits<{ (e: "close", v: boolean): void }>();
 const staticURL = ref("");
 watchEffect(() => {
   const data = props.media.url;
-  const url = typeof data === "string" ? getResource(data) : URL.createObjectURL(data);
+  const url = typeof data === "string" ? getResources(data) : URL.createObjectURL(data);
 
   staticURL.value = url;
   return () => URL.revokeObjectURL(url);

+ 3 - 2
src/components/tagging/sign-new.vue

@@ -108,7 +108,7 @@ const [posStyle, pos, pause, recovery] = usePixel(() => undefined);
 
 const queryItems = computed(() =>
   props.tagging.images.map((image) => ({
-    url: getResource(getFileUrl(image)),
+    url: getResources(getFileUrl(image)),
   }))
 );
 console.log(props.tagging.styleId);
@@ -130,7 +130,8 @@ tag.showDelete = (show) => {
 tag.changeCanMove(false);
 
 const changePos = () => {
-  pos.value = { localPos: tag.getImageCenter(), modelId: props.scenePos.modelId };
+  const old = { localPos: tag.getImageCenter(), modelId: props.scenePos.modelId };
+  console.log(pos.value, old);
 };
 
 watch(taggingStyle, (icon) => icon && tag.changeImage(getFileUrl(icon.icon)));

+ 4 - 4
src/components/tagging/sign.vue

@@ -10,7 +10,7 @@
     <ui-tip :tip="tagging.title" foreShow tipV="top" class="tag-tip">
       <img
         class="tag-img"
-        :src="getResource(getFileUrl(taggingStyle.icon))"
+        :src="getResources(getFileUrl(taggingStyle.icon))"
         @click="iconClickHandler"
         v-if="taggingStyle"
       />
@@ -21,7 +21,7 @@
         <ui-audio
           v-if="tagging.audio"
           class="audio"
-          :src="getResource(getFileUrl(tagging.audio))"
+          :src="getResources(getFileUrl(tagging.audio))"
           ref="audio"
         />
         <div class="content">
@@ -65,7 +65,7 @@ import Preview from "../static-preview/index.vue";
 import { getTaggingStyle, getFuseModel } from "@/store";
 import { getFileUrl, MetaType } from "@/utils";
 import { sdk } from "@/sdk";
-import { custom, getResource } from "@/env";
+import { custom, getResource, getResources } from "@/env";
 import { useViewStack } from "@/hook";
 
 import type { Tagging, TaggingPosition } from "@/store";
@@ -116,7 +116,7 @@ const isHover = ref(false);
 const queryItems = computed(() =>
   props.tagging.images.map((image) => ({
     type: MetaType.image,
-    url: getResource(getFileUrl(image)),
+    url: getResources(getFileUrl(image)),
   }))
 );
 

+ 0 - 1
src/env/index.ts

@@ -197,7 +197,6 @@ export const getResources = (uri: string) => {
 
   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.substring(0, baseURL.pathname.length - 1)

+ 2 - 2
src/lang/locales/en.json

@@ -312,8 +312,8 @@
       "rotation": "Rotate icon",
       "scale": "Icon size",
       "type": "Icon placement method",
-      "typeVal[0]": "Hover",
-      "typeVal[1]": "Attach",
+      "typeVal0": "Hover",
+      "typeVal1": "Attach",
       "visibilityRange": "Visible range"
     },
     "posTip": "Click on the model to select the tag position.",

+ 2 - 2
src/lang/locales/ja.json

@@ -309,8 +309,8 @@
       "rotation": "アイコン回転",
       "scale": "アイコンサイズ",
       "type": "アイコン配置方法",
-      "typeVal[0]": "浮遊",
-      "typeVal[1]": "地面/壁面",
+      "typeVal0": "浮遊",
+      "typeVal1": "地面/壁面",
       "visibilityRange": "表示範囲"
     },
     "posTip": "モデル上をクリックしてタグ位置を選択してください",

+ 2 - 2
src/lang/locales/ko.json

@@ -309,8 +309,8 @@
       "rotation": "회전 아이콘",
       "scale": "아이콘 크기",
       "type": "아이콘 배치 방법",
-      "typeVal[0]": "부유하다",
-      "typeVal[1]": "땅/벽에 붙이다",
+      "typeVal0": "부유하다",
+      "typeVal1": "땅/벽에 붙이다",
       "visibilityRange": "시야 범위"
     },
     "posTip": "모델 위에서 클릭하여 라벨 위치를 선택해 주세요",

+ 2 - 2
src/lang/locales/zh.json

@@ -381,8 +381,8 @@
       "rotation": "旋转图标",
       "scale": "图标大小",
       "type": "图标放置方式",
-      "typeVal[0]": "悬浮",
-      "typeVal[1]": "贴地/墙",
+      "typeVal0": "悬浮",
+      "typeVal1": "贴地/墙",
       "visibilityRange": "可见范围"
     },
     "posTip": "请在模型上单击选择标签位置",

+ 6 - 6
src/layout/edit/scene-select.vue

@@ -61,7 +61,7 @@
       <template #overlay>
         <Menu>
           <MenuItem @click="visible = true">{{ $t("scene.manage") }}</MenuItem>
-          <MenuItem @click="selectModel">{{ $t("material.name") }}</MenuItem>
+          <MenuItem @click="selectModel">{{ $t("fuse.localUpload") }}</MenuItem>
         </Menu>
       </template>
     </Dropdown>
@@ -93,8 +93,8 @@ import {
 } from "@/store";
 
 import { fetchScenesAll, SceneType, uploadMaterialToModel, type Scene } from "@/api";
-import { activeModel, getSceneModel } from "@/sdk";
-import { selectMaterials } from "@/components/materials/quisk";
+import { activeModel, getSceneModel, sceneModelMap } from "@/sdk";
+import { selectMaterials, selectMaterials1 } from "@/components/materials/quisk";
 import { lang, ui18n } from "@/lang";
 import { custom } from "@/env";
 import { actionItems, currentItem } from "@/views/merge";
@@ -205,7 +205,7 @@ const addModelHandler = createLoadPack(async (attachs: any[]) => {
       attach
     }
   });
-  const addPromises = items.map(item => addFuseModel(item.data, item.attach));
+  const addPromises = items.map(item => addFuseModel(item.data, item.attach).then(data => item.data = data));
 
   const addModels = await Promise.all(addPromises);
   await new Promise<void>((resolve) => {
@@ -222,6 +222,7 @@ const addModelHandler = createLoadPack(async (attachs: any[]) => {
   });
 
   items.forEach(item => {
+    console.error('--->', item, getSceneModel(item.data), sceneModelMap)
     if (getSceneModel(item.data)) {
       item.data.rotation = getSceneModel(item.data)!.getDefaultRotation();
     }
@@ -255,14 +256,13 @@ watch(visible, (visible, oldvisible) => {
 });
 
 const selectModel = async () => {
-  let list = await selectMaterials({
+  let list = await selectMaterials1({
     uploadFormat: ["zip"],
     format: ["obj", "ply", "las", "laz", "b3dm", "shp", "osgb", "glb"],
     maxSize: 2 * 1024 * 1024 * 1024,
   });
   if (!list?.length) return;
   list = list.filter(item => item.uploadId)
-
   // const modelList = await Promise.all(list.map(item => uploadMaterialToModel(item.uploadId!)))
   const attachs: any[] = []
   for (let i = 0; i < list.length; i++) {

+ 0 - 6
src/layout/model-list/index.vue

@@ -34,12 +34,6 @@ import { flyModel } from "@/hook/use-fly";
 import { sdk } from "@/sdk/sdk";
 import { ui18n } from "@/lang";
 
-watchEffect(
-  () => {
-    console.error("modeChange", custom.showMode);
-  },
-  { flush: "sync" }
-);
 export type ModelListProps = {
   title?: string;
   canChange?: boolean;

+ 2 - 1
src/sdk/association/animation.ts

@@ -33,7 +33,7 @@ import { Size } from "@/components/drawing/dec";
 import router, { RoutesName } from "@/router";
 import { isEdit, isTemploraryID, paths } from "@/store";
 import { Color } from "three";
-import { custom, showAMsStack } from "@/env";
+import { custom, getResource, getResources, showAMsStack } from "@/env";
 
 export let animationGroup: AnimationGroup;
 export const getAMKey = (am: AnimationModel) => am.key || am.id;
@@ -76,6 +76,7 @@ export const addAM = (data: AnimationModel): Promise<AnimationModel3D> => {
         };
         const am = animationGroup.addAnimationModel({
           ...data,
+          url: getResources(data.url),
           quaAtPath: data.mat?.quaAtPath,
         });
         am.bus.on("loadDone", () => {

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

@@ -25,7 +25,7 @@ import { currentLayout, RoutesName } from "@/router";
 import { unsetFactory } from "@/utils/unset";
 import { getTaggingPosNode, taggingGroup } from "./tagging";
 
-const us = unsetFactory()
+export const us = unsetFactory()
 
 // -----------------模型关联--------------------
 

+ 18 - 10
src/store/map.ts

@@ -1,4 +1,5 @@
 import { params } from "@/env";
+import { aMapToWgs84 } from "@/utils/coord";
 
 export type Address = { address: string; latlng: number[]; id: string };
 const platform = {
@@ -15,13 +16,21 @@ const platform = {
         }
         console.log(res);
         const items = res.geocodes
-          .map((item: any) => ({
-            id: item.location,
-            address: item.formatted_address,
-            latlng: item.location
+          .map((item: any) => {
+            const ll = item.location
               .split(",")
-              .map((item: string) => Number(item.trim())),
-          }))
+              .map((item: string) => Number(item.trim()));
+            const p = aMapToWgs84({
+              x: Number(ll[0]),
+              y: Number(ll[1]),
+            });
+
+            return {
+              id: item.location,
+              address: item.formatted_address,
+              latlng: [p.x, p.y]
+            };
+          })
           .slice(0, 10);
         return items;
       });
@@ -31,7 +40,6 @@ const platform = {
     tipParams.set("basic", "y");
     tipParams.set("key", val);
     tipParams.set("location", "113.05,22.61");
-
     const keyList = (await fetch(`/s/api/gettips?${tipParams.toString()}`)
       .then((res) => res.json())
       .then((res) => res.data)) as { name: string }[];
@@ -54,14 +62,14 @@ const platform = {
         });
     });
 
-    await Promise.all(reqs)
-    return items
+    await Promise.all(reqs);
+    return items;
   },
 };
 
 export const searchAddress = (val: string): Promise<Address[]> => {
   if (!val) return Promise.resolve([]);
-  console.log(import.meta.env.VITE_MAP_PLATFORM)
+  console.log(import.meta.env.VITE_MAP_PLATFORM);
   const p = (
     params.mapPlatform && params.mapPlatform in platform
       ? params.mapPlatform

+ 5 - 4
src/store/sys.ts

@@ -6,6 +6,7 @@ import { useViewStack } from "@/hook";
 import type { UnwrapRef } from "vue";
 import { currentMeta } from "@/router";
 import { ui18n } from "@/lang";
+import { stackVar } from "@/components/drawing/hook";
 
 const Flags = {
   EDIT: 0b10,
@@ -100,11 +101,11 @@ export type AutoSetModeSetting<T> = {
   recovery?: () => void;
 };
 
-let isUnset = false;
+export let isUnset = stackVar(false);
 export const unSetModelUpdate = (run: () => void) => {
-  isUnset = true;
+  const pop = isUnset.push(true)
   run();
-  nextTick(() => (isUnset = false));
+  nextTick(pop);
 };
 export const autoSetModeCallback = <T extends object>(
   current: T,
@@ -137,7 +138,7 @@ export const autoSetModeCallback = <T extends object>(
   };
 
   const handler = (newv: UnwrapRef<T>, oldv?: UnwrapRef<T>) => {
-    if (isSave || isUnset || isLeaveIng) return;
+    if (isSave || isUnset.value || isLeaveIng) return;
     if (!setting.isUpdate || setting.isUpdate(newv, oldv)) {
       isEdit.value || enterEdit();
       isOld.value || enterOld();

+ 5 - 3
src/utils/unset.ts

@@ -1,17 +1,19 @@
+import { isUnset as isStoreUnset } from "@/store";
 import { nextTick } from "vue";
 
 export const unsetFactory = () => {
   let isUnSet = false;
+  
   const unSet = (fn: () => void) => {
-    console.error("unset");
+    const pop = isStoreUnset.push(true)
     isUnSet = true;
     fn();
-    nextTick(() => (isUnSet = false));
+    nextTick(pop)
   };
 
   return {
     get isUnSet() {
-      return isUnSet
+      return isStoreUnset.value
     },
     unSet
   }

+ 1 - 2
src/views/guide/guide/edit-paths.vue

@@ -71,8 +71,7 @@
               class="path-animation"
               v-if="path.playAnimation"
             />
-
-            <img :src="getResource(getFileUrl(path.cover))" />
+            <img :src="getResources(getFileUrl(path.cover))" />
           </div>
           <div class="set-phone-attr" v-if="i !== paths.length - 1">
             <ui-input

+ 1 - 1
src/views/record/shot.vue

@@ -181,7 +181,7 @@ export default defineComponent({
         const existsVideos = [];
 
         if (props.record.url) {
-          existsVideos.push(getResource(props.record.url));
+          existsVideos.push(getResources(props.record.url));
         }
         const fragmentBlobs = getRecordFragmentBlobs(props.record);
         existsVideos.push(...fragmentBlobs, ...blobs);

+ 1 - 1
src/views/record/sign.vue

@@ -124,7 +124,7 @@ export default defineComponent({
       rename: () => (isEditTitle.value = true),
       play: () => (isPlayVideo.value = true),
       download() {
-        const url = getResource(props.record.url!);
+        const url = getResources(props.record.url!);
         const ext = getExtname(url) || "mp4";
         loadPack(saveAs(url, `${props.record.title}.${ext}`));
       },

+ 3 - 3
src/views/tagging-position/sign.vue

@@ -16,14 +16,14 @@
             :value="TaggingPositionType['2d']"
             size="middle"
           >
-            {{$t('tagging.posTabs.typeVal[0]')}}
+            {{ $t("tagging.posTabs.typeVal0") }}
           </RadioButton>
           <RadioButton
             style="width: 50%; text-align: center"
             :value="TaggingPositionType['3d']"
             size="middle"
           >
-            {{$t('tagging.posTabs.typeVal[1]')}}
+            {{ $t("tagging.posTabs.typeVal1") }}
           </RadioButton>
         </RadioGroup>
       </SignItem>
@@ -80,7 +80,7 @@
         </template>
       </SignItem>
       <Button block type="primary" danger ghost size="large" @click="$emit('delete')">
-        {{$t('sys.del')}}
+        {{ $t("sys.del") }}
       </Button>
     </div>
   </CollapsePanel>

+ 1 - 1
src/views/tagging/hot/sign.vue

@@ -75,7 +75,7 @@ const emit = defineEmits<{
 
 const findImage = computed(() => {
   let img = props.tagging.images.find(
-    (a) => getUrlType(getResource(getFileUrl(a))) === MetaType.image
+    (a) => getUrlType(getResources(getFileUrl(a))) === MetaType.image
   );
   if (!img) {
     return getTaggingStyle(props.tagging.styleId)?.icon;

+ 2 - 2
src/views/tagging/index.vue

@@ -26,9 +26,9 @@
         </div>
         <template #overlay>
           <Menu class="tag-menu">
-            <menu-item key="1" @click="exposeTagging" style="text-align: center">{{
+            <!-- <menu-item key="1" @click="exposeTagging" style="text-align: center">{{
               $t("sys.import")
-            }}</menu-item>
+            }}</menu-item> -->
             <menu-item key="2" @click="quiskAdd('tagging')" style="text-align: center">{{
               $t("sys.add")
             }}</menu-item>

+ 1 - 1
src/views/view/sign.vue

@@ -2,7 +2,7 @@
   <ui-group-option class="sign" :class="{ active, search }">
     <div class="content">
       <span class="cover" @click="flyView(view)">
-        <img :src="getResource(getFileUrl(view.cover))" alt="" />
+        <img :src="getResources(getFileUrl(view.cover))" alt="" />
       </span>
       <ui-input
         class="view-title-input"

+ 6 - 0
vite.config.ts

@@ -26,6 +26,12 @@ const proxy = {
     ws: true,
     rewriteWsOrigin: true,
   },
+  "/profile": {
+
+    target: "http://192.168.9.165:9008/",
+    changeOrigin: true,
+    rewrite: (path) => path.replace(/^\/profile/, "/profile"),
+  },
   "/local": {
     target: "http://192.168.9.165:9008/",
     changeOrigin: true,