浏览代码

fix: 修改bug

bill 10 月之前
父节点
当前提交
b64e643be4
共有 7 个文件被更改,包括 118 次插入22 次删除
  1. 60 0
      src/hook/notice.ts
  2. 7 4
      src/layout/model-list/index.vue
  3. 27 7
      src/layout/model-list/sign.vue
  4. 4 0
      src/main.ts
  5. 10 7
      src/views/setting/index.vue
  6. 5 4
      src/views/tagging/edit.vue
  7. 5 0
      vite.config.ts

+ 60 - 0
src/hook/notice.ts

@@ -0,0 +1,60 @@
+import { params } from "@/env";
+import { ref } from "vue";
+import type {ResData} from '@/api'
+
+console.log('scoke 测试')
+const socketUrl = `wss://test-mix3d.4dkankan.com/fusion/ws/${params.caseId}`;
+
+let websocket: WebSocket | null = null;
+function createWebSocket() {
+  websocket = new WebSocket(socketUrl);
+  websocket.onopen = function() {
+    console.log('WebSocket 连接已打开');
+  };
+
+  websocket.onmessage = function(event) {
+    try {
+      const res = JSON.parse(event.data) as {command: string, content: ResData<any>}
+      switch(res.command) {
+        case 'ping':
+          break;
+
+        case 'notice':
+          break;
+      }
+    } catch {
+      console.log('收到错误消息格式:', event.data);  
+    }
+  };
+
+  websocket.onerror = function(event) {
+    console.error('WebSocket 出错:', event);
+  };
+
+  websocket.onclose = function(event) {
+    console.log('WebSocket 连接已关闭,将在 5 秒后重连');
+    setTimeout(createWebSocket, 5000);
+  };
+}
+
+export const notity = ref({})
+const handler = {
+  ping() {
+
+  },
+  notity() {
+
+  }
+}
+
+// 发送数据到服务器
+function sendData(command: string, message: string) {
+  if (websocket && websocket.readyState === WebSocket.OPEN) {
+    websocket.send(message);
+  } else {
+    console.log('WebSocket 连接未打开,无法发送消息');
+  }
+}
+
+// 初始创建 WebSocket 连接
+createWebSocket();

+ 7 - 4
src/layout/model-list/index.vue

@@ -14,7 +14,7 @@
         :canChange="canChange"
         :model="item.raw"
         @delete="modelDelete(item.raw)"
-        @click="(mode: any) => modelChangeSelect(item.raw, mode)"
+        @click="(mode: any) => modelChangeSelect(item.raw, mode, true)"
       />
     </template>
   </List>
@@ -72,12 +72,15 @@ const modelList = computed(() =>
   }))
 );
 
