Commit dcde4ffd by pangchong

style(aiAssistant): 优化代码格式与代码清理

- 调整 AiAssistant constants 中 highlights 数组的排版为单行格式
- 删除 dtdManager.ts 中多余的空行,提升代码简洁度
- 优化 dtdParser.ts 中数组链式调用的换行格式,增强可读性
- 统一 dtdParser.ts 中循环内的自增操作格式,保持代码风格一致
- 精简 EditorToolbar 组件模板中判断块的多行写法,合并为单行表达式
parent c65b23cc
......@@ -1025,10 +1025,7 @@ export const FAQ_DATABASE: FaqItem[] = [
'系统自动校验 DTD 语法并实时生效,后续节点添加、位置移动与 DTD 校验将全面遵循新规则。',
'如需恢复系统默认规则,可在【上传 DTD】悬浮菜单中点击【恢复默认 DTD】。'
],
highlights: [
'上传的自定义 DTD 会自动保存在浏览器本地,刷新页面依然有效。',
'若未上传或执行了恢复默认,系统将无缝回退至内置的 JOBCARD.dtd。'
],
highlights: ['上传的自定义 DTD 会自动保存在浏览器本地,刷新页面依然有效。', '若未上传或执行了恢复默认,系统将无缝回退至内置的 JOBCARD.dtd。'],
actions: [{ label: '上传 DTD 文件', type: 'event', payload: 'trigger_upload_dtd' }],
relatedQuestions: ['faq_import_xml', 'faq_validate_xml'],
isHot: false
......
......@@ -8,7 +8,6 @@ import { VIRTUAL_LAYOUT_TAGS } from '@/configs/xmlTags'
let _schema: DtdSchema | null = null
/**
* 加载 DTD Schema(支持传入 DtdSchema 对象或 DTD 原文文本)
*/
......
......@@ -57,7 +57,10 @@ export function parseModelString(raw: string): DtdContentModel {
const occMatch = str.match(/\)\s*([*?+]?)$/)
const occ = parseOccurrence(occMatch ? occMatch[1] : '')
const inner = str.replace(/^\(\s*#PCDATA\s*\|?/, '').replace(/\)\s*[*?+]?$/, '')
const parts = inner.split('|').map((s) => s.trim()).filter(Boolean)
const parts = inner
.split('|')
.map((s) => s.trim())
.filter(Boolean)
const children: DtdContentModel[] = [
{ type: 'pcdata', occurrence: 'once' },
...parts.map((name) => ({
......@@ -195,7 +198,7 @@ export function parseAttributes(blockText: string): Record<string, DtdAttribute>
i++
while (i < text.length && openParen > 0) {
if (text[i] === '(') openParen++
else if (text[i] === ')') openParen--;
else if (text[i] === ')') openParen--
i++
}
typeDef = text.slice(typeStart, i).trim().replace(/\s+/g, ' ')
......
......@@ -402,11 +402,7 @@
<document-text-outline v-else />
</n-icon>
<span class="text-xs font-medium">{{ isUploadingDtd ? '解析中…' : '上传 DTD' }}</span>
<span
v-if="isCustomDtdActive"
class="w-1.5 h-1.5 rounded-full bg-primary"
title="当前正在生效用户自定义 DTD 规则"
></span>
<span v-if="isCustomDtdActive" class="w-1.5 h-1.5 rounded-full bg-primary" title="当前正在生效用户自定义 DTD 规则"></span>
</button>
</n-dropdown>
......
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