Commit e18a5ac0 by pangchong

fix(StashModal): 限制仅“full”类型暂存支持导出xml

- 在导出按钮添加条件,仅当 activeItem 类型为 "full" 时显示
- 导出函数增加类型校验,非 "full" 类型显示警告提示
- 调整导出逻辑,确保导出文件始终包含 XML 头声明
- 修复了片段暂存导出不当处理的问题,防止导出无效文件
parent 07a1e8c3
...@@ -363,9 +363,13 @@ export function useStashModal() { ...@@ -363,9 +363,13 @@ export function useStashModal() {
} }
const handleExport = (item: StashItem) => { const handleExport = (item: StashItem) => {
if (item.type !== 'full') {
window.$message?.warning('片段暂存不支持单独导出 XML 文件')
return
}
try { try {
const singleLineXml = serializeTreeToXml(item.xmlNode, 0, false).replace(/\r?\n\s*/g, '') const singleLineXml = serializeTreeToXml(item.xmlNode, 0, false).replace(/\r?\n\s*/g, '')
const xml = item.type === 'full' ? `<?xml version="1.0" encoding="utf-8"?>${singleLineXml}` : singleLineXml const xml = `<?xml version="1.0" encoding="utf-8"?>${singleLineXml}`
const blob = new Blob([xml], { type: 'application/xml;charset=utf-8;' }) const blob = new Blob([xml], { type: 'application/xml;charset=utf-8;' })
const safeName = item.name.replace(/[\/\\:*?"<>|]/g, '_') const safeName = item.name.replace(/[\/\\:*?"<>|]/g, '_')
openDownloadModal({ openDownloadModal({
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
</template> </template>
效果预览 效果预览
</CommonButton> </CommonButton>
<CommonButton size="small" secondary @click="handleExport(activeItem)"> <CommonButton v-if="activeItem.type === 'full'" size="small" secondary @click="handleExport(activeItem)">
<template #icon> <template #icon>
<n-icon><DownloadOutline /></n-icon> <n-icon><DownloadOutline /></n-icon>
</template> </template>
......
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