Commit a65ea933 by pangchong

feat(stashModal): 新增预览效果功能

- 在暂存项操作按钮中添加预览效果按钮
- 在活动暂存项操作区域添加预览效果按钮
- 新增ViewEffectModal组件实现预览效果对话框
- 实现handlePreviewEffect方法用于打开预览弹窗
- 在functional模块中定义viewEffectModalRef引用管理弹窗实例
- 添加错误捕获和提示,确保预览失败时友好提示用户
parent 15c68c46
...@@ -14,6 +14,9 @@ export function useStashModal() { ...@@ -14,6 +14,9 @@ export function useStashModal() {
const editingItem = ref<StashItem | null>(null) const editingItem = ref<StashItem | null>(null)
const editingItemName = ref('') const editingItemName = ref('')
// 预览效果弹窗 Ref
const viewEffectModalRef = ref<any>(null)
const selectedNode = computed(() => editorStore.selectedNode) const selectedNode = computed(() => editorStore.selectedNode)
const hasXmlTree = computed(() => !!editorStore.xmlTree) const hasXmlTree = computed(() => !!editorStore.xmlTree)
...@@ -248,6 +251,15 @@ export function useStashModal() { ...@@ -248,6 +251,15 @@ export function useStashModal() {
} }
} }
const handlePreviewEffect = (item: StashItem) => {
try {
const xmlText = serializeTreeToXml(item.xmlNode, 0, false)
viewEffectModalRef.value?.open(`预览暂存效果:${item.name}`, xmlText)
} catch (err: any) {
window.$message?.error(`准备预览失败: ${err.message || err}`)
}
}
return { return {
visible, visible,
stashStore, stashStore,
...@@ -275,6 +287,8 @@ export function useStashModal() { ...@@ -275,6 +287,8 @@ export function useStashModal() {
handleDelete, handleDelete,
handleClearAll, handleClearAll,
handleExport, handleExport,
handleCopyXml handleCopyXml,
handlePreviewEffect,
viewEffectModalRef
} }
} }
...@@ -79,6 +79,9 @@ ...@@ -79,6 +79,9 @@
</span> </span>
</div> </div>
<div class="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"> <div class="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0">
<CommonButton size="tiny" quaternary circle @click.stop="handlePreviewEffect(item)" title="预览效果">
<n-icon><EyeOutline /></n-icon>
</CommonButton>
<CommonButton size="tiny" quaternary circle @click.stop="startRename(item)" title="重命名"> <CommonButton size="tiny" quaternary circle @click.stop="startRename(item)" title="重命名">
<n-icon><CreateOutline /></n-icon> <n-icon><CreateOutline /></n-icon>
</CommonButton> </CommonButton>
...@@ -118,6 +121,12 @@ ...@@ -118,6 +121,12 @@
</div> </div>
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<CommonButton size="small" type="info" secondary @click="handlePreviewEffect(activeItem)">
<template #icon>
<n-icon><EyeOutline /></n-icon>
</template>
预览效果
</CommonButton>
<CommonButton v-if="activeItem.type === 'full'" size="small" type="warning" secondary @click="handleExport(activeItem)"> <CommonButton v-if="activeItem.type === 'full'" size="small" type="warning" secondary @click="handleExport(activeItem)">
<template #icon> <template #icon>
<n-icon><DownloadOutline /></n-icon> <n-icon><DownloadOutline /></n-icon>
...@@ -187,11 +196,15 @@ ...@@ -187,11 +196,15 @@
<n-input v-model:value="editingItemName" placeholder="请输入暂存别名" /> <n-input v-model:value="editingItemName" placeholder="请输入暂存别名" />
</div> </div>
</CommonModal> </CommonModal>
<!-- 预览效果对话框 -->
<ViewEffectModal ref="viewEffectModalRef" />
</CommonModal> </CommonModal>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useStashModal } from './functionals' import { useStashModal } from './functionals'
import ViewEffectModal from '../TemplateSelectModal/components/ViewEffectModal/index.vue'
import { import {
ArchiveOutline, ArchiveOutline,
DocumentTextOutline, DocumentTextOutline,
...@@ -233,7 +246,9 @@ const { ...@@ -233,7 +246,9 @@ const {
handleDelete, handleDelete,
handleClearAll, handleClearAll,
handleExport, handleExport,
handleCopyXml handleCopyXml,
handlePreviewEffect,
viewEffectModalRef
} = useStashModal() } = useStashModal()
defineExpose({ defineExpose({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment