@sparkelf/dsh-genui 0.11.4-patch.2 → 0.13.0-sparkelf.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/ICON-NAMES.md +30 -0
- package/README.md +26 -28
- package/README.zh-CN.md +26 -28
- package/SKILL.md +128 -19
- package/THIRD_PARTY_NOTICES.md +42 -0
- package/assets/genui-icon.svg +20 -0
- package/assets/genui-logo.svg +18 -0
- package/lib/assets/icons.js +1 -0
- package/lib/assets/mermaid.js +325 -325
- package/lib/assets/standalone-runtime.js +10 -9
- package/lib/client.js +32 -31
- package/lib/index.js +523 -80
- package/lib/types/client/action-context.d.ts +1 -1
- package/lib/types/client/artifact/types.d.ts +1 -1
- package/lib/types/client/asset-loader.d.ts +2 -2
- package/lib/types/client/blocks/blocks.d.ts +12 -0
- package/lib/types/client/blocks/icon.d.ts +4 -0
- package/lib/types/client/dom-fence.d.ts +2 -1
- package/lib/types/client/fence-render.d.ts +5 -21
- package/lib/types/client/file-address.d.ts +4 -0
- package/lib/types/client/file-link-context.d.ts +49 -0
- package/lib/types/client/file-link.d.ts +17 -0
- package/lib/types/client/gallery.d.ts +8 -2
- package/lib/types/client/genui-runtime/diagnostics.d.ts +1 -1
- package/lib/types/client/genui-runtime/limits.d.ts +4 -0
- package/lib/types/client/genui-runtime/schema.d.ts +14 -1
- package/lib/types/client/guard.d.ts +4 -1
- package/lib/types/client/i18n/en.d.ts +5 -1
- package/lib/types/client/i18n/index.d.ts +1 -1
- package/lib/types/client/icons/asset-icons.d.ts +1 -0
- package/lib/types/client/icons/icon-data-full.d.ts +23 -0
- package/lib/types/client/icons/icon-data.d.ts +24 -0
- package/lib/types/client/icons/icon-lazy.d.ts +18 -0
- package/lib/types/client/icons/icon-names-full.d.ts +12 -0
- package/lib/types/client/index.d.ts +5 -15
- package/lib/types/client/inline.d.ts +1 -1
- package/lib/types/client/mermaid-colors.d.ts +2 -0
- package/lib/types/client/mermaid-core.d.ts +2 -1
- package/lib/types/client/mermaid-lazy.d.ts +5 -1
- package/lib/types/client/panel-command.d.ts +21 -1
- package/lib/types/client/panel.d.ts +6 -1
- package/lib/types/client/primitive-adapter.d.ts +0 -2
- package/lib/types/client/session-resolver.d.ts +13 -2
- package/lib/types/client/source-fence.d.ts +1 -1
- package/lib/types/client/spec.d.ts +127 -3
- package/lib/types/client/standalone/asset-loader.d.ts +1 -1
- package/lib/types/client/standalone/primitive-adapter.d.ts +0 -4
- package/lib/types/plugin/fence-feedback.d.ts +11 -7
- package/lib/types/plugin/index.d.ts +6 -2
- package/lib/types/shared/fence-language.d.ts +14 -0
- package/lib/types/shared/fence-repair.d.ts +2 -1
- package/lib/types/shared/fence-resolve.d.ts +1 -1
- package/package.json +92 -83
- package/src/client/EChartNode.tsx +17 -3
- package/src/client/GenuiBlock.module.css +411 -76
- package/src/client/action-context.ts +5 -15
- package/src/client/artifact/ArtifactExport.module.css +34 -3
- package/src/client/artifact/ExportableGenuiBlock.tsx +23 -2
- package/src/client/artifact/portability.ts +6 -1
- package/src/client/artifact/types.ts +1 -1
- package/src/client/asset-loader.ts +3 -3
- package/src/client/blocks/advanced.tsx +101 -14
- package/src/client/blocks/blocks.tsx +143 -0
- package/src/client/blocks/charts.tsx +22 -6
- package/src/client/blocks/icon.tsx +93 -0
- package/src/client/blocks/image.tsx +1 -0
- package/src/client/blocks/render-node.tsx +84 -52
- package/src/client/dom-fence.tsx +546 -72
- package/src/client/fence-render.tsx +5 -21
- package/src/client/file-address.ts +37 -0
- package/src/client/file-link-context.tsx +116 -0
- package/src/client/file-link.ts +46 -0
- package/src/client/gallery.ts +161 -133
- package/src/client/genui-runtime/diagnostics.ts +1 -1
- package/src/client/genui-runtime/limits.ts +4 -0
- package/src/client/genui-runtime/normalize.ts +42 -6
- package/src/client/genui-runtime/schema.ts +39 -7
- package/src/client/guard.ts +170 -15
- package/src/client/i18n/en.ts +5 -1
- package/src/client/i18n/index.ts +1 -1
- package/src/client/i18n/zh.ts +5 -1
- package/src/client/icons/asset-icons.ts +16 -0
- package/src/client/icons/icon-data-full.ts +5715 -0
- package/src/client/icons/icon-data.ts +507 -0
- package/src/client/icons/icon-lazy.ts +80 -0
- package/src/client/icons/icon-names-full.ts +12 -0
- package/src/client/index.tsx +27 -51
- package/src/client/inline.ts +17 -6
- package/src/client/mermaid-colors.ts +40 -0
- package/src/client/mermaid-core.ts +69 -61
- package/src/client/mermaid-lazy.ts +99 -4
- package/src/client/panel-command.ts +16 -2
- package/src/client/panel.tsx +18 -5
- package/src/client/parse-partial.ts +6 -1
- package/src/client/primitive-adapter.ts +0 -11
- package/src/client/session-resolver.ts +12 -21
- package/src/client/source-fence.ts +4 -2
- package/src/client/spec.ts +149 -2
- package/src/client/standalone/asset-loader.ts +1 -1
- package/src/client/standalone/primitive-adapter.tsx +1 -9
- package/src/client/table-details.ts +4 -3
- package/src/plugin/fence-feedback.ts +60 -14
- package/src/plugin/index.ts +45 -20
- package/src/plugin/tool.ts +11 -2
- package/src/shared/fence-language.ts +30 -0
- package/src/shared/fence-repair.ts +37 -1
- package/src/shared/fence-resolve.ts +1 -1
- package/tsdown.config.ts +7 -8
- package/lib/invariant.js +0 -19
- package/lib/types/plugin/invariant.d.ts +0 -15
- package/src/plugin/invariant.ts +0 -30
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The dsh-ui fence render pipeline
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* ```dsh-ui fences through the fence-registry extension point and calls
|
|
6
|
-
* {@link renderGenuiFence} with a session-scoped context (sessionId + the
|
|
7
|
-
* settled source identity). An unrepairable body renders {@link FenceFallback}.
|
|
8
|
-
* - **DOM channel** (pristine hosts, no extension point): the DOM observer
|
|
9
|
-
* (`dom-fence.ts`) finds stock code blocks labelled `dsh-ui` and mounts
|
|
10
|
-
* {@link renderResolvedFenceNode} into its own React root, wrapped in the
|
|
11
|
-
* plugin-owned action context. An unrepairable body returns `null` so the
|
|
12
|
-
* stock code block stays visible, with {@link FenceDiagnostic} mounted above
|
|
13
|
-
* it so the defect is never silent (issue #158).
|
|
14
|
-
*
|
|
15
|
-
* Structural types are declared locally on purpose: the context contract is
|
|
16
|
-
* a data shape, and pristine hosts do not export the host-side type names.
|
|
2
|
+
* The dsh-ui fence render pipeline used by the DOM observer and renderer tests.
|
|
3
|
+
* An unrepairable body returns `null` so the stock code block stays visible,
|
|
4
|
+
* with {@link FenceDiagnostic} mounted above it (issue #158).
|
|
17
5
|
*/
|
|
18
6
|
import { Fragment, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type Key, type ReactNode } from 'react'
|
|
19
7
|
import { CodeBlock } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
@@ -112,8 +100,7 @@ export function describeFenceFailure(raw: string, options: { settled?: boolean }
|
|
|
112
100
|
/**
|
|
113
101
|
* The visible diagnostic for a settled, unrenderable ```dsh-ui body.
|
|
114
102
|
*
|
|
115
|
-
*
|
|
116
|
-
* fallback code block, the DOM channel above the host's stock code block. A
|
|
103
|
+
* The DOM channel renders this above the host's stock code block. A
|
|
117
104
|
* fence that keeps degrading to raw JSON must say why it degraded — the
|
|
118
105
|
* console-only path left the defect invisible (issues #158/#172).
|
|
119
106
|
*
|
|
@@ -239,10 +226,7 @@ export function renderResolvedFenceNode(raw: string, key: Key, context?: GenuiFe
|
|
|
239
226
|
}
|
|
240
227
|
|
|
241
228
|
/**
|
|
242
|
-
*
|
|
243
|
-
* but an unrepairable body renders the fallback code block + settled
|
|
244
|
-
* diagnostic — the host replaced its own block with our output — and an
|
|
245
|
-
* unpublishable `panel:true` fence renders `null` (nothing in the flow).
|
|
229
|
+
* Render a complete fence body for renderer-level tests.
|
|
246
230
|
*/
|
|
247
231
|
export function renderGenuiFence(raw: string, key: Key, context?: GenuiFenceContext): ReactNode {
|
|
248
232
|
const spec = resolveGenuiSpec(raw, context)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const FILE_ADDRESS_PREFIX = 'dsh-resource://file/'
|
|
2
|
+
|
|
3
|
+
/** Encode one address segment while keeping a Windows drive colon readable. */
|
|
4
|
+
function encodeSegment(segment: string): string {
|
|
5
|
+
return encodeURIComponent(segment).replace(/%3A/gi, ':')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Encode each path segment independently so separators retain their structure. */
|
|
9
|
+
function encodePath(path: string): string {
|
|
10
|
+
return path.split('/').map(encodeSegment).join('/')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Check whether a path uses a Windows drive or UNC spelling. */
|
|
14
|
+
function isWindowsStylePath(value: string): boolean {
|
|
15
|
+
return /^[A-Za-z]:[/\\]/.test(value) || value.startsWith('\\\\')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Check whether a path is absolute in a spelling accepted by the host. */
|
|
19
|
+
function isAbsoluteWorkspacePath(path: string): boolean {
|
|
20
|
+
return path.startsWith('/') || isWindowsStylePath(path)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Build a session resource address while preserving encoded path segments. */
|
|
24
|
+
export function sessionFileAddress(sessionId: string, path: string): string {
|
|
25
|
+
const normalized = path.replace(/\\/g, '/').replace(/^(?:\.\/)+/, '')
|
|
26
|
+
return `${FILE_ADDRESS_PREFIX}session/${encodeSegment(sessionId)}/${encodePath(normalized)}`
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Resolve workspace absolute paths to session-relative resource addresses. */
|
|
30
|
+
export function fileAddressFor(sessionId: string, cwd: string | undefined, path: string): string {
|
|
31
|
+
const normalized = path.replace(/\\/g, '/')
|
|
32
|
+
if (!isAbsoluteWorkspacePath(normalized)) return sessionFileAddress(sessionId, normalized)
|
|
33
|
+
const root = cwd === undefined ? '' : cwd.replace(/\\/g, '/').replace(/\/+$/, '')
|
|
34
|
+
if (root !== '' && normalized === root) return sessionFileAddress(sessionId, '')
|
|
35
|
+
if (root !== '' && normalized.startsWith(`${root}/`)) return sessionFileAddress(sessionId, normalized.slice(root.length + 1))
|
|
36
|
+
return sessionFileAddress(sessionId, normalized)
|
|
37
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { createContext, createElement, useContext, useMemo, useSyncExternalStore, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react'
|
|
2
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types'
|
|
3
|
+
import { fileAddressFor } from './file-address.ts'
|
|
4
|
+
import { resolveViewedSessionId } from './session-resolver.ts'
|
|
5
|
+
import css from './GenuiBlock.module.css'
|
|
6
|
+
|
|
7
|
+
interface SidebarRightService {
|
|
8
|
+
openResource(address: string, options?: { params: { line: number } }): void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface FileLinkHostContext {
|
|
12
|
+
get(name: 'sidebarRight', strict?: false): SidebarRightService | undefined
|
|
13
|
+
sessions: {
|
|
14
|
+
list: { getSnapshot(): unknown }
|
|
15
|
+
retainInfo(sessionId: SessionId): { getSnapshot(): { retainedBy: { mainView?: number } } }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface FileLinkScope {
|
|
20
|
+
get(name: 'sidebarRight'): SidebarRightService | undefined
|
|
21
|
+
effect(callback: () => void | (() => void), name?: string): unknown
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface FileLinkCordisContext extends FileLinkHostContext {
|
|
25
|
+
inject(services: ['sidebarRight'], callback: (scope: FileLinkScope) => void): unknown
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FileLinkAvailability {
|
|
29
|
+
subscribe(listener: () => void): () => void
|
|
30
|
+
getSnapshot(): boolean
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const FileLinkOpenContext = createContext<((path: string, line?: number) => void) | undefined>(undefined)
|
|
34
|
+
|
|
35
|
+
/** Track an optional host service through arrival, removal, and plugin unload. */
|
|
36
|
+
export function createFileLinkAvailability(ctx: FileLinkCordisContext): FileLinkAvailability {
|
|
37
|
+
let available = ctx.get('sidebarRight', false)?.openResource !== undefined
|
|
38
|
+
const listeners = new Set<() => void>()
|
|
39
|
+
const notify = (): void => {
|
|
40
|
+
for (const listener of listeners) listener()
|
|
41
|
+
}
|
|
42
|
+
const setAvailable = (next: boolean): void => {
|
|
43
|
+
if (available === next) return
|
|
44
|
+
available = next
|
|
45
|
+
notify()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ctx.inject(['sidebarRight'], (scope) => {
|
|
49
|
+
scope.effect(() => {
|
|
50
|
+
setAvailable(scope.get('sidebarRight')?.openResource !== undefined)
|
|
51
|
+
return () => setAvailable(false)
|
|
52
|
+
}, 'genui: file-link sidebarRight')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
subscribe(listener) {
|
|
57
|
+
listeners.add(listener)
|
|
58
|
+
return () => { listeners.delete(listener) }
|
|
59
|
+
},
|
|
60
|
+
getSnapshot: () => available,
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Provide one fence's session-scoped file opener to descendant components. */
|
|
65
|
+
function FileLinkProvider({ ctx, availability, sessionId, streaming, children }: {
|
|
66
|
+
ctx: FileLinkHostContext
|
|
67
|
+
availability: FileLinkAvailability
|
|
68
|
+
sessionId: string | undefined
|
|
69
|
+
streaming: boolean
|
|
70
|
+
children?: ReactNode
|
|
71
|
+
}) {
|
|
72
|
+
const available = useSyncExternalStore(availability.subscribe, availability.getSnapshot, () => false)
|
|
73
|
+
const open = useMemo(() => {
|
|
74
|
+
if (!available || streaming || sessionId === undefined) return undefined
|
|
75
|
+
return (path: string, line?: number): void => {
|
|
76
|
+
const snapshot = ctx.sessions.list.getSnapshot()
|
|
77
|
+
if (resolveViewedSessionId(snapshot as { ids: SessionId[] }, id => ctx.sessions.retainInfo(id)) !== sessionId) return
|
|
78
|
+
const sessions = snapshot as { byId?: Record<string, { cwd?: string } | undefined> }
|
|
79
|
+
const cwd = sessions.byId?.[sessionId]?.cwd
|
|
80
|
+
const address = fileAddressFor(sessionId, cwd, path)
|
|
81
|
+
const sidebar = ctx.get('sidebarRight', false)
|
|
82
|
+
if (sidebar?.openResource === undefined) return
|
|
83
|
+
if (line === undefined) sidebar.openResource(address)
|
|
84
|
+
else sidebar.openResource(address, { params: { line } })
|
|
85
|
+
}
|
|
86
|
+
}, [available, ctx, sessionId, streaming])
|
|
87
|
+
|
|
88
|
+
return createElement(FileLinkOpenContext.Provider, { value: open }, children)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Render a file link as an accessible host navigation button when available. */
|
|
92
|
+
export function FileLink({ path, line, label, children }: { path: string; line?: number; label: string; children?: ReactNode }) {
|
|
93
|
+
const open = useContext(FileLinkOpenContext)
|
|
94
|
+
if (open === undefined) return createElement('span', { title: path }, children)
|
|
95
|
+
return createElement('button', {
|
|
96
|
+
type: 'button',
|
|
97
|
+
className: css.inlineFileLink,
|
|
98
|
+
title: path,
|
|
99
|
+
'aria-label': `${label} (${path})`,
|
|
100
|
+
onClick: (event: ReactMouseEvent<HTMLButtonElement>) => {
|
|
101
|
+
event.stopPropagation()
|
|
102
|
+
open(path, line)
|
|
103
|
+
},
|
|
104
|
+
}, children)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Add session-scoped file navigation to one fence render tree. */
|
|
108
|
+
export function withFileLinkContext(
|
|
109
|
+
ctx: FileLinkHostContext,
|
|
110
|
+
availability: FileLinkAvailability,
|
|
111
|
+
sessionId: string | undefined,
|
|
112
|
+
streaming: boolean,
|
|
113
|
+
children: ReactNode,
|
|
114
|
+
): ReactNode {
|
|
115
|
+
return createElement(FileLinkProvider, { ctx, availability, sessionId, streaming, children })
|
|
116
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { safeHref } from './genui-runtime/value-utils.ts'
|
|
2
|
+
|
|
3
|
+
export interface ParsedFileLink {
|
|
4
|
+
path: string
|
|
5
|
+
line?: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type LinkTarget =
|
|
9
|
+
| { type: 'external'; href: string }
|
|
10
|
+
| { type: 'file'; file: ParsedFileLink }
|
|
11
|
+
| { type: 'invalid' }
|
|
12
|
+
|
|
13
|
+
/** Decode a local file destination and its optional first line fragment. */
|
|
14
|
+
export function parseFileLink(value: string): ParsedFileLink | undefined {
|
|
15
|
+
if (value.length > 2048) return undefined
|
|
16
|
+
const hash = value.indexOf('#')
|
|
17
|
+
const destination = hash < 0 ? value : value.slice(0, hash)
|
|
18
|
+
if (destination.includes('?')) return undefined
|
|
19
|
+
|
|
20
|
+
let path: string
|
|
21
|
+
try {
|
|
22
|
+
path = decodeURIComponent(destination)
|
|
23
|
+
} catch {
|
|
24
|
+
return undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (path === '' || /[\u0000-\u001f\u007f]/.test(path) || /^[\\/]{2}/.test(path)
|
|
28
|
+
|| (/^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path))) return undefined
|
|
29
|
+
if (hash < 0) return { path }
|
|
30
|
+
|
|
31
|
+
const match = /^L([1-9]\d*)(?:-L([1-9]\d*))?$/.exec(value.slice(hash + 1))
|
|
32
|
+
if (match === null) return undefined
|
|
33
|
+
const line = Number(match[1])
|
|
34
|
+
const end = match[2] === undefined ? line : Number(match[2])
|
|
35
|
+
if (!Number.isSafeInteger(line) || !Number.isSafeInteger(end) || end < line) return undefined
|
|
36
|
+
return { path, line }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Classify a link destination while preserving the existing external URL policy. */
|
|
40
|
+
export function classifyLinkTarget(value: unknown): LinkTarget {
|
|
41
|
+
const external = safeHref(value)
|
|
42
|
+
if (external !== undefined) return { type: 'external', href: external }
|
|
43
|
+
if (typeof value !== 'string') return { type: 'invalid' }
|
|
44
|
+
const file = parseFileLink(value.trim())
|
|
45
|
+
return file === undefined ? { type: 'invalid' } : { type: 'file', file }
|
|
46
|
+
}
|
package/src/client/gallery.ts
CHANGED
|
@@ -1,111 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* GenUI gallery: canonical
|
|
3
|
-
*
|
|
2
|
+
* GenUI gallery: the canonical component anthology (选集). Chapters demo the
|
|
3
|
+
* composition patterns (hero → 摘要 → 数据 → 图表册 → 叙事与代码 → 交互), and
|
|
4
|
+
* the appendix lays out the full vocabulary flat. Docs, demos, and renderer
|
|
5
|
+
* tests reuse it as the canonical fence — one spec, four consumers (tests,
|
|
6
|
+
* e2e-visual, README screenshots, the Pages anthology page).
|
|
7
|
+
*
|
|
8
|
+
* Every B-programme field is exercised here: divider.label chapters,
|
|
9
|
+
* card.eyebrow overlines, text display/align, image.caption.
|
|
4
10
|
*/
|
|
5
11
|
import type { GenuiSpec } from './spec.ts'
|
|
6
12
|
|
|
7
13
|
/** Canonical gallery spec for the built-in GenUI component vocabulary. */
|
|
8
14
|
export const gallerySpec: GenuiSpec = {
|
|
9
|
-
title: 'GenUI ·
|
|
15
|
+
title: 'GenUI · 组件选集',
|
|
10
16
|
gap: 14,
|
|
11
17
|
items: [
|
|
12
18
|
{ type: 'hero', label: '可用率 · 近 30 天', value: '99.96%', delta: '+0.02%', tone: 'accent', spark: [99.8, 99.85, 99.9, 99.88, 99.94, 99.96], title: 'hero 封面块', subtitle: '一条回答最多一个:eyebrow + 超大数字 + 标题 + 副标题,带 tone 渐变底色。' },
|
|
19
|
+
{ type: 'text', size: 'display', content: '一篇回答的排版示范:取舍得当、章节分明、每个组件各司其职。', align: 'center' },
|
|
20
|
+
|
|
21
|
+
{ type: 'divider', label: '摘要' },
|
|
13
22
|
{ type: 'grid', cols: 3, items: [
|
|
14
|
-
{ type: 'card', title: '
|
|
15
|
-
{ type: 'card',
|
|
16
|
-
{ type: 'card',
|
|
17
|
-
] },
|
|
18
|
-
{ type: 'grid', cols: 3, items: [
|
|
19
|
-
{ type: 'card', span: 2, title: 'span:2 · 宽卡', items: [
|
|
20
|
-
{ type: 'text', size: 'body', content: 'grid 子节点加 span 就能跨列:一张宽卡 + 一张窄卡。卡片高度由该行最高的一张决定,内容会自动撑满或居中。' },
|
|
21
|
-
{ type: 'chart', kind: 'line', data: [], series: [
|
|
22
|
-
{ label: '本周', data: [{ label: '一', value: 8 }, { label: '二', value: 12 }, { label: '三', value: 9 }, { label: '四', value: 14 }] },
|
|
23
|
-
{ label: '上周', data: [{ label: '一', value: 6 }, { label: '二', value: 9 }, { label: '三', value: 7 }, { label: '四', value: 10 }] }] }] },
|
|
24
|
-
{ type: 'card', title: 'span:1', items: [{ type: 'chart', kind: 'donut', data: [{ label: '视觉', value: 42 }, { label: '采纳', value: 33 }, { label: '可靠', value: 25 }] }] },
|
|
23
|
+
{ type: 'card', eyebrow: '服务', title: '在线率', items: [{ type: 'stat', label: '近 30 天', value: '99.96%', delta: '+0.02%' }] },
|
|
24
|
+
{ type: 'card', eyebrow: '算力', title: 'CPU', items: [{ type: 'stat', label: '峰值负载', value: '42%', delta: '+3.1%', spark: [30, 34, 32, 38, 40, 42] }] },
|
|
25
|
+
{ type: 'card', eyebrow: '容量', title: '内存', items: [{ type: 'stat', label: '已用', value: '6.8GB', delta: '-1.2%' }] },
|
|
25
26
|
] },
|
|
26
|
-
{ type: '
|
|
27
|
-
|
|
28
|
-
{ type: '
|
|
29
|
-
{ type: '
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{ type: 'divider' },
|
|
42
|
-
{ type: 'image', src: '/demo-image.png', alt: '图片展示演示' },
|
|
43
|
-
{ type: 'audio', src: '/demo-audio.mp3', alt: '音频播放器演示' },
|
|
44
|
-
{ type: 'video', src: '/demo-video.mp4', alt: '视频播放器演示', poster: '/demo-video.jpg', aspectRatio: '16:9' },
|
|
45
|
-
{ type: 'grid', cols: 3, items: [
|
|
46
|
-
{ type: 'stat', label: '在线率', value: '99.96%', size: 'hero', delta: '+0.02%' },
|
|
47
|
-
{ type: 'stat', label: 'CPU', value: '42%', delta: '+3.1%', spark: [31, 38, 35, 44, 40, 42] },
|
|
48
|
-
{ type: 'stat', label: '内存', value: '6.8 GB', delta: '-1.2%' },
|
|
49
|
-
{ type: 'stat', label: '请求数', value: '128.4k', spark: [90, 104, 98, 121, 116, 128] },
|
|
50
|
-
] },
|
|
51
|
-
{ type: 'progress', label: '训练进度', value: 72, valueLabel: '72%' },
|
|
52
|
-
{ type: 'progress', label: '覆盖率', value: 64, target: 80, valueLabel: '64% / 目标 80%' },
|
|
53
|
-
{ type: 'progress', variant: 'ring', value: 72, label: '本轮完成度', valueLabel: '第 3 / 4 轮' },
|
|
54
|
-
{ type: 'card', title: '性能指标', items: [
|
|
55
|
-
// 表头可点击排序:数值感知(千分位 / k / 万 / % 都能正确比较),
|
|
56
|
-
// 数值列自动右对齐。
|
|
57
|
-
{ type: 'table', columns: ['指标', 'Q1', 'Q2', 'Q3'], rows: [
|
|
58
|
-
['延迟', 92, 87, 81], ['吞吐', '1.2k', '1.4k', '1.6k'], ['错误率', '0.3%', '0.2%', '0.1%'],
|
|
59
|
-
['营收', '3.5万', '4.1万', '5.2万'], ['注册', '1,234', '2,345', '3,456'],
|
|
60
|
-
] },
|
|
61
|
-
{ type: 'keyvalue', pairs: [
|
|
62
|
-
{ key: '版本', value: 'v0.1.0' }, { key: '环境', value: 'production' }, { key: '区域', value: 'cn-east' },
|
|
27
|
+
{ type: 'progress', variant: 'ring', value: 72, target: 80, label: '训练进度', valueLabel: '72% / 目标 80%' },
|
|
28
|
+
|
|
29
|
+
{ type: 'divider', label: '数据' },
|
|
30
|
+
{ type: 'grid', cols: 2, items: [
|
|
31
|
+
{ type: 'card', eyebrow: '档案', title: '性能指标', items: [
|
|
32
|
+
// 表头可点击排序:数值感知(千分位 / k / 万 / % 都能正确比较),
|
|
33
|
+
// 数值列自动右对齐;升序后首行是 0.3% 的错误率行(e2e 断言依赖:
|
|
34
|
+
// 本表必须是页面上第一个带 Q1 列的表,点击才会命中这里)。
|
|
35
|
+
{ type: 'table', columns: ['指标', 'Q1', 'Q2', 'Q3'], rows: [
|
|
36
|
+
['延迟', 92, 87, 81], ['吞吐', '1.2k', '1.4k', '1.6k'], ['错误率', '0.3%', '0.2%', '0.1%'],
|
|
37
|
+
['营收', '3.5万', '4.1万', '5.2万'], ['注册', '1,234', '2,345', '3,456'],
|
|
38
|
+
] },
|
|
39
|
+
{ type: 'keyvalue', pairs: [
|
|
40
|
+
{ key: '版本', value: 'v0.1.0' }, { key: '环境', value: 'production' }, { key: '区域', value: 'cn-east' },
|
|
41
|
+
] },
|
|
63
42
|
] },
|
|
43
|
+
{ type: 'card', title: '清单', items: [{ type: 'list', items: [
|
|
44
|
+
{ title: '标题项', desc: '带描述的列表项' },
|
|
45
|
+
'纯文本列表项',
|
|
46
|
+
{ title: '另一个标题' },
|
|
47
|
+
] }] },
|
|
64
48
|
] },
|
|
65
|
-
{ type: '
|
|
66
|
-
{ title: '标题项', desc: '带描述的列表项' },
|
|
67
|
-
'纯文本列表项',
|
|
68
|
-
{ title: '另一个标题' },
|
|
69
|
-
] },
|
|
70
|
-
{ type: 'chart', kind: 'bars', data: [
|
|
71
|
-
{ label: '一', value: 10 }, { label: '二', value: 20 }, { label: '三', value: 15 },
|
|
72
|
-
] },
|
|
73
|
-
{ type: 'chart', kind: 'line', data: [
|
|
74
|
-
{ label: '周一', value: 8 }, { label: '周二', value: 12 }, { label: '周三', value: 9 },
|
|
75
|
-
] },
|
|
76
|
-
{ type: 'chart', kind: 'donut', data: [
|
|
77
|
-
{ label: 'A', value: 30 }, { label: 'B', value: 70 },
|
|
78
|
-
] },
|
|
79
|
-
{ type: 'chart', data: [], series: [
|
|
80
|
-
{ label: '本月', data: [{ label: 'Q1', value: 3 }, { label: 'Q2', value: 5 }] },
|
|
81
|
-
{ label: '上月', data: [{ label: 'Q1', value: 2 }, { label: 'Q2', value: 4 }] },
|
|
82
|
-
] },
|
|
83
|
-
{ type: 'chart', kind: 'line', data: [], series: [
|
|
84
|
-
{ label: '本月', data: [{ label: '一', value: 8 }, { label: '二', value: 12 }, { label: '三', value: 9 }] },
|
|
85
|
-
{ label: '上月', data: [{ label: '一', value: 6 }, { label: '二', value: 9 }, { label: '三', value: 7 }] },
|
|
86
|
-
] },
|
|
87
|
-
{ type: 'chart', kind: 'bars', data: [], stacked: true, series: [
|
|
88
|
-
{ label: '已完成', data: [{ label: 'Q1', value: 42 }, { label: 'Q2', value: 58 }, { label: 'Q3', value: 61 }] },
|
|
89
|
-
{ label: '进行中', data: [{ label: 'Q1', value: 18 }, { label: 'Q2', value: 14 }, { label: 'Q3', value: 9 }] },
|
|
90
|
-
] },
|
|
91
|
-
{ type: 'chart', horizontal: true, data: [
|
|
92
|
-
{ label: '自然搜索', value: 82 }, { label: '直接访问', value: 64 }, { label: '社交媒体', value: 41 },
|
|
93
|
-
] },
|
|
49
|
+
{ type: 'text', size: 'h3', content: '主表明细:筛选、排序、钻取全部在本地完成' },
|
|
94
50
|
{ type: 'input', label: '筛选服务 / 状态', placeholder: '输入关键字即时过滤下表', id: 'gallery-filter' },
|
|
95
51
|
{ type: 'table', columns: ['服务', 'P95', '状态'], types: ['text', 'num', 'badge'], filter: 'gallery-filter', rows: [
|
|
96
52
|
['API 网关', '128', '正常'],
|
|
97
53
|
['搜索', '190', '关注'],
|
|
98
54
|
['推荐', '250', '偏高'],
|
|
99
|
-
]
|
|
100
|
-
{ type: 'table', columns: ['服务', 'P95', '状态'], types: ['text', 'num', 'badge'], details: [
|
|
55
|
+
], details: [
|
|
101
56
|
[{ type: 'keyvalue', pairs: [{ key: '负责人', value: '平台组' }, { key: 'SLO', value: 'P95 < 150ms' }] },
|
|
102
57
|
{ type: 'text', size: 'body', content: '展开行可以放任意组件:指标、图表、列表、表单都可以。' }],
|
|
103
58
|
null,
|
|
104
59
|
[{ type: 'progress', value: 91, target: 80, label: '负载水位', valueLabel: '91% / 目标 80%' }],
|
|
105
|
-
], rows: [
|
|
106
|
-
['API 网关', '128', '正常'],
|
|
107
|
-
['搜索', '190', '关注'],
|
|
108
|
-
['推荐', '250', '偏高'],
|
|
109
60
|
] },
|
|
110
61
|
{ type: 'table', columns: ['区域', 'Q1', 'Q2', 'Q3'], types: ['group', 'num', 'num', 'num'], total: true, rows: [
|
|
111
62
|
['华东', '', '', ''],
|
|
@@ -114,43 +65,29 @@ export const gallerySpec: GenuiSpec = {
|
|
|
114
65
|
['华北', '', '', ''],
|
|
115
66
|
['北京', '88', '95', '103'],
|
|
116
67
|
] },
|
|
117
|
-
{ type: 'card', tone: 'success', title: '已通过', items: [
|
|
118
|
-
{ type: 'text', size: 'body', content: '分组表:首列为 group 时,只有第一格有内容的行会渲染成跨列小标题;total 追加一行合计。' },
|
|
119
|
-
] },
|
|
120
68
|
{ type: 'table', columns: ['#', '服务', '近 6 期延迟', '可用率', '负载', '状态'], types: ['index', 'text', 'spark', 'ring', 'bar', 'badge'], rows: [
|
|
121
69
|
['1', 'API 网关', '180,164,150,140,133,128', '99.96', '62', '正常'],
|
|
122
70
|
['2', '搜索', '220,210,230,205,198,190', '99.82', '78', '关注'],
|
|
123
71
|
['3', '推荐', '310,340,300,280,260,250', '99.41', '91', '偏高'],
|
|
124
72
|
] },
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{ type: 'button', label: '主按钮', tone: 'primary' },
|
|
135
|
-
{ type: 'button', label: '危险', tone: 'danger', small: true },
|
|
136
|
-
{ type: 'button', label: '成功', tone: 'success' },
|
|
137
|
-
{ type: 'button', label: '幽灵', tone: 'ghost', icon: '↗' },
|
|
73
|
+
|
|
74
|
+
{ type: 'divider', label: '图表册' },
|
|
75
|
+
{ type: 'grid', cols: 3, items: [
|
|
76
|
+
{ type: 'card', span: 2, title: 'span:2 · 趋势', items: [
|
|
77
|
+
{ type: 'text', size: 'body', content: '宽卡配窄卡是 bento 的基本型:卡片高度由该行最高的一张决定。' },
|
|
78
|
+
{ type: 'chart', kind: 'line', data: [], series: [
|
|
79
|
+
{ label: '本周', data: [{ label: '一', value: 8 }, { label: '二', value: 12 }, { label: '三', value: 9 }, { label: '四', value: 14 }] },
|
|
80
|
+
{ label: '上周', data: [{ label: '一', value: 6 }, { label: '二', value: 9 }, { label: '三', value: 7 }, { label: '四', value: 10 }] }] }] },
|
|
81
|
+
{ type: 'card', title: 'span:1 · 占比', items: [{ type: 'chart', kind: 'donut', data: [{ label: '视觉', value: 42 }, { label: '采纳', value: 33 }, { label: '可靠', value: 25 }] }] },
|
|
138
82
|
] },
|
|
139
|
-
{ type: '
|
|
140
|
-
{ type: '
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{ type: 'radio', label: '主题', options: ['浅色', '深色', '跟随系统'] },
|
|
147
|
-
], wrap: true },
|
|
148
|
-
{ type: 'textarea', label: '备注', placeholder: '多行输入…', rows: 3 },
|
|
149
|
-
{ type: 'accordion', items: [
|
|
150
|
-
{ title: '第一项', items: [{ type: 'json', value: { ok: true, count: 3 } }] },
|
|
151
|
-
{ title: '第二项', items: [{ type: 'code', lang: 'ts', code: 'export const x = 1' }] },
|
|
83
|
+
{ type: 'grid', cols: 2, items: [
|
|
84
|
+
{ type: 'card', title: '堆叠构成', items: [{ type: 'chart', kind: 'bars', data: [], stacked: true, series: [
|
|
85
|
+
{ label: '已完成', data: [{ label: 'Q1', value: 42 }, { label: 'Q2', value: 58 }, { label: 'Q3', value: 61 }] },
|
|
86
|
+
{ label: '进行中', data: [{ label: 'Q1', value: 18 }, { label: 'Q2', value: 14 }, { label: 'Q3', value: 9 }] }] }] },
|
|
87
|
+
{ type: 'card', title: '横向排行', items: [{ type: 'chart', horizontal: true, data: [
|
|
88
|
+
{ label: '自然搜索', value: 82 }, { label: '直接访问', value: 64 }, { label: '社交媒体', value: 41 },
|
|
89
|
+
] }] },
|
|
152
90
|
] },
|
|
153
|
-
{ type: 'copy', label: '复制令牌', text: 'sk-1234567890' },
|
|
154
91
|
{ type: 'echart', preset: 'bar', title: 'echart · preset:bar(只下载 core 引擎)', height: 240, data: [
|
|
155
92
|
{ label: '自然搜索', value: 82 }, { label: '直接访问', value: 64 }, { label: '社交媒体', value: 41 },
|
|
156
93
|
] },
|
|
@@ -170,19 +107,25 @@ export const gallerySpec: GenuiSpec = {
|
|
|
170
107
|
{ label: '模块', value: 50 }, { label: '数据', value: 45 }, { label: '安全', value: 40 },
|
|
171
108
|
{ label: '扩展', value: 30 }, { label: '渲染', value: 25 },
|
|
172
109
|
] },
|
|
173
|
-
|
|
174
|
-
{ type: '
|
|
175
|
-
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
110
|
+
|
|
111
|
+
{ type: 'divider', label: '叙事与代码' },
|
|
112
|
+
{ type: 'grid', cols: 2, items: [
|
|
113
|
+
{ type: 'card', title: '时间线', items: [{ type: 'timeline', items: [
|
|
114
|
+
{ title: '发布 v0.1', desc: '首个可用版本', time: '08-01' },
|
|
115
|
+
{ title: '事件循环', desc: 'action 回流', time: '08-08' },
|
|
116
|
+
{ title: '选集重构', desc: '本页', time: '10-14' },
|
|
117
|
+
] }] },
|
|
118
|
+
{ type: 'card', title: '步骤', items: [{ type: 'steps', current: 2, steps: [
|
|
119
|
+
{ title: '起草', desc: '写规格' }, { title: '渲染', desc: '画组件' }, { title: '验证', desc: '跑测试' },
|
|
120
|
+
] }] },
|
|
181
121
|
] },
|
|
182
122
|
{ type: 'diff', diffs: [
|
|
183
123
|
{ path: 'a.ts', oldText: 'const x = 1', newText: 'const x = 2' },
|
|
184
124
|
] },
|
|
185
|
-
{ type: '
|
|
125
|
+
{ type: 'grid', cols: 2, items: [
|
|
126
|
+
{ type: 'code', lang: 'ts', code: 'export const x = 1' },
|
|
127
|
+
{ type: 'json', value: { ok: true, count: 3 } },
|
|
128
|
+
] },
|
|
186
129
|
{ type: 'mermaid', code: 'graph TD\nA[模型] --> B[渲染器]\nB --> C[组件]' },
|
|
187
130
|
{ type: 'diagram', kind: 'architecture', title: '架构图(配色跟随宿主令牌)', nodes: [
|
|
188
131
|
{ id: 'm', label: '模型', type: 'external', x: 20, y: 40, w: 100, h: 44 },
|
|
@@ -190,15 +133,104 @@ export const gallerySpec: GenuiSpec = {
|
|
|
190
133
|
{ id: 'g', label: 'guard', type: 'backend', x: 312, y: 40, w: 104, h: 44 },
|
|
191
134
|
{ id: 's', label: '组件库', type: 'store', x: 456, y: 40, w: 100, h: 44 },
|
|
192
135
|
], edges: [{ from: 'm', to: 'f' }, { from: 'f', to: 'g' }, { from: 'g', to: 's' }] },
|
|
136
|
+
{ type: 'plot', title: '波动叠加(拖动滑杆即时重绘)', xMin: -6.28, xMax: 6.28, series: [
|
|
137
|
+
{ expr: 'a*sin(b*x)', label: 'a·sin(bx)', color: '#4f8ef7', params: [
|
|
138
|
+
{ name: 'a', value: 1, min: 0.2, max: 2 },
|
|
139
|
+
{ name: 'b', value: 1, min: 0.5, max: 3 },
|
|
140
|
+
] },
|
|
141
|
+
{ expr: '0.8*cos(x)', label: 'cos', color: '#3ecf8e' },
|
|
142
|
+
] },
|
|
193
143
|
{ type: 'scene3d', title: '几何演示', ambient: 1, meshes: [
|
|
194
144
|
{ shape: 'box', color: '#4f8ef7', position: [-1.4, 0, 0], rotation: [0.5, 0.8, 0] },
|
|
195
145
|
{ shape: 'sphere', color: '#3ecf8e', position: [0, 0, 0] },
|
|
196
146
|
{ shape: 'cone', color: '#e0a458', position: [1.4, 0, 0] },
|
|
197
147
|
] },
|
|
198
|
-
{ type: '
|
|
199
|
-
|
|
200
|
-
|
|
148
|
+
{ type: 'callout', tone: 'info', title: '提示', content: '前五章是编排示范,附录平铺全部词汇。' },
|
|
149
|
+
|
|
150
|
+
{ type: 'divider', label: '交互' },
|
|
151
|
+
{ type: 'grid', cols: 2, items: [
|
|
152
|
+
{ type: 'tabs', tabs: [
|
|
153
|
+
{ label: '概览', items: [{ type: 'text', content: '标签页一的内容' }] },
|
|
154
|
+
{ label: '明细', items: [{ type: 'list', items: ['明细 A', '明细 B'] }] },
|
|
155
|
+
{ label: '图表', items: [{ type: 'chart', kind: 'donut', data: [{ label: 'X', value: 40 }, { label: 'Y', value: 60 }] }] },
|
|
156
|
+
] },
|
|
157
|
+
{ type: 'accordion', items: [
|
|
158
|
+
{ title: '第一项', items: [{ type: 'json', value: { ok: true, count: 3 } }] },
|
|
159
|
+
{ title: '第二项', items: [{ type: 'code', lang: 'ts', code: 'export const x = 1' }] },
|
|
160
|
+
] },
|
|
201
161
|
] },
|
|
162
|
+
{ type: 'quiz', question: '1 + 1 = ?', id: 'gallery-q1', options: [
|
|
163
|
+
{ label: '1', feedback: '再想想' }, { label: '2', correct: true }, { label: '3' },
|
|
164
|
+
], explanation: '二进制里 1+1=10,十进制里是 2。' },
|
|
165
|
+
{ type: 'row', items: [
|
|
166
|
+
{ type: 'input', label: '名称', placeholder: '输入…' },
|
|
167
|
+
{ type: 'select', label: '环境', options: ['dev', 'staging', 'production'] },
|
|
168
|
+
], wrap: true },
|
|
169
|
+
{ type: 'row', items: [
|
|
170
|
+
{ type: 'checkbox', label: '自动保存', checked: true },
|
|
171
|
+
{ type: 'switch', label: '通知', checked: true },
|
|
172
|
+
{ type: 'radio', label: '主题', options: ['浅色', '深色', '跟随系统'] },
|
|
173
|
+
], wrap: true },
|
|
174
|
+
{ type: 'textarea', label: '备注', placeholder: '多行输入…', rows: 3 },
|
|
175
|
+
{ type: 'col', gap: 8, items: [
|
|
176
|
+
{ type: 'button', label: '主按钮', tone: 'primary' },
|
|
177
|
+
{ type: 'button', label: '危险', tone: 'danger', small: true },
|
|
178
|
+
{ type: 'button', label: '成功', tone: 'success' },
|
|
179
|
+
{ type: 'button', label: '幽灵', tone: 'ghost', icon: '↗' },
|
|
180
|
+
] },
|
|
181
|
+
{ type: 'row', items: [
|
|
182
|
+
{ type: 'copy', label: '复制令牌', text: 'sk-1234567890' },
|
|
183
|
+
{ type: 'breadcrumb', items: ['首页', '组件', '画廊'] },
|
|
184
|
+
], wrap: true },
|
|
185
|
+
|
|
186
|
+
{ type: 'divider', label: '附录 · 全部词汇' },
|
|
187
|
+
{ type: 'text', size: 'h1', content: '排版层级' },
|
|
188
|
+
{ type: 'text', size: 'h2', content: '二级标题' },
|
|
189
|
+
{ type: 'text', size: 'h3', content: '三级标题' },
|
|
190
|
+
{ type: 'text', size: 'body', content: '正文:组件白名单渲染,不经过任意 HTML 路径。' },
|
|
191
|
+
{ type: 'text', size: 'muted', content: '弱化文本' },
|
|
192
|
+
{ type: 'text', size: 'caption', content: '说明文字', center: true },
|
|
193
|
+
{ type: 'row', items: [
|
|
194
|
+
{ type: 'badge', label: '成功', tone: 'success' },
|
|
195
|
+
{ type: 'badge', label: '警告', tone: 'warn' },
|
|
196
|
+
{ type: 'badge', label: '危险', tone: 'danger' },
|
|
197
|
+
{ type: 'badge', label: '强调', tone: 'accent', icon: '★' },
|
|
198
|
+
{ type: 'avatar', name: 'Alice' },
|
|
199
|
+
{ type: 'avatar', name: 'Bob', color: '#3d9e8f' },
|
|
200
|
+
{ type: 'link', label: '详情链接' },
|
|
201
|
+
], wrap: true },
|
|
202
|
+
// v12 figure primitives: the tinted icon plate carries a stage's semantic
|
|
203
|
+
// role, and `blocks` draws the diagram without a single hand-written
|
|
204
|
+
// coordinate.
|
|
205
|
+
{ type: 'row', items: [
|
|
206
|
+
{ type: 'icon', name: 'Function', tone: 'info', tile: true },
|
|
207
|
+
{ type: 'icon', name: 'Nodes', tone: 'success', tile: true },
|
|
208
|
+
{ type: 'icon', name: 'Warning', tone: 'warning', tile: true },
|
|
209
|
+
{ type: 'icon', name: 'CheckCircle', tone: 'success', size: 24 },
|
|
210
|
+
{ type: 'icon', name: 'Clock', tone: 'muted' },
|
|
211
|
+
] },
|
|
212
|
+
{ type: 'blocks', title: '递归加倍:每轮已知数据量翻倍', rows: [
|
|
213
|
+
{ label: '初始', cells: ['0', '1', '2', '3', '4', '5', '6', '7'], color: '#64748b' },
|
|
214
|
+
{ label: '轮 1', cells: ['01', '23', '45', '67'], color: '#4a7fb5' },
|
|
215
|
+
{ label: '轮 2', cells: ['0123', '4567'], color: '#35688f' },
|
|
216
|
+
{ label: '轮 3', cells: ['01234567'], color: '#1f6f7a' },
|
|
217
|
+
], caption: '每格代表一个已完成组内交换的小组;轮数只需 log₂N。' },
|
|
218
|
+
{ type: 'row', justify: 'center', items: [
|
|
219
|
+
{ type: 'card', flat: true, items: [{ type: 'text', size: 'caption', content: 'flat 面板', align: 'center' }] },
|
|
220
|
+
{ type: 'arrow', length: 24 },
|
|
221
|
+
{ type: 'card', flat: true, items: [{ type: 'text', size: 'caption', mono: true, tone: 'danger', content: '0x1F' }] },
|
|
222
|
+
] },
|
|
223
|
+
{ type: 'blocks', title: '流水线:块 × 轮', columns: 5, rows: [
|
|
224
|
+
{ label: '块 1', cells: ['A', 'B', 'C', '—', '—'], color: '#2f6ea8' },
|
|
225
|
+
{ label: '块 2', cells: ['—', 'A', 'B', 'C', '—'], color: '#1f7d70' },
|
|
226
|
+
{ label: '块 3', cells: ['—', '—', 'A', 'B', 'C'], color: '#8a5a2b' },
|
|
227
|
+
], caption: '示意:假设每个工序耗时一轮,独立工序可以并行。' },
|
|
228
|
+
{ type: 'chart', kind: 'bars', data: [
|
|
229
|
+
{ label: '一', value: 10 }, { label: '二', value: 20 }, { label: '三', value: 15 },
|
|
230
|
+
] },
|
|
231
|
+
{ type: 'image', src: '/demo-image.png', alt: '图片展示演示', caption: '图注:演示图加载失败时展示错误态——caption(B4)在图下方,alt 标签行在图上方。' },
|
|
232
|
+
{ type: 'audio', src: '/demo-audio.mp3', alt: '音频播放器演示' },
|
|
233
|
+
{ type: 'video', src: '/demo-video.mp4', alt: '视频播放器演示', poster: '/demo-video.jpg', aspectRatio: '16:9' },
|
|
202
234
|
{ type: 'file-tree', items: [
|
|
203
235
|
{ name: 'src', type: 'dir', children: [
|
|
204
236
|
{ name: 'client', type: 'dir', children: [{ name: 'GenuiBlock.tsx', type: 'file' }] },
|
|
@@ -206,10 +238,6 @@ export const gallerySpec: GenuiSpec = {
|
|
|
206
238
|
] },
|
|
207
239
|
{ name: 'README.md', type: 'file' },
|
|
208
240
|
] },
|
|
209
|
-
{ type: '
|
|
210
|
-
{ type: 'quiz', question: '1 + 1 = ?', id: 'gallery-q1', options: [
|
|
211
|
-
{ label: '1', feedback: '再想想' }, { label: '2', correct: true }, { label: '3' },
|
|
212
|
-
], explanation: '二进制里 1+1=10,十进制里是 2。' },
|
|
213
|
-
{ type: 'spacer' },
|
|
241
|
+
{ type: 'svg', title: 'svg · 独立图片预览(隔离渲染)', height: 160, code: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 220 120"><rect width="220" height="120" rx="10" fill="#534ab7"/><rect x="16" y="16" width="88" height="40" rx="6" fill="#7f74f2"/><text x="60" y="42" text-anchor="middle" fill="#fff" font-size="13">网关</text><rect x="116" y="64" width="88" height="40" rx="6" fill="#3ecf8e"/><text x="160" y="90" text-anchor="middle" fill="#fff" font-size="13">服务</text><path d="M104 56 L116 76" stroke="#fff" stroke-width="2"/></svg>' },
|
|
214
242
|
],
|
|
215
243
|
}
|