Commit 7fa140dc by pangchong

style(editor): 优化代码格式和模板布局

- 调整DocNodeRenderer组件中部分元素换行以提升可读性
- 合并CreateGraphicModal和TemplateSelectModal中多行元素为单行,提升模板简洁性
- 优化NodeTree组件中fade过渡样式换行,增加样式清晰度
- 规范EditorToolbar/functionals索引文件中对象尾部格式一致性
- 统一图片资源路径拼接函数中hasExtension布尔表达式格式
parent 2a453d67
...@@ -810,7 +810,10 @@ ...@@ -810,7 +810,10 @@
</template> </template>
<!-- 如果 SHEET 没有自己的 TITLE 子节点,则继承展示 GRAPHIC 的 TITLE --> <!-- 如果 SHEET 没有自己的 TITLE 子节点,则继承展示 GRAPHIC 的 TITLE -->
<div v-if="!node.children.some((c) => c.tagName === 'TITLE' || c.tagName === 'TITLEC') && getInheritedTitle()" class="text-sm font-bold text-center mt-3 text-color1"> <div
v-if="!node.children.some((c) => c.tagName === 'TITLE' || c.tagName === 'TITLEC') && getInheritedTitle()"
class="text-sm font-bold text-center mt-3 text-color1"
>
{{ getInheritedTitle() }} {{ getInheritedTitle() }}
</div> </div>
...@@ -846,10 +849,7 @@ ...@@ -846,10 +849,7 @@
<!-- 19.7 GDESC (图形描述) 处理 --> <!-- 19.7 GDESC (图形描述) 处理 -->
<template v-else-if="node.tagName === 'GDESC'"> <template v-else-if="node.tagName === 'GDESC'">
<div <div class="my-1.5 pl-[14pt] pr-[6pt] text-xs text-color3 leading-relaxed" @click.stop="editorStore.setSelectedNodeId(node.id)">
class="my-1.5 pl-[14pt] pr-[6pt] text-xs text-color3 leading-relaxed"
@click.stop="editorStore.setSelectedNodeId(node.id)"
>
<DocNodeRenderer v-for="child in node.children" :key="child.id" :node="child" :parent="node" /> <DocNodeRenderer v-for="child in node.children" :key="child.id" :node="child" :parent="node" />
</div> </div>
</template> </template>
...@@ -858,20 +858,14 @@ ...@@ -858,20 +858,14 @@
<template v-else-if="node.tagName === 'TITLE' || node.tagName === 'TITLEC'"> <template v-else-if="node.tagName === 'TITLE' || node.tagName === 'TITLEC'">
<div <div
class="text-color1 font-bold my-2" class="text-color1 font-bold my-2"
:class="[ :class="[parent && (parent.tagName === 'SHEET' || parent.tagName === 'GRAPHIC') ? 'text-sm text-center' : 'text-base']"
parent && (parent.tagName === 'SHEET' || parent.tagName === 'GRAPHIC') ? 'text-sm text-center' : 'text-base'
]"
@click.stop="editorStore.setSelectedNodeId(node.id)" @click.stop="editorStore.setSelectedNodeId(node.id)"
> >
<template v-if="node.mixedContent && node.mixedContent.length > 0"> <template v-if="node.mixedContent && node.mixedContent.length > 0">
<span v-for="(mixed, idx) in node.mixedContent" :key="idx"> <span v-for="(mixed, idx) in node.mixedContent" :key="idx">
<template v-if="mixed.type === 'text'">{{ mixed.text }}</template> <template v-if="mixed.type === 'text'">{{ mixed.text }}</template>
<template v-else-if="mixed.type === 'element'"> <template v-else-if="mixed.type === 'element'">
<DocNodeRenderer <DocNodeRenderer :node="node.children.find((c) => c.id === mixed.nodeId)!" :parent="node" is-inline />
:node="node.children.find((c) => c.id === mixed.nodeId)!"
:parent="node"
is-inline
/>
</template> </template>
</span> </span>
</template> </template>
...@@ -1222,7 +1216,8 @@ const getImgSrc = (gnbr: string) => { ...@@ -1222,7 +1216,8 @@ const getImgSrc = (gnbr: string) => {
// 拼接工卡基础物理路径目录,让 vite proxy 代理到真实图片地址 // 拼接工卡基础物理路径目录,让 vite proxy 代理到真实图片地址
const basePath = '/mnt/disk2/ftp/tdms/jobcard/cep/MU/MU-B-3333-20260701-001/A320/SMJC/AMEA-A282400-02-1/0/' const basePath = '/mnt/disk2/ftp/tdms/jobcard/cep/MU/MU-B-3333-20260701-001/A320/SMJC/AMEA-A282400-02-1/0/'
const lowerGnbr = gnbr.toLowerCase() const lowerGnbr = gnbr.toLowerCase()
const hasExtension = lowerGnbr.endsWith('.png') || const hasExtension =
lowerGnbr.endsWith('.png') ||
lowerGnbr.endsWith('.jpg') || lowerGnbr.endsWith('.jpg') ||
lowerGnbr.endsWith('.jpeg') || lowerGnbr.endsWith('.jpeg') ||
lowerGnbr.endsWith('.gif') || lowerGnbr.endsWith('.gif') ||
......
<template> <template>
<CommonModal v-model="show" :title="isSheetOnly ? '插入图纸页 (SHEET)' : '插入图片 (GRAPHIC)'" :width="400" @confirm="handleConfirm"> <CommonModal v-model="show" :title="isSheetOnly ? '插入图纸页 (SHEET)' : '插入图片 (GRAPHIC)'" :width="400" @confirm="handleConfirm">
<div class="flex flex-col gap-4 py-2"> <div class="flex flex-col gap-4 py-2">
<div class="text-xs text-color3 mb-1"> <div class="text-xs text-color3 mb-1">请选择插入时需要携带的可选节点:</div>
请选择插入时需要携带的可选节点:
</div>
<!-- GRAPHIC 级别的可选节点 (仅在非 SHEET-only 模式下显示) --> <!-- GRAPHIC 级别的可选节点 (仅在非 SHEET-only 模式下显示) -->
<div v-if="!isSheetOnly" class="p-3 bg-fill-2 border border-divider rounded-lg"> <div v-if="!isSheetOnly" class="p-3 bg-fill-2 border border-divider rounded-lg">
<div class="font-bold text-xs text-color2 mb-2">图片 (GRAPHIC) 可选节点</div> <div class="font-bold text-xs text-color2 mb-2">图片 (GRAPHIC) 可选节点</div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<n-checkbox v-model:checked="form.hasGraphicEffect"> <n-checkbox v-model:checked="form.hasGraphicEffect">包含适用性说明 &lt;EFFECT&gt;</n-checkbox>
包含适用性说明 &lt;EFFECT&gt; <n-checkbox v-model:checked="form.hasGraphicTitle">包含附图标题 &lt;TITLE&gt;</n-checkbox>
</n-checkbox>
<n-checkbox v-model:checked="form.hasGraphicTitle">
包含附图标题 &lt;TITLE&gt;
</n-checkbox>
</div> </div>
</div> </div>
...@@ -22,12 +16,8 @@ ...@@ -22,12 +16,8 @@
<div class="p-3 bg-fill-2 border border-divider rounded-lg"> <div class="p-3 bg-fill-2 border border-divider rounded-lg">
<div class="font-bold text-xs text-color2 mb-2">图纸 (SHEET) 可选节点</div> <div class="font-bold text-xs text-color2 mb-2">图纸 (SHEET) 可选节点</div>
<div class="flex flex-col gap-2"> <div class="flex flex-col gap-2">
<n-checkbox v-model:checked="form.hasSheetEffect"> <n-checkbox v-model:checked="form.hasSheetEffect">包含适用性说明 &lt;EFFECT&gt;</n-checkbox>
包含适用性说明 &lt;EFFECT&gt; <n-checkbox v-model:checked="form.hasSheetTitle">包含图纸标题 &lt;TITLE&gt;</n-checkbox>
</n-checkbox>
<n-checkbox v-model:checked="form.hasSheetTitle">
包含图纸标题 &lt;TITLE&gt;
</n-checkbox>
</div> </div>
</div> </div>
......
...@@ -20,22 +20,18 @@ ...@@ -20,22 +20,18 @@
<n-list-item <n-list-item
v-for="item in templates" v-for="item in templates"
:key="item.id" :key="item.id"
:class="['transition-colors cursor-pointer', selectedTemplate?.id === item.id ? 'bg-primary/5 border-l-4 border-primary' : '']" :class="[
'transition-colors cursor-pointer',
selectedTemplate?.id === item.id ? 'bg-primary/5 border-l-4 border-primary' : ''
]"
@click="selectedTemplate = item" @click="selectedTemplate = item"
@dblclick="handleInsert" @dblclick="handleInsert"
> >
<n-thing <n-thing :title="item.name" :description="`创建人: ${item.creator} | 创建时间: ${item.createTime}`" />
:title="item.name"
:description="`创建人: ${item.creator} | 创建时间: ${item.createTime}`"
/>
<template #suffix> <template #suffix>
<n-space> <n-space>
<CommonButton size="tiny" secondary type="primary" @click.stop="previewXml(item)"> <CommonButton size="tiny" secondary type="primary" @click.stop="previewXml(item)">预览 XML</CommonButton>
预览 XML <CommonButton size="tiny" secondary type="info" @click.stop="previewEffect(item)">预览效果</CommonButton>
</CommonButton>
<CommonButton size="tiny" secondary type="info" @click.stop="previewEffect(item)">
预览效果
</CommonButton>
</n-space> </n-space>
</template> </template>
</n-list-item> </n-list-item>
...@@ -53,17 +49,13 @@ ...@@ -53,17 +49,13 @@
<!-- 左侧:已选中的模板名称提示 --> <!-- 左侧:已选中的模板名称提示 -->
<div class="text-xs text-color2"> <div class="text-xs text-color2">
<span v-if="selectedTemplate"> <span v-if="selectedTemplate">
已选择:<strong class="text-primary">{{ selectedTemplate.name }}</strong> 已选择:
<strong class="text-primary">{{ selectedTemplate.name }}</strong>
<span class="text-color3 ml-3">({{ insertBelowSetting ? '插入下方' : '作为子节点' }})</span> <span class="text-color3 ml-3">({{ insertBelowSetting ? '插入下方' : '作为子节点' }})</span>
</span> </span>
<span v-else class="text-color3">请从列表中选择模板</span> <span v-else class="text-color3">请从列表中选择模板</span>
</div> </div>
<n-pagination <n-pagination v-model:page="page" v-model:page-size="pageSize" :item-count="total" @update:page="fetchData" />
v-model:page="page"
v-model:page-size="pageSize"
:item-count="total"
@update:page="fetchData"
/>
</div> </div>
</div> </div>
</CommonModal> </CommonModal>
......
...@@ -177,6 +177,6 @@ export function useEditorToolbar(emit: any) { ...@@ -177,6 +177,6 @@ export function useEditorToolbar(emit: any) {
extractTranslateModalRef, extractTranslateModalRef,
searchTranslateModalRef, searchTranslateModalRef,
xmlSizeStr, xmlSizeStr,
templateSelectModalRef, templateSelectModalRef
} }
} }
...@@ -468,7 +468,9 @@ const batchDeleteConfirmModalRef = ref<any>(null) ...@@ -468,7 +468,9 @@ const batchDeleteConfirmModalRef = ref<any>(null)
} }
.fade-enter-active, .fade-enter-active,
.fade-leave-active { .fade-leave-active {
transition: opacity 0.25s ease, transform 0.25s ease; transition:
opacity 0.25s ease,
transform 0.25s ease;
} }
.fade-enter-from, .fade-enter-from,
.fade-leave-to { .fade-leave-to {
......
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