refactor(web): remove DSH workspace status bar duplicated in settings

This commit is contained in:
2026-10-22 16:55:03 +08:00
parent ed72985e7b
commit 264a5e664a
+3 -28
View File
@@ -1,10 +1,7 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { ExternalLink, MoreVertical, RefreshCw, RotateCw, Settings2 } from 'lucide-react';
import { api, type Instance } from './api';
import { Alert, message, Status } from './ui';
import { RuntimeSelector } from './RuntimeSelector';
import { Alert, message } from './ui';
import { runtimeSelectionKey, selectRuntime } from './runtimeSelection';
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from './components/ui/dropdown-menu';
import { buttonVariants } from './components/ui/button';
import { cn } from './lib/utils';
@@ -71,33 +68,11 @@ export function useRuntimeInstances(userId: string, page: string) {
export function RuntimeWorkspace({ runtime, visible, manage, settings }: {
runtime: ReturnType<typeof useRuntimeInstances>; visible: boolean; manage: () => void; settings: () => void;
}) {
const [revision, setRevision] = useState(0);
const [frameError, setFrameError] = useState(false);
const selected = runtime.instances?.find(instance => instance.id === runtime.selectedId);
const url = selected ? '/dsh/' + encodeURIComponent(selected.id) + '/' : '';
useEffect(() => { setFrameError(false); }, [selected?.id, revision]);
const iconBtn = cn(buttonVariants({variant: 'ghost', size: 'icon'}), 'text-muted-foreground');
useEffect(() => { setFrameError(false); }, [selected?.id]);
return <section className={cn('min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-card', visible ? 'flex' : 'hidden')} aria-label="DSH 工作台">
<div className="flex shrink-0 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b border-border px-3 py-2 sm:px-4">
<div className="flex min-w-0 items-center gap-2">
<strong className="truncate text-[14px]">{selected?.name || 'DSH'}</strong>
{selected && <Status value={selected.status} />}
</div>
<div className="flex items-center gap-1.5">
<RuntimeSelector runtime={runtime} compact />
<button type="button" title="刷新状态" aria-label="刷新状态" disabled={runtime.loading} onClick={() => void runtime.refresh()} className={iconBtn}>
<RefreshCw className={runtime.loading ? 'animate-spin' : undefined} aria-hidden />
</button>
{selected?.status === 'running' && <DropdownMenu>
<DropdownMenuTrigger className={iconBtn} aria-label="更多操作" title="更多操作"><MoreVertical aria-hidden /></DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onSelect={() => setRevision(value => value + 1)}><RotateCw aria-hidden />重新加载内嵌页面</DropdownMenuItem>
<DropdownMenuItem onSelect={() => window.open(url, '_blank', 'noopener,noreferrer')}><ExternalLink aria-hidden />新窗口打开</DropdownMenuItem>
<DropdownMenuItem onSelect={manage}><Settings2 aria-hidden />管理实例</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>}
</div>
</div>
{runtime.error && <div className="shrink-0 px-3 pt-2"><Alert>{runtime.error} <button className={cn(buttonVariants({variant: 'outline', size: 'sm'}), 'ml-2')} onClick={() => void runtime.refresh()} disabled={runtime.loading}>重试</button></Alert></div>}
{!runtime.instances && runtime.loading && <div className="m-auto max-w-full overflow-auto p-10 text-center wrap-anywhere" role="status">正在加载实例…</div>}
{!runtime.instances && !runtime.loading && <div className="m-auto max-w-full overflow-auto p-10 text-center wrap-anywhere">暂时无法加载实例,请重试。</div>}
@@ -116,7 +91,7 @@ export function RuntimeWorkspace({ runtime, visible, manage, settings }: {
</div>}
{selected?.status === 'running' && <div className="flex min-h-0 flex-1 flex-col">
{frameError && <div className="shrink-0 px-3 pt-2"><Alert>DSH 页面加载失败或登录已失效,请重新加载或在新窗口打开。</Alert></div>}
<iframe className="block min-h-0 w-full flex-1 border-0 bg-card" key={selected.id + ':' + revision} src={url} title={'DSH · ' + selected.name} referrerPolicy="same-origin" onError={() => setFrameError(true)} onLoad={event => {
<iframe className="block min-h-0 w-full flex-1 border-0 bg-card" key={selected.id} src={url} title={'DSH · ' + selected.name} referrerPolicy="same-origin" onError={() => setFrameError(true)} onLoad={event => {
try {
const doc = event.currentTarget.contentDocument;
const path = event.currentTarget.contentWindow?.location.pathname;