Private
Public Access
1
0

重构:文件系统模块化架构,增强 Markdown 渲染

- 拆分 FileSystem.vue 为模块化组件架构
- 新增 Markdown Mermaid 图表渲染支持
- 新增 180+ 编程语言代码高亮
- 修复编辑/预览模式切换渲染问题
- 优化亮色/暗色模式主题适配
- 新增 TypeScript 类型定义
This commit is contained in:
2026-02-04 03:31:22 +08:00
parent eb2cbad17b
commit a5d30684ed
119 changed files with 11244 additions and 12042 deletions

View File

@@ -42,8 +42,8 @@ import { xml } from '@codemirror/legacy-modes/mode/xml'
// 文件扩展名到 CodeMirror 语言包的映射
const LANGUAGE_MAP = {
// JavaScript/TypeScript (使用 javascript 包)
javascript: ['js', 'jsx', 'mjs', 'cjs'],
typescript: ['ts', 'tsx'],
javascript: ['js', 'jsx', 'mjs', 'cjs', 'cts', 'mts'],
typescript: ['ts', 'tsx', 'cts', 'mts'],
// 数据格式
json: ['json'],
@@ -55,7 +55,7 @@ const LANGUAGE_MAP = {
css: ['css', 'scss', 'sass', 'less'],
// 系统编程
cpp: ['cpp', 'c', 'cc', 'cxx', 'h', 'hpp'],
cpp: ['cpp', 'c', 'cc', 'cxx', 'h', 'hpp', 'hxx'],
rust: ['rs'],
go: ['go'],
@@ -64,7 +64,7 @@ const LANGUAGE_MAP = {
php: ['php'],
ruby: ['rb'],
perl: ['pl', 'pm'],
shell: ['sh', 'bash', 'zsh', 'fish', 'cmd', 'bat'],
shell: ['sh', 'bash', 'zsh', 'fish', 'cmd', 'bat', 'ps1'],
sql: ['sql'],
// JVM 语言
@@ -116,7 +116,8 @@ const createExtensions = () => {
highlightActiveLineGutter(),
history(),
keymap.of(defaultKeymap),
keymap.of(historyKeymap),
// 不使用 historyKeymap避免 Ctrl+Z 与外部重置功能冲突
// 用户可以通过外部的重置按钮或 Ctrl+Z全局快捷键恢复原始内容
bracketMatching(),
EditorView.updateListener.of((update) => {
if (update.docChanged) {
@@ -315,7 +316,12 @@ watch(() => props.modelValue, (newValue) => {
})
// 监听主题或文件扩展名变化,重建编辑器
watch([isDark, () => props.fileExtension], recreateEditor)
// 使用 nextTick 确保 DOM 更新完成后再重建,避免视觉抖动
import { nextTick } from 'vue'
watch([isDark, () => props.fileExtension], async () => {
await nextTick()
recreateEditor()
})
</script>
<style scoped>