Explorar o código

refactor(ChildPageDisplay): 优化子页面工具渲染逻辑

移除了冗余的iframeRef引用和手动刷新代码,改用v-for循环渲染对应选中下标的工具iframe,简化实现逻辑
lsc hai 1 día
pai
achega
ef51bcb93e
Modificáronse 1 ficheiros con 5 adicións e 7 borrados
  1. 5 7
      src/views/Editor/Canvas/ChildPageDisplay.vue

+ 5 - 7
src/views/Editor/Canvas/ChildPageDisplay.vue

@@ -20,10 +20,12 @@
 
     <div class="child-page-body" v-if="toolsJson?.url === toolsArray[selectedToolIndex]?.url">
       <div class="question-area">
-        <iframe
-          ref="iframeRef"
-          :src="toolsJson?.url + '&isSet=2' + '&timestamp=' + new Date().getTime()"
+        <template v-for="(tool, index) in toolsArray" :key="tool.tool_id">
+          <iframe
+          v-if="index === selectedToolIndex"
+          :src="tool.url + '&isSet=2' + '&timestamp=' + new Date().getTime()"
           frameborder="0"></iframe>
+        </template>
       </div>
 
       <div class="side-panel" v-if="!toolsJson.isSet">
@@ -55,7 +57,6 @@ const toolsArray = childPageToolsArray.value
 const selectedToolIndex = ref(0)
 const agentid2 = ref('f86aa63c-b7b7-4d03-9b37-b59f116d36f3')// 生成内容
 const loading = ref(true)
-const iframeRef = ref<HTMLIFrameElement>()
 
 
 const toolsJson = computed(() => {
@@ -68,9 +69,6 @@ const formatHint = (str: string, count: number) => {
 
 const selectTool = (index: number) => {
   selectedToolIndex.value = index
-  if (iframeRef.value) {
-    iframeRef.value.contentWindow?.location.reload()
-  }
   console.log('👶 选中工具:', toolsArray[index])
 }