Commit 5bf68247 by pangchong

docs(ai-assistant): 更新 AI 助手知识库及主题色彩规范文档

- 完善主题配置章节,增加基于 tailwind.ui.config.ts 的亮暗主题色彩体系完整参考
- 详细列出核心容器颜色、文字图标颜色及填充边框色阶体系,规范对应 Tailwind 类名
- 明确 1~7 级色阶体系及其对应扩展类名说明,增强视觉一致性指导
- 新增 AI 智能助手知识库同步规范,要求功能改动时必须同步更新问答数据库
- 规范 AI 助手问答准确性要求,确保描述与界面和代码交互保持 100% 一致
- 细化关键字、拼音、标签联动设置,优化上下文感知推荐准确度
- 约束 AI 助手的快捷动作绑定,实现问答与操作闭环体验
- 优化 AiAssistant 组件样式,全面采用 themeVars 颜色变量及 color-mix 函数实现柔和色彩过渡
- 统一对话内容、按钮及高亮提示色彩的设计,提升界面视觉统一性和交互反馈
- 调整 FAQ 分类顺序及命名,新增表格编辑与节点树分类,改进分类逻辑
- 扩展 FAQ 数据库中元素插入说明,增强插图与模板插入步骤的细节描述
- 改进步骤列表渲染,支持子项目缩进及更清晰的编号与项目符号展示
- 多处调整文字颜色与交互样式,提升信息层次感与用户操作体验
parent 88ed2cfd
import type { FaqItem, FaqCategory, ChatMessage, FaqAction, MatchResult } from '../constants'
import type { FaqItem, FaqCategory, ChatMessage, FaqAction, MatchResult, StepItemParsed } from '../constants'
import { FAQ_CATEGORIES, FAQ_DATABASE, HOT_QUESTIONS } from '../constants'
import { useEditorStore } from '@/store/editor'
import { useAiAssistantStore } from '@/store/aiAssistant'
import { storeToRefs } from 'pinia'
/**
* 文本清洗规范化
......@@ -185,6 +184,32 @@ export const getSuggestions = (input: string, limit = 5): FaqItem[] => {
}
/**
* 结构化解析步骤文本,识别主步骤与子项目
*/
export const parseStepItems = (steps: string[]): StepItemParsed[] => {
const result: StepItemParsed[] = []
let mainIndex = 0
for (const rawStep of steps) {
const isSub = /^[\s\t]*[·•\-\*]/.test(rawStep)
if (isSub) {
result.push({
isSubItem: true,
text: rawStep.replace(/^[\s\t]*[·•\-\*]\s*/, '')
})
} else {
mainIndex++
result.push({
isSubItem: false,
stepNumber: mainIndex,
text: rawStep
})
}
}
return result
}
/**
* AI 助手核心业务与交互逻辑 Hook(极致丝滑流式动效架构)
*/
export const useAiAssistant = () => {
......@@ -646,10 +671,13 @@ export const useAiAssistant = () => {
if (msg.faq) {
textToCopy = `【${msg.faq.title}】\n${msg.faq.answer}`
if (msg.faq.steps && msg.faq.steps.length > 0) {
textToCopy += `\n\n操作指引:\n` + msg.faq.steps.map((s, idx) => `${idx + 1}. ${s}`).join('\n')
const parsed = parseStepItems(msg.faq.steps)
textToCopy +=
`\n\n操作指引:\n` +
parsed.map((s) => (s.isSubItem ? ` • ${s.text}` : `${s.stepNumber}. ${s.text}`)).join('\n')
}
if (msg.faq.highlights && msg.faq.highlights.length > 0) {
textToCopy += `\n\n提示:\n` + msg.faq.highlights.join('\n')
textToCopy += `\n\n提示:\n` + msg.faq.highlights.map((h) => `• ${h}`).join('\n')
}
}
......@@ -701,6 +729,7 @@ export const useAiAssistant = () => {
dialogCount,
selectedNodeTag: computed(() => editorStore.selectedNode?.tagName),
FAQ_CATEGORIES,
parseStepItems,
handleBadgeMouseDown,
handleBadgeTouchStart,
handleWindowMouseDown,
......
......@@ -597,6 +597,15 @@ onMounted(() => {
eventBus.on('trigger_open_settings', () => {
appStore.settingsOpen = true
})
eventBus.on('trigger_undo', () => {
if (canUndo.value) editorStore.undo()
})
eventBus.on('trigger_redo', () => {
if (canRedo.value) editorStore.redo()
})
eventBus.on('trigger_toggle_theme', () => {
appStore.isDark = !appStore.isDark
})
})
</script>
......
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