60 lines
2.5 KiB
TypeScript
60 lines
2.5 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 { SettingsCard } from '../SettingsCard'
|
|
import styles from './BrainPanel.module.css'
|
|
|
|
const h = React.createElement
|
|
|
|
const TABS = [
|
|
{ id: 'overview', label: '概览' },
|
|
{ id: 'memory', label: '记忆' },
|
|
{ id: 'departments', label: '部门' },
|
|
{ id: 'skills', label: '技能' },
|
|
{ id: 'mcp', label: 'MCP' },
|
|
{ id: 'connection', label: '连接与上报' },
|
|
] as const
|
|
|
|
function Placeholder(props: { title: string }): any {
|
|
return h('div', { className: styles.placeholder },
|
|
h('h3', { className: styles.placeholderTitle }, props.title),
|
|
h('p', { className: styles.placeholderHint }, '即将上线'),
|
|
)
|
|
}
|
|
|
|
export function BrainPanel(props: { ctx?: any; panelId?: string; usePanelInfo?: any }): any {
|
|
const [tab, setTab] = React.useState('overview')
|
|
const panelId = props.panelId ?? 'dsh-brain'
|
|
const usePanelInfo = props.usePanelInfo
|
|
const active = usePanelInfo === undefined ? true : usePanelInfo((info: { activePanelId: string | null }) => info.activePanelId === panelId)
|
|
let content: any
|
|
if (tab === 'overview') content = h(Overview, { active })
|
|
else if (tab === 'connection') content = h(SettingsCard, null)
|
|
else if (tab === 'memory') content = h(Placeholder, { title: '记忆' })
|
|
else if (tab === 'departments') content = h(Placeholder, { title: '部门' })
|
|
else if (tab === 'skills') content = h(Placeholder, { title: '技能' })
|
|
else content = h(Placeholder, { title: 'MCP' })
|
|
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),
|
|
),
|
|
)
|
|
}
|