bill пре 3 година
родитељ
комит
160d97b46e

+ 2 - 2
src/api/model.ts

@@ -61,8 +61,8 @@ interface ServiceModel {
 const serviceToLocal = (serviceModel: ServiceModel): Model => ({
   show: !serviceModel.hide,
   scale: serviceModel.transform.scale[0],
-  opacity: serviceModel.opacity,
-  bottom: serviceModel.bottom,
+  opacity: serviceModel.opacity || 1,
+  bottom: serviceModel.bottom || 0,
   position: serviceModel.transform.position,
   rotation: serviceModel.transform.rotation,
   id: serviceModel.id.toString(),

+ 5 - 1
src/components/actions/index.vue

@@ -13,7 +13,7 @@
 </template>
 
 <script lang="ts" setup>
-import { ref, toRaw, watchEffect } from 'vue'
+import { ref, toRaw, watchEffect, onBeforeUnmount } from 'vue'
 
 export type ActionsItem = { 
   icon: string, 
@@ -37,6 +37,10 @@ watchEffect((onCleanup) => {
     cleanup && onCleanup(cleanup)
   }
 })
+
+onBeforeUnmount(() => {
+  selected.value = null
+})
 </script>
 
 <style lang="scss" scoped>

+ 0 - 1
src/sdk/association.ts

@@ -27,7 +27,6 @@ const associationModels = (sdk: SDK) => {
       if (getSceneModel(item)) {
         continue;
       }
-      console.log(getResource(item.url))
 
       const itemRaw = toRaw(item)
       const sceneModel = sdk.addModel({

+ 1 - 0
src/store/model.ts

@@ -66,6 +66,7 @@ export const recoverModels = recoverStoreItems(models, getBackupModels)
 export const addModel = async (file: File) => {
   const model = await postAddModel(file)
   unSetModelUpdate(() => models.value.push(serviceToLocal(model)))
+  backupModels()
 }
 export const updateModel = updateStoreItem(models, postUpdateModels)
 export const deleteModel = deleteStoreItem(models, model => postDeleteModel(model.id))

+ 9 - 6
src/utils/store-help.ts

@@ -23,12 +23,12 @@ export const storeSecurityDelete = <T extends any>(items: T[], pushItem: T) => {
 export function addStoreItem <T extends {id: any}>(
   items: Ref<T[]>, 
   addAction: (item: T) => Promise<T>,
-): (item: T) => Promise<void>
+): (item: T) => Promise<T>
 export function addStoreItem <T extends {id: any}, K extends {id: any} = T>(
   items: Ref<T[]>, 
   addAction: (item: K) => Promise<K>,
   transform: (item: T) => Promise<K> | K
-): (item: T) => Promise<void>
+): (item: T) => Promise<K>
 export function addStoreItem <T extends {id: any}, K extends {id: any} = T>(
   items: Ref<T[]>, 
   addAction: (item: K) => Promise<K>,
@@ -42,9 +42,13 @@ export function addStoreItem <T extends {id: any}, K extends {id: any} = T>(
       actionData = item as unknown as K
     }
     const newItem = await addAction(actionData)
-    console.log('???', newItem)
-    Object.assign(item, newItem)
-    storeSecurityPush(items.value, item)
+    const self = items.value.find(findItem => findItem.id === item.id)
+    if (self) {
+      Object.assign(self, newItem)
+    } else {
+      storeSecurityPush(items.value, item)
+    }
+    return newItem
   }
 }
 
@@ -198,7 +202,6 @@ export const diffStoreItemsChange = <T extends Array<{ id: any }>>(newItems: T,
 }
 
 export const recoverStoreItems = <T extends Array<{ id: any }>>(items: Ref<T>, getBackupItems: () => T) => () => {
-  console.log('?????')
   const backupItems = getBackupItems()
   items.value = backupItems.map(oldItem => {
     const model = items.value.find(item => item.id === oldItem.id)

+ 6 - 1
src/views/merge/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <RightPano v-if="custom.currentModel">
+  <RightPano v-if="custom.currentModel && active">
     <ui-group>
       <template #header>
         <Actions class="edit-header" :items="actionItems" />
@@ -38,6 +38,11 @@ import { ref } from 'vue'
 
 import type { ActionsProps } from '@/components/actions/index.vue'
 
+const active = ref(true)
+useViewStack(() => {
+  active.value = true
+  return () => active.value = false
+})
 const defaultAttrs: ModelAttrs = {
   show: true,
   scale: 1,

+ 95 - 93
src/views/tagging/edit.vue

@@ -1,95 +1,95 @@
 <template>
   <div class="edit-hot-layer">
-    <div class="edit-hot-item">
-      <h3 class="edit-title">
-        标注
-        <ui-icon type="close" ctrl @click.stop="$emit('quit')" class="edit-close" />
-      </h3>
-      <!-- <StylesManage 
-        :styles="styles" 
-        :active="(getTaggingStyle(tagging.styleId) as TaggingStyle)" 
-        @change="style => tagging.styleId = style.id" 
-        @delete="deleteStyle"
-        @uploadStyles="uploadStyles" 
-      /> -->
-      <ui-input 
-        require 
-        class="input" 
-        width="100%" 
-        placeholder="请输入热点标题" 
-        type="text" 
-        v-model="tagging.title"
-        maxlength="15" 
-      />
-      <ui-input
-        class="input"
-        width="100%"
-        height="158px"
-        placeholder="特征描述:"
-        type="richtext"
-        v-model="tagging.desc"
-        :maxlength="200"
-      />
-      <ui-input 
-        class="input preplace" 
-        width="100%" 
-        placeholder="" 
-        type="text" 
-        v-model="tagging.part"
-      >
-        <template #preIcon><span>遗留部位:</span></template>
-      </ui-input>
-      <ui-input 
-        class="input preplace" 
-        width="100%" 
-        placeholder="" 
-        type="text" 
-        v-model="tagging.method"
-      >
-        <template #preIcon><span>提取方法:</span></template>
-      </ui-input>
-      <ui-input 
-        class="input preplace" 
-        width="100%" 
-        type="text" 
-        placeholder=""
-        v-model="tagging.principal"
-      >
-        <template #preIcon><span>提取人:</span></template>
-      </ui-input>
-      <ui-input
-          class="input "
-          type="file"
+      <div class="edit-hot-item">
+        <h3 class="edit-title">
+          标注
+          <ui-icon type="close" ctrl @click.stop="$emit('quit')" class="edit-close" />
+        </h3>
+        <!-- <StylesManage 
+          :styles="styles" 
+          :active="(getTaggingStyle(tagging.styleId) as TaggingStyle)" 
+          @change="style => tagging.styleId = style.id" 
+          @delete="deleteStyle"
+          @uploadStyles="uploadStyles" 
+        /> -->
+        <ui-input 
+          require 
+          class="input" 
+          width="100%" 
+          placeholder="请输入热点标题" 
+          type="text" 
+          v-model="tagging.title"
+          maxlength="15" 
+        />
+        <ui-input
+          class="input"
           width="100%"
-          height="225px"
-          preview
-          placeholder="上传图片"
-          othPlaceholder="支持JPG、PNG图片格式,单张不超过5MB,最多支持上传9张。"
-          accept=".jpg, .png"
-          :disable="true"
-          :multiple="true"
-          :maxSize="5 * 1024 * 1024"
-          :maxLen="9"
-          :modelValue="tagging.images"
-          @update:modelValue="fileChange"
-      >
-          <template v-slot:valuable>
-              <Images :tagging="tagging" :hideInfo="true">
-                <template v-slot:icons="{ active }">
-                  <span @click="delImageHandler(active)" class="del-file">
-                    <ui-icon type="del" ctrl />
-                  </span>
-                </template>
-              </Images>
-          </template>
-      </ui-input>
-      <div class="edit-hot" >
-        <span @click="submitHandler" class="fun-ctrl">
-          <ui-icon type="edit" />
-          确定
-        </span>
+          height="158px"
+          placeholder="特征描述:"
+          type="richtext"
+          v-model="tagging.desc"
+          :maxlength="200"
+        />
+        <ui-input 
+          class="input preplace" 
+          width="100%" 
+          placeholder="" 
+          type="text" 
+          v-model="tagging.part"
+        >
+          <template #preIcon><span>遗留部位:</span></template>
+        </ui-input>
+        <ui-input 
+          class="input preplace" 
+          width="100%" 
+          placeholder="" 
+          type="text" 
+          v-model="tagging.method"
+        >
+          <template #preIcon><span>提取方法:</span></template>
+        </ui-input>
+        <ui-input 
+          class="input preplace" 
+          width="100%" 
+          type="text" 
+          placeholder=""
+          v-model="tagging.principal"
+        >
+          <template #preIcon><span>提取人:</span></template>
+        </ui-input>
+        <ui-input
+            class="input "
+            type="file"
+            width="100%"
+            height="225px"
+            preview
+            placeholder="上传图片"
+            othPlaceholder="支持JPG、PNG图片格式,单张不超过5MB,最多支持上传9张。"
+            accept=".jpg, .png"
+            :disable="true"
+            :multiple="true"
+            :maxSize="5 * 1024 * 1024"
+            :maxLen="9"
+            :modelValue="tagging.images"
+            @update:modelValue="fileChange"
+        >
+            <template v-slot:valuable>
+                <Images :tagging="tagging" :hideInfo="true">
+                  <template v-slot:icons="{ active }">
+                    <span @click="delImageHandler(active)" class="del-file">
+                      <ui-icon type="del" ctrl />
+                    </span>
+                  </template>
+                </Images>
+            </template>
+        </ui-input>
+        <div class="edit-hot" >
+          <span @click="submitHandler" class="fun-ctrl">
+            <ui-icon type="edit" />
+            确定
+          </span>
+        </div>
       </div>
-    </div>
   </div>
 </template>
 
@@ -203,14 +203,16 @@ const delImageHandler = async (file: Tagging['images'][number]) => {
   background: rgba(0,0,0,0.3000);
   backdrop-filter: blur(4px);
   z-index: 2000;
+  padding: 20px;
+  overflow-y: auto;
+  display: flex;
+  justify-content: center;
 }
+
 .edit-hot-item {
-  position: absolute;
-  top: 50%;
-  left: 50%;
-  transform: translate(-50%, -50%);
+  margin-top: 100px;
+  margin-bottom: 20px;
   width: 400px;
-  position: relative;
   padding: 20px;
   background: rgba(27, 27, 28, 0.8);
   box-shadow: 0px 0px 10px 0px rgba(0,0,0, 0.3);