mirror of
https://ghproxy.cflmy.top/https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-11-29 08:39:35 +08:00
Merge pull request #9109 from deepseek-harness/settings-slot-separators
fix(client): 修复通用设置 slot 注册项之间的分割线
This commit is contained in:
commit
dc62cf787d
19 files changed
+302
-17
No files matched your search
@@ -0,0 +1,38 @@
|
||||
/** Real client plugin fixture: settings slot separator combinations. */
|
||||
window.__ModuleLoader__.load({
|
||||
id: "@fixture/settings-slots-custom",
|
||||
meta() { return { stylesheets: { "repro.css": { text: () => ".slot-repro-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }\n.slot-repro-copy { min-width: 0; }\n.slot-repro-detail { font-size: 12px; color: var(--dsw-alias-label-secondary); }\n.slot-repro-bordered { border-bottom: 0.5px solid var(--dsw-alias-border-l2); }\n.slot-repro-internal { border-top: 0.5px solid var(--dsw-alias-border-l2); }" } } } },
|
||||
factory(require) {
|
||||
const React = require("react")
|
||||
const h = React.createElement
|
||||
function Row({ t, labelKey, bordered = false, internal = false }) {
|
||||
const [enabled, setEnabled] = React.useState(false)
|
||||
if (bordered && enabled) return null
|
||||
return h("div", { className: "slot-repro-row" + (bordered ? " slot-repro-bordered" : "") + (internal ? " slot-repro-internal" : ""), "data-slot-repro-row": labelKey },
|
||||
h("div", { className: "slot-repro-copy" }, t(labelKey), h("div", { className: "slot-repro-detail" }, t("detail"))),
|
||||
h("input", { type: "checkbox", checked: enabled, onChange: e => setEnabled(e.target.checked), "aria-label": t(labelKey) }))
|
||||
}
|
||||
function Single(props) { return h(Row, { ...props, labelKey: "single" }) }
|
||||
function Pair(props) { return h(React.Fragment, null, h(Row, { ...props, labelKey: "pairA" }), h(Row, { ...props, labelKey: "pairB", internal: true })) }
|
||||
function Bordered(props) { return h(Row, { ...props, labelKey: "bordered", bordered: true }) }
|
||||
function Empty() { return null }
|
||||
function Group({ renderSlot }) { return renderSlot("settings.general.group.repro.item", {}) }
|
||||
return {
|
||||
inject: ["slots", "locale"],
|
||||
apply(ctx) {
|
||||
const ns = "slotReprocustom",
|
||||
zh = { single: "分组槽位:插件单行(不自带线)", pairA: "同一注册返回两行:A", pairB: "同一注册返回两行:B", bordered: "插件自带底线(末尾)", detail: "仅用于分割线复现,勾选不会写入产品设置", group: "插件分割线实验" },
|
||||
en = { single: "Plugin row without a divider", pairA: "Fragment row A", pairB: "Fragment row B", bordered: "Trailing row with its own divider", detail: "Separator fixture only; local state does not save preferences", group: "Plugin divider experiment" }
|
||||
ctx.effect(() => ctx.locale.register(ns, { zh, en }))
|
||||
ctx.slots.inject("settings.general.group", () => ctx.slots.register({ name: "settings.general.group", id: "repro", order: 15, label: () => ctx.locale.bind(ns)("group"), children: { "settings.general.group.repro.item": { kind: "list", scope: "root" } } }, Group))
|
||||
ctx.slots.inject("settings.general.group.repro.item", function* () {
|
||||
yield ctx.slots.register({ name: "settings.general.group.repro.item", id: "repro-custom-0", order: 100, locale: ns }, Single)
|
||||
yield ctx.slots.register({ name: "settings.general.group.repro.item", id: "repro-custom-1", order: 110, locale: ns }, Empty)
|
||||
yield ctx.slots.register({ name: "settings.general.group.repro.item", id: "repro-custom-2", order: 120, locale: ns }, Pair)
|
||||
yield ctx.slots.register({ name: "settings.general.group.repro.item", id: "repro-custom-3", order: 130, locale: ns }, Bordered)
|
||||
yield ctx.slots.register({ name: "settings.general.group.repro.item", id: "repro-custom-4", order: 140, locale: ns }, Empty)
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,2 @@
|
||||
/** Host companion for a settings slot reproduction plugin. */
|
||||
export function apply() {}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@fixture/settings-slots-custom",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./client": "./client.js"
|
||||
},
|
||||
"dsh": {
|
||||
"client": {
|
||||
"platform": "web"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/** Real client plugin fixture: settings slot separator combinations. */
|
||||
window.__ModuleLoader__.load({
|
||||
id: "@fixture/settings-slots-grouped",
|
||||
meta() { return { stylesheets: { "repro.css": { text: () => ".slot-repro-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }\n.slot-repro-copy { min-width: 0; }\n.slot-repro-detail { font-size: 12px; color: var(--dsw-alias-label-secondary); }\n.slot-repro-bordered { border-bottom: 0.5px solid var(--dsw-alias-border-l2); }\n.slot-repro-internal { border-top: 0.5px solid var(--dsw-alias-border-l2); }" } } } },
|
||||
factory(require) {
|
||||
const React = require("react")
|
||||
const h = React.createElement
|
||||
function Row({ t, labelKey, bordered = false, internal = false }) {
|
||||
const [enabled, setEnabled] = React.useState(false)
|
||||
if (bordered && enabled) return null
|
||||
return h("div", { className: "slot-repro-row" + (bordered ? " slot-repro-bordered" : "") + (internal ? " slot-repro-internal" : ""), "data-slot-repro-row": labelKey },
|
||||
h("div", { className: "slot-repro-copy" }, t(labelKey), h("div", { className: "slot-repro-detail" }, t("detail"))),
|
||||
h("input", { type: "checkbox", checked: enabled, onChange: e => setEnabled(e.target.checked), "aria-label": t(labelKey) }))
|
||||
}
|
||||
function Single(props) { return h(Row, { ...props, labelKey: "single" }) }
|
||||
function Pair(props) { return h(React.Fragment, null, h(Row, { ...props, labelKey: "pairA" }), h(Row, { ...props, labelKey: "pairB", internal: true })) }
|
||||
function Bordered(props) { return h(Row, { ...props, labelKey: "bordered", bordered: true }) }
|
||||
function Empty() { return null }
|
||||
function Group({ renderSlot }) { return renderSlot("settings.general.group.repro.item", {}) }
|
||||
return {
|
||||
inject: ["slots", "locale"],
|
||||
apply(ctx) {
|
||||
const ns = "slotReprogrouped",
|
||||
zh = { single: "分组槽位:插件单行(不自带线)", pairA: "同一注册返回两行:A", pairB: "同一注册返回两行:B", bordered: "插件自带底线(末尾)", detail: "仅用于分割线复现,勾选不会写入产品设置", group: "插件分割线实验" },
|
||||
en = { single: "Plugin row without a divider", pairA: "Fragment row A", pairB: "Fragment row B", bordered: "Trailing row with its own divider", detail: "Separator fixture only; local state does not save preferences", group: "Plugin divider experiment" }
|
||||
ctx.effect(() => ctx.locale.register(ns, { zh, en }))
|
||||
ctx.slots.inject("settings.general.group.notifications.item", function* () {
|
||||
yield ctx.slots.register({ name: "settings.general.group.notifications.item", id: "repro-grouped-0", order: 100, locale: ns }, Single)
|
||||
yield ctx.slots.register({ name: "settings.general.group.notifications.item", id: "repro-grouped-1", order: 110, locale: ns }, Empty)
|
||||
yield ctx.slots.register({ name: "settings.general.group.notifications.item", id: "repro-grouped-2", order: 120, locale: ns }, Pair)
|
||||
yield ctx.slots.register({ name: "settings.general.group.notifications.item", id: "repro-grouped-3", order: 130, locale: ns }, Bordered)
|
||||
yield ctx.slots.register({ name: "settings.general.group.notifications.item", id: "repro-grouped-4", order: 140, locale: ns }, Empty)
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,2 @@
|
||||
/** Host companion for a settings slot reproduction plugin. */
|
||||
export function apply() {}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@fixture/settings-slots-grouped",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./client": "./client.js"
|
||||
},
|
||||
"dsh": {
|
||||
"client": {
|
||||
"platform": "web"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/** Real client plugin fixture: settings slot separator combinations. */
|
||||
window.__ModuleLoader__.load({
|
||||
id: "@fixture/settings-slots-legacy",
|
||||
meta() { return { stylesheets: { "repro.css": { text: () => ".slot-repro-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 0; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-primary); }\n.slot-repro-copy { min-width: 0; }\n.slot-repro-detail { font-size: 12px; color: var(--dsw-alias-label-secondary); }\n.slot-repro-bordered { border-bottom: 0.5px solid var(--dsw-alias-border-l2); }\n.slot-repro-internal { border-top: 0.5px solid var(--dsw-alias-border-l2); }" } } } },
|
||||
factory(require) {
|
||||
const React = require("react")
|
||||
const h = React.createElement
|
||||
function Row({ t, labelKey, bordered = false, internal = false }) {
|
||||
const [enabled, setEnabled] = React.useState(false)
|
||||
if (bordered && enabled) return null
|
||||
return h("div", { className: "slot-repro-row" + (bordered ? " slot-repro-bordered" : "") + (internal ? " slot-repro-internal" : ""), "data-slot-repro-row": labelKey },
|
||||
h("div", { className: "slot-repro-copy" }, t(labelKey), h("div", { className: "slot-repro-detail" }, t("detail"))),
|
||||
h("input", { type: "checkbox", checked: enabled, onChange: e => setEnabled(e.target.checked), "aria-label": t(labelKey) }))
|
||||
}
|
||||
function Single(props) { return h(Row, { ...props, labelKey: "single" }) }
|
||||
function Pair(props) { return h(React.Fragment, null, h(Row, { ...props, labelKey: "pairA" }), h(Row, { ...props, labelKey: "pairB", internal: true })) }
|
||||
function Bordered(props) { return h(Row, { ...props, labelKey: "bordered", bordered: true }) }
|
||||
function Empty() { return null }
|
||||
function Group({ renderSlot }) { return renderSlot("settings.general.group.repro.item", {}) }
|
||||
return {
|
||||
inject: ["slots", "locale"],
|
||||
apply(ctx) {
|
||||
const ns = "slotReprolegacy",
|
||||
zh = { single: "旧槽位:插件单行(不自带线)", pairA: "同一注册返回两行:A", pairB: "同一注册返回两行:B", bordered: "插件自带底线(末尾)", detail: "仅用于分割线复现,勾选不会写入产品设置", group: "插件分割线实验" },
|
||||
en = { single: "Plugin row without a divider", pairA: "Fragment row A", pairB: "Fragment row B", bordered: "Trailing row with its own divider", detail: "Separator fixture only; local state does not save preferences", group: "Plugin divider experiment" }
|
||||
ctx.effect(() => ctx.locale.register(ns, { zh, en }))
|
||||
ctx.slots.inject("settings.general.item", function* () {
|
||||
yield ctx.slots.register({ name: "settings.general.item", id: "repro-legacy-0", order: 100, locale: ns }, Single)
|
||||
yield ctx.slots.register({ name: "settings.general.item", id: "repro-legacy-1", order: 110, locale: ns }, Empty)
|
||||
yield ctx.slots.register({ name: "settings.general.item", id: "repro-legacy-2", order: 120, locale: ns }, Pair)
|
||||
yield ctx.slots.register({ name: "settings.general.item", id: "repro-legacy-3", order: 130, locale: ns }, Bordered)
|
||||
yield ctx.slots.register({ name: "settings.general.item", id: "repro-legacy-4", order: 140, locale: ns }, Empty)
|
||||
})
|
||||
},
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,2 @@
|
||||
/** Host companion for a settings slot reproduction plugin. */
|
||||
export function apply() {}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@fixture/settings-slots-legacy",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./client": "./client.js"
|
||||
},
|
||||
"dsh": {
|
||||
"client": {
|
||||
"platform": "web"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# Settings slot separator fixtures
|
||||
|
||||
These three opt-in client plugins contribute real rows to the General page. The [browser regression](../../settings-group-dividers.e2e.ts) loads them through the real Loader; shipped profiles do not include them.
|
||||
|
||||
| Plugin | Destination |
|
||||
|---|---|
|
||||
| [Legacy](fixture-settings-slots-legacy/client.js) | `settings.general.item` |
|
||||
| [Grouped](fixture-settings-slots-grouped/client.js) | `settings.general.group.notifications.item` |
|
||||
| [Custom](fixture-settings-slots-custom/client.js) | A plugin-owned child list in a custom group |
|
||||
|
||||
Each list includes an unbordered single row, a null registration, a Fragment with its own internal line between two rows, a row with its own bottom border, and a trailing null registration. Selecting the final row’s checkbox makes that registration return `null`. Checkboxes hold local React state only and never write product settings. Contributions and locale dictionaries follow the plugin effect lifetime.
|
||||
|
||||
The fixtures preserve the production General stylesheet. They expose the difference between DOM parentage and `display: contents`; see the [list item root documentation](../../../../../docs/subsystems/slots.md#list-item-roots).
|
||||
@@ -24,7 +24,7 @@ function appearance(element: Locator) {
|
||||
})
|
||||
}
|
||||
|
||||
/** A font group can draw its bottom edge on the group or its final row, but not on both. */
|
||||
/** The final font registration leaves its outer edge to the enclosing settings card. */
|
||||
function fontEndSeparators(expander: Locator) {
|
||||
return expander.evaluate((button) => {
|
||||
const details = document.getElementById(button.getAttribute('aria-controls')!)
|
||||
@@ -149,7 +149,7 @@ it('stacks font fields at narrow widths while keeping font-size controls on the
|
||||
await openSettings(page, 'zh')
|
||||
const dialog = page.getByRole('dialog', { name: '设置', exact: true })
|
||||
const expander = dialog.getByRole('button', { name: '更多字体设置', exact: true })
|
||||
expect(await fontEndSeparators(expander)).toBe(1)
|
||||
expect(await fontEndSeparators(expander)).toBe(0)
|
||||
await expander.click()
|
||||
await page.evaluate((platform) => {
|
||||
document.documentElement.toggleAttribute('data-windows-titlebar', platform === 'win32')
|
||||
@@ -179,7 +179,7 @@ it('stacks font fields at narrow widths while keeping font-size controls on the
|
||||
expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width)
|
||||
}
|
||||
|
||||
expect(await fontEndSeparators(expander)).toBe(1)
|
||||
expect(await fontEndSeparators(expander)).toBe(0)
|
||||
const field = dialog.getByRole('textbox', { name: '正文字体', exact: true })
|
||||
await field.fill('Uncommitted font draft')
|
||||
const original = await field.elementHandle()
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/** Real external settings plugins retain internal lines and share only registration-end dividers. */
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { join } from 'node:path'
|
||||
import { chromium, type Locator, type Page } from 'playwright'
|
||||
import { expect, it, onTestFailed, onTestFinished } from 'vitest'
|
||||
import { launchWebScaffold, watchConsole } from './scaffold.ts'
|
||||
import { openSettings, saveFailureShot } from './support.ts'
|
||||
|
||||
const FIXTURES = fileURLToPath(new URL('./fixtures/plugins/', import.meta.url))
|
||||
const CASES = [
|
||||
{ fixture: 'legacy', slot: 'settings.general.item' },
|
||||
{ fixture: 'grouped', slot: 'settings.general.group.notifications.item' },
|
||||
{ fixture: 'custom', slot: 'settings.general.group.repro.item' },
|
||||
] as const
|
||||
|
||||
async function setTheme(page: Page, colorScheme: 'dark' | 'light') {
|
||||
await page.emulateMedia({ colorScheme })
|
||||
await expect.poll(() => page.locator('body').evaluate(element => element.hasAttribute('data-ds-dark-theme')))
|
||||
.toBe(colorScheme === 'dark')
|
||||
}
|
||||
|
||||
async function assertBuiltInCardEdges(settings: Locator, hairline: string) {
|
||||
for (const group of ['data', 'updates']) {
|
||||
const outlet = settings.locator(`[data-slot="settings.general.group.${group}.item"]`)
|
||||
const roots = outlet.locator(':scope > [data-slot-item] > *')
|
||||
await roots.waitFor()
|
||||
expect(await roots.count()).toBe(1)
|
||||
expect((await borders(roots)).bottom).toBe('0px')
|
||||
expect(await outlet.evaluate(element => getComputedStyle(element.parentElement!.parentElement!.parentElement!).borderBottomWidth))
|
||||
.toBe(hairline)
|
||||
}
|
||||
}
|
||||
|
||||
async function borders(row: Locator) {
|
||||
return row.evaluate((element) => {
|
||||
const style = getComputedStyle(element)
|
||||
return { top: style.borderTopWidth, bottom: style.borderBottomWidth }
|
||||
})
|
||||
}
|
||||
|
||||
for (const { fixture, slot } of CASES) {
|
||||
it(`keeps registration-end dividers in ${slot} across themes, null output and Loader removal`, async () => {
|
||||
const scaffold = await launchWebScaffold({
|
||||
extraInstallAnchors: [join(FIXTURES, `fixture-settings-slots-${fixture}`, 'package.json')],
|
||||
})
|
||||
onTestFinished(() => scaffold.close())
|
||||
const entryId = await scaffold.ctx.loader.create({ name: `@fixture/settings-slots-${fixture}` })
|
||||
const browser = await chromium.launch()
|
||||
onTestFinished(() => browser.close())
|
||||
const page = await browser.newPage({ viewport: { width: 1680, height: 1000 }, locale: 'en-US' })
|
||||
const tripwire = watchConsole(page)
|
||||
onTestFailed(() => saveFailureShot(page, `web-e2e-settings-dividers-${fixture}`))
|
||||
await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' })
|
||||
await openSettings(page, 'en')
|
||||
const settings = page.getByRole('dialog', { name: 'Settings', exact: true })
|
||||
await settings.getByRole('button', { name: 'General', exact: true }).click()
|
||||
const outlet = settings.locator(`[data-slot="${slot}"]`)
|
||||
const row = (id: string) => outlet.locator(`[data-slot-repro-row="${id}"]`)
|
||||
await row('bordered').waitFor()
|
||||
expect(await outlet.locator(':scope > [data-slot-item]').count()).toBeGreaterThanOrEqual(5)
|
||||
expect(await outlet.locator(':scope > [data-slot-item]:empty').count()).toBe(2)
|
||||
expect(await outlet.locator('[data-slot-repro-row]').evaluateAll(elements => elements.map(element => element.getAttribute('data-slot-repro-row'))))
|
||||
.toEqual(['single', 'pairA', 'pairB', 'bordered'])
|
||||
expect(await row('pairA').locator('..').evaluate(element => [...element.children].map(child => child.getAttribute('data-slot-repro-row'))))
|
||||
.toEqual(['pairA', 'pairB'])
|
||||
|
||||
for (const theme of ['light', 'dark'] as const) {
|
||||
await setTheme(page, theme)
|
||||
// Chromium can quantize the fixture's declared 0.5px internal line to one CSS pixel.
|
||||
const hairline = (await borders(row('pairB'))).top
|
||||
expect(['0.5px', '1px']).toContain(hairline)
|
||||
expect(await borders(row('single'))).toEqual({ top: '0px', bottom: hairline })
|
||||
expect(await borders(row('pairA'))).toEqual({ top: '0px', bottom: '0px' })
|
||||
expect(await borders(row('pairB'))).toEqual({ top: hairline, bottom: hairline })
|
||||
expect(await borders(row('bordered'))).toEqual({ top: '0px', bottom: '0px' })
|
||||
await assertBuiltInCardEdges(settings, hairline)
|
||||
}
|
||||
|
||||
await row('bordered').getByRole('checkbox').click()
|
||||
await row('bordered').waitFor({ state: 'detached' })
|
||||
await expect.poll(() => outlet.locator(':scope > [data-slot-item]:empty').count()).toBe(3)
|
||||
for (const theme of ['light', 'dark'] as const) {
|
||||
await setTheme(page, theme)
|
||||
const hairline = (await borders(row('pairB'))).top
|
||||
expect(['0.5px', '1px']).toContain(hairline)
|
||||
expect(await borders(row('single'))).toEqual({ top: '0px', bottom: hairline })
|
||||
expect(await borders(row('pairA'))).toEqual({ top: '0px', bottom: '0px' })
|
||||
expect(await borders(row('pairB'))).toEqual({ top: hairline, bottom: '0px' })
|
||||
}
|
||||
|
||||
scaffold.ctx.loader.remove(entryId)
|
||||
await expect.poll(() => settings.locator('[data-slot-repro-row]').count()).toBe(0)
|
||||
if (fixture === 'custom') {
|
||||
await expect.poll(() => settings.getByRole('heading', { name: 'Plugin divider experiment', exact: true }).count()).toBe(0)
|
||||
await expect.poll(() => outlet.count()).toBe(0)
|
||||
} else {
|
||||
expect(await outlet.count()).toBe(1)
|
||||
expect(await outlet.locator(':scope > [data-slot-item]:empty').count()).toBe(0)
|
||||
}
|
||||
expect(tripwire.pageErrors).toEqual([])
|
||||
})
|
||||
}
|
||||
@@ -147,6 +147,7 @@
|
||||
"tests/action-cards-setting.e2e.ts",
|
||||
"tests/caption-overlays.e2e.ts",
|
||||
"tests/settings-appearance.e2e.ts",
|
||||
"tests/settings-group-dividers.e2e.ts",
|
||||
"tests/menu-material.e2e.ts",
|
||||
"tests/desktop-locale.e2e.ts",
|
||||
"tests/settings-import.e2e.ts",
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: 2b3320655142ffdf
|
||||
zh: 20dde077885f62aa
|
||||
/deepseek-ai-dsh-client-ui-settings-general/use-this-package/the-general-section:
|
||||
en: 12622f15a9689aaf
|
||||
zh: 531bfab4d24355be
|
||||
en: 454489c2e409687b
|
||||
zh: 9fcc7ba8c4f7970b
|
||||
/deepseek-ai-dsh-client-ui-settings-general/use-this-package/opening-the-configuration-file:
|
||||
en: 597df68b5913e8d7
|
||||
zh: bc9114f3e877679a
|
||||
|
||||
@@ -52,6 +52,8 @@ The Coding Tools switch controls the shared `ui-settings.enabled` preference des
|
||||
|
||||
The General page renders the `settings.general.group` list with shared headings, theme-aware cards, and spacing. Group registrations supply a unique `id`, localized `label` (a string or locale-following function), and ascending `order`. Empty group outlets and empty child item outlets hide their cards without preventing later contributions; conditional rows leave no empty separators. Each feature owns its row copy, controls, and settings writes.
|
||||
|
||||
For a group component that directly renders its child item outlet, the page draws a divider on each item registration’s final DOM root and removes it from the last non-empty registration. A `null` registration adds no divider. Plugins own the layout and separators inside a registration, including multiple Fragment roots; use element roots for automatic dividers, not plain text or portal-only output.
|
||||
|
||||
Register into an existing group’s item slot to choose its location:
|
||||
|
||||
| Group ID | Order | Item slot |
|
||||
|
||||
@@ -52,6 +52,8 @@ Web 与桌面端的通用设置底部显示当前发布版本,使用构建注
|
||||
|
||||
「通用」页面渲染 `settings.general.group` 列表,并统一提供标题、适配主题的卡片和间距。分组注册项提供唯一的 `id`、本地化的 `label`(字符串或跟随语言的函数)以及升序排列的 `order`。分组 outlet 或设置行子 outlet 为空时隐藏卡片,但不阻止后续贡献;条件渲染的空行不留下分隔线。每项功能拥有自己的设置行文案、控件和设置写入。
|
||||
|
||||
分组组件直接渲染设置行子 outlet 时,页面在每个设置行注册项的最后一个 DOM 根元素上绘制分割线,并清除最后一个非空注册项的底线。返回 `null` 的注册项不产生分割线。插件负责同一注册项内部的布局和分割线,包括 Fragment 的多个根元素;需要自动分割线时应返回元素根节点,而不是纯文本或仅有 portal 的内容。
|
||||
|
||||
注册到已有分组的设置行 slot 即可选择位置:
|
||||
|
||||
| 分组 ID | 顺序 | 设置行 slot |
|
||||
|
||||
@@ -8,12 +8,6 @@
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
|
||||
/* css-selector-gate: General clears the contributed element's own border; only sibling output in this outlet decides which root is last. */
|
||||
.section > [data-slot='settings.general.item'] > :where([data-slot-item]:not(:has(~ [data-slot-error], ~ [data-slot-item] > *))) > :last-child,
|
||||
.section > [data-slot='settings.general.item'] > [data-slot-error]:where(:not(:has(~ [data-slot-error], ~ [data-slot-item] > *))) {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* The page title keeps a 24px gap before the first visible group. */
|
||||
.title {
|
||||
margin: 0 0 -4px;
|
||||
@@ -51,11 +45,14 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Group item outlets flatten their rows; null entries leave no separator. */
|
||||
.card > [data-slot='settings.general.group'] > [data-slot] > * {
|
||||
/* Each registration owns its internal layout; only its final root receives a shared divider. */
|
||||
.card > [data-slot='settings.general.group'] > [data-slot-item] > [data-slot] > [data-slot-item] > :last-child,
|
||||
.card > [data-slot='settings.general.group'] > [data-slot-item] > [data-slot] > [data-slot-error] {
|
||||
border-bottom: 0.5px solid var(--dsw-alias-border-l2);
|
||||
}
|
||||
|
||||
.card > [data-slot='settings.general.group'] > [data-slot] > :last-child {
|
||||
/* css-selector-gate: Only sibling output in this settings outlet determines the final registration; null entries retain empty wrappers. */
|
||||
.card > [data-slot='settings.general.group'] > [data-slot-item] > [data-slot] > [data-slot-item]:where(:not(:has(~ [data-slot-error], ~ [data-slot-item] > *))) > :last-child,
|
||||
.card > [data-slot='settings.general.group'] > [data-slot-item] > [data-slot] > [data-slot-error]:where(:not(:has(~ [data-slot-error], ~ [data-slot-item] > *))) {
|
||||
border-bottom: none;
|
||||
}
|
||||
@@ -200,12 +200,13 @@ describe('GeneralSection', () => {
|
||||
expect(renderSlot).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('declares separators for group items and clears the last one', () => {
|
||||
it('declares registration dividers without styling internal roots', () => {
|
||||
const css = readFileSync(
|
||||
resolve(import.meta.dirname, '../src/client/GeneralSection.module.css'), 'utf8',
|
||||
)
|
||||
expect(css).toContain(".card > [data-slot='settings.general.group'] > [data-slot] > * {")
|
||||
expect(css).toContain(".card > [data-slot='settings.general.group'] > [data-slot] > :last-child {")
|
||||
expect(css).toContain(".card > [data-slot='settings.general.group'] > [data-slot-item] > [data-slot] > [data-slot-item] > :last-child,")
|
||||
expect(css).toContain('[data-slot-item]:where(:not(:has(~ [data-slot-error], ~ [data-slot-item] > *))) > :last-child,')
|
||||
expect(css).not.toContain(".section > [data-slot='settings.general.item']")
|
||||
expect(css).not.toContain(':global(')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
"apps/web/tests/action-cards-setting.e2e.ts",
|
||||
"apps/web/tests/caption-overlays.e2e.ts",
|
||||
"apps/web/tests/settings-appearance.e2e.ts",
|
||||
"apps/web/tests/settings-group-dividers.e2e.ts",
|
||||
"apps/web/tests/menu-material.e2e.ts",
|
||||
"apps/web/tests/desktop-locale.e2e.ts",
|
||||
"apps/web/tests/window-controls.e2e.ts",
|
||||
|
||||
Reference in new issue
Block a user