diff --git a/CHANGELOG.md b/CHANGELOG.md index ccc894f3..c9c010c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - 🧭 **开始页由插件接管,支持两列自适应、可配置行数和「更多」收纳**:右侧栏展开时不再用宿主自带的单列卡片页。宽屏(≥520px)每行两张、窄屏一张;默认最多 6 行(可在设置或「调整顺序」弹窗中改为 ≥1 行),超出容量的入口收进「更多」卡片,菜单行统一为图标 + 标题,可直接打开,也可打开「调整顺序」。开始页内容默认垂直居中,可切换为靠上;设置中新增「接管开始页」开关(默认开),关闭后恢复宿主自带开始页。开始页卡片点击后用新页面替换指南页,和宿主原行为一致。 - 🧪 测试:`tests/guide-layout.spec.ts`(排序 / 隐藏 / 列数与容量 / More 占格 / 最小容量)、`tests/native-guide.spec.tsx`(卡片、More、终端 Shell 菜单、catalog 订阅、chain 注册与释放)。 - - 卡片副标题固定为一行,宽度不足时以省略号截断,长描述不再把卡片撑成两行。 + - 卡片副标题固定为一行,宽度不足时以省略号截断,长描述不再把卡片撑成两行;「更多」菜单的图标放在固定 14px 盒子里并垂直居中,不再比文字高 2px。 - 🗂 **设置里的「开始页」清单接管所有已注册到官方侧边栏的入口**:本插件、宿主终端和第三方 tab 都按 `providerId::entryId` 列出,默认显示;本插件自己的 tab 使用与「侧边栏内容」功能卡片相同的 `tabsEnabled` 功能开关(关闭即禁用并移出开始页,清单行保留以便重新打开);宿主/第三方入口的开关只控制开始页显示,不注销 tab 类型,也不影响快捷键、资源打开或已打开页签。支持上移/下移和恢复默认顺序,排序持久化。 - 🧪 测试:`tests/side-card-section.spec.tsx`(原生入口清单、默认开启、顺序与隐藏状态)、`tests/prefs.spec.ts`(行数 / 顺序 / 可见性校验)。 - 🖥 **终端卡片保留原生 Shell 菜单**:开始页的终端卡片右侧有「…」,菜单通过宿主 `webTerminals.launchShells` 读取 Shell 列表,选择后写入宿主偏好并以该 Shell 打开终端;宿主没有这些能力时卡片退化为普通入口。修复 `launchShells` / `selectShell` 丢失 `this` 导致「Shell 加载失败:Cannot read properties of undefined (reading 'remote')」的问题,并加回归测试。其他第三方自定义开始页卡片组件无法在 chain 接管页中复用,会显示为通用卡片(原因见 `docs/host-contracts.md` §9)。 diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index cf7e2551..b1a22917 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -8,7 +8,7 @@ - 🧭 **The start page is now plugin-owned, with a responsive two-column grid, a configurable row budget, and a More card for overflow.** Expanding the right sidebar no longer shows the host's single-column card page. Wide panes (>= 520px) put two cards on a row and narrow panes one; 6 rows by default (configurable to any value >= 1 in settings or in the Reorder dialog), and entries beyond the budget move into a More card whose rows all carry an icon plus a title and open the entry or the Reorder dialog. The grid is vertically centered by default and can be pinned to the top; settings gain a default-on "Take over the start page" switch that restores the host's page when off. Picking a card replaces the guide tab with the chosen page, exactly like the host did. - 🧪 Tests: `tests/guide-layout.spec.ts` (ordering / visibility / columns and capacity / More occupancy / minimum capacity) and `tests/native-guide.spec.tsx` (cards, More, the terminal shell menu, catalog subscription, chain registration and release). - - Card subtitles stay on one line and end in an ellipsis when the card is narrower than the copy, so a long description no longer grows the card to two lines. + - Card subtitles stay on one line and end in an ellipsis when the card is narrower than the copy, so a long description no longer grows the card to two lines; More-menu glyphs now sit in a fixed 14px box and center vertically instead of riding 2px above the label. - 🗂 **The settings "Start page" inventory now covers every entry registered with the official sidebar.** Plugin tabs, the host terminal, and third-party tabs are listed by `providerId::entryId`, visible by default; Better Sidebar's own tabs use the same `tabsEnabled` feature switch as their sidebar-content card (turning it off disables the tab and removes its start-page card, while the inventory row stays so it can be turned back on); host/third-party entries only have the start-page visibility switch, which never unregisters a tab type or affects shortcuts, resource opens, or already-open tabs. Move up/down and reset order are supported and persisted. - 🧪 Tests: `tests/side-card-section.spec.tsx` (native inventory, default-on, order and visibility) and `tests/prefs.spec.ts` (rows / order / visibility validation). - 🖥 **The terminal card keeps its native shell menu.** The start page's terminal card has a "..." trigger whose menu reads the shell list through the host's `webTerminals.launchShells`, remembers the choice through the host, and opens the terminal with that shell; without those host capabilities the card degrades to a plain entry. Fixed a lost receiver in `launchShells` / `selectShell` that surfaced as "Shell failed to load: Cannot read properties of undefined (reading 'remote')", with a regression test. Other third-party custom start-page card components cannot be reused inside a chain takeover and render as generic cards (see `docs/host-contracts.md` §9 for why). diff --git a/src/client/native/guide.module.css b/src/client/native/guide.module.css index 75bf90b3..21f12724 100644 --- a/src/client/native/guide.module.css +++ b/src/client/native/guide.module.css @@ -149,6 +149,28 @@ color: var(--dsw-alias-label-primary); } +.menuIcon { + display: inline-flex; + align-items: center; + justify-content: center; + width: 14px; + height: 14px; +} + +.menuIcon > span { + display: flex; + align-items: center; + justify-content: center; + width: 14px; + height: 14px; +} + +.menuIcon svg { + display: block; + width: 14px; + height: 14px; +} + .moreSlot { display: flex; min-width: 0; diff --git a/src/client/native/guide.tsx b/src/client/native/guide.tsx index 9bc9edb6..b5b81102 100644 --- a/src/client/native/guide.tsx +++ b/src/client/native/guide.tsx @@ -80,6 +80,12 @@ function cardIcon(entry: NativeGuideEntry): ReactNode { return Icon === undefined ? null : createElement(Icon, { size: 16 }) } +/** Menu glyphs sit in a fixed 14px box; some custom icons keep their own + * baseline, so center the SVG explicitly or it rides 2px above the label. */ +function menuIcon(icon: ReactNode): ReactNode { + return icon === null ? null : +} + /** The terminal card's shell menu: the host's shell catalog, drawn natively here. */ function TerminalMenu(props: { entry: NativeGuideEntry @@ -242,21 +248,21 @@ export function GuideGrid(props: GuideGridProps) { const hostActions = [ ...(onBrowsePlugins === undefined ? [] - : [{ id: 'browse', label: t('guideBrowsePlugins'), icon: }]), + : [{ id: 'browse', label: t('guideBrowsePlugins'), icon: menuIcon() }]), ...(onCreatePlugin === undefined ? [] - : [{ id: 'create', label: t('guideCreatePlugin'), icon: }]), + : [{ id: 'create', label: t('guideCreatePlugin'), icon: menuIcon() }]), ] const moreItems = [ ...layout.overflow.map(entry => ({ id: 'open:' + entry.key, label: entry.title(), - icon: cardIcon(entry), + icon: menuIcon(cardIcon(entry)), })), ...(layout.overflow.length === 0 ? [] : [{ type: 'separator' as const, id: 'overflow-separator' }]), ...hostActions, ...(hostActions.length === 0 ? [] : [{ type: 'separator' as const, id: 'actions-separator' }]), - { id: 'order', label: t('guideOrder'), icon: }, + { id: 'order', label: t('guideOrder'), icon: menuIcon() }, ] /** The grid body; the More anchor is a card-sized Menu trigger. */ diff --git a/tests/guide-css.spec.ts b/tests/guide-css.spec.ts index 651ebc1a..ba5e7198 100644 --- a/tests/guide-css.spec.ts +++ b/tests/guide-css.spec.ts @@ -16,4 +16,16 @@ describe('start-page card description', () => { expect(rule).toMatch(/overflow:\s*hidden/) expect(rule).not.toContain('line-clamp') }) + + it('centers More-menu glyphs in a fixed box', () => { + const rule = css.match(/\.menuIcon\s*\{([\s\S]*?)\n\}/)?.[1] + expect(rule).toBeDefined() + expect(rule).toMatch(/display:\s*inline-flex/) + expect(rule).toMatch(/align-items:\s*center/) + expect(rule).toMatch(/justify-content:\s*center/) + expect(rule).toMatch(/width:\s*14px/) + expect(rule).toMatch(/height:\s*14px/) + expect(css).toMatch(/\.menuIcon\s*>\s*span\s*\{[^}]*display:\s*flex/) + expect(css).toMatch(/\.menuIcon\s+svg\s*\{[^}]*display:\s*block/) + }) })