-const modelChangeSelect = (model: FuseModel, mode: "pano" | "fuse") => {
+const modelChangeSelect = (model: FuseModel, mode: "pano" | "fuse", f = false) => {
   if (getFuseModelShowVariable(model).value) {
     if (custom.currentModel === model && mode === custom.showMode) {
-      return;
+      if (!f) return;
+
+      activeModel({ showMode: "fuse", active: undefined });
+    } else {
+      activeModel({ showMode: mode, active: model });
     }
-    activeModel({ showMode: mode, active: model });
   }
 
   if (currentModel.value !== fuseModel) {

+ 27 - 7
src/layout/model-list/sign.vue

@@ -1,14 +1,34 @@
 <template>
-  <div @click="!model.error && $emit('click', 'fuse')" class="sign-layout" :class="{ disabled: model.error }">
+  <div
+    @click="!model.error && $emit('click', 'fuse')"
+    class="sign-layout"
+    :class="{ disabled: model.error }"
+  >
     <div class="model-header">
       <p>{{ model.title }}</p>
       <div class="model-action">
-        <ui-icon ctrl type="show_roaming_n" @click.stop="$emit('click', 'pano')" class="icon"
-          :class="{ active: custom.showMode === 'pano' && active }" v-if="getSceneModel(props.model)?.supportPano()" />
-        <ui-input type="checkbox" v-model="show" @click.stop :class="{
-          disabled: model.error || custom.showMode === 'pano',
-        }" />
-        <ui-icon v-if="custom.modelsChangeStore" type="del" ctrl @click="$emit('delete')" />
+        <ui-icon
+          ctrl
+          type="show_roaming_n"
+          @click.stop="$emit('click', 'pano')"
+          class="icon"
+          :class="{ active: custom.showMode === 'pano' && active }"
+          v-if="getSceneModel(props.model)?.supportPano()"
+        />
+        <ui-input
+          type="checkbox"
+          v-model="show"
+          @click.stop
+          :class="{
+            disabled: model.error || custom.showMode === 'pano',
+          }"
+        />
+        <ui-icon
+          v-if="custom.modelsChangeStore"
+          type="del"
+          ctrl
+          @click="$emit('delete')"
+        />
       </div>
     </div>
     <div class="model-desc" v-if="active">

+ 4 - 0
src/main.ts

@@ -14,6 +14,10 @@ app.use(Components)
 app.use(router)
 app.mount('#app')
 
+if (import.meta.env.DEV) {
+  import('@/hook/notice')
+}
+
 appStyleImport[params.app]()
 watchEffect((onCleanup) => {
   if ([RoutesName.show, RoutesName.signModel].includes(currentLayout.value!)) {

+ 10 - 7
src/views/setting/index.vue

@@ -12,9 +12,13 @@
     <ui-group title="设置天空">
       <ui-group-option>
         <div class="back-layout">
-          <div v-for="back in backs" :key="back.value" class="back-item"
+          <div
+            v-for="back in backs"
+            :key="back.value"
+            class="back-item"
             :class="{ [back.type]: true, active: setting!.back === back.value }"
-            @click="setting!.back !== back.value && changeBack(back.value)">
+            @click="setting!.back !== back.value && changeBack(back.value)"
+          >
             <img :src="back.image" v-if="['img', 'map'].includes(back.type)" />
             <i class="iconfont" :class="back.image" v-else-if="back.type === 'icon'" />
             <span :style="{ background: back.image }" v-else></span>
@@ -107,7 +111,7 @@ const enterSetPic = () => {
   });
 };
 
-const initBack = setting.value!.back;
+let initBack = setting.value!.back;
 let isFirst = true;
 const changeBack = (back: string) => {
   setting.value!.back = back;
@@ -122,6 +126,7 @@ const changeBack = (back: string) => {
       isFirst = true;
     });
     enterOld(async () => {
+      initBack = setting.value!.back;
       isSave = true;
       await loadPack(updataSetting());
     });
@@ -164,8 +169,7 @@ const changeBack = (back: string) => {
 }
 
 .back-item {
-
-  >span,
+  > span,
   .iconfont,
   img {
     display: block;
@@ -189,8 +193,7 @@ const changeBack = (back: string) => {
   }
 
   &.active {
-
-    >span,
+    > span,
     .iconfont,
     img {
       outline-color: #00c8af;

+ 5 - 4
src/views/tagging/edit.vue

@@ -65,7 +65,6 @@
         type="file"
         width="100%"
         height="225px"
-        require
         preview
         placeholder="上传图片"
         othPlaceholder="支持JPG、PNG图片格式,单张不超过5MB,最多支持上传9张。"
@@ -130,9 +129,11 @@ watchEffect(() => {
 const submitHandler = () => {
   if (!tagging.value.title.trim()) {
     Message.error("标签标题必须填写!");
-  } else if (!tagging.value.images.length) {
-    Message.error("至少上传一张图片!");
-  } else {
+  }
+  //  else if (!tagging.value.images.length) {
+  //   Message.error("至少上传一张图片!");
+  // }
+  else {
     emit("save", tagging.value);
   }
 };

+ 5 - 0
vite.config.ts

@@ -6,6 +6,11 @@ import mkcert from 'vite-plugin-mkcert'
 import { resolve } from 'path'
 
 const proxy = {
+  '/fusion/ws': {
+    target: 'wss://test-mix3d.4dkankan.com/',
+    ws: true,
+    rewriteWsOrigin: true,
+  },
   '/local': {
     target: 'http://192.168.0.38:8808',
     changeOrigin: true,