feat(ui): 自研 Celadon 组件族入库与 AntD 消费全量替换 - base(Kbd/StatusBadge/IconButton/ToolButton)+product(EmptyState/Callout/SegmentedControl/Checkbox/Select/Tooltip/Switch), composio 视觉基底, globals.css 覆盖清理 (ADR-0008)

This commit is contained in:
maomaochong-ai committed 2026-09-06 20:28:51 +08:00
1 parent 30f58aaa08
commit 5c6612c5dd
128 files changed
+2791 -737

No files matched your search

+25
View File
@@ -12,6 +12,8 @@
"@ffmpeg/core": "0.12.10",
"@ffmpeg/ffmpeg": "^0.12.15",
"@ffmpeg/util": "^0.12.2",
"@fontsource-variable/inter": "^5.3.0",
"@fontsource-variable/jetbrains-mono": "^5.3.0",
"@lobehub/icons": "5.16.0",
"@mediapipe/tasks-vision": "^1.0.1",
"@react-three/drei": "^10.7.7",
@@ -47,6 +49,7 @@
"motion": "^12.42.2",
"nanoid": "^6.0.0",
"react": "19.2.7",
"react-aria-components": "^1.21.1",
"react-dom": "19.2.7",
"react-markdown": "^10.1.0",
"react-router": "^8.2.0",
@@ -277,6 +280,10 @@
"@floating-ui/utils": ["@floating-ui/utils@0.2.11", "https://registry.npmmirror.com/@floating-ui/utils/-/utils-0.2.11.tgz", {}, "sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg=="],
"@fontsource-variable/inter": ["@fontsource-variable/inter@5.3.0", "https://registry.npmmirror.com/@fontsource-variable/inter/-/inter-5.3.0.tgz", {}, "sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA=="],
"@fontsource-variable/jetbrains-mono": ["@fontsource-variable/jetbrains-mono@5.3.0", "https://registry.npmmirror.com/@fontsource-variable/jetbrains-mono/-/jetbrains-mono-5.3.0.tgz", {}, "sha512-F32xpS2NsGYoQi2ADSkKTgpJj7ozajsGgDJ8woTnqjmIB+dxDIqImjl4pXZVEExu8UFZ2ndhmX18EBS/hdz3Lw=="],
"@giscus/react": ["@giscus/react@3.1.0", "https://registry.npmmirror.com/@giscus/react/-/react-3.1.0.tgz", { "dependencies": { "giscus": "^1.6.0" }, "peerDependencies": { "react": "^16 || ^17 || ^18 || ^19", "react-dom": "^16 || ^17 || ^18 || ^19" } }, "sha512-0TCO2TvL43+oOdyVVGHDItwxD1UMKP2ZYpT6gXmhFOqfAJtZxTzJ9hkn34iAF/b6YzyJ4Um89QIt9z/ajmAEeg=="],
"@hono/node-server": ["@hono/node-server@1.19.14", "https://registry.npmmirror.com/@hono/node-server/-/node-server-1.19.14.tgz", { "peerDependencies": { "hono": "^4" } }, "sha512-GwtvgtXxnWsucXvbQXkRgqksiH2Qed37H9xHZocE5sA3N8O8O8/8FA3uclQXxXVzc9XBZuEOMK7+r02FmSpHtw=="],
@@ -285,6 +292,12 @@
"@iconify/utils": ["@iconify/utils@3.1.4", "https://registry.npmmirror.com/@iconify/utils/-/utils-3.1.4.tgz", { "dependencies": { "@antfu/install-pkg": "^1.1.0", "@iconify/types": "^2.0.0", "import-meta-resolve": "^4.2.0" } }, "sha512-b1S7B1k9ohZ+iNTi2ATxbRYG9fTrJmUT0rc46bvVnNxqNRGW7dyo/vRREwyniI5IRN2RSJHDcm+s3BjWrSAjHw=="],
"@internationalized/date": ["@internationalized/date@3.12.4", "https://registry.npmmirror.com/@internationalized/date/-/date-3.12.4.tgz", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-M1dEn4c1U1HsSlaVR8upZtSqvXrTkHDfv18H01uCSJyjVLDxnBR38v/fMxecmlwXKR4i9HeZcmgQAPE6A+aGJQ=="],
"@internationalized/number": ["@internationalized/number@3.6.8", "https://registry.npmmirror.com/@internationalized/number/-/number-3.6.8.tgz", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-8UmMFia46DUt+k97zKd9fKWXcWHR+k8ae3eYzILETuT2KbIvLyOfac7zesw+sJdRAAZ7Q9pM1Mk22aXp2LD0Ig=="],
"@internationalized/string": ["@internationalized/string@3.2.10", "https://registry.npmmirror.com/@internationalized/string/-/string-3.2.10.tgz", { "dependencies": { "@swc/helpers": "^0.5.0" } }, "sha512-PDx6//vHSpRnHfxqMqto11zQvhsaU74O3mKv2F/0eicGZcl9NLjQmGlbHz/LsJh5tLKp4A4L7ZVTzN1/MmMTvA=="],
"@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "https://registry.npmmirror.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
"@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "https://registry.npmmirror.com/@jridgewell/remapping/-/remapping-2.3.5.tgz", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
@@ -657,6 +670,8 @@
"@react-three/fiber": ["@react-three/fiber@9.6.1", "https://registry.npmmirror.com/@react-three/fiber/-/fiber-9.6.1.tgz", { "dependencies": { "@babel/runtime": "^7.17.8", "@types/webxr": "*", "base64-js": "^1.5.1", "buffer": "^6.0.3", "its-fine": "^2.0.0", "react-use-measure": "^2.1.7", "scheduler": "^0.27.0", "suspend-react": "^0.1.3", "use-sync-external-store": "^1.4.0", "zustand": "^5.0.3" }, "peerDependencies": { "expo": ">=43.0", "expo-asset": ">=8.4", "expo-file-system": ">=11.0", "expo-gl": ">=11.0", "react": ">=19 <19.3", "react-dom": ">=19 <19.3", "react-native": ">=0.78", "three": ">=0.156" }, "optionalPeers": ["expo", "expo-asset", "expo-file-system", "expo-gl", "react-dom", "react-native"] }, "sha512-zF0rsKcVYpcJwbFEnv2HkHX9cvOEgsfQo/X8lwmR2dn13S4qEQJXir9fxf5js2LQFoXqxOY7MDkOkYx2uZ4gSg=="],
"@react-types/shared": ["@react-types/shared@3.36.1", "https://registry.npmmirror.com/@react-types/shared/-/shared-3.36.1.tgz", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-AzsuD9OfxTOZMMvTRhlN3oHBwOmFN7tDh27LzqmHt4+uOgPhJT7ZM7/kVs/8/o0WxayMUIk3hBmCFRHv1FUoag=="],
"@reduxjs/toolkit": ["@reduxjs/toolkit@2.12.0", "https://registry.npmmirror.com/@reduxjs/toolkit/-/toolkit-2.12.0.tgz", { "dependencies": { "@standard-schema/spec": "^1.0.0", "@standard-schema/utils": "^0.3.0", "immer": "^11.0.0", "redux": "^5.0.1", "redux-thunk": "^3.1.0", "reselect": "^5.1.0" }, "peerDependencies": { "react": "^16.9.0 || ^17.0.0 || ^18 || ^19", "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0" }, "optionalPeers": ["react", "react-redux"] }, "sha512-KiT+RzZbp6mQET+Mg+h2c97+9j1sNflUxQkIHI7Yuzf6Peu+OYpmkn6nbHWmLLWj+1ZODUJFwGZ7gx3L9R9EOw=="],
"@rolldown/binding-android-arm64": ["@rolldown/binding-android-arm64@1.1.5", "https://registry.npmmirror.com/@rolldown/binding-android-arm64/-/binding-android-arm64-1.1.5.tgz", { "os": "android", "cpu": "arm64" }, "sha512-lZg8fqIv2v7FF237bwMgzGZEJvGL79/s5knJ/i6FmsGF4XXlzccZ4jb+TrFIxtSSxFtIpdsgrPZeMk1I9AFcyQ=="],
@@ -725,6 +740,8 @@
"@streamdown/code": ["@streamdown/code@1.1.1", "https://registry.npmmirror.com/@streamdown/code/-/code-1.1.1.tgz", { "dependencies": { "shiki": "^3.19.0" }, "peerDependencies": { "react": "^18.0.0 || ^19.0.0" } }, "sha512-i7HTNuDgZWb+VdrNVOam9gQhIc5MSSDXKWXgbUrn/4vSRaSMM+Rtl10MQj4wLWPNpF7p80waJsAqFP8HZfb0Jg=="],
"@swc/helpers": ["@swc/helpers@0.5.23", "https://registry.npmmirror.com/@swc/helpers/-/helpers-0.5.23.tgz", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw=="],
"@tailwindcss/node": ["@tailwindcss/node@4.3.3", "https://registry.npmmirror.com/@tailwindcss/node/-/node-4.3.3.tgz", { "dependencies": { "@jridgewell/remapping": "^2.3.5", "enhanced-resolve": "^5.24.1", "jiti": "^2.7.0", "lightningcss": "1.32.0", "magic-string": "^0.30.21", "source-map-js": "^1.2.1", "tailwindcss": "4.3.3" } }, "sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg=="],
"@tailwindcss/oxide": ["@tailwindcss/oxide@4.3.3", "https://registry.npmmirror.com/@tailwindcss/oxide/-/oxide-4.3.3.tgz", { "optionalDependencies": { "@tailwindcss/oxide-android-arm64": "4.3.3", "@tailwindcss/oxide-darwin-arm64": "4.3.3", "@tailwindcss/oxide-darwin-x64": "4.3.3", "@tailwindcss/oxide-freebsd-x64": "4.3.3", "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.3", "@tailwindcss/oxide-linux-arm64-gnu": "4.3.3", "@tailwindcss/oxide-linux-arm64-musl": "4.3.3", "@tailwindcss/oxide-linux-x64-gnu": "4.3.3", "@tailwindcss/oxide-linux-x64-musl": "4.3.3", "@tailwindcss/oxide-wasm32-wasi": "4.3.3", "@tailwindcss/oxide-win32-arm64-msvc": "4.3.3", "@tailwindcss/oxide-win32-x64-msvc": "4.3.3" } }, "sha512-krXjAikiaFSPaK/FkAQT5UTx3VormQaiZ5hBFlJZ9UFQGB/rwg1MZIhHAG9smMQRTdyJxP6Qt5MwMtdyU5FWrA=="],
@@ -1137,6 +1154,8 @@
"cli-spinners": ["cli-spinners@2.9.2", "https://registry.npmmirror.com/cli-spinners/-/cli-spinners-2.9.2.tgz", {}, "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg=="],
"client-only": ["client-only@0.0.1", "https://registry.npmmirror.com/client-only/-/client-only-0.0.1.tgz", {}, "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="],
"clsx": ["clsx@2.1.1", "https://registry.npmmirror.com/clsx/-/clsx-2.1.1.tgz", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
"code-block-writer": ["code-block-writer@13.0.3", "https://registry.npmmirror.com/code-block-writer/-/code-block-writer-13.0.3.tgz", {}, "sha512-Oofo0pq3IKnsFtuHqSF7TqBfr71aeyZDVJ0HpmqB7FBM2qEigL0iPONSCZSO9pE9dZTAxANe5XHG9Uy0YMv8cg=="],
@@ -2097,6 +2116,10 @@
"react": ["react@19.2.7", "https://registry.npmmirror.com/react/-/react-19.2.7.tgz", {}, "sha512-HNe9WslTbXmFK8o8cmwgAeJFSBvt1bPdHCVKtaaV+WlAN36mpT4hcRpwbf3fY56ar2oIXzsBpOAiIRHAdY0OlQ=="],
"react-aria": ["react-aria@3.52.1", "https://registry.npmmirror.com/react-aria/-/react-aria-3.52.1.tgz", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.8", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.36.1", "@swc/helpers": "^0.5.0", "aria-hidden": "^1.2.3", "clsx": "^2.0.0", "react-stately": "3.50.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-fdZZruC9/x/joCg0mhKGs5aHpwrXLCSZ4GOJmhhYyiE0ffyEsk9MLFt9LCOCF9tn8ErTD+UDQP4oDUSlZkmpCg=="],
"react-aria-components": ["react-aria-components@1.21.1", "https://registry.npmmirror.com/react-aria-components/-/react-aria-components-1.21.1.tgz", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.36.1", "@swc/helpers": "^0.5.0", "client-only": "^0.0.1", "react-aria": "3.52.1", "react-stately": "3.50.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-J88WflYY0z+EhLX0ce+GjFlQ3ag3ubIgfUTjpKSrBQBu92Xtl4Ub9o118HItUddtbk1Ido0jzyPy94/klZy1hg=="],
"react-avatar-editor": ["react-avatar-editor@15.1.0", "https://registry.npmmirror.com/react-avatar-editor/-/react-avatar-editor-15.1.0.tgz", { "peerDependencies": { "react": "^0.14.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^0.14.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-Zto7u9l6Wd5LPPtjeFJ+7uwoT4bs01OSgkN2kxD18lWl8IiZ0GY3nWCbKPx4qIU7Au1vENsMJm19rfVWHHayaQ=="],
"react-colorful": ["react-colorful@5.8.0", "https://registry.npmmirror.com/react-colorful/-/react-colorful-5.8.0.tgz", { "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-Wy9OzPfjSN9bF12OB8N7UQvlsZ0I+7wHxpN+bV5BjNQGxOj6IiwkRjevJK9yOBjJWGQvAaf1OXtn8rUeEatAng=="],
@@ -2129,6 +2152,8 @@
"react-router": ["react-router@8.2.0", "https://registry.npmmirror.com/react-router/-/react-router-8.2.0.tgz", { "dependencies": { "cookie-es": "^3.1.1" }, "peerDependencies": { "react": ">=19.2.7", "react-dom": ">=19.2.7" }, "optionalPeers": ["react-dom"] }, "sha512-uP1LgGNHyilL1u+ZkecQk74DJOKOb6q4NLNYLRJcD/fjoogftNb5/Rj/07o/QBFsY/5MbAKPm1peTCQuVPv9cQ=="],
"react-stately": ["react-stately@3.50.0", "https://registry.npmmirror.com/react-stately/-/react-stately-3.50.0.tgz", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.8", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.36.1", "@swc/helpers": "^0.5.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-TnckvpDQGU0672wEaLZqdzvhuSeXWjgW6vijMWxiKOxc8CosQUfPGISdcZyfHqjX3XMjEtRxj4w9HumvX4h4mw=="],
"react-style-singleton": ["react-style-singleton@2.2.3", "https://registry.npmmirror.com/react-style-singleton/-/react-style-singleton-2.2.3.tgz", { "dependencies": { "get-nonce": "^1.0.0", "tslib": "^2.0.0" }, "peerDependencies": { "@types/react": "*", "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ=="],
"react-syntax-highlighter": ["react-syntax-highlighter@16.1.1", "https://registry.npmmirror.com/react-syntax-highlighter/-/react-syntax-highlighter-16.1.1.tgz", { "dependencies": { "@babel/runtime": "^7.28.4", "highlight.js": "^10.4.1", "highlightjs-vue": "^1.0.0", "lowlight": "^1.17.0", "prismjs": "^1.30.0", "refractor": "^5.0.0" }, "peerDependencies": { "react": ">= 0.14.0" } }, "sha512-PjVawBGy80C6YbC5DDZJeUjBmC7skaoEUdvfFQediQHgCL7aKyVHe57SaJGfQsloGDac+gCpTfRdtxzWWKmCXA=="],
+3
View File
@@ -24,6 +24,8 @@
"@ffmpeg/core": "0.12.10",
"@ffmpeg/ffmpeg": "^0.12.15",
"@ffmpeg/util": "^0.12.2",
"@fontsource-variable/inter": "^5.3.0",
"@fontsource-variable/jetbrains-mono": "^5.3.0",
"@lobehub/icons": "5.16.0",
"@mediapipe/tasks-vision": "^1.0.1",
"@react-three/drei": "^10.7.7",
@@ -59,6 +61,7 @@
"motion": "^12.42.2",
"nanoid": "^6.0.0",
"react": "19.2.7",
"react-aria-components": "^1.21.1",
"react-dom": "19.2.7",
"react-markdown": "^10.1.0",
"react-router": "^8.2.0",
@@ -1,4 +1,5 @@
import { Alert, Button, Empty, Modal, Tag } from "antd";
import { Button, Modal, Tag } from "antd";
import { EmptyState } from "@/components/ui/product/empty-state";
import { ArrowLeft, ArrowRight, CheckCircle2, ChevronDown, ChevronRight, Copy, FileText, Image as ImageIcon, LoaderCircle, RefreshCw, Sparkles, Target, X } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
@@ -27,6 +28,8 @@ import { modelOptionLabel, useEffectiveConfig } from "@/stores/use-config-store"
import { usePluginStore } from "@/stores/use-plugin-store";
import { useThemeStore } from "@/stores/use-theme-store";
import type { CanvasNodeData } from "@/types/canvas";
import { IconButton } from "@/components/ui/base/buttons";
import { Callout } from "@/components/ui/product/callout";
type AiArtCritiqueModalProps = {
node: CanvasNodeData | null;
@@ -296,7 +299,7 @@ export function AiArtCritiqueModal({ node, upstreamNodes, open, onClose, onUpdat
: "尚未分析"}
</span>
</div>
<Button type="text" size="small" icon={<X className="size-4" />} onClick={close} aria-label="关闭批改报告" />
<IconButton variant="ghost" size="sm" icon={X} onClick={close} aria-label="关闭批改报告" />
</header>
<div className="flex min-h-0 flex-1 flex-col lg:grid lg:grid-cols-[minmax(0,1.45fr)_minmax(360px,.85fr)]">
@@ -305,7 +308,7 @@ export function AiArtCritiqueModal({ node, upstreamNodes, open, onClose, onUpdat
{previewUrl ? (
<img src={previewUrl} alt={input?.title || "输入图片"} className="max-h-full max-w-full rounded-[var(--r-md)] object-contain shadow-[var(--shadow-md)]" draggable={false} />
) : (
<Empty image={<ImageIcon className="mx-auto size-10 opacity-25" />} description={input ? "正在加载图片" : "还没有图片输入"} />
<EmptyState size="compact" icon={ImageIcon} title={input ? "正在加载图片" : "还没有图片输入"} />
)}
{overlayIssues.length && previewUrl ? <CritiqueOverlay issues={overlayIssues} issueNumberById={issueNumberById} selectedIssueId={overlayIssues[0]?.id || null} labelPlacements={labelPlacements} onSelect={openIssue} /> : null}
</div>
@@ -333,10 +336,10 @@ export function AiArtCritiqueModal({ node, upstreamNodes, open, onClose, onUpdat
<aside className="min-h-0 flex-1 overflow-y-auto" data-canvas-wheel-scroll>
<div className="flex min-h-full flex-col gap-4 p-4">
{running || visibleState.status === "running" ? <ArtCritiqueProgress stage={progressStage} theme={theme} /> : null}
{draftReportVisible && visibleState.status === "running" && visibleState.report ? <Alert type="info" showIcon message="报告初稿已生成" description="问题和建议已先展示,正在精确定位并复核矩形标注。" /> : null}
{!enabled && !visibleState.report ? <Alert type="warning" showIcon message="插件尚未启用" description="请先到插件管理中开启 AI 审美批改,再运行分析。" /> : null}
{visibleState.status === "stale" ? <Alert type="warning" showIcon message="输入图片已经变化" description="当前报告针对旧图片生成,请重新批改。" /> : null}
{localError || visibleState.errorMessage ? <Alert type="error" showIcon message="批改失败" description={localError || visibleState.errorMessage} /> : null}
{draftReportVisible && visibleState.status === "running" && visibleState.report ? <Callout tone="info" title="报告初稿已生成">问题和建议已先展示,正在精确定位并复核矩形标注。</Callout> : null}
{!enabled && !visibleState.report ? <Callout tone="warning" title="插件尚未启用">请先到插件管理中开启 AI 审美批改,再运行分析。</Callout> : null}
{visibleState.status === "stale" ? <Callout tone="warning" title="输入图片已经变化">当前报告针对旧图片生成,请重新批改。</Callout> : null}
{localError || visibleState.errorMessage ? <Callout tone="error" title="批改失败">{localError || visibleState.errorMessage}</Callout> : null}
{view === "detail" && detailIssue ? (
<IssueDetailView
@@ -355,7 +358,7 @@ export function AiArtCritiqueModal({ node, upstreamNodes, open, onClose, onUpdat
{visibleState.report ? (
<ReportSummary report={visibleState.report} theme={theme} isDraft={draftReportVisible && visibleState.status === "running"} />
) : (
<Empty className="my-auto" description="还没有批改报告" image={<FileText className="mx-auto size-10 opacity-25" />} />
<EmptyState className="my-auto" size="compact" icon={FileText} title="还没有批改报告" />
)}
{visibleState.report && !visibleState.report.issues.length ? (
@@ -1,5 +1,7 @@
import { Button } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useRef, useState, type ClipboardEvent as ReactClipboardEvent, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
import { Button, Tooltip } from "antd";
import { motion, useReducedMotion } from "motion/react";
import { ArrowUp, CheckCircle2, CircleAlert, ImagePlus, LoaderCircle, RotateCcw, Sparkles, UserRound, Wrench, X, XCircle } from "lucide-react";
@@ -1,4 +1,7 @@
import { Button, Switch, Tooltip } from "antd";
import { Button } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { Switch } from "@/components/ui/base/switch";
import { BookOpenCheck, BookOpenText, Bot, Clapperboard, Focus, Globe2, History, LayoutTemplate, Laptop, PanelRightClose, PanelsTopLeft, Plus, RotateCcw, Workflow } from "lucide-react";
import { useNavigate } from "react-router";
@@ -89,7 +92,7 @@ export function AgentPanelChrome({
<Button type="text" shape="circle" className="!h-6 !w-6 !min-w-6" disabled={!canUndo} style={{ color: theme.node.muted }} icon={<RotateCcw className="size-3" />} onClick={onUndo} aria-label="撤销最近一批 Agent 写回" />
</Tooltip>
<label className="flex h-6 cursor-pointer items-center gap-1 rounded-md px-1" style={{ color: theme.node.muted }}>
<Switch size="small" checked={confirmTools} onChange={onConfirmToolsChange} />
<Switch size="sm" checked={confirmTools} onChange={onConfirmToolsChange} />
<span className="whitespace-nowrap">确认</span>
</label>
</div>
@@ -1,7 +1,9 @@
import { Button, Modal, Segmented, Select } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useMemo, useRef, useState } from "react";
import copyToClipboard from "copy-to-clipboard";
import { Copy, Cpu, Settings2, Trash2, X } from "lucide-react";
import { Button, Modal, Segmented, Select, Tooltip } from "antd";
import { motion } from "motion/react";
import { modelDisplayName, modelIcon, normalizeModelOptionValue, resolveModelChannel, resolveModelRequestConfig, selectableModelsByCapability, useConfigStore, useEffectiveConfig, type AiConfig } from "@/stores/use-config-store";
@@ -1,6 +1,9 @@
import { Button, Input, InputNumber, Segmented, Select, Slider } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useState, type CSSProperties, type ReactNode } from "react";
import { ChevronDown, Dice5, Image as ImageIcon, LoaderCircle, MessageSquare, Music2, Play, Sparkles, Video, Workflow as WorkflowIcon } from "lucide-react";
import { Button, Input, InputNumber, Segmented, Select, Slider, Switch, Tooltip } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { configuredModelMatchesCapability, defaultConfig, modelOptionName, normalizeRunningHubCapability, resolveModelChannel, useEffectiveConfig, type AiConfig, type RunningHubCapability, type RunningHubWorkflow, type RunningHubWorkflowKind } from "@/stores/use-config-store";
import { canvasThemes } from "@/lib/canvas-theme";
@@ -400,7 +403,7 @@ export function WorkflowParameterControls({ fields, node, theme, onConfigChange,
const control = fieldType === "SELECT" || selectOptions.length ? (
<Select status={valueError ? "error" : undefined} size="small" className="w-full" value={value === "" ? undefined : value as string | number} options={selectOptions.map((option) => ({ label: workflowParameterOptionLabel(option), value: workflowParameterOptionValue(option) }))} onChange={(next) => update(field, next)} />
) : fieldType === "BOOLEAN" || typeof value === "boolean" ? (
<Switch size="small" checked={value === true || value === "true"} onChange={(checked) => update(field, checked)} />
<Switch size="sm" checked={value === true || value === "true"} onChange={(checked) => update(field, checked)} />
) : fieldType === "SLIDER" && bounds.min !== undefined && bounds.max !== undefined ? (
<div className="grid min-w-0 grid-cols-[minmax(0,1fr)_64px] items-center gap-2">
<Slider disabled={randomEnabled} className="m-0" min={bounds.min} max={bounds.max} step={bounds.step || 0.01} value={numericValue ?? bounds.min} tooltip={{ open: false }} onChange={(next) => update(field, next)} />
@@ -1,6 +1,7 @@
import { Tooltip } from "@/components/ui/base/tooltip";
import { motion, useReducedMotion } from "motion/react";
import { Bot, PanelBottom, X, ZoomIn, ZoomOut } from "lucide-react";
import { Tooltip } from "antd";
import { aceternityMotion } from "@/lib/aceternity-motion";
import { canvasThemes } from "@/lib/canvas-theme";
@@ -1,11 +1,16 @@
import { Drawer, Button, Input, Popconfirm } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useMemo, useState } from "react";
import { Drawer, Tag, Button, Input, Popconfirm, Empty, Tooltip } from "antd";
import { Clock, Clock3, ExternalLink, History, Search, Trash2, X } from "lucide-react";
import { useNavigate } from "react-router";
import { StatusBadge } from "@/components/ui/base/badges";
import { useCanvasStore } from "@/stores/canvas/use-canvas-store";
import { useCanvasHistoryStore } from "@/stores/canvas/use-canvas-history-store";
import { cn } from "@/lib/utils";
import { EmptyState } from "@/components/ui/product/empty-state";
type TimelineItem = {
id: string;
@@ -140,9 +145,7 @@ export function CanvasHistoryDrawer({ open, onClose }: { open: boolean; onClose:
{/* 时间线列表 */}
{filteredItems.length === 0 ? (
<div className="py-12">
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无匹配的历史记录" />
</div>
<EmptyState description="暂无匹配的历史记录" />
) : (
<div className="relative border-l-2 border-stone-200 dark:border-stone-800 pl-4 space-y-4 pt-1">
{filteredItems.map((item) => {
@@ -178,13 +181,9 @@ export function CanvasHistoryDrawer({ open, onClose }: { open: boolean; onClose:
</button>
)}
{isDeleted ? (
<Tag color="error" className="m-0 text-[11px] leading-tight px-1.5 py-0.5 font-medium">
已删除
</Tag>
<StatusBadge tone="error" size="sm" label="已删除" className="m-0" />
) : (
<Tag color="success" className="m-0 text-[11px] leading-tight px-1.5 py-0.5 font-medium">
活跃中
</Tag>
<StatusBadge tone="success" size="sm" label="活跃中" className="m-0" />
)}
</div>
@@ -1,5 +1,7 @@
import { App, Button, Segmented } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { memo, useCallback, useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent } from "react";
import { App, Button, Segmented, Tooltip } from "antd";
import copyToClipboard from "copy-to-clipboard";
import { CheckCircle2, Copy, ExternalLink, FolderOpen, History, LoaderCircle, PlugZap, Plus, RefreshCw, Terminal, Trash2 } from "lucide-react";
import { motion } from "motion/react";
@@ -1,5 +1,7 @@
import { Segmented, Slider } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useRef, useState, type PointerEvent as ReactPointerEvent } from "react";
import { Segmented, Slider, Tooltip } from "antd";
import { motion, useReducedMotion } from "motion/react";
import { Camera, RotateCcw, Send, X } from "lucide-react";
@@ -1,5 +1,7 @@
import { Button, Modal, Slider } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
import { Button, Modal, Slider, Tooltip } from "antd";
import { Brush, Eraser, Redo2, RotateCcw, Save, Undo2 } from "lucide-react";
import { imageToDataUrl } from "@/services/image-storage";
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent } from "react";
import { ArrowUp, AtSign, ChevronDown, FileText, ImageIcon, ImagePlus, LoaderCircle, Maximize2, Music2, Pencil, SlidersHorizontal, UserRound, Video, WandSparkles, X } from "lucide-react";
import { Button, Image as AntImage, InputNumber, Modal, Tooltip } from "antd";
import { Button, Image as AntImage, InputNumber, Modal } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
import { ArrowUp, AtSign, Boxes, ChevronDown, FileText, ImageIcon, ImagePlus, LoaderCircle, Maximize2, Music2, Pencil, SlidersHorizontal, UserRound, Video, WandSparkles, X } from "lucide-react";
import { ModelPicker } from "@/components/model-picker";
import { defaultConfig, modelOptionName, resolveModelChannel, useEffectiveConfig, type AiConfig } from "@/stores/use-config-store";
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
import { Alert, App, Button, Dropdown, Input, Popover, Tag, Typography } from "antd";
import { App, Button, Dropdown, Input, Popover, Tag, Typography } from "antd";
import { Callout } from "@/components/ui/product/callout";
import { Bubble, Sender, type BubbleItemType } from "@ant-design/x";
import { ArrowUp, Check, ChevronDown, FileText, Image as ImageIcon, LoaderCircle, Music2, Sparkles, UserRound, Video, X } from "lucide-react";
@@ -543,7 +544,7 @@ export function CanvasPromptOptimizerDrawer({ open, children, prompt, generation
bubbleItems.push({
key: "error",
role: "system",
content: <Alert className="canvas-prompt-optimizer-alert" type="error" showIcon message="优化失败" description={error} />,
content: <Callout className="canvas-prompt-optimizer-alert" tone="error" title="优化失败">{error}</Callout>,
});
}
@@ -1,5 +1,8 @@
import { Button, Dropdown, Input, InputNumber, Modal, Segmented, Select, Table } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { Fragment, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
import { Button, Checkbox, Dropdown, Input, InputNumber, Modal, Segmented, Select, Table, Tooltip } from "antd";
import { CheckboxGroup } from "@/components/ui/base/checkbox";
import type { MenuProps } from "antd";
import type { ColumnsType } from "antd/es/table";
import { ChevronDown, ChevronUp, Clapperboard, Copy, Expand, Film, Grid3X3, Image as ImageIcon, ListTree, Merge, MoreHorizontal, Plus, RefreshCw, Send, Square, Trash2, Video } from "lucide-react";
@@ -718,7 +721,7 @@ export function CanvasScriptEditor({
<Modal title={node?.title || "分镜脚本"} open={open} onCancel={onClose} footer={null} width="min(1480px, calc(100vw - 40px))" centered destroyOnHidden>
<div className="mb-3 flex flex-wrap items-center gap-2">
<Input.Search className="w-72" allowClear placeholder="筛选画面、台词或提示词" value={query} onChange={(event) => setQuery(event.target.value)} />
<Checkbox.Group className="script-column-picker" options={columnOptions} value={visibleColumns} onChange={(values) => onVisibleColumnsChange(values as StoryboardColumn[])} />
<CheckboxGroup className="script-column-picker" options={columnOptions} value={visibleColumns} onChange={(values) => onVisibleColumnsChange(values)} />
<span className="min-w-0 flex-1" />
<Button icon={<Plus className="size-4" />} onClick={() => onUpdateRows([...rows, editorRow(rows.length + 1)])}>
新增镜头
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { App, Button, ColorPicker, Input, InputNumber, Modal, Progress, Segmented, Switch } from "antd";
import { App, Button, ColorPicker, Input, InputNumber, Modal, Progress, Segmented } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { Captions, FileDown, FileUp, ListPlus, LoaderCircle, Plus, Scissors, Sparkles, Trash2 } from "lucide-react";
import { saveAs } from "file-saver";
@@ -394,7 +395,7 @@ export function CanvasSubtitleDialog({ node, open, projectId, config, onClose, o
<div className="border-t pt-3" style={{ borderColor: theme.toolbar.border }}>
<div className="mb-2 flex items-center justify-between text-xs font-medium opacity-55">
<span>关键词高亮</span>
<Switch size="small" checked={style.highlightEnabled} onChange={(highlightEnabled) => setStyle((current) => ({ ...current, highlightEnabled }))} />
<Switch size="sm" checked={style.highlightEnabled} onChange={(highlightEnabled) => setStyle((current) => ({ ...current, highlightEnabled }))} />
</div>
<div className="space-y-2.5">
<label className="flex items-center justify-between gap-2 text-xs opacity-70">
@@ -1,5 +1,7 @@
import { App, Button, ColorPicker, Dropdown, Input, Modal, Popover } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useMemo, useState, type ReactNode } from "react";
import { App, Button, ColorPicker, Dropdown, Input, Modal, Popover, Tooltip } from "antd";
import type { Editor, JSONContent } from "@tiptap/core";
import { EditorContent, useEditor } from "@tiptap/react";
import {
@@ -1,9 +1,11 @@
import { App, Button, Dropdown, Input, InputNumber, Modal, Progress } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
// 二期:多轨时间线编辑弹窗。
// 数据源是项目级 TimelineProject:视频/音频节点自动入轨,字幕条目转字幕片段。
// 交互:拖拽移动片段(吸附播放头/片段边缘)、左右边缘裁剪、删除、播放头跳转。
import { useCallback, useEffect, useMemo, useRef, useState, type MutableRefObject } from "react";
import { App, Button, Dropdown, Input, InputNumber, Modal, Progress, Tooltip } from "antd";
import { Captions, Clapperboard, FolderOpen, Library, Lock, LockOpen, Maximize2, MoreHorizontal, Music2, Plus, Scissors, Trash2, Upload, Video, Wand2, ZoomIn, ZoomOut } from "lucide-react";
import { saveAs } from "file-saver";
+2 -2
View File
@@ -1,6 +1,6 @@
import { AnimatePresence, motion } from "motion/react";
import { useEffect, useRef, useState, type MouseEvent as ReactMouseEvent, type ReactNode } from "react";
import { Switch } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { Palette, Info } from "lucide-react";
import { FloatingDock } from "@/components/ui/aceternity/floating-dock";
@@ -207,7 +207,7 @@ export function CanvasToolbar({
<CanvasAppearanceControls appearance={appearance} backgroundMode={backgroundMode} colorTheme={colorTheme} theme={theme} onAppearanceChange={onAppearanceChange} onSaveAppearanceDefault={onSaveAppearanceDefault} onBackgroundModeChange={onBackgroundModeChange} />
<div className="mt-2.5 flex items-center justify-between gap-2 rounded-[var(--dock-item-radius-labeled)] border px-2.5 py-2" style={{ background: theme.spatial.surface, borderColor: theme.toolbar.border }}>
<span className="inline-flex min-w-0 items-center gap-1.5 text-[var(--fs-tiny)] font-semibold"><Info className="size-3" />图片信息</span>
<Switch size="small" checked={showImageInfo} onChange={onShowImageInfoChange} />
<Switch size="sm" checked={showImageInfo} onChange={onShowImageInfoChange} />
</div>
</SpotlightSurface>
</motion.div>
@@ -1,4 +1,5 @@
import { App, Button, ColorPicker, Dropdown, Input, InputNumber, Select, Slider, Switch } from "antd";
import { App, Button, ColorPicker, Dropdown, Input, InputNumber, Select, Slider } from "antd";
import { Switch } from "@/components/ui/base/switch";
import type { MenuProps } from "antd";
import { Box, BoxSelect, Camera, Circle, Cuboid, FileUp, Focus, Image as ImageIcon, LampDesk, Lightbulb, Plus, Redo2, RotateCcw, Save, Trash2, Undo2, UserRound, Video, X } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState, type ReactElement, type ReactNode } from "react";
@@ -1,4 +1,5 @@
import { Tooltip } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { releaseDirectorFocusAfterPointer } from "@/lib/canvas/director/director-shortcuts";
import { DIRECTOR_VIEW_MODES, type DirectorViewMode } from "@/lib/canvas/director/director-view-modes";
@@ -1,4 +1,5 @@
import { Tooltip } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { Bone, Box, Camera, Compass, Crosshair, Layers, Lightbulb, Move3D, Palette, Rotate3D, Scaling, UserRound } from "lucide-react";
import type { ReactNode } from "react";
@@ -1,4 +1,7 @@
import { Alert, Button, InputNumber, Modal, Popconfirm, Segmented, Select, Switch, Tag } from "antd";
import { Button, InputNumber, Modal, Popconfirm, Segmented, Select, Tag } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { Callout } from "@/components/ui/product/callout";
import { StatusBadge } from "@/components/ui/base/badges";
import { CircleAlert, Download, History, Image as ImageIcon, Pause, Play, ScanFace, ShieldCheck } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
@@ -300,27 +303,27 @@ export function PortraitClearanceModal({ projectId, node, upstreamNodes, open, o
<label className="mb-3 block text-xs">去重方式<Select className="mt-1 w-full" value={state.settings.dedupMode} disabled={!enabled} options={[{ value: "phash", label: "pHash 快速" }, { value: "arcface", label: "ArcFace 双条件" }]} onChange={(value) => patchState({ settings: { ...state.settings, dedupMode: value as "phash" | "arcface" } })} /></label>
{state.analysisMode === "local-plus-vision" ? <label className="mb-3 block text-xs">模型并发(最多 10)<InputNumber className="mt-1 w-full" min={1} max={10} precision={0} value={state.settings.modelConcurrency} disabled={!enabled} onChange={(value) => patchState({ settings: { ...state.settings, modelConcurrency: Math.max(1, Math.min(10, Number(value) || 2)) } })} /></label> : null}
{state.mode === "network-search" ? <><label className="mb-3 block text-xs">候选上限<InputNumber className="mt-1 w-full" min={1} max={60} value={state.settings.maxCandidates} disabled={!enabled} onChange={(value) => patchState({ settings: { ...state.settings, maxCandidates: Math.max(1, Math.min(60, Number(value) || 30)) } })} /></label><label className="mb-3 block text-xs">百度滚动次数<InputNumber className="mt-1 w-full" min={0} max={20} value={state.settings.searchScrolls} disabled={!enabled} onChange={(value) => patchState({ settings: { ...state.settings, searchScrolls: Math.max(0, Math.min(20, Number(value) || 0)) } })} /></label></> : null}
<div className="flex items-center justify-between gap-3 text-xs"><span>浏览器调试</span><Switch size="small" checked={state.settings.showBrowserForDebug} disabled={!enabled} onChange={(checked) => patchState({ settings: { ...state.settings, showBrowserForDebug: checked } })} /></div>
<div className="flex items-center justify-between gap-3 text-xs"><span>浏览器调试</span><Switch size="sm" checked={state.settings.showBrowserForDebug} disabled={!enabled} onChange={(checked) => patchState({ settings: { ...state.settings, showBrowserForDebug: checked } })} /></div>
</section>
</aside>
<main className="min-w-0 space-y-4">
{!runtimeReady && enabled ? <Alert type={runtimeConnecting ? "info" : "warning"} showIcon message={runtimeConnecting ? "正在连接本机检测引擎" : runtimeStatus ? "本地模型未就绪" : "本机引擎连接失败"} description={runtimeConnecting ? "正在自动建立本机连接,请稍候。" : runtimeStatus ? (installingModels ? "正在下载并校验本地肖像模型,请稍候。" : runtimeError || "请下载本地肖像模型后再开始排查。") : portraitRuntimeErrorMessage(runtimeError) || "正在自动重连本机引擎,请确认 Canvas Agent 已启动。"} action={runtimeConnecting ? null : runtimeStatus ? <Button size="small" icon={<Download className="size-3.5" />} loading={installingModels} onClick={() => void installModels()}>{installingModels ? "下载中…" : "下载本地模型"}</Button> : <Button size="small" onClick={() => setRuntimeRetryNonce((value) => value + 1)}>立即重连</Button>} /> : null}
{runtimeReady && runtimeError ? <Alert type="error" showIcon message="网络排查请求失败" description={runtimeError} closable onClose={() => setRuntimeError("")} /> : null}
{state.mode === "network-search" && runtimeStatus?.browser.available === false ? <Alert type="warning" showIcon message="未检测到系统浏览器" description="网络排查需要系统 Chrome、Edge 或 Chromium;也可以先连接手动候选,任务不会静默切换搜索服务。" /> : null}
{!runtimeReady && enabled ? <Callout tone={runtimeConnecting ? "info" : "warning"} title={runtimeConnecting ? "正在连接本机检测引擎" : runtimeStatus ? "本地模型未就绪" : "本机引擎连接失败"} action={runtimeConnecting ? null : runtimeStatus ? <Button size="small" icon={<Download className="size-3.5" />} loading={installingModels} onClick={() => void installModels()}>{installingModels ? "下载中…" : "下载本地模型"}</Button> : <Button size="small" onClick={() => setRuntimeRetryNonce((value) => value + 1)}>立即重连</Button>}>{runtimeConnecting ? "正在自动建立本机连接,请稍候。" : runtimeStatus ? (installingModels ? "正在下载并校验本地肖像模型,请稍候。" : runtimeError || "请下载本地肖像模型后再开始排查。") : portraitRuntimeErrorMessage(runtimeError) || "正在自动重连本机引擎,请确认 Canvas Agent 已启动。"}</Callout> : null}
{runtimeReady && runtimeError ? <Callout tone="error" title="网络排查请求失败" onClose={() => setRuntimeError("")}>{runtimeError}</Callout> : null}
{state.mode === "network-search" && runtimeStatus?.browser.available === false ? <Callout tone="warning" title="未检测到系统浏览器">网络排查需要系统 Chrome、Edge 或 Chromium;也可以先连接手动候选,任务不会静默切换搜索服务。</Callout> : null}
<section className="rounded-xl border p-4" style={{ borderColor: "var(--border)" }}>
<div className="flex flex-wrap items-center justify-between gap-3">
<div><h3 className="text-sm font-semibold">当前结果</h3><p className="mt-1 text-xs text-foreground/55">完整结果会在本机任务完成后生成;节点 metadata 只保留可恢复摘要。</p></div>
{state.task ? <Tag color={state.task.status === "failed" ? "red" : state.task.status === "cancelled" ? "orange" : state.task.status === "completed" ? "green" : "blue"}>{state.task.status === "failed" ? "失败" : state.task.status === "cancelled" ? "已停止" : PORTRAIT_TASK_STAGE_LABELS[state.task.stage] || state.task.stage}</Tag> : null}
{state.task ? <StatusBadge tone={state.task.status === "failed" ? "error" : state.task.status === "cancelled" ? "warning" : state.task.status === "completed" ? "success" : "loading"} label={state.task.status === "failed" ? "失败" : state.task.status === "cancelled" ? "已停止" : PORTRAIT_TASK_STAGE_LABELS[state.task.stage] || state.task.stage} /> : null}
</div>
{state.task?.status === "failed" && state.task.errorMessage ? <Alert className="mt-4" type="error" showIcon message="排查任务失败" description={state.task.errorMessage} /> : null}
{state.task?.status === "failed" && state.task.errorMessage ? <Callout className="mt-4" tone="error" title="排查任务失败">{state.task.errorMessage}</Callout> : null}
{state.lastResult ? <><div className="mt-4 grid gap-3 sm:grid-cols-4"><Metric label="最高风险" value={PORTRAIT_RISK_LABELS[state.lastResult.highestRisk]} tone={portraitRiskTone(state.lastResult.highestRisk)} /><Metric label="候选数" value={String(state.lastResult.candidateCount)} /><Metric label="已分析" value={String(result?.comparedCount ?? state.lastResult.comparedCount)} /><Metric label="详情" value={state.lastResult.detailsAvailable ? "可用" : "需重新运行"} /></div>{result ? <PortraitResultPanel result={result} taskId={state.lastResult.taskId} onAddCandidate={onAddCandidate} /> : <div className="mt-4 rounded-lg bg-foreground/[.03] p-3 text-xs text-foreground/55">正在读取本机详细结果,图片和完整模型响应不会写入画布 metadata。</div>}</> : <div className="mt-4 grid min-h-44 place-items-center rounded-lg border border-dashed text-center text-sm text-foreground/45" style={{ borderColor: "var(--border)" }}><div><ScanFace className="mx-auto mb-2 size-8 opacity-45" /><p>{canStart ? "准备好开始排查" : "先连接所需图片"}</p><p className="mt-1 text-xs">本地模式会在 Canvas Agent 中执行,关闭工作台不会取消任务。</p></div></div>}
</section>
<section className="rounded-xl border p-4" style={{ borderColor: "var(--border)" }}>
<div className="mb-3 flex items-center gap-2"><History className="size-4" /><h3 className="text-sm font-semibold">历史运行</h3></div>
{history.length ? <div className="space-y-2">{history.map((item) => <div key={item.taskId} className="flex flex-wrap items-center gap-2 rounded-lg border px-3 py-2 text-xs" style={{ borderColor: "var(--border)" }}><span className="min-w-24 font-medium">{item.mode === "direct-compare" ? "直接比对" : "网络排查"}</span><Tag color={item.status === "completed" ? "green" : item.status === "failed" ? "red" : item.status === "partial" ? "orange" : "blue"}>{PORTRAIT_TASK_STAGE_LABELS[item.stage] || item.status}</Tag><span className="text-foreground/55">{item.processedCandidates}{item.totalCandidates ? ` / ${item.totalCandidates}` : ""} 项</span><span className="ml-auto text-foreground/45">{formatDate(item.updatedAt)}</span><Button size="small" type="link" onClick={() => void openHistoryTask(item)}>查看</Button><Popconfirm title="删除本地排查数据?" description="报告、候选和本机任务将不可恢复。" onConfirm={() => void removeHistory(item.taskId)}><Button size="small" type="link" danger loading={busyAction === `delete-${item.taskId}`}>删除</Button></Popconfirm></div>)}</div> : <div className="rounded-lg bg-foreground/[.03] p-3 text-xs leading-5 text-foreground/55">暂无当前节点历史。不会建立跨项目的人脸身份索引。</div>}
{history.length ? <div className="space-y-2">{history.map((item) => <div key={item.taskId} className="flex flex-wrap items-center gap-2 rounded-lg border px-3 py-2 text-xs" style={{ borderColor: "var(--border)" }}><span className="min-w-24 font-medium">{item.mode === "direct-compare" ? "直接比对" : "网络排查"}</span><StatusBadge variant="filled" tone={item.status === "completed" ? "success" : item.status === "failed" ? "error" : item.status === "partial" ? "warning" : "loading"} label={PORTRAIT_TASK_STAGE_LABELS[item.stage] || item.status} /><span className="text-foreground/55">{item.processedCandidates}{item.totalCandidates ? ` / ${item.totalCandidates}` : ""} 项</span><span className="ml-auto text-foreground/45">{formatDate(item.updatedAt)}</span><Button size="small" type="link" onClick={() => void openHistoryTask(item)}>查看</Button><Popconfirm title="删除本地排查数据?" description="报告、候选和本机任务将不可恢复。" onConfirm={() => void removeHistory(item.taskId)}><Button size="small" type="link" danger loading={busyAction === `delete-${item.taskId}`}>删除</Button></Popconfirm></div>)}</div> : <div className="rounded-lg bg-foreground/[.03] p-3 text-xs leading-5 text-foreground/55">暂无当前节点历史。不会建立跨项目的人脸身份索引。</div>}
</section>
</main>
</div>
@@ -350,7 +353,7 @@ function PortraitInputCard({ label, node, ready }: { label: string; node?: Canva
<div className="text-xs font-medium">{label}</div>
<div className="truncate text-[11px] text-foreground/50">{node?.title || (ready ? "已连接图片" : "待连接")}</div>
</div>
<Tag color={ready ? "green" : "orange"}>{ready ? "已连接" : "待连接"}</Tag>
<StatusBadge tone={ready ? "success" : "warning"} label={ready ? "已连接" : "待连接"} />
</div>;
}
@@ -417,7 +420,7 @@ function ResultPairCard({ taskId, pair, candidate, onAddCandidate }: { taskId: s
<div className="flex gap-3 p-3">
<div className="grid size-24 shrink-0 place-items-center overflow-hidden rounded-md bg-foreground/[.04]">{image ? <img src={image} alt="" className="size-full object-contain" /> : <ScanFace className="size-6 opacity-35" />}</div>
<div className="min-w-0 flex-1">
<div className="flex flex-wrap items-center gap-2"><span className="truncate text-sm font-semibold">{candidate?.title || pair.comparisonImageId}</span><Tag color="default" style={portraitRiskTagStyle(pair.riskLevel)}>{PORTRAIT_RISK_LABELS[pair.riskLevel]}</Tag><Tag color={pair.status === "failed" ? "red" : pair.status === "partial" ? "orange" : "green"}>{pair.status === "failed" ? "失败/跳过" : pair.status === "partial" ? "部分完成" : "完成"}</Tag></div>
<div className="flex flex-wrap items-center gap-2"><span className="truncate text-sm font-semibold">{candidate?.title || pair.comparisonImageId}</span><Tag color="default" style={portraitRiskTagStyle(pair.riskLevel)}>{PORTRAIT_RISK_LABELS[pair.riskLevel]}</Tag><StatusBadge variant="filled" tone={pair.status === "failed" ? "error" : pair.status === "partial" ? "warning" : "success"} label={pair.status === "failed" ? "失败/跳过" : pair.status === "partial" ? "部分完成" : "完成"} /></div>
<div className="mt-1 text-xs text-foreground/55">{candidate?.sourceDomain || pair.source} · {pair.analysisPath === "unable" ? "无法形成可靠路径" : `Path ${pair.analysisPath}`}{pair.overallSimilarity === undefined ? "" : ` · 相似度 ${pair.overallSimilarity.toFixed(4)}`}</div>
<div className="mt-1 flex flex-wrap gap-2">{candidate?.sourcePageUrl ? <button type="button" className="text-xs text-[var(--workspace-accent)] underline" onClick={() => window.open(candidate.sourcePageUrl, "_blank", "noopener,noreferrer")}>打开来源页面</button> : null}{onAddCandidate && candidate && image ? <button type="button" className="text-xs text-[var(--workspace-accent)] underline" onClick={() => void onAddCandidate({ id: candidate.id, title: candidate.title, imageArtifactId: candidate.imageArtifactId }, image)}>添加到画布</button> : null}</div>
</div>
@@ -427,7 +430,7 @@ function ResultPairCard({ taskId, pair, candidate, onAddCandidate }: { taskId: s
{pair.localPrecheck.reliabilityIssues.length ? <div className="mt-1 text-foreground/55"><span className="text-foreground/50">可靠性问题:</span>{pair.localPrecheck.reliabilityIssues.join(";")}</div> : null}
{pair.error ? <div className="mt-1 text-red-600"><span className="font-medium">处理说明:</span>{pair.error.message}</div> : null}
{vision ? <>
<div className="mt-2 flex flex-wrap items-center gap-2"><span className="font-medium">多模态面部特征分析</span><Tag color={vision.status === "success" ? "green" : "gold"}>{vision.status === "success" ? "已完成" : "无法可靠判断"}</Tag>{vision.manualReviewRecommended ? <Tag color="orange">建议人工复核</Tag> : null}</div>
<div className="mt-2 flex flex-wrap items-center gap-2"><span className="font-medium">多模态面部特征分析</span><StatusBadge variant="filled" tone={vision.status === "success" ? "success" : "warning"} label={vision.status === "success" ? "已完成" : "无法可靠判断"} />{vision.manualReviewRecommended ? <StatusBadge variant="filled" tone="warning" label="建议人工复核" /> : null}</div>
<div className="mt-2 overflow-x-auto rounded-md border" style={{ borderColor: "var(--border)" }}><table className="w-full min-w-[520px] text-left text-[11px]"><thead className="bg-foreground/[.04]"><tr><th className="px-2 py-1.5 font-medium">特征维度</th><th className="px-2 py-1.5 font-medium">相似度</th><th className="px-2 py-1.5 font-medium">分析说明</th></tr></thead><tbody>{PORTRAIT_FEATURES.map(({ key, label }) => { const feature = vision.featureComparison[key]; return <tr key={key} className="border-t" style={{ borderColor: "var(--border)" }}><td className="px-2 py-1.5">{label}</td><td className="px-2 py-1.5"><Tag color="default" style={portraitFeatureSimilarityStyle(feature.similarity)}>{PORTRAIT_FEATURE_SIMILARITY_LABELS[feature.similarity]}</Tag></td><td className="px-2 py-1.5 text-foreground/60">{feature.note || "-"}</td></tr>; })}</tbody></table></div>
<div className="mt-2"><span className="text-foreground/50">视觉依据:</span>{vision.basis.join(";") || "无"}</div>
</> : <div className="mt-1 text-foreground/55">{pair.basis.join(";") || "暂无结构化依据"}</div>}
@@ -1,5 +1,7 @@
import { Modal } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useMemo, useState } from "react";
import { Modal, Tooltip } from "antd";
import { Image as ImageIcon, Music2, Play, UserRound } from "lucide-react";
import { canvasNodeVideoPreviewUrl } from "@/lib/canvas/canvas-media-preview";
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useState, type ReactNode } from "react";
import { Button, Input, InputNumber, Modal, Select, Switch } from "antd";
import { Button, Input, InputNumber, Modal, Select } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, Box, Check, FileImage, Link2, Plus, Save, SlidersHorizontal, Trash2 } from "lucide-react";
import { nanoid } from "nanoid";
@@ -198,7 +199,7 @@ function AssetEditor({ asset, onChange, onDelete }: { asset: StyleAssetBinding;
<Field label="启用状态">
<div className="flex h-8 items-center justify-between border-b border-border">
<span className="text-xs text-foreground/55">参与生成执行计划</span>
<Switch size="small" checked={asset.enabled !== false} onChange={(enabled) => onChange({ enabled })} />
<Switch size="sm" checked={asset.enabled !== false} onChange={(enabled) => onChange({ enabled })} />
</div>
</Field>
<Field label="资产名称">
@@ -1,4 +1,5 @@
import { Modal, Switch } from "antd";
import { Modal } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { GripVertical, RotateCcw, X } from "lucide-react";
import { motion, useReducedMotion } from "motion/react";
import { useEffect, useRef, useState } from "react";
@@ -218,7 +219,7 @@ function ToolbarSettingsItem({ item, reducedMotion, theme, dragging, onToggleVis
>
<GripVertical className="size-4" />
</button>
<Switch size="small" checked={item.visible} onChange={(checked) => onToggleVisible(item.id, checked)} aria-label={`${item.visible ? "隐藏" : "显示"}${item.label}`} />
<Switch size="sm" checked={item.visible} onChange={(checked) => onToggleVisible(item.id, checked)} aria-label={`${item.visible ? "隐藏" : "显示"}${item.label}`} />
</div>
<div className="canvas-toolbar-settings-card-content mt-auto flex min-w-0 flex-col items-center gap-1">
<span className="grid size-8 shrink-0 place-items-center rounded-[var(--r-md)]" style={{ background: theme.toolbar.itemHover, color: theme.node.muted }}>
@@ -1,4 +1,6 @@
import { Button, Input, Tooltip } from "antd";
import { Button, Input } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { Plus, Trash2 } from "lucide-react";
import type { ChangeEvent } from "react";
@@ -1,5 +1,7 @@
import { Button } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useState } from "react";
import { Button, Tooltip } from "antd";
import { Mic } from "lucide-react";
import { VoiceRecordingInline } from "./voice-recording-inline";
@@ -1,5 +1,7 @@
import { Button, Spin } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useRef, useState } from "react";
import { Button, Spin, Tooltip } from "antd";
import { Check, Mic, Square, X } from "lucide-react";
import { AudioWaveform } from "./audio-waveform";
+4 -3
View File
@@ -1,5 +1,6 @@
import { type ReactNode, useState } from "react";
import { ConfigProvider, Switch } from "antd";
import { ConfigProvider } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { type CanvasTheme } from "@/lib/canvas-theme";
import { buildImageResolutionOptions, formatImageResolutionSize, imageRatioForSize, imageResolutionChoices, imageResolutionOption, imageSizeForResolution, supportsImageResolutionPresets, type ImageResolutionChoice } from "@/lib/image-resolution-tiers";
@@ -127,7 +128,7 @@ export function ImageSettingsPanel({ config, onConfigChange, theme, showTitle =
</div>
<span title="是否支持透明背景由当前模型接口决定" onMouseDown={(event) => event.stopPropagation()}>
<Switch
size="small"
size="sm"
checked={transparentBackground}
onChange={(checked) => onConfigChange("transparentBackground", checked ? "true" : "false")}
/>
@@ -151,7 +152,7 @@ export function ImageSettingsPanel({ config, onConfigChange, theme, showTitle =
16倍数对齐
</span>
<span title="输入完成后自动向上补成 16 的倍数" onMouseDown={(event) => event.stopPropagation()}>
<Switch size="small" checked={snapDimensionToStep} onChange={setSnapDimensionToStep} />
<Switch size="sm" checked={snapDimensionToStep} onChange={setSnapDimensionToStep} />
</span>
</div>
</div>
@@ -1,10 +1,12 @@
import { App, Button, Form, Input, Select, Switch, Tag } from "antd";
import { App, Button, Form, Input, Select, Tag } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { Cloud, ShieldCheck } from "lucide-react";
import { useEffect, useState } from "react";
import { changesRequireOSSRetest, DEFAULT_OSS_PATH_PREFIX, getS3PresetHints, S3_PRESET_OPTIONS, type OSSConnectionTestResult, type OSSProvider, type S3Preset } from "@/lib/oss-settings";
import { getUserOSSSetting, testUserOSSConnection, updateUserOSSSetting, type UserOSSSetting } from "@/services/api/resources";
import { useUserStore } from "@/stores/use-user-store";
import { StatusBadge } from "@/components/ui/base/badges";
type OSSFormValues = {
enabled?: boolean;
@@ -121,7 +123,7 @@ export function UserOSSSettingsForm() {
<p className="mt-1 max-w-3xl text-xs leading-5 text-foreground/55">启用后,新上传和新生成的媒体优先写入你的存储桶;停用时回退到平台存储。</p>
</div>
<div className="flex shrink-0 gap-2">
<Tag color={setting?.enabled ? "success" : "default"}>{setting?.enabled ? "已启用" : "未启用"}</Tag>
<StatusBadge tone={setting?.enabled ? "success" : "neutral"} label={setting?.enabled ? "已启用" : "未启用"} />
<Tag color={setting?.hasAccessKeySecret ? "processing" : "warning"} icon={<ShieldCheck className="size-3" />}>
{setting?.hasAccessKeySecret ? "密钥已加密" : "未保存密钥"}
</Tag>
@@ -237,7 +239,7 @@ function connectionInput(values: OSSFormValues) {
}
function ConnectionTestStatus({ result, stale }: { result: OSSConnectionTestResult | null; stale: boolean }) {
if (stale) return <Tag color="warning">需重新测试</Tag>;
if (stale) return <StatusBadge tone="warning" label="需重新测试" />;
if (!result) return null;
return <Tag color={result.ok ? "success" : "error"}>{result.ok ? `测试通过${result.testedAt ? ` · ${formatSavedAt(result.testedAt)}` : ""}` : result.message || "测试失败"}</Tag>;
return <StatusBadge tone={result.ok ? "success" : "error"} label={result.ok ? `测试通过${result.testedAt ? ` · ${formatSavedAt(result.testedAt)}` : ""}` : result.message || "测试失败"} />;
}
@@ -1,4 +1,5 @@
import { Popover, Switch } from "antd";
import { Popover } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { CircleUserRound, LogIn, Moon, Sun } from "lucide-react";
import { useEffect, useState } from "react";
import { Link } from "react-router";
@@ -52,7 +53,7 @@ export function WorkspaceAccountMenu() {
<div className="flex h-10 items-center px-2">
{theme === "dark" ? <Moon className="size-3.5 text-foreground/45" /> : <Sun className="size-3.5 text-foreground/45" />}
<span className="ml-2 flex-1 text-xs text-foreground/65">深色模式</span>
<Switch size="small" checked={theme === "dark"} onChange={(checked) => setTheme(checked ? "dark" : "light")} aria-label="深色模式" />
<Switch size="sm" checked={theme === "dark"} onChange={(checked) => setTheme(checked ? "dark" : "light")} aria-label="深色模式" />
</div>
</div>
)}
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState, type ComponentType } from "react"
import { useNavigate } from "react-router";
import { navigationTools } from "@/constant/navigation-tools";
import { Kbd } from "@/components/ui/base/kbd";
import { cn } from "@/lib/utils";
import { useUserStore } from "@/stores/use-user-store";
@@ -100,12 +101,9 @@ toolEntry("projects", "/projects"),
className="min-w-0 flex-1 bg-transparent text-[var(--fs-body)] outline-none placeholder:text-foreground/45"
placeholder="搜索页面或操作…"
/>
<kbd
onClick={onClose}
className="hidden h-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-[var(--workspace-border)] bg-background/60 px-1.5 font-mono text-[var(--fs-tiny)] font-medium text-foreground/60 transition-colors hover:bg-surface-hover hover:text-foreground sm:inline-flex"
>
<Kbd onClick={onClose} className="hidden shrink-0 cursor-pointer transition-colors hover:bg-surface-hover hover:text-foreground sm:inline-flex">
⌘K
</kbd>
</Kbd>
<button
type="button"
onClick={onClose}
@@ -1,4 +1,5 @@
import { App, Popover, Switch } from "antd";
import { App, Popover } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { ChevronRight, CircleUserRound, LogIn, LogOut, Moon, ShieldCheck, Sun } from "lucide-react";
import { useEffect, useState, type ReactNode } from "react";
import { Link, useNavigate } from "react-router";
@@ -88,7 +89,7 @@ export function WorkspaceSidebarFooter({ expandedClassName, collapsedClassName,
<div className="flex h-10 items-center px-2">
{theme === "dark" ? <Moon className="size-3.5 text-foreground/45" /> : <Sun className="size-3.5 text-foreground/45" />}
<span className="ml-2 flex-1 text-xs text-foreground/65">深色模式</span>
<Switch size="small" checked={theme === "dark"} onChange={(checked) => setTheme(checked ? "dark" : "light")} aria-label="深色模式" />
<Switch size="sm" checked={theme === "dark"} onChange={(checked) => setTheme(checked ? "dark" : "light")} aria-label="深色模式" />
</div>
<button type="button" className="flex h-9 w-full items-center gap-2 rounded px-2 text-xs text-foreground/55 hover:bg-surface-hover hover:text-foreground" onClick={() => void handleLogout()}><LogOut className="size-3.5" />退出登录</button>
</div>
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState, type ComponentType, type CSSPrope
import { Link, useLocation, useNavigate, useSearchParams } from "react-router";
import { BrandLogoFrame } from "@/components/brand/brand-logo";
import { Kbd } from "@/components/ui/base/kbd";
import { navigationTools, type NavigationToolSlug } from "@/constant/navigation-tools";
import { useWalletBalance } from "@/hooks/use-wallet-balance";
import { useWorkspaceLogout } from "@/hooks/use-workspace-logout";
@@ -186,9 +187,7 @@ function NavItem({
</span>
<span className="app-workspace-nav-meta flex shrink-0 items-center gap-2">
{item.shortcut ? (
<kbd className="hidden h-5 items-center justify-center rounded-sm border border-[var(--workspace-border)] bg-background/50 px-1.5 font-mono text-[var(--fs-tiny)] font-medium text-foreground/55 group-hover:inline-flex">
{item.shortcut}
</kbd>
<Kbd className="hidden group-hover:inline-flex">{item.shortcut}</Kbd>
) : null}
{item.badge !== undefined ? <span className="flex min-w-5 items-center justify-center rounded-full bg-primary/10 px-1.5 py-0.5 text-[var(--fs-tiny)] font-medium tabular-nums text-primary">{item.badge}</span> : null}
{hasChildren ? <ChevronRight className={cn("size-3.5 shrink-0 text-foreground/40 transition-transform duration-200", isOpen && "rotate-90")} strokeWidth={2} /> : null}
@@ -338,9 +337,7 @@ export function WorkspaceSidebarNav({ collapsed, onNavigate, onOpenSearch, onExp
>
<Search className="size-4 shrink-0 text-muted-foreground group-hover:text-foreground/70" strokeWidth={1.6} />
<span className="app-workspace-sidebar-search-label flex-1 truncate">快速搜索</span>
<kbd className="app-workspace-sidebar-search-shortcut flex h-5 shrink-0 items-center justify-center rounded-sm border border-[var(--workspace-border)] bg-background/50 px-1.5 font-mono text-[var(--fs-tiny)] font-medium text-foreground/55">
⌘K
</kbd>
<Kbd className="app-workspace-sidebar-search-shortcut">⌘K</Kbd>
</button>
</div>
+10 -8
View File
@@ -1,4 +1,6 @@
import { Input, InputNumber, Segmented, Select, Switch } from "antd";
import { Input, InputNumber, Select } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { SegmentedControl } from "@/components/ui/base/segmented-control";
import type { ReactNode } from "react";
import { defaultImageCapabilityConfig, defaultModelCapabilityConfig, normalizeModelCapabilityConfig, type ImageCapabilityConfig, type ModelCapabilityConfig, type TextCapabilityConfig, type VideoCapabilityConfig } from "@/lib/model-capabilities";
@@ -122,7 +124,7 @@ export function ModelCapabilityEditor({ value, onChange, protocol, capability =
</Field>
</ProtocolParameterCard>
<ProtocolParameterCard step="02" title="输出时长" description="定义可用秒数及默认时长">
<Segmented
<SegmentedControl
block
disabled={disabled}
value={profile.duration.selection}
@@ -234,7 +236,7 @@ export function ModelCapabilityEditor({ value, onChange, protocol, capability =
</div>
</CapabilityBlock>
<CapabilityBlock title="输出时长">
<Segmented
<SegmentedControl
block
disabled={disabled}
value={profile.duration.selection}
@@ -440,7 +442,7 @@ function ImageCapabilityEditor({ value, onChange, protocol, model, disabled, sec
<NumberField label="单次生成张数" value={profile.maxOutputs} min={1} disabled={disabled} onChange={(maxOutputs) => update({ maxOutputs: maxOutputs || 1 })} />
</ProtocolParameterCard>
<ProtocolParameterCard step="02" title="尺寸参数" description="定义尺寸字段、支持值与默认值">
<Segmented
<SegmentedControl
block
disabled={disabled}
value={profile.size.parameter}
@@ -543,7 +545,7 @@ function ImageCapabilityEditor({ value, onChange, protocol, model, disabled, sec
<NumberField label="单次生成张数" value={profile.maxOutputs} min={1} disabled={disabled} onChange={(maxOutputs) => update({ maxOutputs: maxOutputs || 1 })} />
</CapabilityBlock>
<CapabilityBlock title="尺寸参数">
<Segmented
<SegmentedControl
block
disabled={disabled}
value={profile.size.parameter}
@@ -708,11 +710,11 @@ function BooleanField({ label, value, disabled, onChange }: { label: string; val
<div className="flex shrink-0 items-center gap-3">
<label className="grid justify-items-center gap-1 text-[var(--fs-tiny)] text-foreground/45">
<span>支持</span>
<Switch aria-label={`${label}支持`} size="small" disabled={disabled} checked={value.supported} onChange={(supported) => onChange({ ...value, supported })} />
<Switch aria-label={`${label}支持`} size="sm" disabled={disabled} checked={value.supported} onChange={(supported) => onChange({ ...value, supported })} />
</label>
<label className="grid justify-items-center gap-1 text-[var(--fs-tiny)] text-foreground/45">
<span>默认</span>
<Switch aria-label={`${label}默认值`} size="small" disabled={disabled || !value.supported} checked={value.default} onChange={(defaultValue) => onChange({ ...value, default: defaultValue })} />
<Switch aria-label={`${label}默认值`} size="sm" disabled={disabled || !value.supported} checked={value.default} onChange={(defaultValue) => onChange({ ...value, default: defaultValue })} />
</label>
</div>
</div>
@@ -728,7 +730,7 @@ function ParameterField({ label, description, supported, disabled, onChange }: {
</div>
<label className="grid shrink-0 justify-items-center gap-1 text-[var(--fs-tiny)] text-foreground/45">
<span>支持</span>
<Switch aria-label={`${label}支持`} size="small" disabled={disabled} checked={supported} onChange={onChange} />
<Switch aria-label={`${label}支持`} size="sm" disabled={disabled} checked={supported} onChange={onChange} />
</label>
</div>
);
+48
View File
@@ -0,0 +1,48 @@
# Celadon UI 组件层
`web/src/components/ui/` 下的自研组件层。规范全文见仓库 `docs/plans/ui-design-system.mdx`(组件编写规范)与 `docs/plans/ui-kit-rollout-plan.mdx`(实施计划)、决策记录 `docs/adr/0008-ui-component-layer-antd-replacement.md`。本文是目录内速查版。
## 分层
| 层 | 目录 | 内容 |
| --- | --- | --- |
| base | `ui/base/` | 原语 + 基础件:`buttons/`、`badges/`、`kbd/`、`segmented-control/` 等 |
| product | `ui/product/` | 跨页面模式件:`empty-state/`、`callout/`、`loading-state/`、`section-card/`、`property-row/` |
| fx | `ui/fx/` | 特效件(原 `aceternity/*` 归位至此命名空间,引用随用随迁,不重写) |
| application | `ui/application/` | 产品块(P3 起):agent-chat、notification-center、app-shell 等 |
> 视觉数值唯一权威源:`composio-brand-package`(仓库根同级兄弟目录),消费规则见实施计划 §2.4。
## 目录与导出
- 每"族"一目录(`base/badges/`),族内按文件拆变体;族级 `index.ts` 汇总导出(组件 + `XxxVariants` 类型);**无全局 barrel**。
- 导入一律深路径 `@/components/ui/<layer>/<family>`;组件 `PascalCase`、文件 `kebab-case.tsx`、目录 `kebab-case/`。
- 变体用 cva(`class-variance-authority`)定义并从 `index.ts` 导出类型;`className` 经 `cn` 合并;ref 转发;根元素 `data-slot`。
## 硬性纪律
1. 样式只消费三层 token(`var(--*)` 或经 `@theme` 映射的工具类,如 `bg-surface`、`text-caption`、`text-status-success`);**禁止裸 `text-[Npx]`/`rounded-[Npx]`/十六进制色值**。字号/行高用注册排版工具类或 token 引用。
2. 明暗自适应由 CSS 变量完成,不读皮肤 ID;持久切换 `aria-pressed` + `data-active`,保留 `:focus-visible`,尊重 `prefers-reduced-motion`。
3. 图标以 lucide 组件引用传入(`icon={Move}`),尺寸/颜色由宿主组件决定,禁止调用方传 icon className 改尺寸。
4. 组件头注释注明:用途、消费 token 组、对标/接管对象(AntD 组件或参考系统组件)、明暗差异要点。
## 进库门槛
新组件必须满足其一:① ≥2 处真实重复(PR 附 grep 证据);② 隔离明确协议/交互契约。纯透传壳不进库。
## 当前族目录
- `base/kbd/` — Kbd(快捷键提示键帽)
- `base/badges/` — StatusBadge(状态点徽章;NodeTypeBadge 规划中)
- `base/buttons/` — IconButton / ToolButton(IconButton 含 ghost/default/outline/solid/danger 变体;ButtonGroup 规划中)
- `base/segmented-control/` — SegmentedControl(分段单选,thumb 滑动,泛型 + block/size)
- `base/checkbox/` — Checkbox + CheckboxGroup(原生 input + 自绘 glyph,checked/indeterminate/bare)
- `base/select/` — Select(RAC 单选壳,value/options/allowClear;多选/搜索 ComboBox 待建)
- `base/tooltip/` — Tooltip(RAC 浮层,AntD 8 向 placement 映射,title 空不渲染)
- `base/switch/` — Switch(button role=switch + data-state,checkedChildren 文本轨、loading、Form.Item 注入)
- `product/empty-state/` — EmptyState(空态占位)
- `product/callout/` — Callout(规划中,P0)
- `base/badges/` — StatusBadge(状态点徽章;NodeTypeBadge 规划中)
- `product/empty-state/` — EmptyState(空态占位)
- `product/callout/` — Callout(规划中,P0)
- `base/buttons/` — IconButton / ToolButton / ButtonGroup(规划中,P0)
@@ -0,0 +1 @@
export { StatusBadge, statusBadgeTone, statusBadgeVariants, type StatusBadgeProps } from "./status-badge";
@@ -0,0 +1,95 @@
import type { HTMLAttributes, ReactNode } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
/**
* StatusBadge — 语义状态徽章。
*
* 两种形态:
* - outline(默认):圆点 + 文本,圆点承担状态色,底色 bg-secondary/60。
* - filled:tone 色块纯文本胶囊(AntD Tag variant="filled" 观感),无圆点。
*
* 用途:展示实体的语义状态(成功/告警/失败/进行中/中性),如任务状态、同步状态、
* 节点状态;替代 AntD Tag 的状态标签场景与各页面私有实现。
* token:outline 圆点取 bg-status-{success|warning|error|loading}、中性取前景色;
* 底色 bg-secondary/60、文本 text-muted-foreground;filled 容器取
* bg-status-{tone}/15 + text-status-{tone}(中性取前景色混合)。
* 对标:AntD Tag(状态色标签,variant="filled" 对应 filled)、BoardUI status-dot(状态点)。
* 明暗:全部颜色走 token,明暗双主题自动适配。
*/
export const statusBadgeTone = cva("shrink-0 rounded-full", {
variants: {
tone: {
neutral: "bg-foreground/50",
success: "bg-status-success",
warning: "bg-status-warning",
error: "bg-status-error",
loading: "bg-status-loading",
},
},
defaultVariants: {
tone: "neutral",
},
});
export const statusBadgeVariants = cva("inline-flex items-center gap-1.5 whitespace-nowrap rounded-full", {
variants: {
variant: {
outline: "bg-secondary/60",
filled: "font-medium",
},
size: {
default: "px-2 py-0.5 text-caption",
sm: "gap-1 px-1.5 py-px text-tiny",
},
},
defaultVariants: {
variant: "outline",
size: "default",
},
});
/** filled 容器底色:tone 色 12–15% 淡底(中性为前景色 8%) */
const filledTintClass: Record<string, string> = {
neutral: "bg-foreground/8",
success: "bg-status-success/15",
warning: "bg-status-warning/15",
error: "bg-status-error/15",
loading: "bg-status-loading/15",
};
/** filled 文本色:tone 原色(中性为前景色 70%) */
const filledInkClass: Record<string, string> = {
neutral: "text-foreground/70",
success: "text-status-success",
warning: "text-status-warning",
error: "text-status-error",
loading: "text-status-loading",
};
export type StatusBadgeProps = HTMLAttributes<HTMLSpanElement> &
VariantProps<typeof statusBadgeTone> &
VariantProps<typeof statusBadgeVariants> & {
/** 徽章文本;状态语义由文本承担(无文本时组件退化为纯圆点/色块) */
label?: ReactNode;
};
export function StatusBadge({ tone, variant = "outline", size, label, className, children, ...props }: StatusBadgeProps) {
const resolvedTone = tone ?? "neutral";
return (
<span
data-slot="status-badge"
className={cn(statusBadgeVariants({ variant, size }), variant === "filled" && filledTintClass[resolvedTone], className)}
{...props}
>
{variant === "outline" ? (
<span aria-hidden className={cn(statusBadgeTone({ tone }), "size-1.5", tone === "loading" && "motion-safe:animate-pulse")} />
) : null}
{label != null ? (
<span className={cn("text-muted-foreground", variant === "filled" && filledInkClass[resolvedTone])}>{label}</span>
) : null}
{children}
</span>
);
}
@@ -0,0 +1,80 @@
import type { ButtonHTMLAttributes } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { Loader2, type LucideIcon } from "lucide-react";
import { cn } from "@/lib/utils";
/**
* IconButton — 纯图标按钮(正方形、尺寸档位、语义变体、loading 态)。
*
* 用途:面板/工具条里的图标触发按钮(新建、删除、收起、关闭等);替代 AntD
* Button `type="text"/"ghost" icon` 小尺寸场景与各页私有 icon-button。
* token:底 bg-surface-hover(ghost 悬停)/bg-surface-active(active 按压)、
* 图标 text-muted-foreground(danger 用 text-status-error)、焦点环 ring-ring;
* hover/active 态全用语义 token,无裸色。
* 图标契约:`icon` 传 lucide 组件引用,尺寸按 `size` 档位由本组件决定;禁止调用方
* 传 icon className 改尺寸。必须传 `aria-label`(纯图标无文本)。
* 对标:dbx ui/button variants(ghost/outline/destructive、icon-xs/sm/lg);
* AntD Button icon-only。
* 明暗:全部颜色走 token;active 按压底用 bg-surface-active,明暗自动适配。
*/
export const iconButtonVariants = cva(
[
"inline-flex shrink-0 items-center justify-center rounded-md",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
"disabled:pointer-events-none disabled:opacity-45",
"motion-safe:active:scale-[0.96]",
],
{
variants: {
variant: {
// 纯透明 + hover 浮底(最常用:面板/工具条)
ghost: "text-muted-foreground hover:bg-surface-hover hover:text-foreground active:bg-surface-active",
// 常驻浅底
default: "bg-surface-secondary text-muted-foreground hover:bg-surface-hover hover:text-foreground active:bg-surface-active",
// 描边
outline: "border border-border bg-transparent text-muted-foreground hover:bg-surface-hover hover:text-foreground",
// 危险(文本色常驻红)
danger: "text-status-error hover:bg-surface-hover active:bg-surface-active",
// 实心(中性黑底白图标,主操作;active 反转成白底黑字 + 内描边,供选中态使用)
solid: "bg-foreground text-background hover:opacity-85 active:opacity-75 data-[active=true]:bg-background data-[active=true]:text-foreground data-[active=true]:ring-1 data-[active=true]:ring-inset data-[active=true]:ring-border",
},
size: {
xs: "size-6 [&_svg]:size-3.5",
sm: "size-7 [&_svg]:size-4",
default: "size-8 [&_svg]:size-4",
lg: "size-9 [&_svg]:size-[18px]",
},
},
defaultVariants: {
variant: "ghost",
size: "default",
},
},
);
export type IconButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof iconButtonVariants> & {
/** lucide 图标组件引用 */
icon: LucideIcon;
/** loading:替换为 spinner 并禁用 */
loading?: boolean;
/** data-active 语义高亮(如开关组内当前项),仅装饰,不改变 aria-pressed */
active?: boolean;
};
export function IconButton({ variant, size, icon: Icon, loading = false, active = false, className, type = "button", disabled, ...props }: IconButtonProps) {
return (
<button
data-slot="icon-button"
type={type}
disabled={disabled || loading}
aria-busy={loading || undefined}
data-active={active || undefined}
className={cn(iconButtonVariants({ variant, size }), className)}
{...props}
>
{loading ? <Loader2 aria-hidden className="animate-spin" /> : <Icon aria-hidden />}
</button>
);
}
@@ -0,0 +1,2 @@
export { IconButton, iconButtonVariants, type IconButtonProps } from "./icon-button";
export { ToolButton, toolButtonVariants, type ToolButtonProps } from "./tool-button";
@@ -0,0 +1,114 @@
import type { ButtonHTMLAttributes, ReactNode } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { Loader2 } from "lucide-react";
import { cn } from "@/lib/utils";
/**
* ToolButton — 工具激活态按钮(持久切换,可展开面板)。
*
* 用途:工具类按钮——画布工具 Dock、面板工具组:被按下时保持高亮(aria-pressed),
* 或展开浮层面板(expands → aria-expanded)。active 持久态与 hover/按压态区分
* 明显,配合画布 ToolDefinition(active/expands/disabled 谓词)渲染。
* token:active 态 bg-surface-active + text-foreground,常态 bg-transparent +
* text-muted-foreground,hover bg-surface-hover;焦点环 ring-ring;
* danger 态激活文字用 text-status-error。间距由 size 档位控制。
* 图标契约:`icon` 传 ReactNode(内联 JSX 或组件元素),与画布 tool-registry 的
* ToolDefinition.icon 字段一致(icons 是内联 JSX 如 <Undo2 />);尺寸由本组件
* [&_svg] 规则统一控制。禁传 icon className 改尺寸。
* 对标:接管画布工具 Dock 中按钮渲染(aria-pressed 语义);AntD Tooltip+Button
* 组合的工具按钮场景。参考 BoardUI tool 切换语义。
* 明暗:全部颜色走 token;active 用按压底语义 token,明暗自动适配。
*/
export const toolButtonVariants = cva(
[
"inline-flex select-none items-center justify-center gap-1.5 rounded-md",
"font-medium transition-colors",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
"disabled:pointer-events-none disabled:opacity-45",
],
{
variants: {
variant: {
// 工具条/面板内常规(常态透明,激活常驻底)
ghost: "text-muted-foreground hover:bg-surface-hover hover:text-foreground",
// 常驻浅底(面板内分组工具)
default: "bg-surface-secondary text-muted-foreground hover:bg-surface-hover hover:text-foreground",
},
size: {
xs: "h-6 px-1.5 text-tiny [&_svg]:size-3.5",
sm: "h-7 px-2 text-caption [&_svg]:size-4",
default: "h-8 px-2.5 text-caption [&_svg]:size-4",
lg: "h-9 px-3 text-body [&_svg]:size-[18px]",
},
tone: {
default: "",
danger: "data-[active=true]:text-status-error",
},
active: {
true: "",
false: "",
},
},
compoundVariants: [
{
variant: ["ghost", "default"],
active: true,
className: "bg-surface-active text-foreground hover:text-foreground",
},
],
defaultVariants: {
variant: "ghost",
size: "default",
tone: "default",
active: false,
},
},
);
export type ToolButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &
VariantProps<typeof toolButtonVariants> & {
/** 图标内容:ReactNode(内联 JSX,与 tool-registry ToolDefinition.icon 对齐) */
icon?: ReactNode;
/** 持久激活态(映射 aria-pressed=true) */
active?: boolean;
/** 面板展开型工具:active 走 aria-expanded 语义而非 pressed */
expands?: boolean;
loading?: boolean;
/** 显式文本标签(提供时按带标签布局渲染) */
label?: ReactNode;
};
export function ToolButton({
variant,
size,
tone,
icon,
active = false,
expands = false,
loading = false,
label,
className,
type = "button",
disabled,
...props
}: ToolButtonProps) {
const pressed = !expands && active;
const expanded = expands && active;
return (
<button
data-slot="tool-button"
type={type}
disabled={disabled || loading}
aria-pressed={pressed || undefined}
aria-expanded={expanded || undefined}
aria-busy={loading || undefined}
data-active={active || undefined}
className={cn(toolButtonVariants({ variant, size, tone, active }), className)}
{...props}
>
{loading ? <Loader2 aria-hidden className="animate-spin" /> : icon}
{label != null ? <span>{label}</span> : null}
</button>
);
}
@@ -0,0 +1,61 @@
import type { ReactNode } from "react";
import { cn } from "@/lib/utils";
import { Checkbox } from "./checkbox";
/**
* CheckboxGroup — 复选框组(自研,原生 input,无依赖)。
*
* - 容器不预设布局:调用方用 className 决定排列(垂直传 `flex flex-col gap-1.5`,
* 网格传 `grid grid-cols-2 gap-2`),与 AntD Checkbox.Group 行为一致。
* - 受控 value: V[] + onChange(values),泛型覆盖枚举/字符串场景;
* 可直接替换 AntD Checkbox.Group(options/value/onChange/disabled)。
* - 对标:AntD Checkbox.Group。
*/
export interface CheckboxGroupOption<V extends string = string> {
value: V;
label: ReactNode;
disabled?: boolean;
}
export interface CheckboxGroupProps<V extends string = string> {
value?: V[];
onChange?: (values: V[]) => void;
options: Array<CheckboxGroupOption<V>>;
/** 组整体禁用 */
disabled?: boolean;
ariaLabel?: string;
className?: string;
}
export function CheckboxGroup<V extends string = string>({
value = [],
onChange,
options,
disabled = false,
ariaLabel,
className,
}: CheckboxGroupProps<V>) {
const toggle = (optionValue: V, checked: boolean) => {
if (disabled) return;
const next = checked ? [...value, optionValue] : value.filter((item) => item !== optionValue);
onChange?.(next);
};
return (
<div data-slot="checkbox-group" role="group" aria-label={ariaLabel} className={className}>
{options.map((option) => (
<Checkbox
key={option.value}
checked={value.includes(option.value)}
disabled={disabled || option.disabled}
onChange={(event) => toggle(option.value, event.target.checked)}
>
{option.label}
</Checkbox>
))}
</div>
);
}
@@ -0,0 +1,126 @@
import { useLayoutEffect, useRef, type InputHTMLAttributes, type ReactNode } from "react";
import { cn } from "@/lib/utils";
/**
* Checkbox — 复选框(自研,原生 input + 自绘 glyph,无依赖)。
*
* 设计约束(对齐 ui/README 与 ADR-0008):
* - 原生 <input type="checkbox"> 承载语义与键盘(简单件不走 react-aria-components);
* hidden input + peer 视觉盒::focus-visible ring 落在盒上,aria 状态由原生保证。
* - 只消费三层 token:box border-border / 选中 bg-foreground + text-background(中性反色),
* hover 加深 border、焦点 ring-ring、禁用 opacity;无裸色。
* - indeterminate:非受控 DOM 属性,useLayoutEffect 同步到 input.indeterminate
* (样式经 data-indeterminate 落在视觉盒上)。
* - API 对齐 AntD Checkbox:checked/defaultChecked/disabled/indeterminate/onChange/children,
* 可直接替换;value 传 string 时随原生 input 提交。
* 对标:AntD Checkbox;boardui base/checkbox。
*/
export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
/** 复选框尺寸(视觉盒)。默认 md。 */
size?: "sm" | "md";
/** 半选态(视觉 + input.indeterminate) */
indeterminate?: boolean;
/** 右侧标签 */
children?: ReactNode;
/** bare:不渲染 label 根(外层已由调用方提供 label/点击区时用,避免 label 嵌套) */
bare?: boolean;
/** 类名附加到根元素 */
className?: string;
}
const BOX_SIZE: Record<"sm" | "md", string> = {
sm: "size-3.5 rounded-[3px]",
md: "size-4 rounded",
};
export function Checkbox({
size = "md",
indeterminate = false,
children,
bare = false,
className,
disabled,
checked,
...props
}: CheckboxProps) {
const inputRef = useRef<HTMLInputElement | null>(null);
useLayoutEffect(() => {
if (inputRef.current) {
inputRef.current.indeterminate = indeterminate;
}
}, [indeterminate]);
const inner = (
<>
<input
ref={inputRef}
type="checkbox"
disabled={disabled}
checked={checked}
className="peer sr-only"
{...props}
/>
<span
aria-hidden="true"
data-indeterminate={indeterminate || undefined}
className={cn(
"flex shrink-0 items-center justify-center border transition-colors motion-reduce:transition-none",
"border-border text-background",
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1 peer-focus-visible:ring-offset-background",
"peer-checked:border-foreground peer-checked:bg-foreground",
"peer-disabled:opacity-45",
!checked && !indeterminate && "bg-transparent group-hover/checkbox:border-foreground/50",
BOX_SIZE[size],
)}
>
{/* checked 勾(indeterminate 时隐藏,改显短横线) */}
<svg
viewBox="0 0 12 12"
className={cn("size-3 stroke-current stroke-[2.2]", indeterminate ? "hidden" : "block")}
>
<path d="M2.5 6.5 L5 9 L9.5 3.5" fill="none" strokeLinecap="round" strokeLinejoin="round" />
</svg>
{/* indeterminate 短横线 */}
<svg
viewBox="0 0 12 12"
className={cn("size-3 stroke-current stroke-[2]", indeterminate ? "block" : "hidden")}
>
<path d="M2.8 6 H9.2" fill="none" strokeLinecap="round" />
</svg>
</span>
</>
);
if (bare) {
return (
<span
className={cn(
"group/checkbox inline-flex items-center",
disabled && "cursor-not-allowed",
className,
)}
>
{inner}
</span>
);
}
return (
<label
data-slot="checkbox"
className={cn(
"group/checkbox inline-flex cursor-pointer select-none items-center gap-2 align-middle",
disabled && "cursor-not-allowed",
className,
)}
>
{inner}
{children !== undefined && (
<span className={cn("text-sm leading-none text-foreground", disabled && "opacity-60")}>{children}</span>
)}
</label>
);
}
@@ -0,0 +1,2 @@
export { Checkbox, type CheckboxProps } from "./checkbox";
export { CheckboxGroup, type CheckboxGroupProps, type CheckboxGroupOption } from "./checkbox-group";
+1
View File
@@ -0,0 +1 @@
export { Kbd, type KbdProps } from "./kbd";
+32
View File
@@ -0,0 +1,32 @@
import type { HTMLAttributes } from "react";
import { cn } from "@/lib/utils";
/**
* Kbd — 快捷键提示键帽。
*
* 用途:展示键盘快捷键(⌘K、Shift+Enter、Esc 等),纯展示,非交互。
* token:字号 `fs-tiny`(text-tiny)、字体 font-mono、背景 bg-background(半透明)、
* 边框 var(--workspace-border)、文本 text-foreground。
* 对标:接管私有实现 workspace-sidebar-nav.tsx / workspace-command-palette.tsx /
* canvas 快捷键弹窗中的 `<kbd>` 重复样式;形态参考 shadcn kbd 与 BoardUI kbd。
* 明暗:背景为背景色半透明 + 主题边框,明暗双主题自动适配,无额外差异。
*/
export interface KbdProps extends HTMLAttributes<HTMLElement> {}
export function Kbd({ className, children, ...props }: KbdProps) {
return (
<kbd
data-slot="kbd"
className={cn(
"inline-flex h-5 shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm",
"border border-[color:var(--workspace-border)] bg-background/60 px-1.5",
"font-mono text-tiny font-medium text-foreground/60",
className,
)}
{...props}
>
{children}
</kbd>
);
}
@@ -0,0 +1 @@
export { SegmentedControl, type SegmentedControlProps, type SegmentedOption, type SegmentedSize } from "./segmented-control";
@@ -0,0 +1,191 @@
import { useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
/**
* SegmentedControl — 分段控制器(自研,无依赖)。
*
* 设计约束(对齐 ui/README 与 ADR-0008):
* - 只消费三层 token 工具类(surface-tertiary / surface-strong / foreground / muted-foreground / ring …),
* 不写死任何色值;明暗自适应随主题 token。
* - 选中项 thumb 走 bg-surface-strong(light #fff / dark #2a2a2a 抬升面)。
* - 键盘:radio 组 roving tabindex(←/→/Home/End,自动跳过禁用项)。
* - thumb 位置 useLayoutEffect 测量 + ResizeObserver 兜底;motion-reduce 下不播动画。
* - API 对齐 AntD Segmented(value/onChange/options/block/size/disabled),
* 可直接置于 antd Form.Item(Form 注入 value/onChange,props 同名兼容)。
* - icon 节点尺寸由调用方控制(与 AntD options.icon 行为一致),用 currentColor 跟随文字色。
*/
export type SegmentedSize = "sm" | "md";
export interface SegmentedOption<V extends string = string> {
value: V;
/** 文本标签(icon-only 时省略) */
label?: ReactNode;
/** 图标节点(与 label 同给时渲染在左侧,尺寸自控) */
icon?: ReactNode;
disabled?: boolean;
/** 原生 title */
title?: string;
}
export interface SegmentedControlProps<V extends string = string> {
value?: V;
onChange?: (value: V) => void;
options: Array<SegmentedOption<V>>;
size?: SegmentedSize;
/** 填满父容器宽度(项均分) */
block?: boolean;
/** 整体禁用 */
disabled?: boolean;
ariaLabel?: string;
className?: string;
}
const SIZE_CLASS: Record<SegmentedSize, { track: string; thumb: string; item: string }> = {
sm: {
track: "h-7 rounded-md p-0.5",
thumb: "rounded-sm",
item: "px-2.5 text-xs",
},
md: {
track: "h-8 rounded-lg p-0.5",
thumb: "rounded-md",
item: "px-3 text-sm",
},
};
export function SegmentedControl<V extends string = string>({
value,
onChange,
options,
size = "md",
block = false,
disabled = false,
ariaLabel,
className = "",
}: SegmentedControlProps<V>) {
const trackRef = useRef<HTMLDivElement | null>(null);
const itemRefs = useRef<Array<HTMLButtonElement | null>>([]);
const [thumb, setThumb] = useState<{ left: number; width: number } | null>(null);
const selectedIndex = options.findIndex((option) => option.value === value);
/** 无选中项时兜底首个可用项,保证 roving tabindex 下键盘始终可达 */
const focusableIndex =
selectedIndex >= 0 ? selectedIndex : options.findIndex((option) => !option.disabled);
useLayoutEffect(() => {
const track = trackRef.current;
if (!track) return;
const measure = () => {
const target = itemRefs.current[selectedIndex];
if (!target) {
setThumb(null);
return;
}
setThumb({ left: target.offsetLeft, width: target.offsetWidth });
};
measure();
const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
observer?.observe(track);
return () => observer?.disconnect();
}, [selectedIndex, options, value]);
const select = (next: V, nextIndex: number) => {
if (disabled || options[nextIndex]?.disabled) return;
onChange?.(next);
itemRefs.current[nextIndex]?.focus();
};
const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {
if (disabled || !["ArrowRight", "ArrowLeft", "Home", "End"].includes(event.key)) return;
event.preventDefault();
if (event.key === "Home") {
const first = options.findIndex((option) => !option.disabled);
if (first >= 0) select(options[first].value, first);
return;
}
if (event.key === "End") {
let last = -1;
options.forEach((option, optionIndex) => {
if (!option.disabled) last = optionIndex;
});
if (last >= 0) select(options[last].value, last);
return;
}
const isPrev = event.key === "ArrowLeft";
for (let step = 1; step <= options.length; step += 1) {
const candidate = (index + (isPrev ? -step : step) + options.length * 2) % options.length;
if (!options[candidate].disabled) {
select(options[candidate].value, candidate);
return;
}
}
};
const itemBase =
"relative z-10 inline-flex select-none items-center justify-center gap-1.5 whitespace-nowrap font-medium outline-none transition-colors motion-reduce:transition-none " +
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 ";
return (
<div
ref={trackRef}
role="radiogroup"
aria-label={ariaLabel}
className={[
"relative inline-flex bg-surface-tertiary",
SIZE_CLASS[size].track,
block ? "flex w-full" : "",
disabled ? "opacity-60" : "",
className,
].join(" ")}
>
{thumb !== null && !disabled && (
<span
aria-hidden="true"
className={[
"pointer-events-none absolute inset-y-0.5 z-0 bg-surface-strong transition-[left,width] duration-200 ease-out motion-reduce:transition-none",
SIZE_CLASS[size].thumb,
].join(" ")}
style={{ left: thumb.left, width: thumb.width }}
/>
)}
{options.map((option, index) => {
const selected = index === selectedIndex && !disabled;
return (
<button
key={option.value}
ref={(element) => {
itemRefs.current[index] = element;
}}
type="button"
role="radio"
aria-checked={selected}
aria-label={option.label ? undefined : option.title ?? option.value}
title={option.title}
disabled={disabled || option.disabled}
tabIndex={index === focusableIndex ? 0 : -1}
onClick={() => {
if (option.disabled) return;
onChange?.(option.value);
}}
onKeyDown={(event) => onKeyDown(event, index)}
className={[
itemBase,
SIZE_CLASS[size].item,
SIZE_CLASS[size].thumb,
block ? "flex-1" : "",
option.disabled
? "cursor-not-allowed text-muted-foreground/40"
: selected
? "cursor-default text-foreground"
: "text-muted-foreground hover:bg-surface-hover hover:text-foreground",
].join(" ")}
>
{option.icon}
{option.label}
</button>
);
})}
</div>
);
}
@@ -0,0 +1 @@
export { Select, type SelectOption, type SelectProps, type SelectSize } from "./select";
@@ -0,0 +1,193 @@
import { useLayoutEffect, useRef, useState, type ReactNode } from "react";
import {
Button as AriaButton,
ListBox as AriaListBox,
ListBoxItem as AriaListBoxItem,
Popover as AriaPopover,
Select as AriaSelect,
} from "react-aria-components";
import { Check, ChevronDown, X } from "lucide-react";
import { cn } from "@/lib/utils";
/**
* Select — 下拉选择(自研,react-aria-components 单选壳,无远程/多选)。
*
* - API 对齐 AntD Select 的单选子集:value/onChange(options 值)/options/placeholder/
* disabled/allowClear/size/className,可直接替换纯单选场景;可直接置于 antd Form.Item。
* - 浮层定位、进出场、焦点与类型选择由 RAC 承担(ADR-0008:复杂控件以 RAC 为无障碍地基)。
* - Popover isNonModal:避免 RAC modal 滚动锁把页面滚动条锁死(同 boardui 注释);
* isDismissable 与 isNonModal 互斥,故外部 dismiss 手动处理(全局 pointerdown capture)。
* - 样式只吃语义 token:trigger border-border/bg-background/hover:border-foreground/40、
* popover bg-surface-strong + hairline、item hover:bg-surface-hover、选中 Check 前景色,无裸色。
* - 范围外(本批不做,后续补):mode="multiple"/"tags"、showSearch(需 ComboBox)、
* loading、labelInValue、maxCount、suffixIcon。
* 对标:AntD Select(单选);boardui base/select。
*/
export type SelectSize = "sm" | "md";
export interface SelectOption<V extends string = string> {
value: V;
label: ReactNode;
disabled?: boolean;
/** 原生 title */
title?: string;
}
export interface SelectProps<V extends string = string> {
value?: V;
onChange?: (value: V) => void;
options?: Array<SelectOption<V>>;
placeholder?: string;
disabled?: boolean;
allowClear?: boolean;
size?: SelectSize;
ariaLabel?: string;
className?: string;
}
const TRIGGER_CLASS: Record<SelectSize, string> = {
sm: "h-7 text-xs",
md: "h-8 text-sm",
};
export function Select<V extends string = string>({
value,
onChange,
options = [],
placeholder,
disabled = false,
allowClear = false,
size = "md",
ariaLabel,
className,
}: SelectProps<V>) {
const triggerRef = useRef<HTMLButtonElement | null>(null);
const popoverRef = useRef<HTMLDivElement | null>(null);
const [open, setOpen] = useState(false);
const [popoverWidth, setPopoverWidth] = useState<number | null>(null);
useLayoutEffect(() => {
const measure = () => {
const width = triggerRef.current?.offsetWidth;
if (width) setPopoverWidth(width + 2);
};
measure();
const observer = typeof ResizeObserver !== "undefined" ? new ResizeObserver(measure) : null;
if (observer && triggerRef.current) observer.observe(triggerRef.current);
return () => observer?.disconnect();
}, [open]);
useLayoutEffect(() => {
if (!open) return;
const onPointerDown = (event: PointerEvent) => {
const target = event.target as Node;
const insideTrigger = triggerRef.current?.contains(target);
const insidePopover = popoverRef.current?.contains(target);
if (!insideTrigger && !insidePopover) setOpen(false);
};
window.addEventListener("pointerdown", onPointerDown, true);
return () => window.removeEventListener("pointerdown", onPointerDown, true);
}, [open]);
const selected = options.find((option) => option.value === value);
const displayLabel = selected?.label ?? value;
const clear = () => {
setOpen(false);
onChange?.(undefined as unknown as V);
};
return (
<AriaSelect
isDisabled={disabled}
isOpen={open}
onOpenChange={setOpen}
selectedKey={value ?? undefined}
onSelectionChange={(key) => {
setOpen(false);
if (key != null) onChange?.(key as V);
}}
aria-label={ariaLabel}
className={cn("inline-flex w-full", className)}
>
<AriaButton
ref={triggerRef}
className={cn(
"flex w-full cursor-pointer items-center justify-between gap-1.5 rounded-md border border-border bg-background px-2.5 font-normal text-foreground outline-none transition-colors motion-reduce:transition-none",
"hover:border-foreground/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
"disabled:cursor-not-allowed disabled:opacity-55",
open && "border-foreground/60",
TRIGGER_CLASS[size],
)}
>
<span className={cn("min-w-0 flex-1 truncate text-left", displayLabel === undefined && "text-muted-foreground")}>
{displayLabel === undefined ? placeholder : displayLabel}
</span>
{allowClear && value !== undefined && !disabled && (
<span
role="button"
tabIndex={-1}
aria-label="清空选择"
className="shrink-0 cursor-pointer rounded p-0.5 text-muted-foreground hover:bg-surface-hover hover:text-foreground"
onPointerDown={(event) => event.stopPropagation()}
onClick={(event) => {
event.stopPropagation();
clear();
}}
>
<X className="size-3.5" />
</span>
)}
<ChevronDown
aria-hidden="true"
className={cn(
"size-4 shrink-0 text-muted-foreground transition-transform duration-200 motion-reduce:transition-none",
open && "rotate-180",
)}
/>
</AriaButton>
<AriaPopover
ref={popoverRef}
isNonModal
placement="bottom"
offset={4}
style={popoverWidth ? { width: popoverWidth } : undefined}
className={cn(
"z-50 rounded-lg border border-border bg-surface-strong p-1 shadow-lg",
"ra-pop-in",
)}
>
<AriaListBox aria-label={ariaLabel ?? placeholder ?? "选项"} className="max-h-60 overflow-auto outline-none">
{options.map((option) => (
<AriaListBoxItem
key={option.value}
id={option.value}
textValue={typeof option.label === "string" ? option.label : option.value}
isDisabled={option.disabled}
className={({ isFocused, isSelected, isDisabled: itemDisabled }) =>
cn(
"flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none transition-colors motion-reduce:transition-none",
"focus-visible:bg-surface-hover",
(isFocused || isSelected) && "bg-surface-hover",
isSelected ? "font-medium text-foreground" : "text-muted-foreground",
itemDisabled && "cursor-not-allowed opacity-50",
)
}
>
{({ isSelected }) => (
<>
<span className={cn("min-w-0 flex-1 truncate")} title={option.title}>
{option.label}
</span>
{isSelected && <Check className="size-3.5 shrink-0 text-foreground" />}
</>
)}
</AriaListBoxItem>
))}
</AriaListBox>
</AriaPopover>
</AriaSelect>
);
}
@@ -0,0 +1 @@
export { Switch, type SwitchProps } from "./switch";
@@ -0,0 +1,156 @@
import { useState, type ButtonHTMLAttributes, type ReactNode } from "react";
import { cn } from "@/lib/utils";
/**
* Switch — 开关(自研,button role=switch,无依赖)。
*
* 设计约束(对齐 ui/README 与 ADR-0008):
* - <button type="button" role="switch" aria-checked> 承载语义与键盘(Space/Enter 原生),
* :focus-visible outline 落自身;无裸色、只消费三层 token。
* - 开 = bg-foreground + 反色 thumb(bg-background 语义对齐 Checkbox 选中态),
* 关 = bg-surface-tertiary + 发丝内描边 + surface-strong 抬升 thumb(同 SegmentedControl 选中面)。
* - thumb 滑动用 translate-x 位移(尺寸档固定行程),motion-reduce 关闭过渡。
* - data-state="on|off" 暴露给上下文 CSS 覆盖(admin 语义绿等保留于页面层,不侵入组件)。
* - API 对齐 AntD Switch:checked/defaultChecked/onChange/disabled/size/checkedChildren/
* unCheckedChildren/loading + aria-* 透传;受控与否由 checked 是否传入决定,
* onChange(checked) 单参。顶层组件接收 checked/onChange → Form.Item valuePropName="checked" 注入兼容。
* 对标:AntD Switch;boardui base/switch。
*/
export interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type" | "size" | "onChange"> {
/** 开关尺寸。默认 md;AntD small → sm 映射。 */
size?: "sm" | "md";
/** 受控:是否开启 */
checked?: boolean;
/** 非受控初始值 */
defaultChecked?: boolean;
/** loading:拇指位换转圈,忽略点击(视觉保留 checked 态) */
loading?: boolean;
/** 开启时轨道内左侧文案(2 字宽度档) */
checkedChildren?: ReactNode;
/** 关闭时轨道内右侧文案 */
unCheckedChildren?: ReactNode;
/** 变化回调(AntD 同签名:仅布尔参) */
onChange?: (checked: boolean) => void;
}
/** 几何档:轨道尺寸与 thumb 行程(thumb 用 left-0.5 起始 + translate-x 档位) */
const SWITCH_SIZE: Record<
"sm" | "md",
{ root: string; thumbPlain: string; thumbText: string; hasTextRoot: string }
> = {
sm: {
root: "h-5 w-8 rounded-full",
thumbPlain: "size-3.5 data-[state=on]:translate-x-3.5",
thumbText: "size-3.5 data-[state=on]:translate-x-3.5",
hasTextRoot: "",
},
md: {
root: "h-6 w-11 rounded-full",
thumbPlain: "size-4 data-[state=on]:translate-x-6",
thumbText: "size-4 data-[state=on]:translate-x-9",
hasTextRoot: "w-14",
},
};
export function Switch({
size = "md",
checked: checkedProp,
defaultChecked = false,
loading = false,
checkedChildren,
unCheckedChildren,
onChange,
disabled,
className,
"aria-label": ariaLabel,
...props
}: SwitchProps) {
const [innerChecked, setInnerChecked] = useState(defaultChecked);
const controlled = checkedProp !== undefined;
const checked = controlled ? checkedProp : innerChecked;
const hasText = checkedChildren !== undefined || unCheckedChildren !== undefined;
const handleClick = () => {
if (disabled || loading) {
return;
}
const next = !checked;
if (!controlled) {
setInnerChecked(next);
}
onChange?.(next);
};
const geometry = SWITCH_SIZE[size];
const thumbClass = hasText ? geometry.thumbText : geometry.thumbPlain;
return (
<button
type="button"
role="switch"
data-slot="switch"
data-state={checked ? "on" : "off"}
aria-checked={checked}
aria-label={ariaLabel}
aria-busy={loading || undefined}
disabled={disabled}
onClick={handleClick}
className={cn(
"relative inline-flex shrink-0 select-none items-center align-middle transition-colors motion-reduce:transition-none",
"data-[state=on]:bg-foreground",
"data-[state=off]:bg-surface-tertiary data-[state=off]:ring-1 data-[state=off]:ring-inset data-[state=off]:ring-foreground/15",
"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
"disabled:cursor-not-allowed disabled:opacity-45",
geometry.root,
hasText && size === "md" && geometry.hasTextRoot,
className,
)}
{...props}
>
{/* 关态文案(右侧) */}
{unCheckedChildren !== undefined ? (
<span
aria-hidden="true"
className={cn(
"absolute top-1/2 right-1.5 -translate-y-1/2 text-xs leading-none font-medium transition-opacity motion-reduce:transition-none",
checked ? "text-foreground/55 opacity-0" : "text-foreground/55 opacity-100",
)}
>
{unCheckedChildren}
</span>
) : null}
{/* 开态文案(左侧,反色) */}
{checkedChildren !== undefined ? (
<span
aria-hidden="true"
className={cn(
"absolute top-1/2 left-1.5 -translate-y-1/2 text-xs leading-none font-medium transition-opacity motion-reduce:transition-none",
checked ? "text-background opacity-100" : "text-background opacity-0",
)}
>
{checkedChildren}
</span>
) : null}
{/* thumb / loading 转圈 */}
{loading ? (
<span
aria-hidden="true"
className={cn(
"absolute inset-0 m-auto size-3.5 animate-spin rounded-full border-[1.5px] border-current border-t-transparent",
checked ? "text-background" : "text-foreground/60",
)}
/>
) : (
<span
aria-hidden="true"
className={cn(
"sc-switch-thumb absolute left-0.5 top-1/2 -translate-y-1/2 rounded-full bg-surface-strong border border-border/80 transition-transform duration-200 ease-out motion-reduce:transition-none",
thumbClass,
)}
/>
)}
</button>
);
}
@@ -0,0 +1 @@
export { Tooltip, type TooltipPlacement, type TooltipProps } from "./tooltip";
@@ -0,0 +1,59 @@
import type { ReactNode } from "react";
import { Tooltip as RACTooltip, TooltipTrigger, type Placement } from "react-aria-components";
import { cn } from "@/lib/utils";
/**
* Tooltip — 气泡提示(自研,react-aria-components overlay)。
*
* - API 对齐 AntD Tooltip(title/placement/children),title 为空时不渲染浮层。
* - 浮层定位、进出场、焦点管理由 RAC 承担(ADR-0008:复杂浮层以 RAC 为无障碍地基)。
* - 样式只吃语义 token:bg-surface-strong(light #fff / dark #2a2a2a)+ text-foreground +
* border-border hairline,无裸色;motion 走 RAC 动画类 + motion-reduce 关停。
* - trigger 包一层 inline-flex span:保证 RAC ref 定位可用(children 可为任意组件)。
* - placement 映射 AntD → RAC(topLeft→top left …)。
* 对标:AntD Tooltip;boardui base/tooltip。
*/
export type TooltipPlacement = "top" | "topLeft" | "topRight" | "bottom" | "bottomLeft" | "bottomRight" | "left" | "right";
const PLACEMENT_MAP: Record<TooltipPlacement, Placement> = {
top: "top",
topLeft: "top left",
topRight: "top right",
bottom: "bottom",
bottomLeft: "bottom left",
bottomRight: "bottom right",
left: "left",
right: "right",
};
export interface TooltipProps {
title?: ReactNode;
placement?: TooltipPlacement;
/** 悬停延迟 ms(默认 350,贴近 AntD mouseEnterDelay) */
delay?: number;
className?: string;
children: ReactNode;
}
export function Tooltip({ title, placement = "top", delay = 350, className, children }: TooltipProps) {
if (!title) return <>{children}</>;
return (
<TooltipTrigger delay={delay}>
<span className="inline-flex">{children}</span>
<RACTooltip
placement={PLACEMENT_MAP[placement]}
offset={6}
className={cn(
"z-50 max-w-64 rounded-md border border-border bg-surface-strong px-2 py-1 text-xs leading-relaxed text-foreground shadow-md",
"ra-pop-in",
className,
)}
>
{title}
</RACTooltip>
</TooltipTrigger>
);
}
@@ -0,0 +1,81 @@
import type { HTMLAttributes, ReactNode } from "react";
import { AlertTriangle, CheckCircle2, Info, X, XCircle, type LucideIcon } from "lucide-react";
import { IconButton } from "@/components/ui/base/buttons";
import { cn } from "@/lib/utils";
/**
* Callout — 语义提示横幅(图标 + 标题 + 正文 + 可选操作)。
*
* 用途:页面/面板内的轻量提示(信息/成功/告警/错误),可带操作按钮;替代 AntD
* Alert 的静态展示场景与页面私有提示块。
* token:底 bg-surface-secondary、边框 var(--workspace-border)/border-border、
* 标题 text-foreground、正文 text-muted-foreground、tone 图标色
* text-status-{success|warning|error}(info/default 用 text-muted-foreground)。
* 对标:AntD Alert;dbx ErrorBanner(错误横幅场景);形态参考 shadcn alert。
* 明暗:全部颜色走 token,明暗双主题自动适配。
*/
export type CalloutTone = "info" | "success" | "warning" | "error";
const calloutIconByTone: Record<CalloutTone, LucideIcon> = {
info: Info,
success: CheckCircle2,
warning: AlertTriangle,
error: XCircle,
};
export interface CalloutProps extends Omit<HTMLAttributes<HTMLDivElement>, "title"> {
/** 语义 tone:default 等同 info(中性) */
tone?: CalloutTone | "default";
title?: ReactNode;
/** 自定义图标组件引用;默认按 tone 取 Info/CheckCircle2/AlertTriangle/XCircle */
icon?: LucideIcon;
action?: ReactNode;
/** 显示右上角关闭按钮(closable);点击后由调用方移除自身 */
onClose?: () => void;
/** 关闭按钮的无障碍标签 */
closeLabel?: string;
}
export function Callout({ tone = "default", title, icon, action, onClose, closeLabel = "关闭", className, children, ...props }: CalloutProps) {
const resolved = tone === "default" ? "info" : tone;
const Icon = icon ?? calloutIconByTone[resolved];
return (
<div
data-slot="callout"
data-tone={resolved}
className={cn(
"flex items-start gap-2.5 rounded-lg border border-border bg-surface-secondary px-3.5 py-2.5",
className,
)}
{...props}
>
<Icon
aria-hidden
strokeWidth={1.75}
className={cn(
"mt-px size-4 shrink-0",
resolved === "success" && "text-status-success",
resolved === "warning" && "text-status-warning",
resolved === "error" && "text-status-error",
resolved === "info" && "text-muted-foreground",
)}
/>
<div className="min-w-0 flex-1">
{title != null ? <p className="text-caption font-medium text-foreground">{title}</p> : null}
{children != null ? (
<div className={cn("text-caption leading-relaxed text-muted-foreground", title != null && "mt-0.5")}>
{children}
</div>
) : null}
</div>
{action != null || onClose != null ? (
<div className="flex shrink-0 items-start gap-1">
{action != null ? <div className="shrink-0">{action}</div> : null}
{onClose != null ? <IconButton variant="ghost" size="sm" icon={X} aria-label={closeLabel} onClick={onClose} /> : null}
</div>
) : null}
</div>
);
}
@@ -0,0 +1 @@
export { Callout, type CalloutProps, type CalloutTone } from "./callout";
@@ -0,0 +1,60 @@
import type { HTMLAttributes, ReactNode } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { Inbox, type LucideIcon } from "lucide-react";
import { cn } from "@/lib/utils";
/**
* EmptyState — 空态占位(图标 + 标题 + 说明 + 可选操作)。
*
* 用途:列表/面板/画布无数据或零结果时的引导占位;替代 AntD Empty 的使用场景
* (搜索零结果、资源为空、列表为空等页面私有实现)。
* token:图标圈底 bg-secondary 半透明、图标色 text-muted-foreground、标题
* text-foreground、说明 text-muted-foreground、字号 fs-body/fs-caption;间距走 --space-*。
* 图标契约:`icon` 传 lucide 组件引用(默认 Inbox),尺寸/颜色由本组件用 token 决定,
* 禁止调用方传 icon className 改尺寸。
* 对标:AntD Empty;形态参考 BoardUI empty-state。
* 明暗:全部颜色走 token,明暗双主题自动适配。
*/
export const emptyStateVariants = cva("flex flex-col items-center justify-center text-center", {
variants: {
size: {
default: "gap-2.5 py-12",
compact: "gap-1.5 py-6",
},
},
defaultVariants: {
size: "default",
},
});
export type EmptyStateProps = HTMLAttributes<HTMLDivElement> &
VariantProps<typeof emptyStateVariants> & {
/** lucide 图标组件引用;默认 Inbox */
icon?: LucideIcon;
title?: ReactNode;
description?: ReactNode;
/** 操作区(按钮/链接等),非必须 */
action?: ReactNode;
};
export function EmptyState({
size,
icon: Icon = Inbox,
title,
description,
action,
className,
...props
}: EmptyStateProps) {
return (
<div data-slot="empty-state" className={cn(emptyStateVariants({ size }), className)} {...props}>
<div className="flex size-11 shrink-0 items-center justify-center rounded-full bg-secondary/60">
<Icon aria-hidden className="size-5 text-muted-foreground" strokeWidth={1.75} />
</div>
{title != null ? <p className="text-body font-medium text-foreground">{title}</p> : null}
{description != null ? <p className="max-w-sm text-caption text-muted-foreground">{description}</p> : null}
{action != null ? <div className="mt-1">{action}</div> : null}
</div>
);
}
@@ -0,0 +1 @@
export { EmptyState, emptyStateVariants, type EmptyStateProps } from "./empty-state";
+2 -2
View File
@@ -1,5 +1,5 @@
import { type ReactNode } from "react";
import { Switch } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { ImageSettingsTheme } from "@/components/image-settings-panel";
import { boolConfig, isSeedanceFastModel, isSeedanceVideoConfig, normalizeSeedanceDuration, normalizeSeedanceRatio, normalizeSeedanceResolution, seedanceRatioOptions } from "@/lib/seedance-video";
@@ -357,7 +357,7 @@ function SwitchRow({ label, checked, theme, onChange }: { label: string; checked
{label}
</span>
<span className="shrink-0" onMouseDown={(event) => event.stopPropagation()}>
<Switch size="small" checked={checked} onChange={onChange} />
<Switch size="sm" checked={checked} onChange={onChange} />
</span>
</div>
);
@@ -1,9 +1,14 @@
import { Button, Collapse, Input, InputNumber, Select, Tag } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useMemo, useState } from "react";
import { Button, Collapse, Empty, Input, InputNumber, Select, Switch, Tag, Tooltip } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { ToolButton } from "@/components/ui/base/buttons";
import { ListFilter, ListPlus, Power, PowerOff } from "lucide-react";
import type { WorkflowFieldMapping } from "@/stores/use-config-store";
import { workflowFieldChoiceValues, workflowFieldConfigurationError, workflowFieldNumberBounds, workflowFieldPresetOptions } from "@/lib/model-capabilities";
import { EmptyState } from "@/components/ui/product/empty-state";
const sourceOptions = [
{ label: "保留工作流默认值", value: "" },
@@ -61,7 +66,7 @@ export function WorkflowFieldMappingEditor({ fields, onChange, disabled = false
};
if (!fields.length) {
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="尚未发现可配置字段,请先拉取工作流参数" />;
return <EmptyState size="compact" description="尚未发现可配置字段,请先拉取工作流参数" />;
}
return (
@@ -77,9 +82,13 @@ export function WorkflowFieldMappingEditor({ fields, onChange, disabled = false
<Button type="text" size="small" danger icon={<PowerOff className="size-3.5" />} disabled={disabled || enabledControllableCount === 0} onClick={() => updateAllFields(false)}>
关闭全部
</Button>
<Button type={showOnlyEnabled ? "default" : "text"} size="small" icon={<ListFilter className="size-3.5" />} aria-pressed={showOnlyEnabled} onClick={() => setShowOnlyEnabled((current) => !current)}>
{showOnlyEnabled ? "显示全部" : "仅显示已开启"}
</Button>
<ToolButton
size="sm"
icon={<ListFilter />}
active={showOnlyEnabled}
label={showOnlyEnabled ? "显示全部" : "仅显示已开启"}
onClick={() => setShowOnlyEnabled((current) => !current)}
/>
</div>
</div>
<Collapse
@@ -114,7 +123,7 @@ export function WorkflowFieldMappingEditor({ fields, onChange, disabled = false
),
extra: (
<span onClick={(event) => event.stopPropagation()}>
<Switch size="small" checked={enabled} disabled={disabled || !safeToOverride} aria-label={`启用字段 ${field.label || field.fieldName}`} onChange={(checked) => updateField(index, { enabled: checked })} />
<Switch size="sm" checked={enabled} disabled={disabled || !safeToOverride} aria-label={`启用字段 ${field.label || field.fieldName}`} onChange={(checked) => updateField(index, { enabled: checked })} />
</span>
),
children: (
@@ -207,7 +216,7 @@ export function WorkflowFieldMappingEditor({ fields, onChange, disabled = false
};
})}
/>
{showOnlyEnabled && !visibleFields.length ? <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无已开启字段" /> : null}
{showOnlyEnabled && !visibleFields.length ? <EmptyState size="compact" description="暂无已开启字段" /> : null}
</div>
);
}
+7 -5
View File
@@ -1,4 +1,6 @@
import { Button, Empty, Select } from "antd";
import { Button, Select } from "antd";
import { IconButton } from "@/components/ui/base/buttons";
import { EmptyState } from "@/components/ui/product/empty-state";
import { Maximize, Power, PowerOff, ZoomIn, ZoomOut } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent } from "react";
@@ -178,10 +180,10 @@ export function WorkflowGraphEditor({ workflowJson, workflowGraph, fields, onCha
<section className="workflow-graph-stage">
<div className="workflow-graph-controls">
<Button size="small" type="text" icon={<ZoomOut />} aria-label="缩小工作流" onClick={() => zoom(-1)} />
<IconButton size="sm" variant="ghost" icon={ZoomOut} aria-label="缩小工作流" onClick={() => zoom(-1)} />
<span>{Math.round(scale * 100)}%</span>
<Button size="small" type="text" icon={<ZoomIn />} aria-label="放大工作流" onClick={() => zoom(1)} />
<Button size="small" type="text" icon={<Maximize />} aria-label="适应窗口" onClick={fitGraph} />
<IconButton size="sm" variant="ghost" icon={ZoomIn} aria-label="放大工作流" onClick={() => zoom(1)} />
<IconButton size="sm" variant="ghost" icon={Maximize} aria-label="适应窗口" onClick={fitGraph} />
</div>
<div
ref={viewportRef}
@@ -251,7 +253,7 @@ export function WorkflowGraphEditor({ workflowJson, workflowGraph, fields, onCha
</g>
</svg>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={emptyDescription} />
<EmptyState size="compact" title={emptyDescription} />
)}
</div>
</section>
@@ -1,4 +1,6 @@
import { App, Button, Empty, Input, InputNumber, Progress, Select, Switch } from "antd";
import { App, Button, Input, InputNumber, Progress, Select } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { EmptyState } from "@/components/ui/product/empty-state";
import { FileAudio, FileImage, Film, Grip, Play, RotateCcw, Square, Upload, WandSparkles } from "lucide-react";
import { useEffect, useMemo, useRef, useState, type PointerEvent as ReactPointerEvent, type ReactNode } from "react";
@@ -256,7 +258,7 @@ export function WorkflowTestWorkbench({ provider, workflowId, workflowKind = "wo
position={positions.output}
onMove={(point) => setPositions((current) => ({ ...current, output: point }))}
>
<div className="workflow-test-output">{resultUrls.length ? <ResultPreview capability={capability} urls={resultUrls} /> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={error || stage} />}</div>
<div className="workflow-test-output">{resultUrls.length ? <ResultPreview capability={capability} urls={resultUrls} /> : <EmptyState size="compact" title={error || stage} />}</div>
<Progress percent={progress} size="small" status={error ? "exception" : running ? "active" : undefined} showInfo={running || progress > 0} />
</WorkflowNode>
</div>
+5 -5
View File
@@ -309,10 +309,10 @@ export const DEFAULT_CLASSIC_SKIN: SkinDefinition = {
info: "#2563eb",
workspace: "#ffffff",
workspaceGrid: "#f3f3f3",
adminBackground: "#f3f4f6",
adminBackground: "#f5f5f5",
adminSurface: "#ffffff",
adminSubtle: "#f7f8fa",
adminStrong: "#eceff3",
adminSubtle: "#f6f6f6",
adminStrong: "#ececec",
authBackground: "#08090c",
authPanel: "#0b0c10",
authCard: "#121318",
@@ -361,9 +361,9 @@ export const DEFAULT_CLASSIC_SKIN: SkinDefinition = {
info: "#60a5fa",
workspace: "#181818",
workspaceGrid: "#222222",
adminBackground: "#101010",
adminBackground: "#0f0f0f",
adminSurface: "#181818",
adminSubtle: "#202020",
adminSubtle: "#222222",
adminStrong: "#2a2a2a",
authBackground: "#08090c",
authPanel: "#0b0c10",
+2
View File
@@ -1,3 +1,5 @@
import "@fontsource-variable/inter";
import "@fontsource-variable/jetbrains-mono";
import { runLocalRuntimeBootstrap } from "@/services/local-runtime-bootstrap";
import { bootstrapAppearance } from "@/services/appearance-bootstrap";
@@ -1,4 +1,5 @@
import { App, Button, Form, Input, InputNumber, Modal, Select, Switch } from "antd";
import { App, Button, Form, Input, InputNumber, Modal, Select } from "antd";
import { Switch } from "@/components/ui/base/switch";
import type { FormInstance } from "antd";
import type { ColumnsType } from "antd/es/table";
import { Pencil, Plus, Power, Search, Trash2 } from "lucide-react";
@@ -1,4 +1,5 @@
import { App, Button, Form, Input, Select, Skeleton, Switch } from "antd";
import { App, Button, Form, Input, Select, Skeleton } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, BadgeCheck, ChevronDown, Globe2, KeyRound, LockKeyhole, RefreshCw, RotateCcw, Save, ShieldCheck, UserPlus, UsersRound } from "lucide-react";
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { useBlocker } from "react-router";
@@ -1,5 +1,6 @@
import { useEffect, useRef, useState, type ChangeEvent } from "react";
import { App, Button, Form, Input, Modal, Select, Switch } from "antd";
import { App, Button, Form, Input, Modal, Select } from "antd";
import { Switch } from "@/components/ui/base/switch";
import type { InputRef } from "antd";
import type { ColumnsType } from "antd/es/table";
import { PencilLine, Pin, Plus, RefreshCw, Search, Send, Upload, X } from "lucide-react";
@@ -1,4 +1,5 @@
import { ConfigProvider, Dropdown, Tooltip } from "antd";
import { ConfigProvider, Dropdown } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import type { MenuProps } from "antd";
import {
ArrowLeft,
@@ -131,7 +132,7 @@ export function AdminShell() {
<main className="admin-shell app-user-workspace flex h-full min-h-0 overflow-hidden text-foreground">
<aside className={cn("app-workspace-sidebar admin-sidebar hidden shrink-0 flex-col overflow-hidden lg:flex", collapsed && "is-collapsed")}>
<div className="admin-sidebar-identity shrink-0">
<Tooltip mouseEnterDelay={0.1} title={collapsed ? "查看更新日志" : undefined} placement="right" rootClassName="app-workspace-sidebar-tooltip">
<Tooltip delay={100} title={collapsed ? "查看更新日志" : undefined} placement="right">
<AppChangelogButton
className={cn("admin-sidebar-brand-button", collapsed && "is-collapsed")}
icon={<BrandLogoFrame className="admin-sidebar-brand-mark grid shrink-0 place-items-center bg-foreground text-background" logoClassName="size-5 object-contain" alt="" fallback={<InfinityIcon className="size-4" />} />}
@@ -145,7 +146,7 @@ export function AdminShell() {
</div>
<AdminNavigation collapsed={collapsed} />
<div className="admin-sidebar-footer shrink-0">
<Tooltip mouseEnterDelay={0.1} title={collapsed ? "返回创作台" : undefined} placement="right" rootClassName="app-workspace-sidebar-tooltip">
<Tooltip delay={100} title={collapsed ? "返回创作台" : undefined} placement="right">
<NavLink
to="/"
aria-label={collapsed ? "返回创作台" : undefined}
@@ -157,7 +158,7 @@ export function AdminShell() {
</Tooltip>
</div>
</aside>
<Tooltip mouseEnterDelay={0.1} title={collapsed ? "展开侧栏" : "收起侧栏"} placement="right" rootClassName="app-workspace-sidebar-tooltip">
<Tooltip delay={100} title={collapsed ? "展开侧栏" : "收起侧栏"} placement="right">
<button type="button" className={cn("admin-sidebar-edge-toggle hidden lg:grid", collapsed && "is-collapsed")} onClick={toggleCollapsed} aria-label={collapsed ? "展开侧栏" : "收起侧栏"} aria-expanded={!collapsed}>
{collapsed ? <ChevronRight className="size-3.5" aria-hidden="true" /> : <ChevronLeft className="size-3.5" aria-hidden="true" />}
</button>
@@ -293,7 +294,7 @@ function AdminNavigation({ collapsed }: { collapsed: boolean }) {
return (
<div key={group.label} className="admin-nav-group">
{!collapsed ? (
<div className="admin-nav-group-label mb-1 px-2.5 text-[var(--fs-tiny)] font-medium text-foreground/38">
<div className="admin-nav-group-label">
<span>{group.label}</span>
</div>
) : (
@@ -301,16 +302,16 @@ function AdminNavigation({ collapsed }: { collapsed: boolean }) {
)}
<div className={cn("admin-nav-group-items space-y-0.5", collapsed && "is-collapsed")}>
{visibleItems.map((item) => (
<Tooltip key={item.path} mouseEnterDelay={0.1} title={collapsed ? item.label : undefined} placement="right" rootClassName="app-workspace-sidebar-tooltip">
<Tooltip key={item.path} delay={100} title={collapsed ? item.label : undefined} placement="right">
<NavLink
to={item.path}
end={item.path === "/admin"}
aria-label={collapsed ? item.label : undefined}
className={({ isActive }) =>
cn(
"app-workspace-nav-link flex h-8 items-center rounded-md text-[var(--fs-body)] transition-colors",
"app-workspace-nav-link flex h-8 items-center rounded-md transition-colors",
collapsed ? "justify-center px-0" : "gap-2.5 px-2.5",
isActive ? "is-active font-medium" : "text-foreground/62 hover:bg-surface-hover hover:text-foreground",
isActive ? "is-active" : "text-foreground/62 hover:bg-surface-hover hover:text-foreground",
)
}
>
+21 -13
View File
@@ -1,3 +1,5 @@
import { StatusBadge } from "@/components/ui/base/badges";
import { EmptyState } from "@/components/ui/product/empty-state";
import { App, Button, Dropdown, Table } from "antd";
import type { ButtonProps, MenuProps, TableProps } from "antd";
import { saveAs } from "file-saver";
@@ -12,12 +14,18 @@ export const configuredSecretText = "已配置 · 留空不改";
export type AdminStatusTone = "neutral" | "success" | "warning" | "error" | "info";
/** admin 状态徽章:归并到自研 StatusBadge(outline 圆点胶囊),admin 全部页面零改动统一视觉。
* tone 归一:info 在 admin 中本就是前景中性(--admin-status-info: var(--foreground))→ neutral。 */
const adminToneToBadgeTone: Record<AdminStatusTone, "neutral" | "success" | "warning" | "error"> = {
neutral: "neutral",
success: "success",
warning: "warning",
error: "error",
info: "neutral",
};
export function AdminStatusBadge({ label, tone = "neutral", title }: { label: string; tone?: AdminStatusTone; title?: string }) {
return (
<span className="admin-status-badge" data-tone={tone} title={title}>
{label}
</span>
);
return <StatusBadge tone={adminToneToBadgeTone[tone]} title={title} label={label} />;
}
export function AdminStatTile({ label, value, detail, trend }: { label: string; value: string | number; detail?: string; trend?: { value: string; tone?: AdminStatusTone } }) {
@@ -133,14 +141,14 @@ export function AdminExportButton({
export function AdminTableEmpty({ filtered = false, title, description, action }: { filtered?: boolean; title?: string; description?: string; action?: ReactNode }) {
return (
<div className="flex min-h-40 flex-col items-center justify-center px-6 py-8 text-center">
<span className="grid size-9 place-items-center rounded-md bg-muted/35 text-foreground/45">
<SearchX className="size-4" />
</span>
<div className="mt-3 text-sm font-medium">{title || (filtered ? "没有符合筛选条件的数据" : "暂无数据")}</div>
{description ? <p className="mt-1 max-w-sm text-xs leading-5 text-foreground/50">{description}</p> : null}
{action ? <div className="mt-4">{action}</div> : null}
</div>
<EmptyState
size="compact"
icon={SearchX}
title={title || (filtered ? "没有符合筛选条件的数据" : "暂无数据")}
description={description}
action={action}
className="min-h-40 w-full justify-center"
/>
);
}
@@ -1,5 +1,7 @@
import { useEffect, useState } from "react";
import { App, Button, Descriptions, Drawer, Empty, Progress, Skeleton, Tabs } from "antd";
import { App, Button, Descriptions, Drawer, Progress, Skeleton, Tabs } from "antd";
import { IconButton } from "@/components/ui/base/buttons";
import { EmptyState } from "@/components/ui/product/empty-state";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { PaginationBar } from "@/components/layout/workspace-page";
@@ -97,8 +99,8 @@ export function AdminUserDetailDrawer({ userId, onClose, previousUserId, nextUse
rootClassName="admin-drawer"
extra={onNavigate ? (
<div className="flex items-center gap-1">
<Button type="text" size="small" aria-label="上一条用户" disabled={!previousUserId} icon={<ChevronLeft className="size-4" />} onClick={() => previousUserId && onNavigate(previousUserId)} />
<Button type="text" size="small" aria-label="下一条用户" disabled={!nextUserId} icon={<ChevronRight className="size-4" />} onClick={() => nextUserId && onNavigate(nextUserId)} />
<IconButton size="sm" variant="ghost" aria-label="上一条用户" disabled={!previousUserId} icon={ChevronLeft} onClick={() => previousUserId && onNavigate(previousUserId)} />
<IconButton size="sm" variant="ghost" aria-label="下一条用户" disabled={!nextUserId} icon={ChevronRight} onClick={() => nextUserId && onNavigate(nextUserId)} />
</div>
) : null}
>
@@ -225,7 +227,7 @@ export function AdminUserDetailDrawer({ userId, onClose, previousUserId, nextUse
]}
/>
) : (
<Empty description="没有用户详情" />
<EmptyState size="compact" title="没有用户详情" />
)}
</Drawer>
);
@@ -1,5 +1,7 @@
import { App, Button, DatePicker, Drawer, Form, Input, Modal, Select, Tabs, Tag } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useCallback, useEffect, useMemo, useState, type ReactNode } from "react";
import { App, Button, DatePicker, Drawer, Form, Input, Modal, Select, Tabs, Tag, Tooltip } from "antd";
import type { ColumnsType } from "antd/es/table";
import dayjs, { type Dayjs } from "dayjs";
import { AlertTriangle, BarChart3, CircleDollarSign, Clock3, Gauge, Pencil, Plus, RefreshCw, Settings2, Trash2, UsersRound, Workflow } from "lucide-react";
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { App, Button, Descriptions, Drawer, Empty, Skeleton, Tabs, Typography } from "antd";
import { App, Button, Descriptions, Drawer, Skeleton, Tabs, Typography } from "antd";
import { EmptyState } from "@/components/ui/product/empty-state";
import { RefreshCw } from "lucide-react";
import { formatCredits } from "@/constant/credits";
@@ -49,7 +50,7 @@ export function ApiLogDetailDrawer({ logId, onClose, onLogUpdated }: { logId: st
return (
<Drawer title="请求详情" open={Boolean(logId)} onClose={onClose} size="min(920px, 100vw)" destroyOnHidden rootClassName="admin-drawer">
{loading ? <Skeleton active paragraph={{ rows: 12 }} /> : log ? <LogDetail log={log} querying={querying} onQueryProviderTask={queryProviderTask} /> : <Empty description="没有请求详情" />}
{loading ? <Skeleton active paragraph={{ rows: 12 }} /> : log ? <LogDetail log={log} querying={querying} onQueryProviderTask={queryProviderTask} /> : <EmptyState size="compact" title="没有请求详情" />}
</Drawer>
);
}
@@ -125,7 +126,7 @@ function requestKindText(value: ApiCallLog["requestKind"]) {
}
function PayloadPanel({ value, empty }: { value?: string; empty: string }) {
if (!value) return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={empty} />;
if (!value) return <EmptyState size="compact" title={empty} />;
return (
<div className="relative">
<div className="absolute right-3 top-2 z-10">
@@ -1,4 +1,6 @@
import { App, Button, Form, Input, InputNumber, Select, Skeleton, Switch } from "antd";
import { App, Button, Form, Input, InputNumber, Skeleton } from "antd";
import { Select } from "@/components/ui/base/select";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, AtSign, BadgeCheck, KeyRound, MailCheck, RefreshCw, RotateCcw, Save, Send, Server } from "lucide-react";
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { useBlocker } from "react-router";
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { App, Button, Skeleton, Switch } from "antd";
import { App, Button, Skeleton } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, Clapperboard, Coins, ListChecks, LockKeyhole, MonitorCog, PlugZap, RadioTower, RefreshCw, ShieldCheck, Sparkles } from "lucide-react";
import { cn } from "@/lib/utils";
@@ -1,4 +1,6 @@
import { Alert, Button, InputNumber, Select, Switch, Tag } from "antd";
import { Button, InputNumber, Select, Tag } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { Callout } from "@/components/ui/product/callout";
import { RotateCcw } from "lucide-react";
import type { ReactNode } from "react";
@@ -233,7 +235,7 @@ export function CapabilityScopeEditor({ capability, sourceSpecs, value, onChange
</Button>
</div>
{sourceError ? <Alert type="warning" showIcon message="当前选择需要调整" description={`${sourceError}。可重新选择,或采用全部可用范围。`} /> : null}
{sourceError ? <Callout tone="warning" title="当前选择需要调整">{`${sourceError}。可重新选择,或采用全部可用范围。`}</Callout> : null}
{source.operations?.length ? (
<CapabilityBlock title="生成方式">
@@ -263,7 +265,7 @@ export function CapabilityScopeEditor({ capability, sourceSpecs, value, onChange
</div>
</div>
<div className="col-span-12 sm:col-span-1">
<Switch size="small" checked={Boolean(selected)} onChange={(enabled) => updateInput(current, definition.name, enabled ? limit : undefined, update)} />
<Switch size="sm" checked={Boolean(selected)} onChange={(enabled) => updateInput(current, definition.name, enabled ? limit : undefined, update)} />
</div>
<div className="col-span-6 sm:col-span-3">
<NumberInput
@@ -310,7 +312,7 @@ export function CapabilityScopeEditor({ capability, sourceSpecs, value, onChange
</CapabilityBlock>
) : null}
{!sourceInputs.length && !sourceOptions.length && !source.operations?.length ? <Alert type="info" showIcon message="该类型暂无额外能力参数" description="线路仍可按优先级和权重参与路由。" /> : null}
{!sourceInputs.length && !sourceOptions.length && !source.operations?.length ? <Callout tone="info" title="该类型暂无额外能力参数">线路仍可按优先级和权重参与路由。</Callout> : null}
</div>
);
}
@@ -481,7 +483,7 @@ function OptionRuleEditor({ definition, source, value, onChange }: { definition:
<div className="text-xs text-foreground/45">{constraintSummary(source, definition.unit)}</div>
</div>
<div className="col-span-12 sm:col-span-1">
<Switch size="small" checked={Boolean(value)} onChange={(enabled) => onChange(enabled ? source : undefined)} />
<Switch size="sm" checked={Boolean(value)} onChange={(enabled) => onChange(enabled ? source : undefined)} />
</div>
<div className="col-span-12 sm:col-span-6">
{source.values ? (
+2 -1
View File
@@ -1,4 +1,5 @@
import { App, Button, Input, Modal, Select } from "antd";
import { IconButton } from "@/components/ui/base/buttons";
import type { ColumnsType } from "antd/es/table";
import { Download, Eye, Play, Search } from "lucide-react";
import { saveAs } from "file-saver";
@@ -294,7 +295,7 @@ function MediaResult({ log, onPreview }: { log: ApiCallLog; onPreview: (url: str
) : null}
{!previewUnavailable && log.mediaCount > 1 ? <span className="absolute bottom-0.5 right-0.5 rounded-sm bg-black/65 px-1 text-[var(--fs-micro)] leading-4 text-white">{log.mediaCount}</span> : null}
</button>
<Button type="text" size="small" className="!size-7 !min-w-7 !p-0" icon={<Download className="size-3.5" />} onClick={() => downloadMedia(url, kind)} title="下载原文件" aria-label="下载原文件" />
<IconButton size="sm" variant="ghost" icon={Download} onClick={() => downloadMedia(url, kind)} title="下载原文件" aria-label="下载原文件" />
</div>
);
}
@@ -1,5 +1,7 @@
import { AlipayCircleFilled, WechatFilled } from "@ant-design/icons";
import { Alert, App, Button, DatePicker, Drawer, Form, Input, InputNumber, Select, Switch, Tabs } from "antd";
import { Callout } from "@/components/ui/product/callout";
import { App, Button, DatePicker, Drawer, Form, Input, InputNumber, Select, Tabs } from "antd";
import { Switch } from "@/components/ui/base/switch";
import type { ColumnsType } from "antd/es/table";
import dayjs, { type Dayjs } from "dayjs";
import { Eye, Plus, RefreshCw, Search, Settings2, XCircle } from "lucide-react";
@@ -497,7 +499,7 @@ export default function AdminPaymentsPage() {
}
scroll
>
<Alert className="my-4" type="info" showIcon message="平台不提供支付退款" description="管理端仅提供查单、关单和对账。关单前始终先向渠道查单;对账发现已支付未入账订单时会幂等补发积分。" />
<Callout className="my-4" tone="info" title="平台不提供支付退款">管理端仅提供查单、关单和对账。关单前始终先向渠道查单;对账发现已支付未入账订单时会幂等补发积分。</Callout>
<Tabs
activeKey={activeTab}
onChange={setActiveTab}
@@ -610,12 +612,7 @@ export default function AdminPaymentsPage() {
>
{providerDrawer ? (
<Form form={providerForm} layout="vertical" requiredMark="optional">
<Alert
className="mb-4"
type={providerDrawer.pluginEnabled ? "info" : "warning"}
showIcon
message={providerDrawer.pluginEnabled ? "密钥会加密保存,历史订单固定使用创建时的配置版本。" : "该宿主插件当前已在插件管理中停用;保存配置后仍需开放插件才能接受新订单。"}
/>
<Callout className="mb-4" tone={providerDrawer.pluginEnabled ? "info" : "warning"} title={providerDrawer.pluginEnabled ? "密钥会加密保存,历史订单固定使用创建时的配置版本。" : "该宿主插件当前已在插件管理中停用;保存配置后仍需开放插件才能接受新订单。"} />
<Form.Item name="enabled" label="渠道配置启用" valuePropName="checked">
<Switch />
</Form.Item>
@@ -703,7 +700,7 @@ export default function AdminPaymentsPage() {
setDetailItems([]);
}}
>
{detailRun?.error ? <Alert className="mb-4" type="error" showIcon message="对账执行失败" description={detailRun.error} /> : null}
{detailRun?.error ? <Callout className="mb-4" tone="error" title="对账执行失败">{detailRun.error}</Callout> : null}
<AdminDataTable
toolbar={
<Select
+2 -1
View File
@@ -1,4 +1,5 @@
import { App, Button, Input, Select, Switch } from "antd";
import { App, Button, Input, Select } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlipayCircleFilled, WechatFilled } from "@ant-design/icons";
import type { ColumnsType } from "antd/es/table";
import { CloudUpload, PlugZap, RefreshCw, Search, Trash2, UsersRound } from "lucide-react";
@@ -1,4 +1,5 @@
import { App, Button, Form, Input, Skeleton, Switch } from "antd";
import { App, Button, Form, Input, Skeleton } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { Copyright, Globe2, Image as ImageIcon, MonitorPlay, Moon, Palette, RefreshCw, RotateCcw, Save, Search, Sun, Type, Undo2, Upload } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
import { useBlocker } from "react-router";
@@ -1,4 +1,5 @@
import { App, Button, Form, Input, Skeleton, Switch } from "antd";
import { App, Button, Form, Input, Skeleton } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, CloudUpload, KeyRound, RefreshCw, RotateCcw, Save } from "lucide-react";
import { useCallback, useEffect, useRef, useState } from "react";
import { useBlocker } from "react-router";
@@ -1,4 +1,8 @@
import { Button, Form, Input, InputNumber, Segmented, Select, Tooltip } from "antd";
import { Button, Form, Input, InputNumber } from "antd";
import { Select } from "@/components/ui/base/select";
import { IconButton } from "@/components/ui/base/buttons";
import { SegmentedControl } from "@/components/ui/base/segmented-control";
import { Tooltip } from "@/components/ui/base/tooltip";
import { Check, Copy, LockKeyhole, Moon, Plus, Sparkles, Sun, Trash2 } from "lucide-react";
import { useMemo, useState } from "react";
@@ -82,7 +86,7 @@ export function SkinThemeEditor({
</button>
<div className="admin-skin-card-actions">
<Tooltip title="复制这套主题">
<Button type="text" size="small" aria-label={`复制 ${theme.name}`} icon={<Copy className="size-3.5" />} disabled={disabled || themes.length >= 16} onClick={() => onDuplicate(theme.id)} />
<IconButton size="sm" variant="ghost" icon={Copy} aria-label={`复制 ${theme.name}`} disabled={disabled || themes.length >= 16} onClick={() => onDuplicate(theme.id)} />
</Tooltip>
<Tooltip title={theme.locked ? "系统默认主题不可删除" : "删除这套主题"}>
<Button
@@ -134,7 +138,8 @@ export function SkinThemeEditor({
<strong>颜色体系</strong>
<span>同一用途的控件统一消费下列语义颜色</span>
</div>
<Segmented<SkinThemeMode>
<SegmentedControl<SkinThemeMode>
ariaLabel="皮肤预览模式"
value={mode}
options={[
{
@@ -1,4 +1,5 @@
import { App, Button, Input, Skeleton, Switch } from "antd";
import { App, Button, Input, Skeleton } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, BadgeCheck, CircleCheck, CloudDownload, KeyRound, RefreshCw, RotateCcw, Save, Server, ShieldCheck, Trash2, Wifi } from "lucide-react";
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { useBlocker } from "react-router";
@@ -1,4 +1,5 @@
import { App, Button, Input, Skeleton, Switch } from "antd";
import { App, Button, Input, Skeleton } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, ArrowDown, ArrowUp, BadgeCheck, Eye, ListOrdered, Plus, RefreshCw, RotateCcw, Save, Search, ShieldAlert, ShieldCheck, Trash2 } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useBlocker } from "react-router";
@@ -1,4 +1,6 @@
import { App, Button, Form, Input, Select, Skeleton, Switch } from "antd";
import { App, Button, Form, Input, Skeleton } from "antd";
import { Select } from "@/components/ui/base/select";
import { Switch } from "@/components/ui/base/switch";
import { AlertTriangle, BadgeCheck, Check, Cloud, Database, Globe2, HardDrive, KeyRound, LocateFixed, RefreshCw, RotateCcw, Save, Server, ShieldCheck, Wifi } from "lucide-react";
import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
import { useBlocker } from "react-router";
@@ -1,4 +1,6 @@
import { Alert, App, Button, Drawer, Form, Input, Popconfirm, Select, Tabs, Tag } from "antd";
import { App, Button, Drawer, Form, Input, Popconfirm, Select, Tabs } from "antd";
import { StatusBadge } from "@/components/ui/base/badges";
import { Callout } from "@/components/ui/product/callout";
import type { ColumnsType } from "antd/es/table";
import { Braces, Copy, FileJson, FileText, Plus, Power, Search, ShieldCheck, Trash2 } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
@@ -212,19 +214,13 @@ export default function StoryboardPromptsPage() {
</div>
{pendingOperation ? (
<Alert
type="warning"
showIcon
title="当前版本有未保存修改"
description={`切换到“${definitionByOperation.get(pendingOperation)?.label || pendingOperation}”会丢弃当前草稿。`}
action={<div className="flex gap-2"><Button size="small" onClick={() => setPendingOperation("")}>继续编辑</Button><Button size="small" danger onClick={() => loadDraftBaseline(pendingOperation)}>放弃并切换</Button></div>}
/>
<Callout tone="warning" title="当前版本有未保存修改" action={<div className="flex gap-2"><Button size="small" onClick={() => setPendingOperation("")}>继续编辑</Button><Button size="small" danger onClick={() => loadDraftBaseline(pendingOperation)}>放弃并切换</Button></div>}>{`切换到“${definitionByOperation.get(pendingOperation)?.label || pendingOperation}”会丢弃当前草稿。`}</Callout>
) : null}
<div className="grid min-h-0 flex-1 gap-0 lg:grid-cols-3">
<section className="flex min-h-0 flex-col border-b border-border p-4 lg:col-span-2 lg:border-b-0 lg:border-r">
<div className="mb-3 flex shrink-0 flex-wrap items-start justify-between gap-3">
<div className="flex flex-wrap items-center gap-2"><h3 className="text-sm font-semibold">模板内容</h3>{dirty ? <Tag variant="filled" color="warning">未保存</Tag> : null}</div>
<div className="flex flex-wrap items-center gap-2"><h3 className="text-sm font-semibold">模板内容</h3>{dirty ? <StatusBadge variant="filled" tone="warning" label="未保存" /> : null}</div>
<div className="flex flex-wrap justify-end gap-2">
{selectedDefinition?.variables.map((variable) => (
<Button key={variable.placeholder} size="small" icon={<Braces className="size-3.5" />} onClick={() => editorRef.current?.insertText(variable.placeholder)}>
+16 -1
View File
@@ -1,5 +1,5 @@
import type { ColumnsType } from "antd/es/table";
import { Eye, Pencil, Power } from "lucide-react";
import { Eye, Pencil, Power, Trash2 } from "lucide-react";
import { formatCredits } from "@/constant/credits";
import { IdentityProviderBadge } from "@/components/layout/identity-provider-badge";
@@ -24,12 +24,14 @@ export function createUserColumns({
onView,
onEdit,
onToggleStatus,
onPurge,
}: {
actorId?: string;
visibleColumns: Set<UserColumnKey>;
onView: (user: AdminUser) => void;
onEdit: (user: AdminUser) => void;
onToggleStatus: (user: AdminUser) => Promise<void>;
onPurge: (user: AdminUser) => void;
}): ColumnsType<AdminUser> {
const columns: Array<ColumnsType<AdminUser>[number] & { key: UserColumnKey }> = [
{
@@ -79,6 +81,19 @@ export function createUserColumns({
},
onClick: () => onToggleStatus(user),
},
{
key: "purge",
label: "删除用户",
icon: <Trash2 className="size-3.5" />,
danger: true,
disabled: user.id === actorId,
confirm: {
title: "彻底删除这个用户?",
description: "该账号及其全部关联数据将被永久移除且不可恢复。停用可保留数据,仅当账号无资金流水和创作内容时才允许删除。",
okText: "彻底删除",
},
onClick: () => onPurge(user),
},
]}
/>
),
+2 -1
View File
@@ -1,4 +1,5 @@
import { App, Button, Drawer, Form, Input, Select } from "antd";
import { App, Button, Drawer, Form, Input } from "antd";
import { Select } from "@/components/ui/base/select";
import { useEffect, useState } from "react";
import { createAdminUser, updateAdminUser, type AdminUser, type LocalUser } from "@/services/api/auth";
+19 -3
View File
@@ -1,10 +1,11 @@
import { App, Button, Checkbox, Dropdown, Input, Select } from "antd";
import { App, Button, Dropdown, Input, Select } from "antd";
import { Checkbox } from "@/components/ui/base/checkbox";
import { Ban, Search, Settings2, UserPlus } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { PaginationBar } from "@/components/layout/workspace-page";
import { useDebouncedValue } from "@/hooks/use-debounced-value";
import { bulkDisableAdminUsers, deleteAdminUser, listAdminUsers, updateAdminUser, type AdminUser, type LocalUser } from "@/services/api/auth";
import { bulkDisableAdminUsers, deleteAdminUser, listAdminUsers, purgeAdminUser, updateAdminUser, type AdminUser, type LocalUser } from "@/services/api/auth";
import { useUserStore } from "@/stores/use-user-store";
import { AdminBatchBar, AdminDataTable, AdminTableEmpty } from "../components/admin-ui";
import { useTableUrlState } from "../lib/use-table-url-state";
@@ -101,13 +102,27 @@ export default function UsersPanel({ onUserChanged }: { onUserChanged?: (user: L
}
}, [message, replaceUser]);
const purgeUser = useCallback(async (user: AdminUser) => {
try {
await purgeAdminUser(user.id);
setUsers((items) => items.filter((item) => item.id !== user.id));
setTotal((value) => Math.max(0, value - 1));
setSelectedUserIds((ids) => ids.filter((id) => id !== user.id));
if (detailUserId === user.id) setDetailUserId(null);
message.success(`用户 ${user.displayName || user.username} 已彻底删除`);
} catch (error) {
message.error(error instanceof Error ? error.message : "删除用户失败");
}
}, [detailUserId, message]);
const columns = useMemo(() => createUserColumns({
actorId: actor?.id,
visibleColumns,
onView: (user) => setDetailUserId(user.id),
onEdit: (user) => { setCreateUserOpen(false); setEditingUser(user); },
onToggleStatus: toggleStatus,
}), [actor?.id, toggleStatus, visibleColumns]);
onPurge: purgeUser,
}), [actor?.id, purgeUser, toggleStatus, visibleColumns]);
const resetFilters = () => update({ filter: "", role: "all", status: "all", page: 1 });
@@ -182,6 +197,7 @@ export default function UsersPanel({ onUserChanged }: { onUserChanged?: (user: L
{userColumnOptions.map((option) => (
<label key={option.key} className="flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-muted/60">
<Checkbox
bare
checked={visibleColumns.has(option.key)}
disabled={option.locked}
onChange={(event) => setVisibleColumns((current) => {
@@ -1,5 +1,6 @@
import { useMemo, useRef, useState } from "react";
import { App, Button, Modal, Progress, Select, Tag } from "antd";
import { App, Button, Modal, Progress, Select } from "antd";
import { StatusBadge } from "@/components/ui/base/badges";
import { FileImage, UploadCloud, X } from "lucide-react";
import { ASSET_CATEGORY_OPTIONS, type AssetCategory } from "@/lib/asset-category";
@@ -85,7 +86,7 @@ export function AssetBatchUploadModal({ open, defaultFolderId, folders, onClose,
<input ref={inputRef} type="file" hidden accept="image/*" multiple onChange={(event) => { chooseFiles(Array.from(event.target.files || [])); event.currentTarget.value = ""; }} />
{hasFiles ? <div className="space-y-2">
<div className="flex items-center justify-between text-xs text-foreground/55"><span>已选择 {items.length} 张 · 成功 {doneCount} 张</span><button type="button" className="text-foreground/45 hover:text-foreground" onClick={() => setItems([])} disabled={uploading}>清空</button></div>
<div className="batch-upload-list">{items.map((item) => <div key={item.id} className="batch-upload-item"><FileImage className="size-4 shrink-0 text-foreground/45" /><span className="min-w-0 flex-1 truncate" title={item.file.name}>{item.file.name}</span>{item.status === "uploading" ? <Progress percent={item.percent || 10} size="small" showInfo={false} className="w-20" /> : item.status === "done" ? <Tag color="green">完成</Tag> : item.status === "error" ? <Tag color="red" title={item.error}>失败</Tag> : <Tag>待上传</Tag>}<button type="button" aria-label={`移除 ${item.file.name}`} title="移除" className="batch-upload-remove" onClick={() => setItems((current) => current.filter((entry) => entry.id !== item.id))} disabled={uploading}><X className="size-3.5" /></button></div>)}</div>
<div className="batch-upload-list">{items.map((item) => <div key={item.id} className="batch-upload-item"><FileImage className="size-4 shrink-0 text-foreground/45" /><span className="min-w-0 flex-1 truncate" title={item.file.name}>{item.file.name}</span>{item.status === "uploading" ? <Progress percent={item.percent || 10} size="small" showInfo={false} className="w-20" /> : item.status === "done" ? <StatusBadge tone="success" size="sm" label="完成" /> : item.status === "error" ? <StatusBadge tone="error" size="sm" label="失败" title={item.error} /> : <StatusBadge tone="neutral" size="sm" label="待上传" />}<button type="button" aria-label={`移除 ${item.file.name}`} title="移除" className="batch-upload-remove" onClick={() => setItems((current) => current.filter((entry) => entry.id !== item.id))} disabled={uploading}><X className="size-3.5" /></button></div>)}</div>
</div> : null}
<div className="flex justify-end gap-2"><Button onClick={close} disabled={uploading}>取消</Button><Button type="primary" icon={<UploadCloud className="size-4" />} onClick={() => void uploadBatch()} disabled={!items.some((item) => item.status === "queued" || item.status === "error")} loading={uploading}>{failedItems.length ? `重试失败项 (${failedItems.length})` : "开始上传"}</Button></div>
</div>
+3 -2
View File
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { keepPreviousData, useQuery, useQueryClient } from "@tanstack/react-query";
import { App, Button, Drawer, Dropdown, Form, Input, Modal, Popconfirm, Progress, Select, Space, Tag, Typography } from "antd";
import type { MenuProps } from "antd";
import { IconButton } from "@/components/ui/base/buttons";
import { useNavigate } from "react-router";
import { CollectionGrid, ListToolbar, PageHeader, PaginationBar, WorkspacePage } from "@/components/layout/workspace-page";
@@ -559,7 +560,7 @@ export default function AssetsPage() {
<Button icon={<FolderOpen className="size-3.5" />} onClick={() => navigate("/plugins/eagle")}>
Eagle 素材库
</Button>
<Button title="导出全部素材" aria-label="导出全部素材" icon={<Download className="size-4" />} onClick={() => void exportAllAssets()} />
<IconButton variant="solid" icon={Download} aria-label="导出全部素材" title="导出全部素材" onClick={() => void exportAllAssets()} />
<Dropdown
trigger={["click"]}
menu={{
@@ -569,7 +570,7 @@ export default function AssetsPage() {
],
}}
>
<Button title="导入素材" aria-label="导入素材" icon={<FileUp className="size-4" />} />
<IconButton variant="solid" icon={FileUp} aria-label="导入素材" title="导入素材" />
</Dropdown>
</>
)}
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { Command, Search } from "lucide-react";
import { Kbd } from "@/components/ui/base/kbd";
import { Modal } from "antd";
import {
@@ -105,7 +106,7 @@ export function CanvasShortcutsModal({ open, onClose }: { open: boolean; onClose
<footer className="canvas-shortcuts-footer">
<span>共 {results.length} 个快捷键</span>
<span className="canvas-shortcuts-close-hint"><kbd>Esc</kbd> 关闭</span>
<span className="canvas-shortcuts-close-hint"><Kbd>Esc</Kbd> 关闭</span>
</footer>
</div>
</Modal>
@@ -140,7 +141,7 @@ function ShortcutRow({ shortcut, showCategory }: { shortcut: CanvasShortcutItem;
{combination.map((key, keyIndex) => (
<span key={`${key}-${keyIndex}`} className="canvas-shortcuts-key-part">
{keyIndex ? <i>+</i> : null}
<kbd>{key}</kbd>
<Kbd>{key}</Kbd>
</span>
))}
</span>
+2 -1
View File
@@ -1,7 +1,8 @@
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useNavigate, useSearchParams } from "react-router";
import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
import { App, Button, Dropdown, Modal, Select } from "antd";
import { App, Button, Dropdown, Modal } from "antd";
import { Select } from "@/components/ui/base/select";
import { ArrowDownAZ, Clock3, Download, FileUp, History, ListFilter, MoreHorizontal, Plus, Search, SlidersHorizontal, Trash2, X } from "lucide-react";
import { CollectionGrid, PageHeader, WorkspacePage } from "@/components/layout/workspace-page";
+280 -288
View File
@@ -1,11 +1,13 @@
import { lazy, Suspense, useCallback, useEffect, useMemo, useRef, useState, type CSSProperties, type PointerEvent, type ReactNode, type RefObject } from "react";
import { App, Button, Drawer, Modal, Popover, Spin, Tooltip } from "antd";
import { App, Button, Drawer, Dropdown, Modal, Popover, Spin } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { Reorder } from "motion/react";
import { ArrowDown, ArrowUp, Brain, Check, ChevronDown, ChevronLeft, ChevronRight, Clapperboard, Clock3, Copy, Download, FileText, Film, History, Image as ImageIcon, LoaderCircle, Maximize2, MessageSquareText, Minimize2, Music2, Plus, RefreshCw, Search, SlidersHorizontal, Sparkles, Trash2, WandSparkles, Waves, X } from "lucide-react";
import { ArrowDown, ArrowUp, Brain, Check, ChevronDown, ChevronLeft, ChevronRight, Clapperboard, Clock3, Copy, Download, FileText, Film, History, Image as ImageIcon, LoaderCircle, Maximize2, MessageSquareText, Minimize2, MoreHorizontal, Music2, Pencil, Plus, RefreshCw, Search, SlidersHorizontal, Sparkles, Trash2, UserRound, WandSparkles, Waves, X } from "lucide-react";
import { Link } from "react-router";
import { AIMessageMarkdown } from "@/components/ai/ai-message-markdown";
import { GenerationToolCard, type GenerationToolStatus } from "@/components/ai/generation-tool-card";
import { WorkingDots, WorkingGlow } from "@/components/ai/working-indicator";
import { MessageReasoning } from "@/components/ai/message-reasoning";
import type { AssetLibraryPickerItem } from "@/components/assets/asset-library-picker-modal";
import { CachedResourceImage } from "@/components/cached-resource-image";
@@ -30,7 +32,7 @@ import type { Skill } from "@/services/api/skills";
import type { GenerationTask } from "@/services/api/task-center";
import { resolveResourceUrl } from "@/services/api/resources";
import { loadCreationConversations, pendingCreationTaskIds, removeCreationConversationSnapshot, saveCreationConversations, updateCreationConversationSnapshot } from "@/services/creation-conversation-store";
import { modelDisplayName, modelOptionName, resolveModelChannel, selectableModelsByCapability, useConfigStore, useEffectiveConfig } from "@/stores/use-config-store";
import { modelOptionName, resolveModelChannel, selectableModelsByCapability, useConfigStore, useEffectiveConfig } from "@/stores/use-config-store";
import { useCreationPreferencesStore } from "@/stores/use-creation-preferences-store";
import { useAssetStore, type Asset } from "@/stores/use-asset-store";
import { useAppearanceStore } from "@/stores/use-appearance-store";
@@ -48,10 +50,28 @@ const loadCreationRuntime = () => import("./creation-runtime");
type CreationRuntime = Awaited<ReturnType<typeof loadCreationRuntime>>;
type CreationMode = "text" | "image" | "video";
type CreationViewMode = "chat" | "storyboard";
type CreationStatus = "streaming" | "pending" | "done" | "error" | "cancelled";
type CreationSettings = { ratio: string; seconds: string; quality: string; videoQuality: string; count: string };
type CreationRetryContext = GenerationRetryContext & { retryContextsByBatchIndex?: GenerationRetryContext[] };
// —— 设备级 UI 偏好(仅当前浏览器;storage 不可用时自动降级为会话内默认)——
const TEXT_STREAMING_PREF_KEY = "creation.composer.text-streaming";
const TEXT_THINKING_PREF_KEY = "creation.composer.text-thinking";
function readComposerPref(key: string, fallback: boolean): boolean {
try {
const stored = window.localStorage.getItem(key);
return stored === null ? fallback : stored === "1";
} catch {
return fallback;
}
}
function writeComposerPref(key: string, value: boolean) {
try {
window.localStorage.setItem(key, value ? "1" : "0");
} catch {
// 存储不可用(隐私模式/禁用):仅当前会话生效,忽略
}
}
type CreationMessage = {
id: string;
role: "user" | "assistant";
@@ -101,6 +121,8 @@ const countOptions = ["1", "2", "3", "4"];
const conversationTimeFormatter = new Intl.DateTimeFormat("zh-CN", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: false });
const messageTimeFormatter = new Intl.DateTimeFormat("zh-CN", { hour: "2-digit", minute: "2-digit", hour12: false });
const historyDayFormatter = new Intl.DateTimeFormat("zh-CN", { month: "numeric", day: "numeric" });
function newConversation(): CreationConversation {
return { id: createClientId(), title: "新创作", updatedAt: new Date().toISOString(), messages: [] };
}
@@ -109,20 +131,30 @@ function newMessage(role: CreationMessage["role"], content: string, extra: Parti
return { id: createClientId(), role, content, createdAt: new Date().toISOString(), ...extra };
}
type CreationShot = { user?: CreationMessage; result?: CreationMessage };
type CreationShotRailEntry = { key: string; ordinal: number; user: CreationMessage; result?: CreationMessage };
function shotsFromMessages(messages: CreationMessage[]): CreationShot[] {
const shots: CreationShot[] = [];
/* 从消息流聚合“视频镜头轨道”:每个视频 user 消息是一镜,紧跟的同 mode 结果归属该镜 */
function creationShotRail(messages: CreationMessage[]): CreationShotRailEntry[] {
const rail: CreationShotRailEntry[] = [];
let ordinal = 0;
let lastIndex = -1;
for (const message of messages) {
const isVideo = (message.mode || "text") === "video";
if (message.role === "user") {
shots.push({ user: message });
} else if (shots.length) {
shots[shots.length - 1].result = message;
} else {
shots.push({ result: message });
if (!isVideo) continue;
ordinal += 1;
rail.push({ key: message.id, ordinal, user: message });
lastIndex = rail.length - 1;
} else if (isVideo && lastIndex >= 0 && !rail[lastIndex].result) {
rail[lastIndex].result = message;
}
}
return shots;
return rail;
}
function creationVideoShotOrdinal(shots: CreationShotRailEntry[], item: CreationMessage): number {
const own = shots.find((entry) => item.role === "user" ? entry.user.id === item.id : entry.result?.id === item.id);
return own?.ordinal || 0;
}
function completedCreationGenerationTask(runtime: CreationRuntime, input: { taskId: string; task?: GenerationTask; mode: "image" | "video"; prompt: string; result: BackendGenerationResult; conversationId: string; messageId: string; batchIndex?: number; batchCount?: number }): GenerationTask {
@@ -167,13 +199,10 @@ export default function CreatePage() {
const [quality, setQuality] = useState("auto");
const [videoQuality, setVideoQuality] = useState(config.vquality || "720");
const [count, setCount] = useState(String(Math.max(1, Math.min(4, Number(config.count) || 1))));
const [textStreaming, setTextStreaming] = useState(true);
const [textThinking, setTextThinking] = useState(false);
const [textStreaming, setTextStreaming] = useState(() => readComposerPref(TEXT_STREAMING_PREF_KEY, true));
const [textThinking, setTextThinking] = useState(() => readComposerPref(TEXT_THINKING_PREF_KEY, false));
const [busy, setBusy] = useState(false);
const [referenceReplacementBusy, setReferenceReplacementBusy] = useState(false);
const [viewMode, setViewMode] = useState<CreationViewMode>("chat");
const [selectedShotIndex, setSelectedShotIndex] = useState(-1);
const [composingNextShot, setComposingNextShot] = useState(false);
const [historyOpen, setHistoryOpen] = useState(false);
const [libraryOpen, setLibraryOpen] = useState(false);
const externalAssetSources = useExternalAssetSources(libraryOpen);
@@ -229,9 +258,14 @@ export default function CreatePage() {
const isEmpty = !activeConversation?.messages.length;
const pendingTaskIds = useMemo(() => pendingCreationTaskIds(conversations), [conversations]);
const recoveryTaskKey = useMemo(() => pendingTaskIds.filter((id) => !activeGenerationTaskIdsRef.current.has(id)).join("|"), [pendingTaskIds]);
const shots = useMemo(() => shotsFromMessages(activeConversation?.messages || []), [activeConversation]);
const visibleShotIndex = shots.length ? selectedShotIndex >= 0 && selectedShotIndex < shots.length ? selectedShotIndex : shots.length - 1 : -1;
const videoShots = useMemo(() => creationShotRail(activeConversation?.messages || []), [activeConversation]);
const jumpToShot = (shot: CreationShotRailEntry) => { const id = shot.result?.id; if (id) document.getElementById(`creation-shot-${id}`)?.scrollIntoView({ block: "start", behavior: "smooth" }); };
useEffect(() => {
writeComposerPref(TEXT_STREAMING_PREF_KEY, textStreaming);
writeComposerPref(TEXT_THINKING_PREF_KEY, textThinking);
}, [textStreaming, textThinking]);
useEffect(() => {
if (!composerPreferencesHydrated || composerPreferencesInitialized) return;
const saved = useCreationPreferencesStore.getState().preferences;
@@ -660,8 +694,6 @@ export default function CreatePage() {
setPrompt("");
setAttachments([]);
setDraftReferences([]);
setSelectedShotIndex(-1);
setComposingNextShot(false);
setBusy(true);
const controller = new AbortController();
const requestLifecycle = runtime.beginGenerationConsumer(controller.signal);
@@ -801,8 +833,6 @@ export default function CreatePage() {
setPrompt("");
setAttachments([]);
setDraftReferences([]);
setSelectedShotIndex(-1);
setComposingNextShot(false);
setHistoryOpen(false);
};
@@ -812,8 +842,6 @@ export default function CreatePage() {
setPrompt("");
setAttachments([]);
setDraftReferences([]);
setSelectedShotIndex(-1);
setComposingNextShot(false);
setHistoryOpen(false);
};
@@ -843,8 +871,6 @@ export default function CreatePage() {
setPrompt("");
setAttachments([]);
setDraftReferences([]);
setSelectedShotIndex(-1);
setComposingNextShot(false);
}
toast.success("历史对话已删除,素材仍保留");
} catch (error) {
@@ -855,6 +881,15 @@ export default function CreatePage() {
});
};
const renameConversationTitle = (conversation: CreationConversation, title: string) => {
const nextTitle = title.trim().slice(0, 120);
if (!nextTitle || nextTitle === conversation.title.trim()) return;
const next = updateCreationConversationSnapshot(conversationsRef.current, conversation.id, (item) => ({ ...item, title: nextTitle }));
conversationsRef.current = next;
setConversations(next);
void saveCreationConversations(next).catch((error) => toast.error(error instanceof Error ? error.message : "对话重命名保存失败"));
};
const restoreMessageDraft = (item: CreationMessage) => {
const nextMode = item.mode || "text";
const nextSettings = item.settings;
@@ -880,8 +915,6 @@ export default function CreatePage() {
const restoreForRetry = () => {
followLatestMessageRef.current = true;
restoreMessageDraft(previous);
setSelectedShotIndex(-1);
setComposingNextShot(false);
const removedIds = new Set([item.id, previous.id]);
updateActive((conversation) => {
const messages = conversation.messages.filter((message) => !removedIds.has(message.id));
@@ -922,21 +955,16 @@ export default function CreatePage() {
followLatestMessageRef.current = container.scrollHeight - container.scrollTop - container.clientHeight <= 160;
};
const nextShotNumber = shots.length + 1;
const beginComposeNextShot = () => {
setComposingNextShot(true);
setSelectedShotIndex(-1);
window.requestAnimationFrame(() => composerFocusRef.current?.focus());
};
const cancelComposeNextShot = () => setComposingNextShot(false);
const generationActive = activeConversation.messages.some((message) => message.role === "assistant" && message.status === "pending");
const composerProps = {
mode,
prompt,
setPrompt,
busy,
generationActive,
referenceReplacementBusy,
attachments,
referenceImageSize,
@@ -973,12 +1001,9 @@ export default function CreatePage() {
promptOptimizerProvider,
composerFocusRef,
onPromptFocus: loadAddedSkills,
placeholderOverride: viewMode === "storyboard" && composingNextShot ? `${formatShotOrdinal(nextShotNumber - 1)} · 写下这一镜的镜头、画面或故事` : undefined,
onSubmit: () => void submit(),
};
const visibleShot = shots[visibleShotIndex];
const visibleShotResultIndex = visibleShot?.result ? activeConversation.messages.indexOf(visibleShot.result) : -1;
return <>
<div className="creation-home relative flex h-full min-h-0 flex-col overflow-hidden">
@@ -1001,49 +1026,21 @@ export default function CreatePage() {
onOpenLibrary={() => { selectMode("image"); setLibraryOpen(true); }}
/>
</main>
</> : viewMode === "chat" ? <div className="creation-thread-workbench">
<CreationWorkspaceToolbar viewMode={viewMode} onViewModeChange={setViewMode} onNewConversation={startNewConversation} onOpenHistory={() => setHistoryOpen(true)} />
</> : <div className="creation-thread-workbench">
<CreationWorkspaceToolbar onNewConversation={startNewConversation} onOpenHistory={() => setHistoryOpen(true)} shots={videoShots} onJumpToShot={jumpToShot} />
<main ref={threadScrollRef} onScroll={handleThreadScroll} className="creation-thread-scroll creation-scrollbar">
<section className="creation-thread-stage"><div className="creation-results">{activeConversation.messages.map((item, index) => <CreationMessageView
key={item.id}
<section className="creation-thread-stage"><div className="creation-results">{activeConversation.messages.map((item, index) => <div key={item.id} id={`creation-shot-${item.id}`} className="creation-thread-message"><CreationMessageView
item={item}
modelName={item.model ? modelDisplayName(config, item.model) : ""}
shotNumber={creationVideoShotOrdinal(videoShots, item)}
onRetryFailure={() => retryFailedMessage(item, index)}
onCreateVariant={() => createVariant(item, index)}
/>)}</div></section>
onEditUserMessage={(text) => { setPrompt(text); window.requestAnimationFrame(() => composerFocusRef.current?.focus()); }}
/></div>)}</div></section>
</main>
<section className="creation-thread-composer"><CreationComposer {...composerProps} variant="thread" /></section>
</div> : <div className="storyboard-workbench">
<StoryboardToolbar
shots={shots}
activeIndex={visibleShotIndex}
composing={composingNextShot}
onSelect={(index) => { setSelectedShotIndex(index); setComposingNextShot(false); }}
onBeginCompose={beginComposeNextShot}
onCancelCompose={cancelComposeNextShot}
onNewConversation={startNewConversation}
onOpenHistory={() => setHistoryOpen(true)}
viewMode={viewMode}
onViewModeChange={setViewMode}
/>
<main ref={threadScrollRef} onScroll={handleThreadScroll} className="storyboard-workbench-stage creation-scrollbar">
<div className="storyboard-workbench-stage-inner">
{composingNextShot ? <StoryboardNextShotCard shotNumber={nextShotNumber} onCancel={cancelComposeNextShot} /> : visibleShot ? <StoryboardShotCard
shot={visibleShot}
shotNumber={visibleShotIndex + 1}
modelName={visibleShot.result?.model ? modelDisplayName(config, visibleShot.result.model) : ""}
busy={busy}
onRetryFailure={() => { if (visibleShotResultIndex >= 0 && visibleShot.result) retryFailedMessage(visibleShot.result, visibleShotResultIndex); }}
onCreateVariant={() => { if (visibleShotResultIndex >= 0 && visibleShot.result) createVariant(visibleShot.result, visibleShotResultIndex); }}
/> : null}
</div>
</main>
<section className="storyboard-workbench-composer">
<CreationComposer {...composerProps} variant="thread" />
</section>
</div>}
</div>
<CreationHistoryDrawer open={historyOpen} conversations={historyConversations} activeId={activeConversation.id} onClose={() => setHistoryOpen(false)} onSelect={selectConversation} onDelete={confirmDeleteConversation} />
<CreationHistoryDrawer open={historyOpen} conversations={historyConversations} activeId={activeConversation.id} onNew={startNewConversation} onClose={() => setHistoryOpen(false)} onSelect={selectConversation} onDelete={confirmDeleteConversation} onRename={renameConversationTitle} />
{libraryOpen ? <Suspense fallback={null}><AssetLibraryPickerModal
remoteLibrary
open={libraryOpen}
@@ -1058,15 +1055,67 @@ export default function CreatePage() {
</>;
}
const creationAssetCategoryLabels: Record<string, string> = { all: "全部素材", ...ASSET_CATEGORY_LABELS };
function CreationHistoryDrawer({ open, conversations, activeId, onClose, onSelect, onDelete }: { open: boolean; conversations: CreationConversation[]; activeId: string; onClose: () => void; onSelect: (conversation: CreationConversation) => void; onDelete: (conversation: CreationConversation) => void }) {
function creationConversationBucket(updatedAt: string): "today" | "yesterday" | "week" | "earlier" {
const at = new Date(updatedAt).getTime();
if (!Number.isFinite(at)) return "earlier";
const nowStart = new Date();
nowStart.setHours(0, 0, 0, 0);
const targetStart = new Date(at);
targetStart.setHours(0, 0, 0, 0);
const days = Math.round((nowStart.getTime() - targetStart.getTime()) / 86400000);
if (days <= 0) return "today";
if (days === 1) return "yesterday";
if (days < 7) return "week";
return "earlier";
}
const creationBucketLabels: Record<"today" | "yesterday" | "week" | "earlier", string> = { today: "今天", yesterday: "昨天", week: "近 7 天", earlier: "更早" };
function CreationHistoryDrawer({ open, conversations, activeId, onNew, onClose, onSelect, onDelete, onRename }: { open: boolean; conversations: CreationConversation[]; activeId: string; onNew: () => void; onClose: () => void; onSelect: (conversation: CreationConversation) => void; onDelete: (conversation: CreationConversation) => void; onRename: (conversation: CreationConversation, title: string) => void }) {
const [keyword, setKeyword] = useState("");
const [renamingId, setRenamingId] = useState<string | null>(null);
const [menuOpenId, setMenuOpenId] = useState<string | null>(null);
const renameInputRef = useRef<HTMLInputElement>(null);
const skipRenameCommitRef = useRef(false);
const assistantName = useAppearanceStore((state) => state.appearance.brandName);
const exportUser = useUserStore((state) => state.user);
const { message: drawerToast } = App.useApp();
useEffect(() => {
if (open) setKeyword("");
if (!open) return;
setKeyword("");
setRenamingId(null);
setMenuOpenId(null);
}, [open]);
const commitRename = (conversation: CreationConversation) => {
const shouldSkip = skipRenameCommitRef.current;
skipRenameCommitRef.current = false;
const value = renameInputRef.current?.value.trim() || "";
setRenamingId(null);
if (shouldSkip || !value) return;
const original = conversation.title.trim() || "新创作";
if (value === original) return;
onRename(conversation, value);
};
const cancelRename = () => {
skipRenameCommitRef.current = true;
setRenamingId(null);
};
const beginRename = (conversation: CreationConversation) => {
skipRenameCommitRef.current = false;
setMenuOpenId(null);
setRenamingId(conversation.id);
};
const visibleConversations = useMemo(() => {
const query = keyword.trim().toLowerCase();
if (!query) return conversations;
@@ -1082,67 +1131,110 @@ function CreationHistoryDrawer({ open, conversations, activeId, onClose, onSelec
});
}, [conversations, keyword]);
return <Drawer open={open} onClose={onClose} placement="right" size="min(440px, 100vw)" closeIcon={<X className="size-4" />} className="creation-history-drawer" rootClassName="creation-history-drawer-root" styles={{ body: { padding: 0 } }} title={<div className="creation-history-title"><span>历史对话</span><small>{conversations.length} 个对话</small></div>}>
<div className="creation-history-content">
<label className="creation-history-search">
<Search aria-hidden="true" />
<input value={keyword} onChange={(event) => setKeyword(event.target.value)} placeholder="搜索对话标题或内容" aria-label="搜索历史对话" />
</label>
<button type="button" className="creation-history-new" onClick={onNew}><span className="creation-history-new-icon"><Plus /></span><span className="creation-history-new-copy"><strong>新建创作</strong><small>开启一个新的创作对话</small></span></button>
{visibleConversations.length ? <ul className="creation-history-list" aria-label="历史对话,按更新时间倒序排列">
{visibleConversations.map((conversation) => {
{visibleConversations.flatMap((conversation, index) => {
const showGroupHead = !keyword.trim() && (index === 0 || creationConversationBucket(conversation.updatedAt) !== creationConversationBucket(visibleConversations[index - 1].updatedAt));
const latest = conversationPreviewMessage(conversation);
const active = conversation.id === activeId;
return <li key={conversation.id} className={active ? "is-active" : undefined}>
<button type="button" className="creation-history-item-main" aria-current={active ? "page" : undefined} onClick={() => onSelect(conversation)}>
<span className="creation-history-time"><time dateTime={conversation.updatedAt}>{formatConversationTime(conversation.updatedAt)}</time><em>{latest?.mode ? modeLabels[latest.mode] : "创作"}</em></span>
<strong className="creation-history-item-heading">{conversation.title.trim() || "新创作"}</strong>
<span className="creation-history-snippet">{latest ? displayCreationPrompt(latest.content, latest.references || []).trim() || "还没有开始创作" : "还没有开始创作"}</span>
</button>
<Tooltip title="删除对话"><button type="button" className="creation-history-delete" aria-label={`删除对话:${conversation.title.trim() || "新创作"}`} onClick={() => onDelete(conversation)}><Trash2 /></button></Tooltip>
</li>;
const HistoryTypeIcon = latest?.mode === "video" ? Clapperboard : latest?.mode === "image" ? ImageIcon : latest?.mode === "text" ? MessageSquareText : Sparkles;
return [
showGroupHead ? <li key={`${conversation.id}-group`} className="creation-history-group-head"><h4>{creationBucketLabels[creationConversationBucket(conversation.updatedAt)]}</h4></li> : null,
<li key={conversation.id} className={active ? "is-active" : undefined}>
{renamingId === conversation.id ? (
<div className="creation-history-rename">
<input ref={renameInputRef} className="creation-history-rename-input" defaultValue={conversation.title.trim() || "新创作"} aria-label="重命名对话标题" autoFocus onFocus={(event) => event.currentTarget.select()} onKeyDown={(event) => { if (event.key === "Enter") { event.preventDefault(); event.currentTarget.blur(); } else if (event.key === "Escape") { cancelRename(); } }} onBlur={() => commitRename(conversation)} />
</div>
) : (
<div className={menuOpenId === conversation.id ? "creation-history-row is-menu-open" : "creation-history-row"}>
<button type="button" className="creation-history-item-main" aria-current={active ? "page" : undefined} onClick={() => { setMenuOpenId(null); onSelect(conversation); }}>
<span className="creation-history-item-icon" aria-hidden="true"><HistoryTypeIcon /></span>
<span className="creation-history-item-text">
<strong className="creation-history-item-heading">{conversation.title.trim() || "新创作"}</strong>
<span className="creation-history-snippet">{latest ? <><em>{latest.mode ? modeLabels[latest.mode] : "创作"}</em><span>{displayCreationPrompt(latest.content, latest.references || []).trim() || "还没有开始创作"}</span></> : <><em>创作</em><span>还没有开始创作</span></>}</span>
</span>
</button>
<span className="creation-history-time-slot" aria-hidden={menuOpenId === conversation.id}><time dateTime={conversation.updatedAt}>{formatHistoryRelativeTime(conversation.updatedAt)}</time></span>
<Dropdown trigger={["click"]} placement="bottomRight" open={menuOpenId === conversation.id} onOpenChange={(open) => setMenuOpenId(open ? conversation.id : null)} overlayClassName="creation-history-menu-overlay" menu={{ items: [{ key: "rename", label: "重命名", icon: <Pencil /> }, { key: "export", label: "导出对话", icon: <Download /> }, { key: "delete", label: "删除对话", danger: true, icon: <Trash2 /> }], onClick: ({ key }) => { setMenuOpenId(null); if (key === "rename") { beginRename(conversation); } else if (key === "export") { downloadCreationConversation(conversation, assistantName, exportUser?.displayName || "你"); drawerToast.success("对话已导出为 Markdown"); } else { onDelete(conversation); } } }}>
<button type="button" className={menuOpenId === conversation.id ? "creation-history-more is-open" : "creation-history-more"} aria-label={`更多操作:${conversation.title.trim() || "新创作"}`} onClick={(event) => event.preventDefault()}><MoreHorizontal /></button>
</Dropdown>
</div>
)}
</li>,
];
})}
</ul> : <div className="creation-history-empty">{keyword.trim() ? "没有找到匹配的对话" : "暂无历史对话"}</div>}
</div>
</Drawer>;
}
function CreationViewSwitch({ viewMode, onChange }: { viewMode: CreationViewMode; onChange: (mode: CreationViewMode) => void }) {
return <div className="creation-view-switch" role="group" aria-label="创作视图">
<button type="button" aria-pressed={viewMode === "chat"} onClick={() => onChange("chat")}><MessageSquareText />连续对话</button>
<button type="button" aria-pressed={viewMode === "storyboard"} onClick={() => onChange("storyboard")}><Clapperboard />镜头创作</button>
</div>;
}
function CreationWorkspaceToolbar({ viewMode, onViewModeChange, onNewConversation, onOpenHistory }: { viewMode: CreationViewMode; onViewModeChange: (mode: CreationViewMode) => void; onNewConversation: () => void; onOpenHistory: () => void }) {
function CreationWorkspaceToolbar({ shots, onJumpToShot, onNewConversation, onOpenHistory }: { shots: CreationShotRailEntry[]; onJumpToShot: (shot: CreationShotRailEntry) => void; onNewConversation: () => void; onOpenHistory: () => void }) {
const [railOpen, setRailOpen] = useState(false);
const railRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!railOpen) return;
const onPointerDown = (event: MouseEvent) => { if (railRef.current && !railRef.current.contains(event.target as Node)) setRailOpen(false); };
window.addEventListener("mousedown", onPointerDown);
return () => window.removeEventListener("mousedown", onPointerDown);
}, [railOpen]);
return <header className="creation-thread-toolbar">
<CreationViewSwitch viewMode={viewMode} onChange={onViewModeChange} />
<div className="storyboard-workbench-bar-actions">
<Tooltip title="新建创作"><button type="button" aria-label="新建创作" className="storyboard-workbench-bar-action" onClick={onNewConversation}><Plus /></button></Tooltip>
<Tooltip title="历史对话"><button type="button" aria-label="查看历史对话" className="storyboard-workbench-bar-action" onClick={onOpenHistory}><History /></button></Tooltip>
<div className="creation-toolbar-shots" ref={railRef}>
<button type="button" className="creation-rail-trigger" aria-expanded={railOpen} aria-haspopup="listbox" onClick={() => setRailOpen((open) => !open)}><Clapperboard />镜头时间线{shots.length > 0 ? <em className="creation-rail-count">{shots.length}</em> : null}</button>
{railOpen ? <div className="creation-rail-pop" role="listbox" aria-label="镜头时间线">
<div className="creation-rail-pop-head"><span className="creation-rail-pop-title">镜头时间线<small>{shots.length ? `共 ${shots.length} 镜` : "空轨道"}</small></span><button type="button" className="creation-rail-pop-close" aria-label="关闭镜头列表" onClick={() => setRailOpen(false)}><X /></button></div>
{shots.length ? <ol className="creation-rail-list">{shots.map((shot) => {
const resultStatus = shot.result?.status;
const statusLabel = resultStatus === "done" ? "完成" : resultStatus === "error" ? "生成失败" : resultStatus === "pending" ? "生成中" : resultStatus === "cancelled" ? "已停止" : "待生成";
return <li key={shot.key}><button type="button" role="option" aria-selected="false" className="creation-rail-row" onClick={() => { setRailOpen(false); onJumpToShot(shot); }}>
<span className="creation-rail-row-shot">{formatShotOrdinal(shot.ordinal - 1)}</span>
<span className="creation-rail-row-prompt">{shot.user.content || "视频镜头"}</span>
<span className={`creation-rail-row-state is-${resultStatus || "idle"}`}>{statusLabel}</span>
</button></li>;
})}</ol> : <p className="creation-rail-empty">在下方发送一条视频消息,就会自动成为第 1 镜。</p>}
</div> : null}
</div>
<div className="creation-toolbar-actions">
<Tooltip title="新建创作"><button type="button" aria-label="新建创作" className="creation-toolbar-action" onClick={onNewConversation}><Plus /></button></Tooltip>
<Tooltip title="历史对话"><button type="button" aria-label="查看历史对话" className="creation-toolbar-action" onClick={onOpenHistory}><History /></button></Tooltip>
</div>
</header>;
}
function CreationMessageView({ item, modelName, onRetryFailure, onCreateVariant }: { item: CreationMessage; modelName: string; onRetryFailure: () => void; onCreateVariant: () => void }) {
function CreationMessageView({ item, shotNumber, onRetryFailure, onCreateVariant, onEditUserMessage }: { item: CreationMessage; shotNumber: number; onRetryFailure: () => void; onCreateVariant: () => void; onEditUserMessage: (text: string) => void }) {
const brandName = useAppearanceStore((state) => state.appearance.brandName);
if (item.role === "user") return <CreationUserMessage item={item} />;
if (item.role === "user") return <CreationUserMessage item={item} shotNumber={shotNumber} onEditUserMessage={onEditUserMessage} />;
const mode = item.mode || "text";
const stateLabel = item.status === "pending" ? "生成中" : item.status === "cancelled" ? "已停止" : item.status === "error" ? "生成失败" : "";
const heading = <><span className="creation-message-mark"><Sparkles /></span><strong>{mode === "image" ? "图像生成" : mode === "video" ? "视频生成" : `${brandName} AI`}</strong>{mode !== "text" ? <span className="creation-message-progress-copy">{item.status === "pending" ? `${brandName}正在生成${mode === "video" ? "视频" : "图像"}……` : item.status === "done" ? `你的${mode === "video" ? "视频" : "图像"}已创建` : null}</span> : null}{modelName ? <span className="creation-message-model">{modelName}</span> : null}{item.createdAt ? <time dateTime={item.createdAt}>{formatMessageTime(item.createdAt)}</time> : null}{stateLabel ? <span className={`creation-message-state is-${item.status}`}>{stateLabel}</span> : null}{mode !== "text" && item.status === "done" ? <button type="button" className="creation-message-variant-action" onClick={onCreateVariant}><RefreshCw />生成同款</button> : null}</>;
const heading =
mode !== "text" ? (
<>{shotNumber > 0 ? <span className="creation-shot-badge">镜 {shotNumber}</span> : null}<span className="creation-message-mark"><Sparkles /></span><strong>{mode === "image" ? "图像生成" : "视频生成"}</strong>{item.status === "pending" ? <span className="creation-message-progress-copy">{brandName}正在生成{mode === "video" ? "视频" : "图像"}……</span> : item.status === "done" ? <span className="creation-message-progress-copy">你的{mode === "video" ? "视频" : "图像"}已创建</span> : null}{item.status === "done" ? <button type="button" className="creation-message-variant-action" onClick={onCreateVariant}><RefreshCw />生成同款</button> : null}{item.createdAt ? <time dateTime={item.createdAt}>{formatMessageTime(item.createdAt)}</time> : null}{stateLabel ? <span className={`creation-message-state is-${item.status}`}>{stateLabel}</span> : null}</>
) : (
<>{shotNumber > 0 ? <span className="creation-shot-badge">镜 {shotNumber}</span> : null}<span className="creation-message-mark"><Sparkles /></span><strong>{brandName}</strong>{item.createdAt ? <time dateTime={item.createdAt}>{formatMessageTime(item.createdAt)}</time> : null}{stateLabel ? <span className={`creation-message-state is-${item.status}`}>{stateLabel}</span> : null}</>
);
const toolStatus: GenerationToolStatus = item.status === "pending" ? "running" : item.status === "error" ? "error" : item.status === "cancelled" ? "cancelled" : "completed";
return <article className={`creation-assistant-message is-${mode}`}>
{mode === "text" ? <><div className="creation-message-heading">{heading}</div>{item.reasoning ? <MessageReasoning reasoning={item.reasoning} isStreaming={item.status === "streaming"} /> : null}<div className="creation-message-content">{item.content ? <AIMessageMarkdown isStreaming={item.status === "streaming"}>{item.content}</AIMessageMarkdown> : <span>正在生成…</span>}</div></> : <GenerationToolCard status={toolStatus} isBulk={(item.resultUrls?.length || Number(item.settings?.count) || 1) > 1} heading={heading}><MediaResult item={item} onRetryFailure={onRetryFailure} onCreateVariant={onCreateVariant} /></GenerationToolCard>}
{mode === "text" ? <><div className="creation-message-heading">{heading}</div>{item.reasoning ? <div className="creation-message-reasoning-wrap"><MessageReasoning reasoning={item.reasoning} isStreaming={item.status === "streaming"} /></div> : null}<div className="creation-message-content">{item.content ? <AIMessageMarkdown isStreaming={item.status === "streaming"}>{item.content}</AIMessageMarkdown> : <span style={{ display: "inline-flex", alignItems: "center", gap: 8 }}><WorkingDots dotSize={5} gap={2} /><span>正在生成…</span></span>}</div></> : <GenerationToolCard status={toolStatus} heading={heading}><MediaResult item={item} onRetryFailure={onRetryFailure} onCreateVariant={onCreateVariant} /></GenerationToolCard>}
{item.error && mode === "text" ? <div className="creation-message-error"><span>{generationErrorMessage(item.error)}</span><button type="button" onClick={onRetryFailure}><RefreshCw />重新生成</button></div> : null}
</article>;
}
function CreationUserMessage({ item }: { item: CreationMessage }) {
function CreationUserMessage({ item, shotNumber, onEditUserMessage }: { item: CreationMessage; shotNumber: number; onEditUserMessage: (text: string) => void }) {
const [previewUrl, setPreviewUrl] = useState("");
const [previewType, setPreviewType] = useState<"image" | "video">("image");
const copyText = useCopyText();
const visiblePrompt = displayCreationPrompt(item.content, item.references || []);
const user = useUserStore((state) => state.user);
const userAvatarUrl = user?.avatarUrl?.trim();
return <article className="creation-user-message">
<div className="creation-user-message-meta"><span>你</span>{item.createdAt ? <time dateTime={item.createdAt}>{formatMessageTime(item.createdAt)}</time> : null}<Tooltip title="复制消息"><button type="button" className="creation-user-message-copy" aria-label="复制提示词" onClick={() => copyText(visiblePrompt, "提示词已复制")}><Copy /></button></Tooltip></div>
<div className="creation-user-message-meta">{shotNumber > 0 ? <span className="creation-shot-badge">镜 {shotNumber}</span> : null}{item.createdAt ? <time dateTime={item.createdAt}>{formatMessageTime(item.createdAt)}</time> : null}<strong>{user?.displayName || "你"}</strong><span className="creation-user-avatar">{userAvatarUrl ? <img src={userAvatarUrl} alt="" referrerPolicy="no-referrer" loading="lazy" decoding="async" /> : <UserRound />}</span></div>
<div className="creation-user-message-copy-wrap"><p>{visiblePrompt}</p></div>
{item.references?.length ? <CreationMessageReferences references={item.references} /> : null}
{item.attachments?.length ? <div className="creation-user-message-attachments">{item.attachments.map((attachment) => {
@@ -1153,6 +1245,7 @@ function CreationUserMessage({ item }: { item: CreationMessage }) {
const previewUrl = kind === "image" ? imageUrl : url;
return <button key={attachment.id} type="button" className={!previewable ? "is-file" : undefined} onClick={() => { if (!previewable) return; setPreviewType(kind === "video" ? "video" : "image"); setPreviewUrl(kind === "video" ? attachment.url || "" : previewUrl); }} aria-label={previewable ? `预览 ${attachment.name || "附件"}` : attachment.name || "附件"} disabled={previewable && !previewUrl}>{kind === "video" ? <video src={attachment.url || ""} poster={url !== attachment.url ? url : undefined} muted playsInline preload="metadata" /> : kind === "image" ? <CachedResourceImage storageKey={attachment.storageKey} src={imageUrl} alt={attachment.name || "附件"} width={44} height={44} loading="lazy" decoding="async" /> : kind === "audio" ? <Music2 /> : <FileText />}{previewable ? <span aria-hidden="true"><Maximize2 /></span> : null}</button>;
})}</div> : null}
<div className="creation-user-message-actions"><Tooltip title="复制提示词"><button type="button" className="creation-user-message-copy" aria-label="复制提示词" onClick={() => copyText(visiblePrompt, "提示词已复制")}><Copy /></button></Tooltip><Tooltip title="编辑并重新发送"><button type="button" className="creation-user-message-edit" aria-label="编辑提示词" onClick={() => onEditUserMessage(visiblePrompt)}><Pencil /></button></Tooltip></div>
<CreationMediaPreviewModal url={previewUrl} type={previewType} onClose={() => setPreviewUrl("")} />
</article>;
}
@@ -1177,7 +1270,7 @@ function MediaResult({ item, onRetryFailure, onCreateVariant }: { item: Creation
function CreationMediaPending({ mode, ratio }: { mode: CreationMode; ratio?: string }) {
const brandName = useAppearanceStore((state) => state.appearance.brandName);
return <div className={`creation-media-pending is-${mode}`} style={{ aspectRatio: creationMediaAspectRatio(ratio, mode) }} aria-live="polite"><span className="creation-media-pending-icon"><Sparkles /></span><span className="sr-only">{brandName}正在生成{mode === "video" ? "视频" : "图像"}</span></div>;
return <div className={`creation-media-pending is-${mode}`} style={{ aspectRatio: creationMediaAspectRatio(ratio, mode) }} aria-live="polite"><span className="creation-media-pending-icon"><WorkingDots dotSize={7} gap={3} minOpacity={0.3} /></span><span className="sr-only">{brandName}正在生成{mode === "video" ? "视频" : "图像"}</span></div>;
}
function CreationMessageReferences({ references }: { references: CreationReference[] }) {
@@ -1289,6 +1382,7 @@ type ComposerProps = {
prompt: string;
setPrompt: (value: string) => void;
busy: boolean;
generationActive: boolean;
referenceReplacementBusy: boolean;
attachments: CreationAttachment[];
referenceImageSize?: { width: number; height: number };
@@ -1344,6 +1438,7 @@ function CreationComposer(props: ComposerProps) {
const [trackState, setTrackState] = useState({ canScrollLeft: false, canScrollRight: false, isExpanded: true, isDragging: false });
const previousAttachmentCountRef = useRef(0);
const interactionBusy = props.busy || props.referenceReplacementBusy;
const hasWork = interactionBusy || props.generationActive;
const canSubmit = Boolean(props.prompt.trim()) && !interactionBusy;
const creditsEnabled = useUserStore((state) => state.features.creditsEnabled);
const priceChannel = resolveModelChannel(props.config, props.model);
@@ -1358,7 +1453,13 @@ function CreationComposer(props: ComposerProps) {
});
const showCost = creditsEnabled && credits !== null;
const formattedCredits = credits?.toLocaleString("zh-CN", { maximumFractionDigits: 6 });
const actionLabel = props.referenceReplacementBusy ? "正在替换参考图" : props.busy ? "生成中" : showCost ? `预计消耗 ${formattedCredits} 积分,发送` : "发送";
const actionLabel = props.referenceReplacementBusy ? "正在替换参考图" : interactionBusy || (props.generationActive && !canSubmit) ? "生成中" : showCost ? `预计消耗 ${formattedCredits} 积分,发送` : "发送";
// Send-button working state must span the WHOLE generation (not just the
// submit-lock window): spinner + glow stay while a message is pending and
// the composer is empty; typing a next prompt returns the arrow so the
// user knows a new send is possible.
const showWorkingSpinner = interactionBusy || (props.generationActive && !canSubmit);
const showWorkingGlow = props.generationActive && !canSubmit;
const placeholder = props.mode === "text"
? "描述你的故事、角色或想继续讨论的创意"
: props.mode === "image"
@@ -1559,8 +1660,8 @@ function CreationComposer(props: ComposerProps) {
{props.mode === "video" || (props.mode === "image" && imageSettingsSupported) ? <GenerationSettingsMenu {...props} /> : null}
{props.mode === "video" ? <DurationMenu profile={props.videoProfile} seconds={props.seconds} onChange={props.setSeconds} /> : null}
{props.mode === "text" ? <>
<Tooltip title={props.textStreaming ? "流式输出已开启" : "流式输出已关闭"}><button type="button" className="creation-chat-control" aria-pressed={props.textStreaming} onClick={() => props.setTextStreaming(!props.textStreaming)}><Waves /><span>流式</span></button></Tooltip>
<Tooltip title={props.textThinking ? "思考已开启,会展示模型返回的推理摘要" : "开启模型思考"}><button type="button" className="creation-chat-control" aria-pressed={props.textThinking} onClick={() => props.setTextThinking(!props.textThinking)}><Brain /><span>思考</span></button></Tooltip>
<Tooltip title={interactionBusy ? "生成中,此开关将在下次发送时生效" : (props.textStreaming ? "流式输出已开启" : "流式输出已关闭")}><button type="button" className="creation-chat-control" aria-pressed={props.textStreaming} disabled={interactionBusy} onClick={() => props.setTextStreaming(!props.textStreaming)}><Waves /><span>流式</span></button></Tooltip>
<Tooltip title={interactionBusy ? "生成中,此开关将在下次发送时生效" : (props.textThinking ? "思考已开启,会展示模型返回的推理摘要" : "开启模型思考")}><button type="button" className="creation-chat-control" aria-pressed={props.textThinking} disabled={interactionBusy} onClick={() => props.setTextThinking(!props.textThinking)}><Brain /><span>思考</span></button></Tooltip>
</> : null}
{props.prompt.trim() || props.attachments.length || props.references.some((reference) => reference.active) ? <Tooltip title="清空提示词和参考内容"><button type="button" className="creation-chat-control is-clear" onClick={props.onClearComposer} disabled={interactionBusy} aria-label="清空提示词和参考内容"><Trash2 /><span>清空</span></button></Tooltip> : null}
</div>
@@ -1569,16 +1670,18 @@ function CreationComposer(props: ComposerProps) {
className={`canvas-node-composer-submit ${showCost ? "has-cost" : ""}`}
disabled={interactionBusy || !canSubmit}
style={{
color: !interactionBusy && !canSubmit ? "var(--creation-faint)" : "var(--creation-text)",
"--canvas-composer-submit-action": !interactionBusy && !canSubmit ? "var(--creation-surface-hover)" : "var(--creation-text)",
"--canvas-composer-submit-action-fg": !interactionBusy && !canSubmit ? "var(--creation-faint)" : "var(--creation-bg)",
position: "relative",
color: !hasWork && !canSubmit ? "var(--creation-faint)" : "var(--creation-text)",
"--canvas-composer-submit-action": !hasWork && !canSubmit ? "var(--creation-surface-hover)" : "var(--creation-text)",
"--canvas-composer-submit-action-fg": !hasWork && !canSubmit ? "var(--creation-faint)" : "var(--creation-bg)",
} as CSSProperties}
onClick={interactionBusy ? undefined : props.onSubmit}
aria-label={actionLabel}
title={actionLabel}
>
{showWorkingGlow ? <WorkingGlow active color="var(--creation-text)" radius="999px" /> : null}
{showCost ? <span className="canvas-node-composer-submit-cost"><CreditSymbol /><span>{formattedCredits}</span></span> : null}
<span className="canvas-node-composer-submit-action" aria-hidden>{interactionBusy ? <LoaderCircle className="size-3 animate-spin" /> : <ArrowUp className="size-3" />}</span>
<span className="canvas-node-composer-submit-action" aria-hidden>{showWorkingSpinner ? <LoaderCircle className="size-3 animate-spin" /> : <ArrowUp className="size-3" />}</span>
</Button>
</footer>
<CreationMediaPreviewModal url={previewUrl} type={previewType} onClose={() => setPreviewUrl("")} />
@@ -1729,198 +1832,73 @@ const creationEmptySuggestions: Array<{ mode: CreationMode; icon: typeof Clapper
];
function CreationEmptySuggest({ onStartPrompt, onOpenLibrary }: { onStartPrompt: (mode: CreationMode, prompt: string) => void; onOpenLibrary: () => void }) {
const [main, ...rest] = creationEmptySuggestions;
const MainIcon = main.icon;
return <div className="creation-empty-suggest">
{creationEmptySuggestions.map((item) => {
<button type="button" className="creation-hero-prompt" onClick={() => { if (main.openLibrary) onOpenLibrary(); else onStartPrompt(main.mode, main.prompt); }}>
<span className="creation-hero-prompt-ray" aria-hidden="true" />
<span className={`library-icon-tile suggest-icon is-${main.mode}`}><MainIcon size={16} strokeWidth={2} /></span>
<span className="creation-hero-prompt-copy">
<strong>{main.title}</strong>
<span className="creation-hero-prompt-hint">{main.hint}</span>
<em className="creation-hero-prompt-text">“{main.prompt}”</em>
</span>
<Sparkles className="creation-hero-prompt-spark" aria-hidden="true" />
</button>
<div className="creation-empty-suggest-grid">{rest.map((item) => {
const Icon = item.icon;
return <button key={item.title} type="button" className="suggest-card" onClick={() => { if (item.openLibrary) onOpenLibrary(); else onStartPrompt(item.mode, item.prompt); }}>
<span className={`library-icon-tile suggest-icon is-${item.mode}`}><Icon size={15} strokeWidth={2} /></span>
<span className={`library-icon-tile suggest-icon is-${item.mode}`}><Icon size={16} strokeWidth={2} /></span>
<span className="suggest-copy"><strong>{item.title}</strong><span>{item.hint}</span></span>
</button>;
})}
})}</div>
</div>;
}
type CreationThinking = { title: string; hint: string; steps: string[] };
type CreationThinking = { title: string; hint: string; steps: string[]; activity: string };
function thinkingFor(mode: CreationMode, brandName: string): CreationThinking {
if (mode === "image") return { title: "正在为你画这一镜", hint: `${brandName}正在理解你的构图意图,并把画面交给模型出图。`, steps: ["理解构图", "定调画风", "生成画面"] };
if (mode === "text") return { title: "正在为你写这段", hint: `${brandName}正在梳理你的创作脉络,组织语言与结构。`, steps: ["梳理脉络", "组织语言", "输出段落"] };
return { title: "正在为你拍这一镜", hint: `${brandName}正在拆解你的镜头脚本,设计运镜与光线,并交给模型渲染成片。`, steps: ["拆解镜头", "设计运镜", "定调布光", "渲染成片"] };
if (mode === "image") return { title: "正在为你画这一镜", hint: `${brandName}正在理解你的构图意图,并把画面交给模型出图。`, steps: ["理解构图", "定调画风", "生成画面"], activity: "正在理解构图并把画面交给模型出图" };
if (mode === "text") return { title: "正在为你写这段", hint: `${brandName}正在梳理你的创作脉络,组织语言与结构。`, steps: ["梳理脉络", "组织语言", "输出段落"], activity: "正在梳理脉络并组织语言" };
return { title: "正在为你拍这一镜", hint: `${brandName}正在拆解你的镜头脚本,设计运镜与光线,并交给模型渲染成片。`, steps: ["拆解镜头", "设计运镜", "定调布光", "渲染成片"], activity: "正在按导演思路拆解镜头并渲染" };
}
function directorNoteFor(mode: CreationMode, settings: CreationSettings): string {
if (mode === "video") return `已按 ${[`${settings.seconds}s`, ...(settings.videoQuality ? [videoResolutionLabel(settings.videoQuality)] : []), settings.ratio].join(" · ")} 渲染这一镜,等待你的下一句指令。`;
if (mode === "image") return `已按 ${settings.ratio} 出图 ${settings.count} 张,等待你的下一句指令。`;
return "";
}
function StoryboardToolbar({ shots, activeIndex, composing, onSelect, onBeginCompose, onCancelCompose, onNewConversation, onOpenHistory, viewMode, onViewModeChange }: { shots: CreationShot[]; activeIndex: number; composing: boolean; onSelect: (index: number) => void; onBeginCompose: () => void; onCancelCompose: () => void; onNewConversation: () => void; onOpenHistory: () => void; viewMode: CreationViewMode; onViewModeChange: (mode: CreationViewMode) => void }) {
const [railOpen, setRailOpen] = useState(false);
const nextShotNumber = shots.length + 1;
const closeRail = () => setRailOpen(false);
const statusOf = (shot: CreationShot) => shot.result?.status || "queued";
const shotTitle = (shot: CreationShot) => shot.user ? displayCreationPrompt(shot.user.content, shot.user.references || []).trim() || "未命名镜头" : "镜头";
return <header className="storyboard-workbench-bar" aria-label="镜头工具条">
<div className="storyboard-workbench-rail">
<Tooltip title="镜头时间线"><button type="button" className={`storyboard-workbench-rail-button${railOpen ? " is-open" : ""}${composing ? " is-draft" : ""}`} aria-expanded={railOpen} aria-label="镜头时间线" onClick={() => setRailOpen((value) => !value)}><Film /><span className="storyboard-workbench-rail-badge">{composing ? nextShotNumber : shots.length}</span></button></Tooltip>
{railOpen ? <div className="storyboard-workbench-rail-pop" role="listbox" aria-label="镜头列表">
<div className="storyboard-workbench-rail-pop-head"><span className="storyboard-workbench-rail-pop-title"><Clapperboard />镜头时间线<small>{composing ? `下一镜 ${formatShotOrdinal(nextShotNumber - 1)}` : `${shots.length} 个镜头`}</small></span><button type="button" className="storyboard-workbench-rail-pop-close" aria-label="关闭镜头列表" onClick={closeRail}><X /></button></div>
<ul className="creation-scrollbar">
{shots.map((shot, index) => {
const status = statusOf(shot);
const title = shotTitle(shot);
const thumbUrl = shot.result?.resultUrls?.[0];
const thumbIsVideo = shot.result?.mode === "video";
return <li key={shot.user?.id || shot.result?.id || index}>
<button type="button" className={`storyboard-workbench-rail-row${index === activeIndex && !composing ? " is-active" : ""}`} onClick={() => { onSelect(index); closeRail(); }}>
<span className="storyboard-workbench-rail-thumb">{thumbUrl ? (thumbIsVideo ? <video muted preload="metadata" src={thumbUrl} /> : <img src={thumbUrl} alt="" />) : <span className="storyboard-workbench-rail-thumb-ph"><Clapperboard /><em>{formatShotOrdinal(index)}</em></span>}</span>
<span className="storyboard-workbench-rail-info">
<span className="storyboard-workbench-rail-head"><span className="storyboard-workbench-rail-row-shot">{formatShotOrdinal(index)}</span><span className={`storyboard-workbench-rail-row-state is-${status}`}>{status === "pending" ? "生成中" : status === "error" ? "失败" : status === "done" ? "完成" : "待生成"}</span>{shot.result?.createdAt ? <time dateTime={shot.result.createdAt}>{formatMessageTime(shot.result.createdAt)}</time> : null}</span>
<span className="storyboard-workbench-rail-row-title">{title}</span>
</span>
</button>
</li>;
})}
{composing ? <li><button type="button" className="storyboard-workbench-rail-row is-draft" onClick={() => { onCancelCompose(); closeRail(); }}><span className="storyboard-workbench-rail-thumb"><span className="storyboard-workbench-rail-thumb-ph"><Clapperboard /><em>{formatShotOrdinal(nextShotNumber - 1)}</em></span></span><span className="storyboard-workbench-rail-info"><span className="storyboard-workbench-rail-head"><span className="storyboard-workbench-rail-row-shot">{formatShotOrdinal(nextShotNumber - 1)}</span><span className="storyboard-workbench-rail-row-state">待撰写</span></span><span className="storyboard-workbench-rail-row-title">等待你的脚本</span></span></button></li> : null}
</ul>
<button type="button" className="storyboard-workbench-rail-pop-add" onClick={() => { closeRail(); onBeginCompose(); }}><Plus />新增镜头</button>
</div> : null}
</div>
<div className="storyboard-workbench-bar-actions">
<CreationViewSwitch viewMode={viewMode} onChange={onViewModeChange} />
<Tooltip title={composing ? "收起下一镜" : "新增镜头"}><button type="button" aria-label={composing ? "收起下一镜" : "新增镜头"} className="storyboard-workbench-bar-action" onClick={composing ? onCancelCompose : onBeginCompose}>{composing ? <X /> : <Clapperboard />}</button></Tooltip>
<Tooltip title="新建创作"><button type="button" aria-label="新建创作" className="storyboard-workbench-bar-action" onClick={onNewConversation}><Plus /></button></Tooltip>
<Tooltip title="历史对话"><button type="button" aria-label="查看历史对话" className="storyboard-workbench-bar-action" onClick={onOpenHistory}><History /></button></Tooltip>
</div>
</header>;
}
function StoryboardShotCard({ shot, shotNumber, modelName, busy, onRetryFailure, onCreateVariant }: { shot: CreationShot; shotNumber: number; modelName: string; busy: boolean; onRetryFailure: () => void; onCreateVariant: () => void }) {
const brandName = useAppearanceStore((state) => state.appearance.brandName);
const user = shot.user;
const result = shot.result;
const status = result?.status || "queued";
const mode = result?.mode || user?.mode || "video";
const briefVisible = Boolean(user?.content.trim() || user?.references?.length || user?.attachments?.length);
const copyText = useCopyText();
const assets = useAssetStore((state) => state.assets);
const visiblePrompt = user ? displayCreationPrompt(user.content, user.references || []) : "";
const resultUrls = result?.resultUrls || [];
const resultAssetIds = result && resultUrls.length ? creationResultAssetIds(assets, { messageId: result.id, taskIds: result.taskIds || [], resultUrls }) : [];
const canvasHandoffPath = result ? creationCanvasHandoffPath(resultAssetIds, resultUrls.length) : "";
const canvasPath = canvasHandoffPath || "/canvas";
return <article className={`storyboard-workbench-card is-${status}`}>
<header className="storyboard-workbench-card-head">
<div className="storyboard-workbench-card-heading">
<span className="storyboard-workbench-card-shot"><span className="storyboard-workbench-card-shot-index">{formatShotOrdinal(shotNumber - 1)}</span></span>
<span className="storyboard-workbench-card-mode">{mode === "video" ? <Film /> : mode === "image" ? <ImageIcon /> : <MessageSquareText />}{modeLabels[mode]}</span>
{modelName ? <span className="storyboard-workbench-card-model">{modelName}</span> : null}
{status === "pending" ? <span className="storyboard-workbench-card-state is-pending"><LoaderCircle className="animate-spin" />生成中</span> : status === "error" ? <span className="storyboard-workbench-card-state is-error">生成失败</span> : status === "done" ? <span className="storyboard-workbench-card-state is-done"><Check />已完成</span> : <span className="storyboard-workbench-card-state">待生成</span>}
</div>
<div className="storyboard-workbench-card-actions">
{status === "error" ? <button type="button" onClick={onRetryFailure} disabled={busy}><RefreshCw />重新生成</button> : null}
{status === "done" && result?.resultUrls?.length ? <button type="button" onClick={onCreateVariant} disabled={busy}><RefreshCw />生成变体</button> : null}
{status === "done" && resultUrls.length ? <Link to={canvasPath}>{canvasHandoffPath ? "添加到画布" : "打开画布"}</Link> : null}
{resultUrls.map((url, index) => <a key={`${url}-download`} href={url} download>{resultUrls.length > 1 ? `下载 ${index + 1}` : <><Download />下载</>}</a>)}
</div>
</header>
<div className="storyboard-workbench-card-body">
<div className="storyboard-workbench-thread" aria-label={`镜头 ${shotNumber} 的对话过程`}>
{briefVisible && user ? <div className="storyboard-workbench-turn is-user">
<div className="storyboard-workbench-turn-copy">
<div className="storyboard-workbench-turn-meta"><span className="storyboard-workbench-turn-role">{shotScriptLabels[mode]}</span>{user.createdAt ? <time className="storyboard-workbench-turn-time" dateTime={user.createdAt}>{formatMessageTime(user.createdAt)}</time> : null}<Tooltip title="复制消息"><button type="button" className="creation-user-message-copy" aria-label="复制提示词" onClick={() => copyText(visiblePrompt, "提示词已复制")}><Copy /></button></Tooltip></div>
<div className="storyboard-workbench-turn-bubble">
<p className="storyboard-workbench-turn-text">{visiblePrompt}</p>
{user.references?.length ? <CreationMessageReferences references={user.references} /> : null}
{user.attachments?.length ? <StoryboardBriefAttachments attachments={user.attachments} /> : null}
</div>
</div>
</div> : null}
{briefVisible && user ? <div className="storyboard-workbench-handoff" aria-hidden="true"><span className="storyboard-workbench-handoff-rail" /><span className="storyboard-workbench-handoff-badge"><ArrowDown />交给{brandName} AI</span><span className="storyboard-workbench-handoff-rail" /></div> : null}
<div className="storyboard-workbench-turn is-ai">
<span className="storyboard-workbench-ai-avatar"><Clapperboard /></span>
<div className="storyboard-workbench-turn-copy">
<div className="storyboard-workbench-turn-meta"><span className="storyboard-workbench-turn-role is-ai"><Sparkles />{brandName} AI</span>{modelName ? <span className="storyboard-workbench-turn-model">{modelName}</span> : null}{result?.createdAt ? <time className="storyboard-workbench-turn-time" dateTime={result.createdAt}>{formatMessageTime(result.createdAt)}</time> : null}</div>
<div className="storyboard-workbench-turn-bubble">
<StoryboardShotResult result={result} onRetryFailure={onRetryFailure} onCreateVariant={onCreateVariant} canvasPath={canvasPath} canvasHandoffAvailable={Boolean(canvasHandoffPath)} />
</div>
</div>
</div>
</div>
</div>
</article>;
}
function StoryboardNextShotCard({ shotNumber, onCancel }: { shotNumber: number; onCancel: () => void }) {
const brandName = useAppearanceStore((state) => state.appearance.brandName);
return <article className="storyboard-workbench-card is-next">
<header className="storyboard-workbench-card-head">
<div className="storyboard-workbench-card-heading">
<span className="storyboard-workbench-card-shot"><span className="storyboard-workbench-card-shot-index">{formatShotOrdinal(shotNumber - 1)}</span>下一镜</span>
<span className="storyboard-workbench-card-state is-draft"><Clapperboard />待撰写</span>
</div>
<div className="storyboard-workbench-card-actions">
<button type="button" onClick={onCancel}><X />取消撰写</button>
</div>
</header>
<div className="storyboard-workbench-card-body">
<div className="storyboard-workbench-next-panel">
<span className="storyboard-workbench-next-panel-icon"><Clapperboard /></span>
<div className="storyboard-workbench-next-panel-copy">
<strong>{formatShotOrdinal(shotNumber - 1)} 等待你的脚本</strong>
<span>在下方写下这一镜的镜头、画面或故事。{brandName}会拆解脚本、设计运镜并渲染成片,这一镜会作为 {formatShotOrdinal(shotNumber - 1)} 自动加入镜头轨道。</span>
</div>
</div>
</div>
</article>;
}
function StoryboardBriefAttachments({ attachments }: { attachments: CreationAttachment[] }) { const [previewUrl, setPreviewUrl] = useState("");
const [previewType, setPreviewType] = useState<"image" | "video">("image");
return <><div className="creation-user-message-attachments storyboard-workbench-brief-attachments">{attachments.map((attachment) => {
const kind = creationAttachmentKind(attachment);
const previewable = kind === "image" || kind === "video";
const url = attachment.previewUrl || ("dataUrl" in attachment ? attachment.dataUrl : attachment.url) || "";
const imageUrl = kind === "image" ? resolveResourceUrl(attachment.storageKey, url) : "";
const previewUrl = kind === "image" ? imageUrl : url;
return <button key={attachment.id} type="button" className={!previewable ? "is-file" : undefined} onClick={() => { if (!previewable) return; setPreviewType(kind === "video" ? "video" : "image"); setPreviewUrl(kind === "video" ? attachment.url || "" : previewUrl); }} aria-label={previewable ? `预览 ${attachment.name || "附件"}` : attachment.name || "附件"} disabled={previewable && !previewUrl}>{kind === "video" ? <video src={attachment.url || ""} poster={url !== attachment.url ? url : undefined} muted playsInline preload="metadata" /> : kind === "image" ? <CachedResourceImage storageKey={attachment.storageKey} src={imageUrl} alt={attachment.name || "附件"} width={44} height={44} loading="lazy" decoding="async" /> : kind === "audio" ? <Music2 /> : <FileText />}{previewable ? <span aria-hidden="true"><Maximize2 /></span> : null}</button>;
})}</div><CreationMediaPreviewModal url={previewUrl} type={previewType} onClose={() => setPreviewUrl("")} /></>;
}
function StoryboardShotResult({ result, onRetryFailure, onCreateVariant, canvasPath, canvasHandoffAvailable }: { result?: CreationMessage; onRetryFailure: () => void; onCreateVariant: () => void; canvasPath: string; canvasHandoffAvailable: boolean }) {
const brandName = useAppearanceStore((state) => state.appearance.brandName);
const [previewUrl, setPreviewUrl] = useState("");
const [previewType, setPreviewType] = useState<"image" | "video">("image");
const openPreview = (url: string, type: "image" | "video") => { setPreviewType(type); setPreviewUrl(url); };
if (!result) return <div className="storyboard-workbench-empty"><Film />这一镜还没开始——在下方写出你的脚本,我来接手。</div>;
const mode = result.mode || "video";
const status = result.status || "queued";
const resultUrls = result.resultUrls || [];
if (status === "pending" || status === "queued") {
const thinking = thinkingFor(mode, brandName);
return <div className="storyboard-workbench-pending"><div className="storyboard-workbench-thinking">
<span className="storyboard-workbench-thinking-copy"><strong>{thinking.title}</strong><span>{thinking.hint}</span></span>
<span className="storyboard-workbench-pipeline" aria-hidden="true">{thinking.steps.map((step, index) => <em key={step} style={{ "--step": index } as CSSProperties}><i>{String(index + 1).padStart(2, "0")}</i>{step}</em>)}</span>
</div></div>;
}
if (status === "error") return <div className="storyboard-workbench-error"><span>{generationErrorMessage(result.error || "")}</span><button type="button" onClick={onRetryFailure}><RefreshCw />重新生成</button></div>;
if (status === "cancelled") return <div className="storyboard-workbench-error"><span>{result.content || "已停止"}</span><button type="button" onClick={onRetryFailure}><RefreshCw />重新生成</button></div>;
if (mode === "text") return <div className="creation-message-content storyboard-workbench-text">{result.content ? <AIMessageMarkdown isStreaming={status === "streaming"}>{result.content}</AIMessageMarkdown> : <span>正在生成…</span>}</div>;
if (!resultUrls.length) return <div className="storyboard-workbench-empty"><Film />没有返回可预览结果 <button type="button" onClick={onRetryFailure}>重试</button></div>;
const note = result.settings ? directorNoteFor(mode, result.settings) : "";
return <>
{mode === "video" ? <button type="button" className="creation-video-result" onClick={() => openPreview(resultUrls[0], "video")} aria-label="预览生成视频"><video muted preload="metadata" className="size-full object-cover" src={resultUrls[0]} /><span><Maximize2 />预览视频</span></button> : <div className="creation-image-result-grid">{resultUrls.map((url) => <button key={url} type="button" className="creation-image-result" onClick={() => openPreview(url, "image")} aria-label="预览生成图片"><img src={url} alt="生成结果" /><span><Maximize2 /></span></button>)}</div>}
{note ? <p className="storyboard-workbench-director-note"><span>导演手记</span>{note}</p> : null}
<div className="storyboard-workbench-media-meta"><span>{mode === "video" ? "视频结果" : `${resultUrls.length} 张图片`}</span><button type="button" onClick={onCreateVariant}><RefreshCw />生成变体</button><Link to={canvasPath}>{canvasHandoffAvailable ? "添加到画布" : "打开画布"}</Link>{resultUrls.map((url, index) => <a key={`${url}-download`} href={url} download>{resultUrls.length > 1 ? `下载 ${index + 1}` : <><Download />下载</>}</a>)}</div>
<CreationMediaPreviewModal url={previewUrl} type={previewType} onClose={() => setPreviewUrl("")} />
</>;
}
function formatMessageTime(value: string) {
const timestamp = new Date(value).getTime();
return Number.isFinite(timestamp) ? conversationTimeFormatter.format(timestamp) : "";
}
function buildConversationExportMarkdown(conversation: CreationConversation, assistantName: string, userName: string) {
const lines: string[] = [`# ${conversation.title.trim() || "新创作"}`, ""];
for (const message of conversation.messages) {
const stamp = formatMessageTime(message.createdAt);
const modeTag = message.mode && message.mode !== "text" ? (message.mode === "image" ? "[图像生成] " : "[视频生成] ") : "";
const speaker = message.role === "user" ? (userName || "我") : assistantName;
if (message.role === "user") {
const prompt = displayCreationPrompt(message.content, message.references || []).trim();
if (!prompt) continue;
lines.push(`## ${speaker} · ${stamp}`, "", prompt, "");
} else {
const body = (message.content || "").trim();
if (body) lines.push(`## ${speaker} · ${stamp}`, "", `${modeTag}${body}`, "");
else if (message.resultUrls?.length) lines.push(`## ${speaker} · ${stamp}`, "", `${modeTag}已生成,素材保留在项目中。`, "");
else continue;
if (message.reasoning?.trim()) lines.push("> 思考过程:", message.reasoning.trim(), "");
}
}
return lines.join("\n").trim() + "\n";
}
function downloadCreationConversation(conversation: CreationConversation, assistantName: string, userName: string) {
const safeTitle = (conversation.title.trim() || "新创作").replace(/[\\/:*?"<>|]/g, "_").slice(0, 60) || "新创作";
const blob = new Blob([buildConversationExportMarkdown(conversation, assistantName, userName)], { type: "text/markdown;charset=utf-8" });
const url = URL.createObjectURL(blob);
const anchor = document.createElement("a");
anchor.href = url;
anchor.download = `${safeTitle}.md`;
document.body.appendChild(anchor);
anchor.click();
anchor.remove();
URL.revokeObjectURL(url);
}
function conversationPreviewMessage(conversation: CreationConversation) {
let fallback: CreationMessage | undefined;
for (let index = conversation.messages.length - 1; index >= 0; index -= 1) {
@@ -2026,6 +2004,20 @@ function conversationTimestamp(value: string) {
return Number.isFinite(timestamp) ? timestamp : 0;
}
function formatHistoryRelativeTime(value: string) {
const timestamp = conversationTimestamp(value);
if (!timestamp) return "";
const seconds = Math.max(0, Math.round((Date.now() - timestamp) / 1000));
if (seconds < 60) return "刚刚";
const minutes = Math.round(seconds / 60);
if (minutes < 60) return `${minutes} 分钟前`;
const hours = Math.round(minutes / 60);
if (hours < 24) return `${hours} 小时前`;
const days = Math.round(hours / 24);
if (days < 7) return `${days} 天前`;
return historyDayFormatter.format(timestamp);
}
function formatConversationTime(value: string) {
const timestamp = conversationTimestamp(value);
if (!timestamp) return "时间未知";
+5 -5
View File
@@ -1,11 +1,13 @@
import { useCallback, useMemo, useState } from "react";
import { Button, Switch, Table, Tag } from "antd";
import { Button, Table } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { CanvasDirectorWorkbench } from "@/components/canvas/director/canvas-director-workbench";
import { DIRECTOR_REPRO_MATRIX, createDirectorReproScene, directorReproSceneIsOffline, injectDirectorReproModel, type DirectorReproModelVariant } from "@/lib/canvas/director/director-repro-fixture";
import { readDirectorReproSnapshot, type DirectorReproSnapshot } from "@/lib/canvas/director/director-repro-runtime";
import { resetDirectorDiagnosticDedupe } from "@/lib/canvas/director/director-diagnostics-recorder";
import { getClientDiagnosticEvents } from "@/services/diagnostics/client-diagnostics";
import { StatusBadge } from "@/components/ui/base/badges";
import type { DirectorScene } from "@/types/director";
/**
@@ -65,9 +67,7 @@ export default function DirectorReproLab() {
<div className="min-h-dvh overflow-y-auto p-5" style={{ background: "var(--bg)", color: "var(--fg)" }}>
<header className="mb-4 flex flex-wrap items-center gap-3">
<h1 className="text-lg font-semibold">导演台 P0 复现台</h1>
<Tag color={directorReproSceneIsOffline(scene) ? "green" : "red"} data-testid="offline-tag">
{directorReproSceneIsOffline(scene) ? "fixture 无网络资产" : "已注入模型资产"}
</Tag>
<StatusBadge tone={directorReproSceneIsOffline(scene) ? "error" : "success"} data-testid="offline-tag" label={directorReproSceneIsOffline(scene) ? "fixture 无网络资产" : "已注入模型资产"} />
<span className="text-[var(--fs-tiny)] opacity-70" data-testid="object-count">
对象数 {scene.objects.length}
</span>
@@ -172,7 +172,7 @@ function DiagnosticEventList({ events }: { events: DirectorEventRow[] }) {
scroll={{ y: 220 }}
columns={[
{ title: "时间", dataIndex: "timestamp", width: 200, render: (value: string) => <span className="font-mono text-[var(--fs-tiny)]">{value}</span> },
{ title: "级别", dataIndex: "level", width: 88, render: (value: string) => <Tag color={value === "error" ? "red" : value === "warning" ? "orange" : "blue"}>{value}</Tag> },
{ title: "级别", dataIndex: "level", width: 96, render: (value: string) => <StatusBadge size="sm" tone={value === "error" ? "error" : value === "warning" ? "warning" : "neutral"} label={value} /> },
{ title: "稳定码", dataIndex: "code", render: (value: string) => <span className="font-mono text-[var(--fs-tiny)]">{value}</span> },
{ title: "消息", dataIndex: "message" },
]}
+5 -3
View File
@@ -1,6 +1,8 @@
import { ArrowLeft, ChevronDown, ChevronUp, Download, FileAudio, FileBox, FileImage, FileVideo, FolderOpen, FolderPlus, RefreshCw, Search, Settings2, Upload } from "lucide-react";
import { useEffect, useMemo, useRef, useState, type ChangeEvent } from "react";
import { App, Button, Drawer, Empty, Input, Spin, Tag, Tree, Typography } from "antd";
import { App, Button, Drawer, Input, Spin, Tag, Tree, Typography } from "antd";
import { IconButton } from "@/components/ui/base/buttons";
import { EmptyState } from "@/components/ui/product/empty-state";
import type { DataNode } from "antd/es/tree";
import { useNavigate } from "react-router";
@@ -183,7 +185,7 @@ export default function EagleLibraryPage() {
<aside className="eagle-folder-sidebar thin-scrollbar flex gap-2 overflow-x-auto py-3 lg:sticky lg:top-0 lg:block lg:max-h-[calc(100vh-190px)] lg:overflow-y-auto lg:pr-3">
<div className="eagle-folder-sidebar-header">
<span className="text-[var(--fs-label)] font-semibold">Eagle 文件夹</span>
<Button type="text" size="small" icon={<RefreshCw className="size-3.5" />} aria-label="刷新 Eagle 文件夹" loading={loading} onClick={() => void load()} />
<IconButton size="sm" variant="ghost" icon={RefreshCw} aria-label="刷新 Eagle 文件夹" loading={loading} onClick={() => void load()} />
</div>
<button type="button" className={"assets-filter-item " + (selectedFolder === "" ? "is-active" : "")} aria-pressed={selectedFolder === ""} onClick={() => handleFolderSelect("root")}>
<span className="assets-filter-item-label">全部素材</span>
@@ -233,7 +235,7 @@ export default function EagleLibraryPage() {
</CollectionGrid>
<PaginationBar current={page} pageSize={pageSize} total={items.length} pageSizeOptions={[20, 40, 80]} onChange={(nextPage, nextPageSize) => { setPage(nextPageSize !== pageSize ? 1 : nextPage); setPageSize(nextPageSize); }} />
</>
) : <div className="eagle-empty-state"><Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="当前 Eagle 文件夹没有文件" /></div>}
) : <div className="eagle-empty-state"><EmptyState size="compact" title="当前 Eagle 文件夹没有文件" /></div>}
</section>
</div>
</div>
+2 -1
View File
@@ -1,4 +1,5 @@
import { App, Button, Input, Modal, Select, Switch, Typography } from "antd";
import { App, Button, Input, Modal, Select, Typography } from "antd";
import { Switch } from "@/components/ui/base/switch";
import { AudioLines, CalendarDays, CheckCircle2, Clock3, CreditCard, ExternalLink, Film, FolderOpen, Image as ImageIcon, MessageSquareText, PlugZap, RefreshCw, Search, Settings2, ShieldCheck, SlidersHorizontal } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
import { useNavigate } from "react-router";
+4 -3
View File
@@ -1,6 +1,7 @@
import { lazy, Suspense } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { Alert, App, Tooltip } from "antd";
import { Alert, App } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { ArrowLeft, BookOpenText, Clapperboard, Images, LayoutDashboard, LayoutGrid, Plus, Scissors, Settings2, type LucideIcon } from "lucide-react";
import { Link, Navigate, useNavigate, useParams } from "react-router";
@@ -173,7 +174,7 @@ function ProjectWorkspaceTopBar({ detail, projectId, activeView, unitId, stage,
const active = item.key === activeView;
const href = item.key === "chapters" ? chapterHref : item.key === "workflow" ? workflowHref : `/projects/${projectId}/${item.key}`;
return (
<Tooltip key={item.key} title={item.label} mouseEnterDelay={0.15}>
<Tooltip key={item.key} title={item.label} delay={150}>
<Link
to={href}
aria-label={item.label}
@@ -190,7 +191,7 @@ function ProjectWorkspaceTopBar({ detail, projectId, activeView, unitId, stage,
{activeView === "workflow" ? (
<WorkflowChapterNavigator projectId={projectId} units={detail.units} unitId={unitId} stage={stage} />
) : (
<Tooltip title={createCanvasLabel} mouseEnterDelay={0.15}><button type="button" onClick={onCreateCanvas} className="project-workspace-create" aria-label={createCanvasLabel}><Plus /></button></Tooltip>
<Tooltip title={createCanvasLabel} delay={150}><button type="button" onClick={onCreateCanvas} className="grid size-8 shrink-0 place-items-center rounded-md text-foreground/42 transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" aria-label={createCanvasLabel}><Plus className="size-4" /></button></Tooltip>
)}
</div>
);
+3 -1
View File
@@ -1,6 +1,8 @@
import { App, Button, Popconfirm, Select } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useEffect, useMemo, useState } from "react";
import { useMutation, useQuery } from "@tanstack/react-query";
import { App, Button, Popconfirm, Select, Tooltip } from "antd";
import { Link2, Unlink, X } from "lucide-react";
import { CanvasProjectCard } from "@/components/canvas/canvas-project-card";
+5 -2
View File
@@ -1,7 +1,10 @@
import { App, Button, Dropdown, Form, Input, InputNumber, Modal, Popconfirm } from "antd";
import { Tooltip } from "@/components/ui/base/tooltip";
import { useDeferredValue, useEffect, useMemo, useRef, useState, type ChangeEvent, type DragEvent, type ReactNode } from "react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useVirtualizer } from "@tanstack/react-virtual";
import { Alert, App, Button, Dropdown, Form, Input, InputNumber, Modal, Popconfirm, Tooltip } from "antd";
import { Callout } from "@/components/ui/product/callout";
import CharacterCount from "@tiptap/extension-character-count";
import Color from "@tiptap/extension-color";
import Highlight from "@tiptap/extension-highlight";
@@ -630,7 +633,7 @@ export default function ProjectChaptersView({ detail, refreshProject }: ProjectD
<div className="mt-1 truncate text-sm font-medium text-foreground/85">{selectedUnit?.title}</div>
<div className="mt-1 text-[var(--fs-tiny)] text-foreground/38">正文将作为分镜依据,生成结果会直接写入“分镜制作”。</div>
</div>
{storyboardImpact.shotCount ? <Alert type="warning" showIcon message={`本章已有 ${storyboardImpact.shotCount} 个分镜`} description="继续后会先生成新分镜;生成成功后,再按确认内容整体替换旧镜头及其关联数据。" /> : null}
{storyboardImpact.shotCount ? <Callout tone="warning" title={`本章已有 ${storyboardImpact.shotCount} 个分镜`}>继续后会先生成新分镜;生成成功后,再按确认内容整体替换旧镜头及其关联数据。</Callout> : null}
<label className="block">
<span className="mb-1.5 block text-xs font-medium text-foreground/68">文本模型</span>
<ModelPicker config={effectiveConfig} capability="text" value={selectedTextModel} onChange={setSelectedTextModel} fullWidth placeholder="选择用于生成分镜的文本模型" showSelectedPrice={false} onMissingConfig={() => navigateToSettings({ continueCreation: true })} />
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff. Show more