fix: 工作台状态持久化(视图覆盖写回views[id],布局条目照旧) + feat: tsx/css等代码文件点击预览
This commit is contained in:
@@ -380,10 +380,16 @@ function WorktableSection(props: any) {
|
||||
setActiveSplitId(splitStore.active && splitStore.spec ? splitStore.spec.id : null)
|
||||
}), [])
|
||||
|
||||
// 引擎内 spec 变更(窗内容/聊天位置/窗位互换)→ 回写布局条目持久化
|
||||
// 引擎内 spec 变更(窗内容/聊天位置/窗位互换)→ 回写持久化:
|
||||
// 布局项目写 layouts 条目;入驻项目(视图覆盖工作区)写 views[id]。每个项目都保持上一次的样子。
|
||||
useEffect(() => {
|
||||
splitStore.onSpecMutated = (spec) => {
|
||||
persistProjects((prev) => ({ ...prev, layouts: prev.layouts.map((l) => (l.id === spec.id ? spec : l)) }))
|
||||
persistProjects((prev) => {
|
||||
if (prev.layouts.some((l) => l.id === spec.id)) {
|
||||
return { ...prev, layouts: prev.layouts.map((l) => (l.id === spec.id ? spec : l)) }
|
||||
}
|
||||
return { ...prev, views: { ...prev.views, [spec.id]: spec } }
|
||||
})
|
||||
}
|
||||
return () => { splitStore.onSpecMutated = null }
|
||||
}, [])
|
||||
|
||||
@@ -937,7 +937,7 @@ function ExplorerPane(props: { row: PaneRow; index: number }) {
|
||||
url: '/api/worktable/site/' + encodeURIComponent(dir) + '/' + encodeURIComponent(e.name),
|
||||
title: e.name,
|
||||
})
|
||||
} else if (/\.(md|markdown|mdown|txt|log|pdf|png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(e.name)) {
|
||||
} else if (/\.(md|markdown|mdown|txt|log|tsx|ts|jsx|js|css|json|pdf|png|jpe?g|gif|webp|svg|bmp|ico)$/i.test(e.name)) {
|
||||
splitStore.openTab(props.row, props.index, { kind: 'file', path: e.path })
|
||||
} else {
|
||||
setError(T('pane.openLater'))
|
||||
|
||||
Reference in New Issue
Block a user