Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(mobile): gate the mobile layout on the 1024px breakpoint (#1128) (#1130)

Hairyaf276df90b70
diff --git a/packages/dsh-tauri-mobile-ui/src/client/constants/index.ts b/packages/dsh-tauri-mobile-ui/src/client/constants/index.ts
index 211a4713..7691fc69 100644
--- a/packages/dsh-tauri-mobile-ui/src/client/constants/index.ts
+++ b/packages/dsh-tauri-mobile-ui/src/client/constants/index.ts
@@ -1,3 +1,3 @@
-import { MOBILE_MEDIA_QUERIES } from 'dsh-tauri/client'
+import { MOBILE_POINTER_QUERIES } from 'dsh-tauri/client'
-export const MOBILE_SETTINGS_MEDIA = `${MOBILE_MEDIA_QUERIES.join(' and ')} and (max-width: 767px)`
+export const MOBILE_SETTINGS_MEDIA = `${MOBILE_POINTER_QUERIES.join(' and ')} and (max-width: 767px)`
diff --git a/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.test.tsx b/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.test.tsx
index c31860b3..af6847c1 100644
--- a/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.test.tsx
+++ b/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.test.tsx
@@ -38,7 +38,8 @@ vi.mock('dsh-tauri/client', () => ({
registerLocale: vi.fn(),
...dictionaries,
}),
- MOBILE_MEDIA_QUERIES: ['(hover: none)', '(any-pointer: coarse)', '(any-hover: none)'],
+ MOBILE_MEDIA_QUERIES: ['(hover: none)', '(any-pointer: coarse)', '(any-hover: none)', '(max-width: 1023px)'],
+ MOBILE_BREAKPOINT: 1024,
detectMobileDevice: () => mocks.mobile,
invokeParent: mocks.invokeParent,
listenParent: mocks.listenParent,
diff --git a/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.tsx b/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.tsx
index 615d5ccf..d19aaeec 100644
--- a/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.tsx
+++ b/packages/dsh-tauri-mobile-ui/src/client/register/sidebar.tsx
@@ -7,6 +7,7 @@ import {
detectMobileDevice,
invokeParent,
listenParent,
+ MOBILE_BREAKPOINT,
MOBILE_MEDIA_QUERIES,
} from 'dsh-tauri/client'
import { useSyncExternalStore } from 'react'
@@ -19,7 +20,6 @@ import { getMobileSessionId, getMobileSessionTitle } from '../service/sidebar-se
const SHELL_OVERLAY_SLOT = 'shell.overlay'
const SIDEBAR_TOGGLE_COMMAND = 'dsh://sidebar:toggle'
const SIDEBAR_COLLAPSED_EVENT = 'dsh://sidebar:collapsed'
-const SIDEBAR_BREAKPOINT = 1024
const SIDEBAR_PROPERTIES = [
'--dsh-mobile-sidebar-width',
'--dsh-mobile-sidebar-offset',
@@ -58,7 +58,7 @@ function getFrame(): HTMLElement | null {
function canOwnMobileSidebar(): boolean {
const frame = getFrame()
- return detectMobileDevice() && window.innerWidth < SIDEBAR_BREAKPOINT
+ return detectMobileDevice() && window.innerWidth < MOBILE_BREAKPOINT
&& (frame === null || frame.hasAttribute('data-rightbar-collapsed'))
}
diff --git a/packages/dsh-tauri-mobile-ui/src/client/register/styles.test.ts b/packages/dsh-tauri-mobile-ui/src/client/register/styles.test.ts
index 78862d89..c5128e4c 100644
--- a/packages/dsh-tauri-mobile-ui/src/client/register/styles.test.ts
+++ b/packages/dsh-tauri-mobile-ui/src/client/register/styles.test.ts
@@ -3,11 +3,12 @@ import { afterEach, expect, it, vi } from 'vitest'
import desktopStyle from '../../../../dsh-tauri-ui/src/client/styles/global.cssr'
import { cssr } from '../../../../dsh-tauri-ui/src/client/utils/cssr'
import { mountStyle } from '../../../../dsh-tauri-ui/src/client/utils/style'
-import { MOBILE_MEDIA_QUERIES } from '../../../../dsh-tauri/src/client/utils/device'
+import { MOBILE_MEDIA_QUERIES, MOBILE_POINTER_QUERIES } from '../../../../dsh-tauri/src/client/utils/device'
import { registerStyles } from './styles'
vi.mock('dsh-tauri/client', () => ({
MOBILE_MEDIA_QUERIES,
+ MOBILE_POINTER_QUERIES,
defineRegister: (setup: (controller: unknown) => void) => () => {
const disposers: Array<() => void> = []
setup({ add: (dispose: () => void) => disposers.push(dispose) })
@@ -28,7 +29,7 @@ it('owns mobile styles and composer activation until unload, and can reload clea
const dispose = register()
const style = document.querySelector('style[cssr-id="dsh-tauri-mobile-ui-styles"]')
expect(style?.getAttribute('data-plugin')).toBe('dsh-tauri-mobile-ui')
- expect(style?.textContent).toContain('@media (hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(style?.textContent).toContain('@media (hover: none) and (any-pointer: coarse) and (any-hover: none) and (max-width: 1023px)')
for (const selector of [
'[data-dsh-mobile-preferences]',
'[data-slot="conversation.composer.bar"] [class$="_dock"]',
diff --git a/packages/dsh-tauri-mobile-ui/src/client/styles/mobile.cssr.test.ts b/packages/dsh-tauri-mobile-ui/src/client/styles/mobile.cssr.test.ts
index 69429fe9..a12c28a2 100644
--- a/packages/dsh-tauri-mobile-ui/src/client/styles/mobile.cssr.test.ts
+++ b/packages/dsh-tauri-mobile-ui/src/client/styles/mobile.cssr.test.ts
@@ -7,15 +7,17 @@ import mobileStyle from './mobile.cssr'
vi.mock('dsh-tauri/client', () => ({ MOBILE_MEDIA_QUERIES }))
vi.mock('dsh-tauri-ui/client', () => ({ cssr }))
+const MOBILE_MEDIA = '(hover: none) and (any-pointer: coarse) and (any-hover: none) and (max-width: 1023px)'
+
describe('mobile conversation layout', () => {
const root = postcss.parse(mobileStyle.render())
- it('keeps the existing mobile layout overrides scoped to touch devices', () => {
- const media = root.nodes.find(node => node.type === 'atrule' && node.name === 'media' && node.params === '(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ it('keeps the existing mobile layout overrides scoped to narrow touch devices', () => {
+ const media = root.nodes.find(node => node.type === 'atrule' && node.name === 'media' && node.params === MOBILE_MEDIA)
expect(media?.type).toBe('atrule')
if (media?.type !== 'atrule')
throw new Error('Missing mobile media query')
- expect(media.params).toBe('(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(media.params).toBe(MOBILE_MEDIA)
const css = media.toString()
for (const selector of [
'[data-dsh-mobile-preferences]',
@@ -82,7 +84,7 @@ describe('mobile conversation layout', () => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
- expect(rule.parent.params).toBe('(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
@@ -193,7 +195,7 @@ describe('mobile conversation layout', () => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
- expect(rule.parent.params).toBe('(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
@@ -205,7 +207,7 @@ describe('mobile conversation layout', () => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
- expect(rule.parent.params).toBe('(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
@@ -217,7 +219,7 @@ describe('mobile conversation layout', () => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
- expect(rule.parent.params).toBe('(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
@@ -228,7 +230,7 @@ describe('mobile conversation layout', () => {
const parent = rule.parent
expect(parent?.type).toBe('atrule')
if (parent?.type === 'atrule')
- expect(parent.params).toBe('(hover: none) and (any-pointer: coarse) and (any-hover: none)')
+ expect(parent.params).toBe(MOBILE_MEDIA)
rule.walkDecls((decl) => {
declarations.push([decl.prop, decl.value, decl.important])
})
diff --git a/packages/dsh-tauri-mobile-ui/src/client/styles/settings.cssr.test.ts b/packages/dsh-tauri-mobile-ui/src/client/styles/settings.cssr.test.ts
index 10b32ef9..aa927e56 100644
--- a/packages/dsh-tauri-mobile-ui/src/client/styles/settings.cssr.test.ts
+++ b/packages/dsh-tauri-mobile-ui/src/client/styles/settings.cssr.test.ts
@@ -2,10 +2,10 @@ import type { Rule } from 'postcss'
import postcss from 'postcss'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { cssr } from '../../../../dsh-tauri-ui/src/client/utils/cssr'
-import { MOBILE_MEDIA_QUERIES } from '../../../../dsh-tauri/src/client/utils/device'
+import { MOBILE_POINTER_QUERIES } from '../../../../dsh-tauri/src/client/utils/device'
import settingsStyle from './settings.cssr'
-vi.mock('dsh-tauri/client', () => ({ MOBILE_MEDIA_QUERIES }))
+vi.mock('dsh-tauri/client', () => ({ MOBILE_POINTER_QUERIES }))
vi.mock('dsh-tauri-ui/client', () => ({ cssr }))
afterEach(() => vi.restoreAllMocks())
diff --git a/packages/dsh-tauri-ui/src/client/register/settings.register.test.ts b/packages/dsh-tauri-ui/src/client/register/settings.register.test.ts
index b79866d0..d66535e8 100644
--- a/packages/dsh-tauri-ui/src/client/register/settings.register.test.ts
+++ b/packages/dsh-tauri-ui/src/client/register/settings.register.test.ts
@@ -32,17 +32,25 @@ const host = globalThis as unknown as MatchMediaHost
const originalWindow = host.window
const disposers: Array<() => void> = []
-/** 手机端才有三条设备查询全部成立;触屏为主但另接鼠标的设备缺 `(any-hover: none)`。 */
+/** 手机端才有三条设备查询加窄屏门槛全部成立;触屏为主但另接鼠标的设备缺 `(any-hover: none)`。 */
const MOBILE_DEVICE = {
'(hover: none)': true,
'(any-pointer: coarse)': true,
'(any-hover: none)': true,
+ '(max-width: 1023px)': true,
}
const TOUCHSCREEN_WITH_MOUSE = {
'(hover: none)': true,
'(any-pointer: coarse)': true,
'(any-hover: none)': false,
}
+/** issue #1128:触屏笔记本命中三条指针查询,但宽度在 1024px 以上仍走桌面布局。 */
+const TOUCHSCREEN_DESKTOP = {
+ '(hover: none)': true,
+ '(any-pointer: coarse)': true,
+ '(any-hover: none)': true,
+ '(max-width: 1023px)': false,
+}
function stubDevice(answers: Record<string, boolean>): void {
host.window = {
@@ -137,6 +145,19 @@ describe('registerSettings launcher seat', () => {
])
})
+ /** 触屏笔记本在桌面宽度下仍可用鼠标式设置面板:不能被手机端判据误伤。 */
+ it('keeps the own sidebar on a touchscreen desktop window', () => {
+ stubDevice(TOUCHSCREEN_DESKTOP)
+
+ const { injected } = activate()
+
+ expect(injected.map(entry => entry.key)).toEqual([
+ 'shell.overlay',
+ 'sidebar.settings',
+ 'settings.launcher',
+ ])
+ })
+
/** 桌面端仍走自有侧栏,手机端判据不误伤。 */
it('keeps the own sidebar on a touchscreen desktop', () => {
stubDevice({ '(hover: none)': false, '(any-pointer: coarse)': true, '(any-hover: none)': false })
diff --git a/packages/dsh-tauri/src/client/constants/index.ts b/packages/dsh-tauri/src/client/constants/index.ts
index 009ae065..9778982c 100644
--- a/packages/dsh-tauri/src/client/constants/index.ts
+++ b/packages/dsh-tauri/src/client/constants/index.ts
@@ -1,6 +1,17 @@
export { PLUGIN_ID } from '../../shared/constants'
-export const MOBILE_MEDIA_QUERIES = ['(hover: none)', '(any-pointer: coarse)', '(any-hover: none)'] as const
+export const MOBILE_POINTER_QUERIES = ['(hover: none)', '(any-pointer: coarse)', '(any-hover: none)'] as const
+
+/**
+ * issue #1128:官方布局在 1024px 以上走桌面,触屏笔记本同样命中三条指针查询;
+ * 移动布局必须叠加同一门槛,否则桌面布局会被移动表的 `!important` 隐藏规则掏空。
+ */
+export const MOBILE_BREAKPOINT = 1024
+
+export const MOBILE_MEDIA_QUERIES = [
+ ...MOBILE_POINTER_QUERIES,
+ `(max-width: ${MOBILE_BREAKPOINT - 1}px)`,
+] as const
/**
* 官方「新建会话」按钮:适配层的 DOM 退级目标,同时是侧边栏 UI 微调的居中目标。
diff --git a/packages/dsh-tauri/src/client/utils/device.test.ts b/packages/dsh-tauri/src/client/utils/device.test.ts
index f2f0a4ab..81dbd254 100644
--- a/packages/dsh-tauri/src/client/utils/device.test.ts
+++ b/packages/dsh-tauri/src/client/utils/device.test.ts
@@ -1,7 +1,12 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
-import { detectMobileDevice, isMobileDevice } from './device'
+import { detectMobileDevice, isMobileDevice, MOBILE_MEDIA_QUERIES } from './device'
-const MOBILE_QUERIES = ['(hover: none)', '(any-pointer: coarse)', '(any-hover: none)']
+const MOBILE_QUERIES = [
+ '(hover: none)',
+ '(any-pointer: coarse)',
+ '(any-hover: none)',
+ '(max-width: 1023px)',
+]
function matcher(answers: Record<string, boolean>) {
const queries: string[] = []
@@ -25,21 +30,33 @@ afterEach(() => {
})
describe('isMobileDevice', () => {
- it('treats a touch device with a coarse pointer as mobile', () => {
+ it('treats a narrow touch device with a coarse pointer as mobile', () => {
const probe = matcher({
'(hover: none)': true,
'(any-pointer: coarse)': true,
'(any-hover: none)': true,
+ '(max-width: 1023px)': true,
})
expect(isMobileDevice(probe.matches)).toBe(true)
expect(probe.queries).toEqual(MOBILE_QUERIES)
})
+ it('keeps a touchscreen desktop above the layout breakpoint on the desktop branch', () => {
+ const touchDesktop = matcher({
+ '(hover: none)': true,
+ '(any-pointer: coarse)': true,
+ '(any-hover: none)': true,
+ '(max-width: 1023px)': false,
+ })
+
+ expect(isMobileDevice(touchDesktop.matches)).toBe(false)
+ })
+
it('keeps every partially matching device on the desktop branch', () => {
- const mouseDesktop = matcher({ '(hover: none)': false, '(any-pointer: coarse)': false })
- const touchscreenLaptop = matcher({ '(hover: none)': false, '(any-pointer: coarse)': true })
- const hoverTouch = matcher({ '(hover: none)': true, '(any-pointer: coarse)': false })
+ const mouseDesktop = matcher({ '(hover: none)': false, '(any-pointer: coarse)': false, '(max-width: 1023px)': true })
+ const touchscreenLaptop = matcher({ '(hover: none)': false, '(any-pointer: coarse)': true, '(max-width: 1023px)': true })
+ const hoverTouch = matcher({ '(hover: none)': true, '(any-pointer: coarse)': false, '(max-width: 1023px)': true })
expect(isMobileDevice(mouseDesktop.matches)).toBe(false)
expect(isMobileDevice(touchscreenLaptop.matches)).toBe(false)
@@ -51,30 +68,24 @@ describe('isMobileDevice', () => {
'(hover: none)': true,
'(any-pointer: coarse)': true,
'(any-hover: hover)': true,
+ '(max-width: 1023px)': true,
})
expect(isMobileDevice(tabletWithMouse.matches)).toBe(false)
- expect(tabletWithMouse.queries).toEqual(MOBILE_QUERIES)
})
- it('ignores viewport width', () => {
- const narrowDesktop = matcher({
- '(max-width: 480px)': true,
- '(hover: none)': false,
- '(any-pointer: coarse)': false,
- })
-
- expect(isMobileDevice(narrowDesktop.matches)).toBe(false)
- expect(narrowDesktop.queries).not.toContain('(max-width: 480px)')
+ it('uses the same 1024px breakpoint as the official layout', () => {
+ expect(MOBILE_MEDIA_QUERIES).toContain('(max-width: 1023px)')
})
})
describe('detectMobileDevice', () => {
- it('probes the device capabilities through the kernel matchMedia', () => {
+ it('probes the device capabilities and the layout breakpoint through the kernel matchMedia', () => {
const probe = matcher({
'(hover: none)': true,
'(any-pointer: coarse)': true,
'(any-hover: none)': true,
+ '(max-width: 1023px)': true,
})
stubWindow(probe.matchMedia)
@@ -82,6 +93,17 @@ describe('detectMobileDevice', () => {
expect(probe.queries).toEqual(MOBILE_QUERIES)
})
+ it('falls back to desktop on a touchscreen desktop window', () => {
+ const probe = matcher({
+ '(hover: none)': true,
+ '(any-pointer: coarse)': true,
+ '(any-hover: none)': true,
+ })
+ stubWindow(probe.matchMedia)
+
+ expect(detectMobileDevice()).toBe(false)
+ })
+
it.each([undefined, {}])('falls back to desktop when matchMedia is unavailable (%s)', (window) => {
vi.stubGlobal('window', window)
expect(detectMobileDevice()).toBe(false)
diff --git a/packages/dsh-tauri/src/client/utils/device.ts b/packages/dsh-tauri/src/client/utils/device.ts
index beafca78..dc7bc9d8 100644
--- a/packages/dsh-tauri/src/client/utils/device.ts
+++ b/packages/dsh-tauri/src/client/utils/device.ts
@@ -1,6 +1,6 @@
-import { MOBILE_MEDIA_QUERIES } from '../constants'
+import { MOBILE_BREAKPOINT, MOBILE_MEDIA_QUERIES, MOBILE_POINTER_QUERIES } from '../constants'
-export { MOBILE_MEDIA_QUERIES }
+export { MOBILE_BREAKPOINT, MOBILE_MEDIA_QUERIES, MOBILE_POINTER_QUERIES }
export function isMobileDevice(match: (query: string) => boolean): boolean {
return MOBILE_MEDIA_QUERIES.every(query => match(query))
}
diff --git a/src-tauri/src/service/patch/mobile_composer.rs b/src-tauri/src/service/patch/mobile_composer.rs
index 82392e47..127a8644 100644
--- a/src-tauri/src/service/patch/mobile_composer.rs
+++ b/src-tauri/src/service/patch/mobile_composer.rs
@@ -8,8 +8,9 @@ const LEGACY_MOBILE: &str = r#"function isDshMobileComposer() {
return typeof window !== "undefined" && typeof window.matchMedia === "function" && ["(hover: none)", "(any-pointer: coarse)", "(any-hover: none)"].every(query => window.matchMedia(query).matches);
}
"#;
+/// issue #1128:指针查询在触屏桌面上同样成立,必须叠加与官方布局一致的 1024px 门槛。
const MOBILE: &str = r#"function isDshMobileComposer() {
- return typeof document !== "undefined" && document.documentElement.hasAttribute("data-dsh-mobile-ui") && typeof window.matchMedia === "function" && ["(hover: none)", "(any-pointer: coarse)", "(any-hover: none)"].every(query => window.matchMedia(query).matches);
+ return typeof document !== "undefined" && document.documentElement.hasAttribute("data-dsh-mobile-ui") && typeof window.matchMedia === "function" && window.innerWidth < 1024 && ["(hover: none)", "(any-pointer: coarse)", "(any-hover: none)"].every(query => window.matchMedia(query).matches);
}
"#;
const KEYMAP: &str = "function registerComposerKeymap(editor, handlers) {";
@@ -84,6 +85,7 @@ mod tests {
panic!("not patched")
};
assert!(result.contains(MOBILE));
+ assert!(result.contains("window.innerWidth < 1024"));
assert!(result.contains(ENTER_PATCHED));
assert!(result.contains(AUTOFOCUS_PATCHED));
assert!(result.contains(ROOT_PATCHED));
diff --git a/test/e2e/plugins/mobile-touch-desktop.e2e.ts b/test/e2e/plugins/mobile-touch-desktop.e2e.ts
new file mode 100644
index 00000000..a3cf0f6d
--- /dev/null
+++ b/test/e2e/plugins/mobile-touch-desktop.e2e.ts
@@ -0,0 +1,63 @@
+import type { Browser } from 'playwright'
+import { chromium } from 'playwright'
+import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'
+import mobileStyle from '../../../packages/dsh-tauri-mobile-ui/src/client/styles/mobile.cssr'
+
+vi.mock('../../../packages/dsh-tauri/dist/client.cjs', () => import('../../../packages/dsh-tauri/src/client/utils/device'))
+vi.mock('../../../packages/dsh-tauri-ui/dist/client.cjs', () => import('../../../packages/dsh-tauri-ui/src/client/utils/cssr'))
+
+const MOBILE_MEDIA = '(hover: none) and (any-pointer: coarse) and (any-hover: none) and (max-width: 1023px)'
+const HIDDEN = [
+ '[data-slot="conversation.header"] [class$="_header"]',
+ '[data-slot="conversation.composer.bar"] [class$="_dock"]',
+ '[class$="_composerStack"] > [data-slot="conversation.input.dock"]',
+]
+const MARKUP = `<!doctype html><html data-dsh-mobile-ui><body>
+ <div data-slot="conversation.session.header"><div data-slot="conversation.header"><header class="wSkVaW_header">Session title</header></div></div>
+ <div data-slot="conversation.composer.bar"><div class="wSkVaW_dock">Queued messages</div></div>
+ <div class="wSkVaW_composerStack"><div data-slot="conversation.input.dock"><div class="wSkVaW_dock">Steer panel</div></div></div>
+</body></html>`
+
+let browser: Browser
+beforeAll(async () => {
+ browser = await chromium.launch()
+})
+afterAll(async () => {
+ await browser?.close()
+})
+
+async function layout(viewport: { width: number, height: number }) {
+ const page = await browser.newPage({ isMobile: true, hasTouch: true, viewport })
+ try {
+ await page.setContent(MARKUP)
+ await page.addStyleTag({ content: mobileStyle.render() })
+ return {
+ matches: await page.evaluate(media => matchMedia(media).matches, MOBILE_MEDIA),
+ displays: await Promise.all(HIDDEN.map(selector => page.locator(selector).evaluate(element => getComputedStyle(element).display))),
+ }
+ }
+ finally {
+ await page.close()
+ }
+}
+
+describe('mobile layout on touch devices', () => {
+ it('keeps the session header, queue dock and steer dock on a touchscreen desktop window', async () => {
+ const { matches, displays } = await layout({ width: 1280, height: 720 })
+
+ expect(matches, '1280px 触屏窗口不得命中移动布局').toBe(false)
+ expect(displays, '触屏桌面窗口不得隐藏会话头、排队插话面板与状态条').toEqual(['block', 'block', 'block'])
+ })
+
+ it('still hides them on a phone viewport', async () => {
+ const { matches, displays } = await layout({ width: 390, height: 844 })
+
+ expect(matches, '手机视口必须继续命中移动布局').toBe(true)
+ expect(displays, '手机仍由顶栏与抽屉接管,三条桌面入口保持隐藏').toEqual(['none', 'none', 'none'])
+ })
+
+ it('switches exactly at the 1024px breakpoint of the official layout', async () => {
+ expect((await layout({ width: 1024, height: 720 })).matches, '1024px 与官方布局同门槛,交还桌面').toBe(false)
+ expect((await layout({ width: 1023, height: 720 })).matches, '1023px 仍是移动布局').toBe(true)
+ })
+})