dsh-brain/src-client/panel/BrainPanel.tsx

48 lines
1.9 KiB
TypeScript

// Brain total panel: the shell-rendered centre page of the dsh-brain bundle.
import * as React from 'react'
import { Overview } from './Overview'
import { MemoryTab } from './MemoryTab'
import { RawTab } from './RawTab'
import { DepartmentTab } from './DepartmentTab'
import styles from './BrainPanel.module.css'
const h = React.createElement
const TABS = [
{ id: 'overview', label: '概览' },
{ id: 'memory', label: '记忆' },
{ id: 'raw', label: '原始记录' },
{ id: 'departments', label: '部门' },
] as const
export function BrainPanel(): any {
const [tab, setTab] = React.useState('overview')
let content: any
if (tab === 'overview') content = h(Overview)
else if (tab === 'memory') content = h(MemoryTab, { scope: 'global' })
else if (tab === 'raw') content = h(RawTab, {})
else content = h(DepartmentTab, { scope: 'global' })
return h('div', { className: styles.nativeWorkspace, 'data-dsh-plugin': 'dsh-brain', 'data-dsh-part': 'brain-panel' },
h('div', { className: styles.windowDragBand, 'data-window-drag': true, 'aria-hidden': 'true' }),
h('div', { className: styles.panelInner },
h('div', { className: styles.header },
h('div', { className: styles.titleBlock },
h('h3', { className: styles.title }, 'Brain'),
h('p', { className: styles.subtitle }, '全局记忆、原始记录、部门与运行状态'),
),
),
h('div', { className: styles.tabBar, role: 'tablist', 'aria-label': 'Brain 面板页签' },
TABS.map((item) => h('button', {
key: item.id,
type: 'button',
role: 'tab',
'aria-selected': tab === item.id,
className: tab === item.id ? styles.tab + ' ' + styles.tabActive : styles.tab,
onClick: () => setTab(item.id),
}, item.label)),
),
h('div', { className: styles.content }, content),
),
)
}