bill 3 лет назад
Родитель
Сommit
fe47b91966

+ 3 - 2
src/components/actions/index.vue

@@ -31,9 +31,10 @@ const clickHandler = (select: ActionsItem) => {
   selected.value = equal(selected.value, select) ? null : select
 }
 
-watchEffect(() => {
+watchEffect((onCleanup) => {
   if (selected.value) {
-    return selected.value.action()
+    const cleanup = selected.value.action()
+    cleanup && onCleanup(cleanup)
   }
 })
 </script>

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

@@ -55,7 +55,7 @@ const props = defineProps<SignProps>()
 const posStyle = ref<null | { left: string, top: string}>(null)
 const updatePosStyle = () => {
   const screenPos = sdk.getScreenByPosition(props.scenePos.localPos, props.scenePos.modelId)
-  if (!screenPos) {
+  if (!screenPos?.trueSide) {
     posStyle.value = null
   } else {
     posStyle.value = {

+ 2 - 3
src/sdk/association.ts

@@ -71,7 +71,6 @@ const associationTaggings = (el: HTMLDivElement) => {
 
   shallowWatchArray(getTaggings, (taggings, oldTaggings) => {
     const { added, deleted } = diffArrayChange(taggings, oldTaggings)
-    console.log(added, deleted)
     for (const item of added) {
       taggingVMs.set(toRaw(item), mount(el, TaggingComponent, { tagging: item }))
     }
@@ -100,7 +99,7 @@ const fullView = async (fn: () => void) => {
 }
 
 export const isScenePlayIng = ref(false)
-export const playSceneGuide = async (paths: SceneGuidePath[], changeIndexCallback: (index: number) => void) => {
+export const playSceneGuide = async (paths: SceneGuidePath[], changeIndexCallback?: (index: number) => void) => {
   if (isScenePlayIng.value) {
     throw new Error('导览正在播放')
   }
@@ -108,7 +107,7 @@ export const playSceneGuide = async (paths: SceneGuidePath[], changeIndexCallbac
 
   const sceneGuide = sdk.enterSceneGuide(paths)
 
-  sceneGuide.bus.on('changePoint', changeIndexCallback)
+  changeIndexCallback && sceneGuide.bus.on('changePoint', changeIndexCallback)
 
   const quitHandler = () => (isScenePlayIng.value = false)
   const clearHandler = isEdit.value ? null : await fullView(quitHandler)

+ 2 - 2
src/utils/store-help.ts

@@ -105,13 +105,13 @@ export function fetchStoreItems <T extends {id: any}, K extends {id: any} = T>(
   items: Ref<T[]>, 
   fetchAction: () => Promise<T[]>, 
   callback: (() => void) | null,
-): (item: T) => Promise<void>
+): () => Promise<void>
 export function fetchStoreItems <T extends {id: any}, K extends {id: any} = T>(
   items: Ref<T[]>, 
   fetchAction: () => Promise<K[]>, 
   callback: (() => void) | null,
   transform: (items: K[]) => Promise<T[]> | T[],
-): (item: T) => Promise<void>
+): () => Promise<void>
 export function fetchStoreItems <T extends {id: any}, K extends {id: any} = T>(
   items: Ref<T[]>, 
   fetchAction: () => Promise<K[]>, 

+ 0 - 1
src/utils/watch.ts

@@ -30,7 +30,6 @@ export const arrayChildEffectScope = <T extends any[]>(
 ) => {
   const scopes = new WeakMap<T, EffectScope>()
   shallowWatchArray(getItems, (newItems, oldItems) => {
-    console.log('shallowWatchArray', newItems, oldItems)
     const { added, deleted } = diffArrayChange(newItems, oldItems)
     for (const addItem of added) {
       const scope = effectScope()

+ 3 - 3
src/views/guide/edit-paths.vue

@@ -3,7 +3,7 @@
     <div class="overflow">
       <ui-icon 
         ctrl 
-        :type="isScenePlayIng ? 'pausecircle-fill' : 'playon_fill'" 
+        :type="isScenePlayIng ? 'pause' : 'preview'" 
         :disabled="!paths.length" 
         @click="play"
       />
@@ -137,7 +137,7 @@ const play = () => {
   if (isScenePlayIng.value) {
     pauseSceneGuide()
   } else {
-    playSceneGuide(sdk, toRaw(paths.value), (index) => current.value = paths.value[index])
+    playSceneGuide(toRaw(paths.value), (index) => current.value = paths.value[index])
   }
 }
 
@@ -174,7 +174,7 @@ watchEffect(async () => {
     .icon {
       margin-right: 20px;
       color: #fff;
-      font-size: 50px;
+      font-size: 30px;
     }
   }
 

+ 7 - 2
src/views/guide/sign.vue

@@ -3,7 +3,12 @@
     <div class="info">
       <div class="guide-cover">
         <img :src="getFileUrl(guide.cover)" />
-        <ui-icon type="preview" class="icon" ctrl @click="emit('play')" />
+        <ui-icon 
+          type="preview" 
+          class="icon" 
+          ctrl 
+          @click="emit('play')" v-if="guide.paths.length" 
+        />
       </div>
       <div>
         <p>{{ guide.title }}</p>
@@ -65,7 +70,7 @@ const actions = {
         content: '';
         position: absolute;
         inset: 0;
-        background: rgba(0,0,0,.6)
+        background: rgba(0,0,0,.2)
       }
 
       .icon {

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

@@ -47,7 +47,10 @@ const actionItems: ActionsProps['items'] = [
     text: '移动',
     action: () => {
       getSceneModel(custom.currentModel)?.enterMoveMode()
-      return () => getSceneModel(custom.currentModel)?.leaveTransform()
+      return () => {
+        console.log(getSceneModel(custom.currentModel), 'leave')
+        getSceneModel(custom.currentModel)?.leaveTransform()
+      }
     }
   },
   {