Commit 082136f7 by pangchong

refactor(DocNodeRenderer): 优化代码结构与格式

- 统一箭头函数和条件表达式的书写格式
- 调整部分模板标签的换行和空格,提升代码可读性
- 优化文本内容获取逻辑,保持一致性和简洁
- 保留 ZONELST 节点的提示文本和样式不变
- 移除无效的 HTML 属性等多余符号
parent b862acf8
......@@ -61,22 +61,20 @@ export function useDocNodeRenderer(props: { node: XmlNode; parent?: XmlNode | nu
const parent = props.parent
if (!parent) return false
const isParaPair = (node.tagName === 'PARA' || node.tagName === 'PARAC')
const isTitlePair = (node.tagName === 'TITLE' || node.tagName === 'TITLEC')
const isParaPair = node.tagName === 'PARA' || node.tagName === 'PARAC'
const isTitlePair = node.tagName === 'TITLE' || node.tagName === 'TITLEC'
if (!isParaPair && !isTitlePair) return false
const siblingTagName = node.tagName === 'PARA' ? 'PARAC' :
node.tagName === 'PARAC' ? 'PARA' :
node.tagName === 'TITLE' ? 'TITLEC' : 'TITLE'
const siblingTagName = node.tagName === 'PARA' ? 'PARAC' : node.tagName === 'PARAC' ? 'PARA' : node.tagName === 'TITLE' ? 'TITLEC' : 'TITLE'
const siblings = parent.children.filter(c => c.tagName === siblingTagName)
const siblings = parent.children.filter((c) => c.tagName === siblingTagName)
const getEffectiveText = (n: XmlNode): string => {
if (n.textContent) return n.textContent.trim()
if (n.mixedContent && n.mixedContent.length > 0) {
return n.mixedContent
.filter(item => item.type === 'text')
.map(item => item.text || '')
.filter((item) => item.type === 'text')
.map((item) => item.text || '')
.join('')
.trim()
}
......@@ -85,8 +83,8 @@ export function useDocNodeRenderer(props: { node: XmlNode; parent?: XmlNode | nu
if (nn.textContent) return nn.textContent.trim()
if (nn.mixedContent && nn.mixedContent.length > 0) {
return nn.mixedContent
.filter(item => item.type === 'text')
.map(item => item.text || '')
.filter((item) => item.type === 'text')
.map((item) => item.text || '')
.join('')
.trim()
}
......@@ -103,7 +101,7 @@ export function useDocNodeRenderer(props: { node: XmlNode; parent?: XmlNode | nu
const currentEffectiveText = getEffectiveText(node)
if (!currentEffectiveText) return false
const hasDuplicateSibling = siblings.some(sib => {
const hasDuplicateSibling = siblings.some((sib) => {
return getEffectiveText(sib) === currentEffectiveText
})
......
......@@ -788,7 +788,10 @@
<!-- 25. ZONELST 隐藏处理 (只在被选中时渲染灰色提示框) -->
<template v-else-if="node.tagName === 'ZONELST'">
<div v-if="isSelected" class="p-2 border border-dashed border-divider rounded bg-fill-2 text-center text-xs text-color3 select-none print-hide">
<div
v-if="isSelected"
class="p-2 border border-dashed border-divider rounded bg-fill-2 text-center text-xs text-color3 select-none print-hide"
>
[ 区域列表 &lt;ZONELST&gt; PDF 渲染中已设为隐藏,不予展示内容 ]
</div>
</template>
......
......@@ -32,7 +32,7 @@
</div>
<!-- 用于打印/预览的隐藏容器,不使用虚拟滚动以加载完整文档 -->
<div id="print-preview-container" style="display: none;">
<div id="print-preview-container" style="display: none">
<DocNodeRenderer v-if="editorStore.xmlTree" :node="editorStore.xmlTree" :parent="null" />
</div>
</div>
......
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