Skip to content

Commit ded510e

Browse files
committed
refactor: Optimize the tab component to resize internal components and follow the tab component to jump proportionally
1 parent c904bac commit ded510e

File tree

3 files changed

+47
-31
lines changed

3 files changed

+47
-31
lines changed

frontend/src/views/chat/chat-block/ChartBlock.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const dataObject = computed<{
6363
const assistantStore = useAssistantStore()
6464
const isCompletePage = computed(() => !assistantStore.getAssistant || assistantStore.getEmbedded)
6565
66+
const isAssistant = computed(() => assistantStore.getAssistant)
67+
6668
const chartId = computed(() => props.message?.record?.id + (props.enlarge ? '-fullscreen' : ''))
6769
6870
const data = computed(() => {
@@ -395,7 +397,7 @@ watch(
395397
</div>
396398
</el-popover>
397399
</div>
398-
<div v-if="message?.record?.chart && isCompletePage">
400+
<div v-if="message?.record?.chart && !isAssistant">
399401
<el-tooltip effect="dark" :content="t('chat.add_to_dashboard')" placement="top">
400402
<el-button class="tool-btn" text @click="addToDashboard">
401403
<el-icon size="16">

frontend/src/views/dashboard/canvas/CanvasCore.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
864864
865865
html2canvas(clonedSlot).then((canvas) => {
866866
img.src = canvas.toDataURL()
867-
infoBox.value.cloneItem.appendChild(img)
867+
infoBox.value.cloneItem?.appendChild(img)
868868
})
869869
870870
if (containerRef.value) {
@@ -994,6 +994,12 @@ function startMove(e: MouseEvent, item: CanvasItem, index: number) {
994994
if (infoBox.value.resizeItem) {
995995
delete infoBox.value.resizeItem.isPlayer
996996
props.resizeEnd(e, infoBox.value.resizeItem, infoBox.value.resizeItem._dragId)
997+
998+
if (infoBox.value.resizeItem.component === 'SQTab') {
999+
const refTabInstance =
1000+
currentInstance.refs['shape_component_' + infoBox.value.resizeItem.id][0]
1001+
refTabInstance.outResizeEnd()
1002+
}
9971003
}
9981004
if (infoBox.value.moveItem) {
9991005
props.dragEnd(e, infoBox.value.moveItem, infoBox.value.moveItem._dragId)

frontend/src/views/dashboard/components/sq-tab/index.vue

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ const beforeHandleCommand = (item: any, param: any) => {
119119
}
120120
}
121121
const isEditMode = computed(() => props.showPosition === 'canvas')
122-
122+
const outResizeEnd = () => {
123+
state.tabShow = false
124+
nextTick(() => {
125+
state.tabShow = true
126+
})
127+
}
123128
const addTabItem = (item: CanvasItem) => {
124129
// do addTabItem
125130
const index = configItem.value.propValue.findIndex(
@@ -168,6 +173,7 @@ onMounted(() => {
168173
169174
defineExpose({
170175
addTabItem,
176+
outResizeEnd,
171177
})
172178
</script>
173179

@@ -224,35 +230,37 @@ defineExpose({
224230
</template>
225231
</el-tab-pane>
226232
</template>
227-
<div
228-
v-for="(tabItem, index) in configItem.propValue"
229-
:key="tabItem.name + '-content'"
230-
class="tab-content-custom"
231-
:class="{ 'switch-hidden': configItem.activeTabName !== tabItem.name }"
232-
>
233-
<SQPreview
234-
v-if="showPosition === 'preview'"
235-
:ref="'tabPreviewRef_' + index"
236-
class="tab-dashboard-preview"
237-
:component-data="tabItem.componentData"
238-
:canvas-view-info="canvasViewInfo"
239-
:base-matrix-count="tabBaseMatrixCount"
240-
:canvas-id="tabItem.name"
241-
></SQPreview>
242-
<DashboardEditor
243-
v-else
244-
:ref="'tabEditorRef_' + index"
245-
class="tab-dashboard-editor-main"
246-
:canvas-component-data="tabItem.componentData"
247-
:canvas-view-info="canvasViewInfo"
248-
:move-in-active="configItem.moveInActive"
249-
:base-matrix-count="tabBaseMatrixCount"
250-
:canvas-id="tabItem.name"
251-
:parent-config-item="configItem"
252-
@parent-add-item-box="(item) => emits('parentAddItemBox', item)"
233+
<template v-if="state.tabShow">
234+
<div
235+
v-for="(tabItem, index) in configItem.propValue"
236+
:key="tabItem.name + '-content'"
237+
class="tab-content-custom"
238+
:class="{ 'switch-hidden': configItem.activeTabName !== tabItem.name }"
253239
>
254-
</DashboardEditor>
255-
</div>
240+
<SQPreview
241+
v-if="showPosition === 'preview'"
242+
:ref="'tabPreviewRef_' + index"
243+
class="tab-dashboard-preview"
244+
:component-data="tabItem.componentData"
245+
:canvas-view-info="canvasViewInfo"
246+
:base-matrix-count="tabBaseMatrixCount"
247+
:canvas-id="tabItem.name"
248+
></SQPreview>
249+
<DashboardEditor
250+
v-else
251+
:ref="'tabEditorRef_' + index"
252+
class="tab-dashboard-editor-main"
253+
:canvas-component-data="tabItem.componentData"
254+
:canvas-view-info="canvasViewInfo"
255+
:move-in-active="configItem.moveInActive"
256+
:base-matrix-count="tabBaseMatrixCount"
257+
:canvas-id="tabItem.name"
258+
:parent-config-item="configItem"
259+
@parent-add-item-box="(item) => emits('parentAddItemBox', item)"
260+
>
261+
</DashboardEditor>
262+
</div>
263+
</template>
256264
</custom-tab>
257265
<el-dialog
258266
v-model="state.dialogVisible"

0 commit comments

Comments
 (0)