diff --git a/src/App.tsx b/src/App.tsx index 4f1c551..63208cd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -14,7 +14,6 @@ import { Workspaces, workspaceShortcuts } from './components/Workspaces' import { AgentTracker } from './components/AgentTracker' import { SettingsModal } from './components/SettingsModal' import { ProjectSettingsModal } from './components/ProjectSettingsModal' -import { DocViewer } from './components/DocViewer' import { TopBar } from './components/TopBar' import { workspaceEntries } from './components/Workspaces' @@ -37,7 +36,7 @@ export function App() { }) const toast = useStore(s => s.toast) const trackerRunId = useStore(s => s.ui.trackerRunId) - const viewingArtifact = useStore(s => s.ui.viewingArtifact) + const previewExpanded = previewOpen && ui.previewExpanded const pendingBadge = useStore(s => s.cards.filter(c => c.status === 'action_required').length) // authState:checking → login(登录)→ mustchange(首登强制改密)→ ok(放行)。 const [authState, setAuthState] = useState<'checking' | 'login' | 'mustchange' | 'ok'>('checking') @@ -143,14 +142,16 @@ export function App() { )} -
+ {previewOpen && ( <> -
-
+ {!previewExpanded && ( +
+ )} +
@@ -180,7 +181,6 @@ export function App() { {ui.projectSettingsId && } {ui.adminZoneOpen && } {ui.changePwOpen && store.setUI({ changePwOpen: false })} />} - {viewingArtifact && } {toast &&
{toast}
}
) diff --git a/src/components/ArtifactsPanel.tsx b/src/components/ArtifactsPanel.tsx index 2f0fd7c..c502ecd 100644 --- a/src/components/ArtifactsPanel.tsx +++ b/src/components/ArtifactsPanel.tsx @@ -37,7 +37,7 @@ export function ArtifactsPanel() { : visible.length === 0 ?
没有匹配「{q}」的文件
: visible.map(a => ( - // 预览落在对话右侧预览区。弹层盖住主区,先收起再打开。 + // 预览落在对话右侧预览区。工作区弹层盖住主区,先收起再打开。
{ store.closeWorkspace(); store.requestPreview(a) }} title={`预览 ${a.name}`}> @@ -46,7 +46,7 @@ export function ArtifactsPanel() { {a.kind} · {humanSize(a.size) || '—'} · {shortTime(a.updatedAt)} - + e.stopPropagation()}> diff --git a/src/components/DocViewer.tsx b/src/components/DocViewer.tsx deleted file mode 100644 index c164b0f..0000000 --- a/src/components/DocViewer.tsx +++ /dev/null @@ -1,68 +0,0 @@ -// 文档查看器(4.4 → 预览能力收敛):格式渲染统一交给 @ui FilePreview -// (md/图片/pdf/代码/数据/docx/xlsx/pptx/URL 一套分派),这里只保留 OverlayHost -// 容器、工具栏与文本族的在线编辑保存。 -import { useEffect, useState } from 'react' -import { api } from '../api' -import { store } from '../store' -import { OverlayHost, Icon, Btn, FilePreview } from '@ui' -import type { Artifact } from '../contracts' -import { humanSize } from '../messageparts' - -export function DocViewer({ artifact }: { artifact: Artifact }) { - const [content, setContent] = useState(null) - const [editing, setEditing] = useState(false) - const [dirty, setDirty] = useState(false) - - const textKind = isTextKind(artifact) - useEffect(() => { - if (!textKind) return - setContent(null) - fetch(api.artifactContentUrl(artifact.id)).then(r => r.text()).then(setContent).catch(() => setContent('(读取失败)')) - }, [artifact.id]) - - const source = { - kind: 'artifact' as const, - id: artifact.id, - name: artifact.name, - mime: artifact.mime, - contentUrl: api.artifactContentUrl(artifact.id), - downloadUrl: api.artifactDownloadUrl(artifact.id), - } - - return ( - store.viewArtifact(null)}> -
-
- {artifact.kind}{humanSize(artifact.size) ? ` · ${humanSize(artifact.size)}` : ''} - - {dirty && 未保存} - {textKind && ( - <> - setEditing(e => !e)}>{editing ? '预览' : '编辑'} - {editing && { - await api.saveArtifactContent(artifact.id, content ?? '') - setDirty(false) - store.toast('已保存') - }}>保存} - - )} - - 下载 - -
-
- {editing && textKind ? ( -