Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/dsh-desktop-workbenches/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,12 +1264,12 @@ window.__ModuleLoader__.load({
h('button', { type: 'button', className: 'dshWbWorkbenchHome', title: '工作台主页', 'aria-label': '打开工作台主页', 'aria-current': marketSelected ? 'page' : undefined, onClick: () => { setOpen(false); service.showMarket() } },
h(MarketIcon, { name: 'market', size: 16 }), h('span', null, '工作台')),
pinned.length > 0
? h('button', { type: 'button', className: 'dshWbModeSwitch', title: `切换工作台(当前:${active?.title || '默认'})`, 'aria-label': `切换工作台,当前:${active?.title || '默认'}`, 'aria-haspopup': 'menu', 'aria-expanded': open, disabled, onClick: () => setOpen((value) => !value) },
h('span', { className: 'dshWbCurrentModeLabel' }, active?.title || '默认'), h(MarketIcon, { name: 'switch', size: 16 }))
: h('span', { className: 'dshWbCurrentMode', title: '默认', 'aria-label': '当前工作台:默认' }, h('span', { className: 'dshWbCurrentModeLabel' }, '默认')),
? h('button', { type: 'button', className: 'dshWbModeSwitch', title: `切换工作台(当前:${active?.title || '会话'})`, 'aria-label': `切换工作台,当前:${active?.title || '会话'}`, 'aria-haspopup': 'menu', 'aria-expanded': open, disabled, onClick: () => setOpen((value) => !value) },
h('span', { className: 'dshWbCurrentModeLabel' }, active?.title || '会话'), h(MarketIcon, { name: 'switch', size: 16 }))
: h('span', { className: 'dshWbCurrentMode', title: '会话', 'aria-label': '当前模式:会话' }, h('span', { className: 'dshWbCurrentModeLabel' }, '会话')),
open && pinned.length > 0 && h('div', { className: 'dshWbModeMenu', role: 'menu', 'aria-label': '选择会话模式' },
h('button', { type: 'button', className: 'dshWbModeOption', role: 'menuitemradio', 'aria-checked': !state.active, onClick: chooseNative },
h(MarketIcon, { name: 'home', size: 16 }), h('span', { className: 'dshWbModeOptionLabel' }, '原生会话'), h('span', { className: 'dshWbModeOptionCheck', 'aria-hidden': true }, !state.active ? '✓' : '')),
h(MarketIcon, { name: 'home', size: 16 }), h('span', { className: 'dshWbModeOptionLabel' }, '会话'), h('span', { className: 'dshWbModeOptionCheck', 'aria-hidden': true }, !state.active ? '✓' : '')),
...pinned.map((item, index) => h('div', { key: item.id, className: 'dshWbModeOptionRow', role: 'none', 'data-dragging': draggingId === item.id || undefined, 'data-drop-edge': dropTarget?.id === item.id ? dropTarget.edge : undefined, onDragOver: (event) => onDragOver(event, item.id), onDrop: (event) => onDrop(event, item.id) },
h('button', { type: 'button', className: 'dshWbModeOption', role: 'menuitemradio', 'aria-checked': item.id === state.active, onClick: () => chooseWorkbench(item) },
h(WorkbenchIcon, { entry: item, size: 16 }), h('span', { className: 'dshWbModeOptionLabel' }, item.title), h('span', { className: 'dshWbModeOptionCheck', 'aria-hidden': true }, item.id === state.active ? '✓' : '')),
Expand Down Expand Up @@ -1318,7 +1318,7 @@ window.__ModuleLoader__.load({
return h('div', { className: 'dshWbPreview', role: 'img', 'aria-label': `${entry.title}界面预览(模拟)` },
h('div', { className: 'dshWbPreviewBar', 'aria-hidden': true }, h('span', { className: 'dshWbPreviewDot' }), h('span', { className: 'dshWbPreviewDot' }), h('span', { className: 'dshWbPreviewDot' })),
h('div', { className: 'dshWbPreviewCanvas', style: { gridTemplateColumns: columns } },
h('div', { className: 'dshWbPreviewPane', style: { order: entry.layout?.businessSide === 'left' ? 2 : 1 } }, h('em'), '原生会话', h('i'), h('i')),
h('div', { className: 'dshWbPreviewPane', style: { order: entry.layout?.businessSide === 'left' ? 2 : 1 } }, h('em'), '会话', h('i'), h('i')),
h('div', { className: 'dshWbPreviewPane', style: { order: entry.layout?.businessSide === 'left' ? 1 : 2 } }, h('em'), entry.panelTitle || '业务区域', h('i'), h('i'))))
}
function ScreenshotGallery({ entry }) {
Expand Down Expand Up @@ -1556,7 +1556,7 @@ ${ACCEPTANCE_READING}先确认要公开的仓库和内容,不得公开密钥
h('header', { className: 'dshWbMarketHeader' },
h('div', { className: 'dshWbMarketHeaderText' },
h('h1', null, tab === 'submit' ? '制作属于你的工作台' : '工作台'),
h('p', { className: 'dshWbMuted' }, tab === 'submit' ? '遵循规范开发、安装并验证,也可以准备材料提交到工作台市场。' : '工作台把专属界面、会话和资料组织在一起。可通过顶部快捷栏在原生会话与不同工作台之间切换。')),
h('p', { className: 'dshWbMuted' }, tab === 'submit' ? '遵循规范开发、安装并验证,也可以准备材料提交到工作台市场。' : '工作台把专属界面、会话和资料组织在一起。可通过顶部快捷栏在会话与不同工作台之间切换。')),
h('div', { className: 'dshWbMarketHeaderActions' },
tab !== 'submit' && h(Button, { className: `dshWbBtn dshWbRefresh${tab === 'mine' ? ' dshWbCheckUpdates' : ''}`, title: checkingUpdates ? '正在检查更新' : tab === 'mine' ? '检查更新' : '刷新目录', 'aria-label': checkingUpdates ? '正在检查更新' : tab === 'mine' ? '检查更新' : '刷新目录', 'aria-busy': catalogRefreshing || checkingUpdates, disabled: catalogRefreshing || checkingUpdates, onClick: () => service.run(tab === 'mine' ? service.checkUpdates() : service.refreshCatalog()) }, h(MarketIcon, { name: 'refresh', size: 17 }), tab === 'mine' && (checkingUpdates ? '正在检查…' : '检查更新')),
h(Button, { primary: tab !== 'submit', className: `dshWbBtn${tab !== 'submit' ? ' dshWbPrimary' : ''} dshWbCreate`, onClick: () => { setTab(tab === 'submit' ? 'market' : 'submit'); setDetail(null); setCopyStatus('') } }, h(MarketIcon, { name: tab === 'submit' ? 'search' : 'plus' }), tab === 'submit' ? '返回工作台市场' : '制作我的工作台'))),
Expand Down Expand Up @@ -1665,7 +1665,7 @@ ${ACCEPTANCE_READING}先确认要公开的仓库和内容,不得公开密钥
class PanelBoundary extends React.Component {
state = { error: false }
static getDerivedStateFromError() { return { error: true } }
render() { return this.state.error ? h('div', { role: 'alert' }, '业务面板加载失败。原生会话和公共入口仍可使用。') : this.props.children }
render() { return this.state.error ? h('div', { role: 'alert' }, '业务面板加载失败。会话和公共入口仍可使用。') : this.props.children }
}
// The portal destination stays stable; providers may dock its mount anywhere
// inside their own main-area layout without remounting the native input.
Expand Down
12 changes: 7 additions & 5 deletions test/workbench-client.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ describe('workbench market screenshot and metadata display', () => {
const fullSource = code
it('explains the workbench concept and the sidebar shortcut model', () => {
expect(fullSource).toContain("tab === 'submit' ? '制作属于你的工作台' : '工作台'")
expect(fullSource).toContain('工作台把专属界面、会话和资料组织在一起。可通过顶部快捷栏在原生会话与不同工作台之间切换。')
expect(fullSource).toContain('工作台把专属界面、会话和资料组织在一起。可通过顶部快捷栏在会话与不同工作台之间切换。')
})

it('does not embed provider-specific market screenshots in Desktop', async () => {
Expand All @@ -1769,13 +1769,13 @@ describe('workbench market screenshot and metadata display', () => {
it('renders a persistent Workbench home area beside the current mode and switch button', () => {
expect(fullSource).toContain('function WorkbenchSidebarSwitcher({ service, wide, startSession, usePanelInfo })')
expect(fullSource).toContain("'data-dsh-workbench-switcher': ''")
expect(fullSource).toContain("className: 'dshWbModeSwitch', title: `切换工作台(当前:${active?.title || '默认'})`, 'aria-label': `切换工作台,当前:${active?.title || '默认'}`, 'aria-haspopup': 'menu', 'aria-expanded': open")
expect(fullSource).toContain("className: 'dshWbModeSwitch', title: `切换工作台(当前:${active?.title || '会话'})`, 'aria-label': `切换工作台,当前:${active?.title || '会话'}`, 'aria-haspopup': 'menu', 'aria-expanded': open")
expect(fullSource).toContain("role: 'menu', 'aria-label': '选择会话模式'")
expect(fullSource).toContain("role: 'menuitemradio'")
expect(fullSource).toContain('service.openNative(startSession)')
expect(fullSource).toContain("name: 'home'")
expect(fullSource).not.toContain('dshWbSidebarTooltip')
expect(fullSource).toContain("active?.title || '默认'")
expect(fullSource).toContain("active?.title || '会话'")
expect(fullSource).toContain("title: '工作台主页', 'aria-label': '打开工作台主页'")
expect(fullSource).toContain('setOpen(false); service.showMarket()')
expect(fullSource).toContain('.dshWbWorkbenchHome{display:flex;align-items:center;justify-content:flex-start;gap:8px;flex:1 1 0;min-width:88px;')
Expand Down Expand Up @@ -1820,6 +1820,7 @@ describe('workbench market screenshot and metadata display', () => {
expect(ui.find(tree, node => node.props?.role === 'menu')).toHaveLength(1)
const modes = ui.find(tree, node => node.props?.role === 'menuitemradio')
expect(modes).toHaveLength(2)
expect(ui.find(modes[0], node => node.props?.className === 'dshWbModeOptionLabel')[0].props.children).toEqual(['会话'])
expect(modes.map(mode => mode.props['aria-checked'])).toEqual([false, true])
modes[0].props.onClick()
expect(ui.service.openNative).toHaveBeenCalledOnce()
Expand All @@ -1833,10 +1834,11 @@ describe('workbench market screenshot and metadata display', () => {
expect(ui.find(tree, node => node.props?.role === 'menu')).toHaveLength(0)
})

it('shows Default without a switch button when no Workbench is pinned', () => {
it('shows 会话 without a switch button when no Workbench is pinned', () => {
const ui = sidebarSwitcher()
const tree = ui.render()
expect(ui.find(tree, node => node.props?.className === 'dshWbCurrentModeLabel')[0].props.children).toEqual(['默认'])
expect(ui.find(tree, node => node.props?.className === 'dshWbCurrentModeLabel')[0].props.children).toEqual(['会话'])
expect(ui.find(tree, node => node.props?.className === 'dshWbCurrentMode')[0].props['aria-label']).toBe('当前模式:会话')
expect(ui.find(tree, node => node.props?.className === 'dshWbModeSwitch')).toHaveLength(0)
expect(ui.find(tree, node => node.props?.className === 'dshWbWorkbenchHome')).toHaveLength(1)
expect(code).not.toContain('.dshWbCurrentModeIcon{')
Expand Down
Loading