feat(admin): 站点外观 - 支持 Tab 分类与主题渐变按钮配置

This commit is contained in:
ddCat committed 2026-09-18 23:28:57 +08:00
1 parent f77bd2bfa0
commit 3cb1423f7e
27 files changed
+869 -375

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ docs/content/docs/backend/*
!docs/content/docs/backend/http-api.mdx !docs/content/docs/backend/http-api.mdx
!docs/content/docs/backend/code-map.mdx !docs/content/docs/backend/code-map.mdx
!docs/content/docs/backend/newapi-channel-2.mdx !docs/content/docs/backend/newapi-channel-2.mdx
!docs/content/docs/backend/video-token-billing.mdx
!docs/content/docs/backend/creative-agent-runtime.mdx !docs/content/docs/backend/creative-agent-runtime.mdx
# Keep the creative Agent design versioned without unignoring generated docs. # Keep the creative Agent design versioned without unignoring generated docs.
!docs/content/docs/overview/ !docs/content/docs/overview/
+2
View File
@@ -105,6 +105,7 @@
- 第三方覆盖限定在具体组件,不新增全局 `.ant-modal-*`、`.dark .ant-switch-*`、`.ant-checkbox-*` 或 Segmented 状态补丁。新增 CSS 前先搜索同名选择器,回到唯一源规则修改。 - 第三方覆盖限定在具体组件,不新增全局 `.ant-modal-*`、`.dark .ant-switch-*`、`.ant-checkbox-*` 或 Segmented 状态补丁。新增 CSS 前先搜索同名选择器,回到唯一源规则修改。
- 遵循 `docs/ui-design-system.md` 及项目三层 token:Primitive → Semantic → Component。inline style 优先引用 `var(--token-name)`,不要散落颜色、圆角、阴影和层级字面值。 - 遵循 `docs/ui-design-system.md` 及项目三层 token:Primitive → Semantic → Component。inline style 优先引用 `var(--token-name)`,不要散落颜色、圆角、阴影和层级字面值。
- 主操作、普通选中、Checkbox/Radio、Switch 是不同颜色角色;持久切换使用 `aria-pressed`,`type="primary"` 只表示当前主要命令。尊重 `prefers-reduced-motion`,键盘导航保留 `:focus-visible`。 - 主操作、普通选中、Checkbox/Radio、Switch 是不同颜色角色;持久切换使用 `aria-pressed`,`type="primary"` 只表示当前主要命令。尊重 `prefers-reduced-motion`,键盘导航保留 `:focus-visible`。
- 修改既有页面时直接修改真实组件、样式和路由。不得创建独立 HTML 来代替真实页面验证;只有用户明确要求原型或隔离设计稿时才可生成,并放在临时目录或用户指定位置,不得放入 `web/public/` 或产品构建目录。
## 7. 本地开发、部署和数据目录 ## 7. 本地开发、部署和数据目录
@@ -124,6 +125,7 @@
- 云端 Agent:前端事件流和审批路径依赖后端 `/api/agent` 接口;在该接口实现后补充后端冒烟、Worker 运行和 SSE 断线重连验证。 - 云端 Agent:前端事件流和审批路径依赖后端 `/api/agent` 接口;在该接口实现后补充后端冒烟、Worker 运行和 SSE 断线重连验证。
- 文档站:`cd docs && bun run types:check` 或 `bun run build`。 - 文档站:`cd docs && bun run types:check` 或 `bun run build`。
- UI 变更能浏览器验证时,检查关键路由、明暗主题、滚动、弹窗、空态和核心交互;不能验证时说明替代依据,不把静态阅读或 `git diff` 写成运行验证。 - UI 变更能浏览器验证时,检查关键路由、明暗主题、滚动、弹窗、空态和核心交互;不能验证时说明替代依据,不把静态阅读或 `git diff` 写成运行验证。
- 验证必须针对真实实现:优先专项测试、类型检查、项目 build 或真实路由浏览器验收。独立 HTML、静态仿制页面和脱离应用状态的截图不能作为真实页面通过的证据。
同类失败连续三次时停止盲试,记录现象、已排除项和新假设,再切换路径或请求用户决策。 同类失败连续三次时停止盲试,记录现象、已排除项和新假设,再切换路径或请求用户决策。
+4 -1
View File
@@ -31,7 +31,7 @@ const (
) )
const ( const (
appearanceSchemaVersion = 7 appearanceSchemaVersion = 8
appearanceLogoMaxBytes int64 = 5 << 20 appearanceLogoMaxBytes int64 = 5 << 20
appearancePosterMaxBytes int64 = 10 << 20 appearancePosterMaxBytes int64 = 10 << 20
appearanceVideoMaxBytes int64 = 256 << 20 appearanceVideoMaxBytes int64 = 256 << 20
@@ -346,6 +346,9 @@ func (s *Service) readAppearance() (*model.SystemSetting, AppearanceSetting, err
return nil, AppearanceSetting{}, err return nil, AppearanceSetting{}, err
} }
value := defaultAppearanceSetting() value := defaultAppearanceSetting()
// Decode stored themes without reusing built-in slice entries: omitted
// fields must be migrated according to each stored theme's identity.
value.SkinThemes = nil
if strings.TrimSpace(setting.ValueJSON) == "" || json.Unmarshal([]byte(setting.ValueJSON), &value) != nil { if strings.TrimSpace(setting.ValueJSON) == "" || json.Unmarshal([]byte(setting.ValueJSON), &value) != nil {
return nil, AppearanceSetting{}, errors.New("外观配置格式无效") return nil, AppearanceSetting{}, errors.New("外观配置格式无效")
} }
@@ -0,0 +1,111 @@
package app
import (
"encoding/json"
"testing"
"infinite-canvas/backend/internal/model"
)
func TestAppearanceButtonFillRoundTripAndValidation(t *testing.T) {
svc, _, _, admin := newAppearanceTestService(t)
themes := defaultAppearanceSkinThemes()
custom := cloneAppearanceSkin(themes[0], "custom-gradient", "渐变主题", "主按钮渐变")
custom.Tokens.Buttons.Light.Angle = 45
custom.Tokens.Buttons.Light.Start = "#123456"
custom.Tokens.Buttons.Dark.Mode = "solid"
themes = append(themes, custom)
input := AppearanceSetting{BrandName: "测试站点", BrandSlug: "test", AuthHeroTitle: defaultAppearanceHeroTitle, SkinID: custom.ID, SkinThemes: themes}
saved, err := svc.UpdateAppearance(admin, input)
if err != nil {
t.Fatal(err)
}
if saved.Public.ActiveSkin.Tokens.Buttons != custom.Tokens.Buttons {
t.Fatal("public projection lost button parameters")
}
loaded, err := svc.AdminAppearance(admin)
if err != nil {
t.Fatal(err)
}
if loaded.Public.ActiveSkin.Tokens.Buttons != custom.Tokens.Buttons {
t.Fatal("stored button parameters changed")
}
for name, mutate := range map[string]func(*AppearanceSkinButtonFill){
"mode": func(fill *AppearanceSkinButtonFill) { fill.Mode = "image" },
"negative angle": func(fill *AppearanceSkinButtonFill) { fill.Angle = -1 },
"large angle": func(fill *AppearanceSkinButtonFill) { fill.Angle = 361 },
"css injection": func(fill *AppearanceSkinButtonFill) { fill.End = "red; background:url(x)" },
"missing color": func(fill *AppearanceSkinButtonFill) { fill.Foreground = "" },
} {
t.Run(name, func(t *testing.T) {
bad := input
bad.SkinThemes = append([]AppearanceSkinTheme(nil), themes...)
mutate(&bad.SkinThemes[len(themes)-1].Tokens.Buttons.Light)
if _, err := svc.UpdateAppearance(admin, bad); err == nil {
t.Fatal("invalid fill accepted")
}
})
}
input.SkinThemes[0].Tokens.Buttons.Light.Start = "#000000"
if _, err := svc.UpdateAppearance(admin, input); err == nil {
t.Fatal("classic fill mutation accepted")
}
}
func TestAppearanceLegacyButtonFills(t *testing.T) {
themes := defaultAppearanceSkinThemes()
for index := range themes {
themes[index].Tokens.Buttons = AppearanceSkinButtons{}
}
migrated := normalizeAppearanceSkinThemes(themes)
if err := validateAppearanceSkinThemes(migrated, "classic"); err != nil {
t.Fatal(err)
}
for _, skin := range migrated {
expected := "solid"
if skin.ID == "classic" {
expected = "gradient"
}
if skin.Tokens.Buttons.Light.Mode != expected || skin.Tokens.Buttons.Dark.Mode != expected {
t.Fatalf("wrong fill for %s", skin.ID)
}
}
var fill AppearanceSkinButtonFill
if err := json.Unmarshal([]byte(`{"angle":1.5}`), &fill); err == nil {
t.Fatal("fractional angle accepted")
}
}
func TestAppearanceReadsLegacyButtonFillsByStoredIdentity(t *testing.T) {
svc, db, _, admin := newAppearanceTestService(t)
classic := defaultClassicAppearanceSkin()
custom := cloneAppearanceSkin(classic, "custom-legacy", "旧主题", "保持纯色")
encoded, err := json.Marshal([]AppearanceSkinTheme{custom, classic})
if err != nil {
t.Fatal(err)
}
var themes []map[string]any
if err := json.Unmarshal(encoded, &themes); err != nil {
t.Fatal(err)
}
for _, skin := range themes {
delete(skin["tokens"].(map[string]any), "buttons")
}
encoded, err = json.Marshal(map[string]any{"schemaVersion": 7, "skinId": custom.ID, "skinThemes": themes})
if err != nil {
t.Fatal(err)
}
if err := db.Create(&model.SystemSetting{Key: appearanceSettingKey, ValueJSON: string(encoded)}).Error; err != nil {
t.Fatal(err)
}
loaded, err := svc.AdminAppearance(admin)
if err != nil {
t.Fatal(err)
}
if loaded.Public.ActiveSkin.Tokens.Buttons.Light.Mode != "solid" || loaded.SkinThemes[1].Tokens.Buttons.Light.Mode != "gradient" {
t.Fatal("legacy fields inherited another theme's fill")
}
if err := validateAppearanceSkinThemes(loaded.SkinThemes, custom.ID); err != nil {
t.Fatal(err)
}
}
+58
View File
@@ -96,6 +96,35 @@ type AppearanceSkinTokens struct {
Light AppearanceSkinModeTokens `json:"light"` Light AppearanceSkinModeTokens `json:"light"`
Dark AppearanceSkinModeTokens `json:"dark"` Dark AppearanceSkinModeTokens `json:"dark"`
Components AppearanceSkinComponentTokens `json:"components"` Components AppearanceSkinComponentTokens `json:"components"`
Buttons AppearanceSkinButtons `json:"buttons"`
}
type AppearanceSkinButtons struct {
Light AppearanceSkinButtonFill `json:"light"`
Dark AppearanceSkinButtonFill `json:"dark"`
}
type AppearanceSkinButtonFill struct {
Mode string `json:"mode"`
Angle int `json:"angle"`
Start string `json:"start"`
End string `json:"end"`
HoverStart string `json:"hoverStart"`
HoverEnd string `json:"hoverEnd"`
ActiveStart string `json:"activeStart"`
ActiveEnd string `json:"activeEnd"`
Foreground string `json:"foreground"`
}
func defaultAppearanceSkinButtons(gradient bool) AppearanceSkinButtons {
fill := AppearanceSkinButtonFill{
Mode: "solid", Angle: 115, Start: "#6554df", End: "#386fbc",
HoverStart: "#5744cf", HoverEnd: "#356bbb", ActiveStart: "#4938b8", ActiveEnd: "#2c5da5", Foreground: "#ffffff",
}
if gradient {
fill.Mode = "gradient"
}
return AppearanceSkinButtons{Light: fill, Dark: fill}
} }
type AppearanceSkinTheme struct { type AppearanceSkinTheme struct {
@@ -159,6 +188,9 @@ func defaultAppearanceSkinThemes() []AppearanceSkinTheme {
}) })
violet.Tokens.Components = appearanceSkinComponentPreset(7, 7, 12, 14, 9, 4) violet.Tokens.Components = appearanceSkinComponentPreset(7, 7, 12, 14, 9, 4)
studio.Tokens.Buttons = defaultAppearanceSkinButtons(false)
warm.Tokens.Buttons = defaultAppearanceSkinButtons(false)
violet.Tokens.Buttons = defaultAppearanceSkinButtons(false)
return []AppearanceSkinTheme{classic, studio, warm, violet} return []AppearanceSkinTheme{classic, studio, warm, violet}
} }
@@ -181,6 +213,7 @@ func defaultClassicAppearanceSkin() AppearanceSkinTheme {
AdminBackground: "#101010", AdminSurface: "#181818", AdminSubtle: "#202020", AdminStrong: "#2a2a2a", AuthBackground: "#08090c", AuthPanel: "#0b0c10", AuthCard: "#121318", AuthAccent: "#93c5fd", AuthMuted: "#8a8b91", AdminBackground: "#101010", AdminSurface: "#181818", AdminSubtle: "#202020", AdminStrong: "#2a2a2a", AuthBackground: "#08090c", AuthPanel: "#0b0c10", AuthCard: "#121318", AuthAccent: "#93c5fd", AuthMuted: "#8a8b91",
}, },
Components: appearanceSkinComponentPreset(6, 6, 12, 12, 8, 4), Components: appearanceSkinComponentPreset(6, 6, 12, 12, 8, 4),
Buttons: defaultAppearanceSkinButtons(true),
}, },
} }
} }
@@ -234,6 +267,11 @@ func normalizeAppearanceSkinThemes(themes []AppearanceSkinTheme) []AppearanceSki
result[index].Name = strings.TrimSpace(result[index].Name) result[index].Name = strings.TrimSpace(result[index].Name)
result[index].Description = strings.TrimSpace(result[index].Description) result[index].Description = strings.TrimSpace(result[index].Description)
result[index].Locked = result[index].ID == defaultAppearanceSkinID result[index].Locked = result[index].ID == defaultAppearanceSkinID
// Only a wholly absent legacy button block is upgraded. Partial or
// malformed submitted parameters remain invalid on the write path.
if result[index].Tokens.Buttons == (AppearanceSkinButtons{}) {
result[index].Tokens.Buttons = defaultAppearanceSkinButtons(result[index].Locked)
}
var fallback AppearanceSkinTokens var fallback AppearanceSkinTokens
for _, builtin := range builtins { for _, builtin := range builtins {
if builtin.ID == result[index].ID { if builtin.ID == result[index].ID {
@@ -325,6 +363,11 @@ func validateAppearanceSkinThemes(themes []AppearanceSkinTheme, selectedID strin
if err := validateAppearanceSkinComponents(skin.Tokens.Components); err != nil { if err := validateAppearanceSkinComponents(skin.Tokens.Components); err != nil {
return err return err
} }
for _, fill := range []AppearanceSkinButtonFill{skin.Tokens.Buttons.Light, skin.Tokens.Buttons.Dark} {
if err := validateAppearanceSkinButtonFill(fill); err != nil {
return err
}
}
} }
if !foundClassic { if !foundClassic {
return BadAuthRequest("经典黑白为系统默认主题,不能修改或删除") return BadAuthRequest("经典黑白为系统默认主题,不能修改或删除")
@@ -345,6 +388,21 @@ func validateAppearanceSkinMode(mode AppearanceSkinModeTokens) error {
return nil return nil
} }
func validateAppearanceSkinButtonFill(fill AppearanceSkinButtonFill) error {
if fill.Mode != "solid" && fill.Mode != "gradient" {
return BadAuthRequest("主按钮填充模式无效")
}
if fill.Angle < 0 || fill.Angle > 360 {
return BadAuthRequest("主按钮渐变角度必须在 0 到 360 之间")
}
for _, color := range []string{fill.Start, fill.End, fill.HoverStart, fill.HoverEnd, fill.ActiveStart, fill.ActiveEnd, fill.Foreground} {
if !appearanceColorPattern.MatchString(color) {
return BadAuthRequest("主按钮颜色必须使用 6 或 8 位十六进制颜色")
}
}
return nil
}
func validateAppearanceSkinComponents(value AppearanceSkinComponentTokens) error { func validateAppearanceSkinComponents(value AppearanceSkinComponentTokens) error {
for _, candidate := range []struct { for _, candidate := range []struct {
value, min, max int value, min, max int
@@ -23,7 +23,7 @@ description: 影策后端核心持久化表与状态边界
容器内命令 `migrate-schema up` 应用缺失迁移,`migrate-schema status` 输出当前和期望版本,`migrate-schema verify` 只检查兼容性。`CANVAS_AUTO_MIGRATE=true` 仅用于开发和旧部署兼容;受管生产部署设置为 `false`,并由 Compose 的一次性 `migrate` 服务先完成迁移。后续迁移必须新增版本,不得修改已经发布迁移的实现或校验和。 容器内命令 `migrate-schema up` 应用缺失迁移,`migrate-schema status` 输出当前和期望版本,`migrate-schema verify` 只检查兼容性。`CANVAS_AUTO_MIGRATE=true` 仅用于开发和旧部署兼容;受管生产部署设置为 `false`,并由 Compose 的一次性 `migrate` 服务先完成迁移。后续迁移必须新增版本,不得修改已经发布迁移的实现或校验和。
当前结构版本为 23。版本 2 为 `schema_migrations.applied_at` 增加 `idx_schema_migrations_applied_at` 索引;版本 3 `asset_taxonomy_candidate_identity` 为资产候选增加规范化名称和来源,收敛资产分类,并为待确认候选建立项目内部分唯一索引;版本 4 `resource_upload_key` 为资源上传幂等补充 `resources.upload_key` 列和用户维度唯一索引;版本 5 `payment_topup` 创建积分充值、支付通知和对账所需结构;版本 6 `resource_playback_variant` 增加资源播放副本状态;版本 7 `asset_library_folders` 增加用户素材自定义分类及 `assets.folder_id`;版本 8 `logical_model_active_code` 将前台模型 code 的唯一约束限定为未归档记录;版本 9 `channel_presentation` 为渠道添加 `public_alias`(默认空字符串)与 `sort_order`(默认 0),为渠道模型添加 `sort_order`(默认 0),不重写既有凭据、价格或能力配置;版本 10 `creation_runtime` 创建创作运行与提交表,并为任务增加可空且唯一的 `creation_submission_id`,旧任务无需伪造提交标识即可继续使用;版本 11 `cloud_agent_runtime` 创建 `cloud_agent_executions`;版本 12 `agent_token_charge_limit` 为账单增加 Agent Token 收费上限;版本 13 `cloud_agent_canvas_mutation` 持久化 Agent 画布变更;版本 14 `cloud_agent_recovery_control` 增加运行恢复控制字段和旧运行回填;版本 15 `agent_profiles` 创建常驻偏好表;版本 16 `agent_lessons` 创建用户记忆表(含分类、路线 JSON、注入/查阅计数);版本 17 `agent_lessons_owner_index` 为 `(author_user_id, status)` 增加复合索引;版本 18 `agent_memory_settings` 创建按用户隔离的压缩周期与最近一次压缩任务状态;版本 19 `payment_plugin_version` 为已有 `payment_provider_configs` 和 `payment_orders` 补上 `plugin_version`,用于把配置和订单钉在具体插件版本上;版本 20 `banner_announcements` 创建首页常驻滚动通知表;版本 21 `banner_announcement_title_runs` 为通知标题增加样式分段;版本 22 `banner_announcement_notice_type` 增加通知类型底色;版本 23 `canvas_revision_history` 为既有画布回填 `revision = 1` 并新增历史快照与资源引用表。已发布版本的实现和校验和不得修改。 当前结构版本为 26。版本 2 为 `schema_migrations.applied_at` 增加 `idx_schema_migrations_applied_at` 索引;版本 3 `asset_taxonomy_candidate_identity` 为资产候选增加规范化名称和来源,收敛资产分类,并为待确认候选建立项目内部分唯一索引;版本 4 `resource_upload_key` 为资源上传幂等补充 `resources.upload_key` 列和用户维度唯一索引;版本 5 `payment_topup` 创建积分充值、支付通知和对账所需结构;版本 6 `resource_playback_variant` 增加资源播放副本状态;版本 7 `asset_library_folders` 增加用户素材自定义分类及 `assets.folder_id`;版本 8 `logical_model_active_code` 将前台模型 code 的唯一约束限定为未归档记录;版本 9 `channel_presentation` 为渠道添加 `public_alias`(默认空字符串)与 `sort_order`(默认 0),为渠道模型添加 `sort_order`(默认 0),不重写既有凭据、价格或能力配置;版本 10 `creation_runtime` 创建创作运行与提交表,并为任务增加可空且唯一的 `creation_submission_id`,旧任务无需伪造提交标识即可继续使用;版本 11 `cloud_agent_runtime` 创建 `cloud_agent_executions`;版本 12 `agent_token_charge_limit` 为账单增加 Agent Token 收费上限;版本 13 `cloud_agent_canvas_mutation` 持久化 Agent 画布变更;版本 14 `cloud_agent_recovery_control` 增加运行恢复控制字段和旧运行回填;版本 15 `agent_profiles` 创建常驻偏好表;版本 16 `agent_lessons` 创建用户记忆表(含分类、路线 JSON、注入/查阅计数);版本 17 `agent_lessons_owner_index` 为 `(author_user_id, status)` 增加复合索引;版本 18 `agent_memory_settings` 创建按用户隔离的压缩周期与最近一次压缩任务状态;版本 19 `payment_plugin_version` 为已有 `payment_provider_configs` 和 `payment_orders` 补上 `plugin_version`,用于把配置和订单钉在具体插件版本上;版本 20 `banner_announcements` 创建首页常驻滚动通知表;版本 21 `banner_announcement_title_runs` 为通知标题增加样式分段;版本 22 `banner_announcement_notice_type` 增加通知类型底色;版本 23 `canvas_revision_history` 为既有画布回填 `revision = 1` 并新增历史快照与资源引用表。版本 24 `channel_model_label` 为渠道模型增加 `channel_label`(最长 80 字、非空、默认空字符串),不重写模型标识、上游 ID、价格或能力;版本 25 `video_token_formula_snapshot` 为账单增加视频公式用量及用量来源快照。版本 26 `channel_model_description` 为渠道模型增加 `description`(最长 500 字、非空、默认空字符串),供二级选项展示使用说明,不重写身份或价格。已发布版本的实现和校验和不得修改。
历史发布曾使用版本 6 `asset_library_folders`,之后合并引入了上述 6/7 顺序冲突。迁移器仅在该历史记录的名称和校验和均精确匹配时选择历史顺序:保留版本 6 的素材目录记录及时间,在版本 7 应用 `resource_playback_variant`,再继续版本 8。新数据库及已采用“6 播放副本、7 素材目录”的数据库保持原顺序;状态检查与启动校验采用同一套识别规则。未知名称、被改动的校验和或冲突的版本 7 记录仍会拒绝迁移,不通过删除、改名或伪造已应用记录绕过检查。 历史发布曾使用版本 6 `asset_library_folders`,之后合并引入了上述 6/7 顺序冲突。迁移器仅在该历史记录的名称和校验和均精确匹配时选择历史顺序:保留版本 6 的素材目录记录及时间,在版本 7 应用 `resource_playback_variant`,再继续版本 8。新数据库及已采用“6 播放副本、7 素材目录”的数据库保持原顺序;状态检查与启动校验采用同一套识别规则。未知名称、被改动的校验和或冲突的版本 7 记录仍会拒绝迁移,不通过删除、改名或伪造已应用记录绕过检查。
@@ -86,6 +86,8 @@ docker compose -f docker-compose.deploy.yml up -d backend web
## 平台外观配置 ## 平台外观配置
当前外观 JSON 合同版本为 8,主题参数新增 `skinThemes[].tokens.buttons.light/dark`:填充模式、角度、常态/悬停/按下双色和文字色。经典主题默认为紫蓝渐变,其余旧主题缺少此块时保持纯色;公开 `activeSkin` 使用相同结构。无表结构迁移,读取补齐只在内存执行,管理员保存时写回。回退应用版本前保留外观 JSON 备份,旧版本不支持新按钮填充参数。
平台外观复用既有 `system_settings` 表,不新增结构迁移。键 `appearance` 的 JSON 值使用版本化合同;版本 3 保存品牌名称、英文品牌标识、登录页主标题与可选说明文案、浅色与可选深色 Logo 资源 ID、Logo 外框开关、登录页视频资源 ID、可选封面资源 ID 和预留皮肤 ID。只配置一套 Logo 时,公开投影会在浅色和深色主题复用同一资源;旧版本缺少深色 Logo 与外框字段时分别回退到单 Logo 和启用外框,不改变既有视觉。资源元数据和文件仍分别由 `resources` 表与当前资源存储承担。恢复默认外观时删除这条设置记录并回到内置值,不级联删除已经上传的资源。 平台外观复用既有 `system_settings` 表,不新增结构迁移。键 `appearance` 的 JSON 值使用版本化合同;版本 3 保存品牌名称、英文品牌标识、登录页主标题与可选说明文案、浅色与可选深色 Logo 资源 ID、Logo 外框开关、登录页视频资源 ID、可选封面资源 ID 和预留皮肤 ID。只配置一套 Logo 时,公开投影会在浅色和深色主题复用同一资源;旧版本缺少深色 Logo 与外框字段时分别回退到单 Logo 和启用外框,不改变既有视觉。资源元数据和文件仍分别由 `resources` 表与当前资源存储承担。恢复默认外观时删除这条设置记录并回到内置值,不级联删除已经上传的资源。
公开接口只投影品牌名、英文品牌标识、登录页公开文案、深浅主题使用的稳定 slot 资源 URL、Logo 外框状态、配置状态和修订标识,不返回内部资源 ID、对象路径或存储凭据。管理员保存新配置前,服务层会校验文本长度与安全字符、资源为就绪状态、类型与 slot 匹配,且新绑定资源由当前管理员上传;两套 Logo、视频和封面中任何正在使用的资源都会进入管理员删除保护。品牌变更同时写入 `admin_audit_events`。 公开接口只投影品牌名、英文品牌标识、登录页公开文案、深浅主题使用的稳定 slot 资源 URL、Logo 外框状态、配置状态和修订标识,不返回内部资源 ID、对象路径或存储凭据。管理员保存新配置前,服务层会校验文本长度与安全字符、资源为就绪状态、类型与 slot 匹配,且新绑定资源由当前管理员上传;两套 Logo、视频和封面中任何正在使用的资源都会进入管理员删除保护。品牌变更同时写入 `admin_audit_events`。
@@ -187,10 +189,12 @@ docker compose -f docker-compose.deploy.yml up -d backend web
| 表 | 用途 | 关键边界 | | 表 | 用途 | 关键边界 |
| --- | --- | --- | | --- | --- | --- |
| `model_channels` | 保存系统渠道与用户渠道的连接配置,以及系统渠道前台别名和排序 | 系统渠道密钥不进入公开目录;公开名称优先使用 `public_alias`,为空时使用原名;按 `sort_order, created_at, id` 升序展示 | | `model_channels` | 保存系统渠道与用户渠道的连接配置,以及系统渠道前台别名和排序 | 系统渠道密钥不进入公开目录;公开名称优先使用 `public_alias`,为空时使用原名;按 `sort_order, created_at, id` 升序展示 |
| `channel_models` | 保存系统渠道中的产品模型标识、上游模型 ID、显示名称、模型 Logo、排序、能力、协议和版本状态 | 模型排序独立保存,不递增价格或能力版本;能力、协议、启用状态和价格仍由 service 强校验 | | `channel_models` | 保存系统渠道中的产品模型标识、上游模型 ID、显示名称、渠道展示名、模型描述、模型 Logo、排序、能力、协议和版本状态 | `channel_label` 最长 80 字,空值沿用渠道公开名称;`description` 最长 500 字、非空、默认空字符串,用于二级菜单说明;同一渠道内的产品模型标识仍唯一,跨渠道同能力同标识可在前端归组;模型排序独立保存,不递增价格或能力版本 |
| `channel_model_price_tiers` | 保存系统模型按规格匹配的上游 SKU 与价格 | 价格档与渠道模型同事务保存;未启用或未完成定价的规格不进入普通用户目录。档位 `provider_model_key` 非空时优先于渠道模型上游键发往供应商;管理端修改模型级上游 ID 时,与旧值相同的档位键自动级联跟随,其余显式 SKU 保持不变 | | `channel_model_price_tiers` | 保存系统模型按规格匹配的上游 SKU 与价格 | 价格档与渠道模型同事务保存;未启用或未完成定价的规格不进入普通用户目录。档位 `provider_model_key` 非空时优先于渠道模型上游键发往供应商;管理端修改模型级上游 ID 时,与旧值相同的档位键自动级联跟随,其余显式 SKU 保持不变 |
| `logical_models` | 保存前台模型的公开名称、Logo、能力类型和归档状态 | 前台模型与系统渠道模型分别维护展示信息;供应线路通过 revision 和 route 关联;`code` 仅在 `archived_at IS NULL` 的活动记录中唯一,归档后可用同 code 重建目录项 | | `logical_models` | 保存前台模型的公开名称、Logo、能力类型和归档状态 | 前台模型与系统渠道模型分别维护展示信息;供应线路通过 revision 和 route 关联;`code` 仅在 `archived_at IS NULL` 的活动记录中唯一,归档后可用同 code 重建目录项 |
所有视频协议开放 Token 定价。`channel_model_price_tiers.selector_json` 支持 `videoGenerateAudio: "true" | "false"`,省略表示任意音频;参考视频仍匹配 `operation: "video_to_video"`。视频仅使用输出 Token 单价,输入和缓存价必须为 0,明确配置的零价表示免费。schema v25 为 `billing_orders` 新增 `video_formula_tokens`(非空、默认 0,提交时固化不含余量的公式用量)及 `usage_source`(非空、默认空字符串,`provider` 或 `video_formula`)。缺少有效上游用量的新视频订单按公式快照结算并记录 `usage_available=false`,不伪造上游用量;历史快照为 0 的订单保持旧规则。价格档、费率、倍率、预留金额和既有账单不被迁移重算。前后端和 schema 一起升级,旧程序不支持新公式结算及非 Ark Token 配置,回滚需匹配数据库备份与二进制版本。完整算法见[视频 Token 计费](/docs/backend/video-token-billing)。
图片分档尺寸保存在现有模型能力 JSON 的 `image.size.presets` 中,不新增表、列或 SQL 迁移。每项结构为 `{ tier, ratio, size, width, height }`,例如 `{ "tier": "1k", "ratio": "16:9", "size": "1824x1024", "width": 1824, "height": 1024 }`。 图片分档尺寸保存在现有模型能力 JSON 的 `image.size.presets` 中,不新增表、列或 SQL 迁移。每项结构为 `{ tier, ratio, size, width, height }`,例如 `{ "tier": "1k", "ratio": "16:9", "size": "1824x1024", "width": 1824, "height": 1024 }`。
- `tier` 仅允许 `1k`、`2k`、`4k`,管理员分别配置各档支持的比例;新增比例自动计算像素,原有精确尺寸不被重算。 - `tier` 仅允许 `1k`、`2k`、`4k`,管理员分别配置各档支持的比例;新增比例自动计算像素,原有精确尺寸不被重算。
+27
View File
@@ -9,6 +9,33 @@ description: 信封、错误码与 OpenAPI
机器可读规范:运行中的 `GET /api/openapi.yaml`,源文件 `backend/internal/handler/openapi.yaml`。前端 TypeScript 仍走 `web/src/services/api` 的 `http`,不从 OpenAPI 生成客户端。 机器可读规范:运行中的 `GET /api/openapi.yaml`,源文件 `backend/internal/handler/openapi.yaml`。前端 TypeScript 仍走 `web/src/services/api` 的 `http`,不从 OpenAPI 生成客户端。
## 站点皮肤主按钮
`GET /public/appearance` 返回当前 `activeSkin`;管理员通过 `GET/PUT /admin/settings/appearance` 读取、保存完整主题库。外观合同版本 8 新增 `tokens.buttons.light/dark`,字段为 `mode`(`solid|gradient`)、整数 `angle`(0–360)、HEX 色值 `start/end`、`hoverStart/hoverEnd`、`activeStart/activeEnd`、`foreground`。纯色模式使用既有主操作颜色,渐变仅用于主按钮。非法模式、角度、色值或修改锁定经典主题均拒绝保存;整块缺失的旧配置按主题身份补齐。此变更不增加数据表迁移。
## 模型规格报价
`GET /model-catalog` 在 `source=system` 时返回 `channels[].models[]`。每项的 `modelKey` 是产品模型标识,`displayName` 是产品展示名,`icon` 是模型图标键,`channelLabel` 是可选的渠道展示名(默认空字符串)。后台渠道模型创建与更新请求使用相同的 `channelLabel` 字段;服务端去除首尾空白并限制为 80 字,空字符串表示恢复使用渠道公开名称。
渠道模型创建、更新、管理列表、公开目录和会话模型价格信息均使用 `description` 表达模型描述。服务端去除首尾空白后限制为 500 字,允许空字符串清除描述;无管理员权限或超长内容拒绝保存。创作端二级选项在悬浮、聚焦或选中时展示该字段,长内容可悬浮查看完整文本;未填写的系统模型不按名称生成宣传文案。描述区域保留固定行高,悬浮不改变菜单项尺寸。
创作端按 `capability + modelKey` 精确分组,二级菜单保留各渠道模型的独立选择;选中值继续使用 `channelId::modelKey`,报价和生成请求保留该渠道身份。展示名、渠道展示名和 Logo 不参与路由、权限及计费。`source=frontend` 的逻辑模型目录继续按原逻辑模型身份工作,不将逻辑模型的供应线路公开成可选渠道。
同一产品在不同渠道中的 `modelKey` 应保持一致,名称与 Logo 也应统一;不同产品版本使用不同标识。已有模型标识不会自动改写。一级顺序按后台渠道和模型排序首次出现的位置确定,二级保持后台渠道顺序;若历史配置的展示名或 Logo 不一致,以稳定渠道身份排序选取元数据,不随当前选择和渠道排序跳变。
以下接口需要登录 Cookie,返回 `data.quote`,仅校验和报价,不创建任务、账单或冻结余额,不调用供应商生成接口。
| 接口 | 请求 |
| --- | --- |
| `POST /model-catalog/quote` | `{ channelId, modelKey, intent }`,仅允许启用的系统渠道与可用模型,复用任务准入、默认参数和价格档选择 |
| `POST /models/:id/quote` | 直接提交 `intent`,按前台逻辑模型当前可用线路和价格策略报价 |
`intent` 包含 `capability`(`text/image/video/audio`)、`operation`、`inputs`(素材类型到数量的映射)和 `options`(请求规格)。素材数量必须为 0–128 的整数,再按模型能力限制校验。视频规格包括 `vquality`、`size`、`videoSeconds`、布尔值 `videoGenerateAudio`,显式 `false` 必须保留。
报价包含 `logicalModelId`(系统渠道直连为空)、`billingMode`、`quantity`、`amountMicrocredits`、`estimated`。视频 Token 报价另有 `videoTokenEstimate`:`formulaTokens`、`reservedTokens`、`outputWidth`、`outputHeight`、`framesPerSecond`、`outputSeconds`、`referenceSeconds`、`referenceDurationEstimated`、`dimensionsEstimated`、`reservationMarginPercent`。
Token 报价的 `estimated` 为 `true`,`quantity` 是预留 Token 数。参考素材数量不包含时长信息,带参考视频时统一按 15 秒估算并返回 `referenceDurationEstimated: true`。所有视频协议均支持 Token 定价;10% 预留是平台策略,不是费用上限。成功后优先有效上游用量,无有效用量时按提交的公式快照结算,余量不计入公式费用。账单新增 `videoFormulaTokens` 及 `usageSource`(`provider` / `video_formula`),公式结算的 `usageAvailable` 为 `false`,`outputTokens` 表示公式数量。算法、配置与异常用量处理见[视频 Token 计费](/docs/backend/video-token-billing)。
## 画布保存、历史与恢复 ## 画布保存、历史与恢复
画布内容使用数据库递增的 `revision` 做乐观并发校验;`updatedAt` 仅用于展示,不作为版本依据。新建 `PUT /canvas-projects/:id` 的 `project.revision` 为 0,已有画布必须带上读取到的版本。数据库在同一次条件更新中匹配 ID、用户与版本,成功后返回 `data.project` 摘要及递增后的版本;缺失版本返回 428,陈旧版本返回 409,非法版本返回 400。客户端不能获取新版号后直接重发旧内容。 画布内容使用数据库递增的 `revision` 做乐观并发校验;`updatedAt` 仅用于展示,不作为版本依据。新建 `PUT /canvas-projects/:id` 的 `project.revision` 为 0,已有画布必须带上读取到的版本。数据库在同一次条件更新中匹配 ID、用户与版本,成功后返回 `data.project` 摘要及递增后的版本;缺失版本返回 428,陈旧版本返回 409,非法版本返回 400。客户端不能获取新版号后直接重发旧内容。
@@ -5,6 +5,51 @@ description: 当前项目已实现功能的手工验证清单与未确认边界
# 待测试 # 待测试
## 站点皮肤、控件焦点与外观分类
主按钮填充改为主题参数统一管理,经典黑白采用黑白基础色与 115° 紫蓝渐变;复制主题后可分别编辑明暗模式的纯色/渐变、角度、常态/悬停/按下双色和文字色。创作页“开始创作”与前后台主按钮使用相同参数,危险、幽灵和禁用按钮不套用渐变。后台隔离用户工作台外壳与浮层样式。输入、选择、日期和搜索控件移除重复焦点阴影,保留键盘焦点与错误状态。站点及外观按品牌、登录页、欢迎页、SEO、页尾备案、皮肤六个 Tab 展示,页面草稿统一保存,欢迎页开关继续独立即时保存。
- [x] 前端生产构建、后续类型检查及 9 项主题/渐变专项通过,覆盖主按钮状态、纯色切换清理、复制隔离和非法参数降级。后端外观专项通过,覆盖保存/读取/公开投影、旧数据补齐、非法参数拒绝及经典主题保护。外观 JSON 升为版本 8,无表结构迁移。
- [x] 隔离浏览器在真实外观路由验证跨 Tab 草稿保留、撤销、校验定位、隐藏视频卸载,以及明暗模式下经典/自定义按钮常态和悬停颜色、输入框无阴影、键盘焦点可见及 390px 无横向溢出。会话与配置使用测试状态,未保存真实站点设置。
- [x] 渐变扩展后,真实创作页和插件页验证经典主按钮明暗配色;后台编辑器验证纯色/渐变切换、角度修改、跨 Tab 草稿保留、撤销后保存按钮禁用、危险按钮不套用渐变。修复旧配置归一化后误报未保存状态;选择框键盘导航使用可见外框。浏览器 API 为隔离测试配置,持久化由后端临时 SQLite 服务测试验证。
- [ ] 用真实管理账号保存主题并刷新前后台,确认常态、悬停、按下、禁用、危险操作和浮层控件配色一致;验证媒体文件跨 Tab 选择后保存与刷新回填。
- [ ] 渐变相关三文件回归为 16 通过、1 失败,失败为原有后台旧警告色别名断言。上一轮完整相关回归还发现模型编辑器网格 CSS 顺序、首屏内置 Logo 引用、BrandLogo 旧主题 hook 三项原有失败;未修改这些无关实现。
## 模型描述与稳定悬浮
后台渠道模型编辑的“模型身份”区新增“模型描述”,公开目录和会话配置透传到二级选项。说明行预留固定高度,一级菜单取消悬浮位移,二级选项取消高度动画;选中、悬浮及键盘聚焦仍显示说明。系统模型未填写描述时不生成名称推测文案。
- [x] 前端 21 项专项测试及含类型检查的生产构建通过;后端保存/公开投影/描述长度专项、数据库包全套迁移回归及接口路由/OpenAPI 冒烟通过。
- [x] 隔离浏览器加载真实选择器,连续六次切换悬浮的位置和尺寸一致;已配置/空描述、聚焦显示、渠道选择、键盘、明暗图标及 390px 无横向溢出通过。真实编辑组件验证描述回填、修改后提交去空白文本、清空后提交空字符串;接口被测试拦截,未写真实模型。
- [ ] 在真实管理账号下保存、重新打开并清空描述,刷新创作端确认内容同步;在画布与创作页确认长描述、明暗主题与键盘选择。
- [ ] PostgreSQL 部署验证 schema v26。此次迁移只添加默认空字符串列;关闭自动迁移时先执行 `migrate-schema up` 和 `migrate-schema verify`。不提供降级迁移,回退使用匹配的数据库备份与二进制版本;未操作实际部署数据库。
## 产品模型分组与渠道展示名
系统渠道目录按能力与产品模型标识分组,二级展示独立渠道名称和价格;后台新增“渠道展示名”,留空使用渠道公开名称。选中值仍为渠道 ID 与模型标识,逻辑模型及个人渠道保持原选择合同。模型 Logo 按需加载原色版本,移除菜单位置染色。
- [x] 前端专项覆盖同产品多个渠道、价格透传、名称变化不改调用身份、能力隔离、排序时元数据稳定,以及逻辑模型和个人渠道边界。
- [x] 后端 SQLite 专项覆盖字段保存、公开目录及会话投影、长度与管理员校验;版本 24 迁移重复执行保留旧记录的身份和价格。
- [x] 前端构建与类型检查通过;隔离浏览器在现有应用中加载真实选择器组件,验证 3 个渠道及 0.3/0.3/0.2 积分单价、鼠标和键盘选中身份、Esc 关闭、390px 无横向溢出,以及明暗主题下图标原色保持一致。使用测试配置,未修改真实渠道。
- [x] 数据库包全套回归通过;旧迁移测试夹具补齐基线应有的 `billing_orders`,覆盖 v24、v25 连续升级。
- [ ] 使用实际配置确认跨渠道的产品模型标识、展示名和 Logo 一致,填写各渠道展示名后验证画布、创作页与 Agent 模型入口。
- [ ] 在 PostgreSQL 部署执行版本 24 迁移并验证目录;迁移只新增默认空字符串列,不自动规范化现有产品模型标识。关闭自动迁移的部署先运行 `migrate-schema up` 与 `migrate-schema verify`;没有降级迁移,回退需匹配数据库备份与二进制版本。
## 全协议视频 Token 计费闭环
所有视频协议开放 Token 价格,包含 NewAPI 通道 2;系统渠道和前台逻辑模型共用报价与火山式 24 FPS 公式。平台额外预留 10%,成功后优先有效上游用量,无有效用量时按提交的公式快照结算并退回余量,账单标注公式来源。schema v25 新增公式快照和来源列,不重算历史订单。方案与回滚边界见[视频 Token 计费](/docs/backend/video-token-billing)。
- [x] 后端专项覆盖官方公式、不同代际像素、4K、参考时长非法值、音频分档、免费价、真实用量严格解析、账单退差和补扣。
- [x] SQLite 集成测试覆盖系统渠道报价与任务预留一致、两种逻辑模型价格策略、报价无账户/账本/任务写入、不可用渠道拒绝与非法素材数量拒绝。
- [x] 收尾回归覆盖内部模型别名下的报价/预留一致、统一价格保存强校验,以及最高合法单价、倍率、最终金额溢出和汇总后一次取整;预估与结算共用精确金额算法。
- [x] 前端专项覆盖表单保存/回填、音频 false 匹配、Token 单价摘要、新旧报价接口与预估边界文案。
- [x] NewAPI 通道 2、NewAPI 视频及自定义视频的 SQLite 集成覆盖报价、预留、无上游用量公式结算、退回 10% 余量和重复结算幂等;v25 迁移重复执行保留历史账单。
- [x] 最新后端 app/repository/database 视频计费专项、数据库包全套回归通过;前端 41 项计费测试、`bun run build` 和文档 `bun run types:check` 通过。未执行真实收费生成或真实数据库迁移。
- [ ] 登录管理端配置有声/无声及参考视频价格档,在模型菜单、画布与短剧生产页变更时长/清晰度/音频,确认当前参数报价更新,切换免费档显示 0。
- [ ] 用真实方舟与 Agent Plan 渠道完成视频任务,核对上游 `completion_tokens`、账单实际金额及退补差额;参考视频最低消耗可能高于公式预估,确认用户能查看预估边界说明。
- [ ] 使用 Artbox 的 NewAPI 通道 2 保存“视频 Token”,完成无用量视频任务后确认公式结算、10% 余量退回、来源标注;重复轮询/回调不重复扣费。
- [ ] PostgreSQL 部署验证 schema v25;新代码未启动或未迁移时不要用旧后端保存非 Ark Token 价格。历史无公式快照的收费订单缺少用量仍进入待核对。
## Agent 历史事件重放导致画布反复冲突 ## Agent 历史事件重放导致画布反复冲突
旧会话的画布增量可能缺少版本号。页面刷新重放事件时,原实现先标记冲突;后续完整快照即使确认内容一致,也提前返回而不清除冲突。现在增量拒绝只触发快照校准,由完整快照确认真实冲突;内容一致时更新同步基线并恢复已同步状态。云端仍为已核对的同一基线时,保留待保存的本地编辑,不误判为并发修改。真实冲突继续保留草稿并阻止覆盖,不重放无版本增量,不修改历史数据。 旧会话的画布增量可能缺少版本号。页面刷新重放事件时,原实现先标记冲突;后续完整快照即使确认内容一致,也提前返回而不清除冲突。现在增量拒绝只触发快照校准,由完整快照确认真实冲突;内容一致时更新同步基线并恢复已同步状态。云端仍为已核对的同一基线时,保留待保存的本地编辑,不误判为并发修改。真实冲突继续保留草稿并阻止覆盖,不重放无版本增量,不修改历史数据。
+10 -4
View File
@@ -2,7 +2,7 @@
## 1. 目标与边界 ## 1. 目标与边界
本模块让部署方在不修改源码的前提下管理站点身份、登录页内容、搜索摘要、首页收尾信息与全站皮肤。默认 `classic` 皮肤必须等同项目既有样式;自定义品牌不得在首次渲染、邮件、诊断包、素材插件或后台说明中短暂或持续露出内置品牌。 本模块让部署方在不修改源码的前提下管理站点身份、登录页内容、搜索摘要、首页收尾信息与全站皮肤。默认 `classic` 皮肤采用黑白基础配色与紫蓝渐变主按钮;自定义品牌不得在首次渲染、邮件、诊断包、素材插件或后台说明中短暂或持续露出内置品牌。
技术兼容标识不属于品牌文案:仓库名、容器/升级器路径、剪贴板协议、localStorage key、插件 API version、数据库基线校验值和 User-Agent 可以继续使用 `open-ai-canvas` 或 `infinite-canvas`。英文品牌标识只用于新资源路径建议,不能自动改写已有对象存储前缀或历史资源。 技术兼容标识不属于品牌文案:仓库名、容器/升级器路径、剪贴板协议、localStorage key、插件 API version、数据库基线校验值和 User-Agent 可以继续使用 `open-ai-canvas` 或 `infinite-canvas`。英文品牌标识只用于新资源路径建议,不能自动改写已有对象存储前缀或历史资源。
@@ -17,7 +17,7 @@
| 首页收尾 | 版权信息、备案开关、备案号 | 备案号只有在显式开启且非空时显示,并链接工信部备案系统 | | 首页收尾 | 版权信息、备案开关、备案号 | 备案号只有在显式开启且非空时显示,并链接工信部备案系统 |
| 皮肤 | `skinId`、`skinThemes` | 选择当前皮肤并维护主题库;每套同时定义亮色、暗色与组件参数 | | 皮肤 | `skinId`、`skinThemes` | 选择当前皮肤并维护主题库;每套同时定义亮色、暗色与组件参数 |
配置继续存储在 `system_settings.appearance` JSON 中,schema version 为 6,不增加关系型数据库迁移。旧配置缺失 SEO、版权、备案、主题库、独立开关状态或破坏性操作交互色时,运行时会按原有主色、控件色和危险色向后补齐;只有管理员保存后才写回数据库。管理接口返回完整 `skinThemes`,公开接口只返回当前 `activeSkin`,避免将未启用的运营草稿暴露给前台。 配置继续存储在 `system_settings.appearance` JSON 中,schema version 为 8,不增加关系型数据库迁移。旧配置缺失 SEO、版权、备案、主题库、独立开关状态或破坏性操作交互色时,运行时会按原有主色、控件色和危险色向后补齐;只有管理员保存后才写回数据库。管理接口返回完整 `skinThemes`,公开接口只返回当前 `activeSkin`,避免将未启用的运营草稿暴露给前台。
## 3. 皮肤架构 ## 3. 皮肤架构
@@ -28,7 +28,11 @@
3. Component:按钮、输入、卡片、弹层、菜单与复选框圆角,以及控件高度、描边、焦点环、图标、字重、悬停抬升、动效和阴影。 3. Component:按钮、输入、卡片、弹层、菜单与复选框圆角,以及控件高度、描边、焦点环、图标、字重、悬停抬升、动效和阴影。
4. Adapter:将同一份语义令牌同时映射到 CSS Custom Properties 和 Ant Design 全局/组件 token。 4. Adapter:将同一份语义令牌同时映射到 CSS Custom Properties 和 Ant Design 全局/组件 token。
皮肤合同位于 `backend/internal/service/appearance_skins.go`,前端映射位于 `web/src/lib/skin-themes.ts`。页面不得按皮肤 ID 写条件样式;业务组件只能消费语义 token。`classic` 在运行时不写覆盖变量,使既有 `globals.css` 与 `app-theme.ts` 保持原样式唯一事实源;服务端会逐字段比对经典主题,任何删除或伪造修改都会被拒绝。其他主题均为可编辑数据,用根节点 CSS 变量覆盖自研组件语义层,并向 Ant Design `ConfigProvider` 提供同一套颜色、交互状态、圆角、尺寸、动效和阴影值。 皮肤合同位于 `backend/internal/app/appearance_skins.go`,前端映射位于 `web/src/lib/skin-themes.ts`。页面不得按皮肤 ID 写条件样式;业务组件只能消费语义 token。`classic` 只注入主按钮填充变量,基础表面继续由 `globals.css` 与 `app-theme.ts` 提供;服务端会逐字段比对经典主题,任何删除或伪造修改都会被拒绝。其他主题均为可编辑数据,用根节点 CSS 变量覆盖自研组件语义层,并向 Ant Design `ConfigProvider` 提供同一套颜色、交互状态、圆角、尺寸、动效和阴影值。
`tokens.buttons.light/dark` 分别配置主按钮填充:`mode` 为 `solid` 或 `gradient`,`angle` 为 0–360 的整数;`start/end`、`hoverStart/hoverEnd`、`activeStart/activeEnd` 和 `foreground` 为 HEX 色值。纯色模式消费原有 `primary/primaryHover/primaryActive/primaryForeground`,渐变模式使用独立参数,不改变链接、选中态、开关或危险操作。经典默认角度为 115°,常态 `#6554df → #386fbc`,悬停 `#5744cf → #356bbb`,按下 `#4938b8 → #2c5da5`,文字为白色。后台可复制经典主题后调整两种模式的全部参数。
旧数据整块缺少 `buttons` 时,经典主题补入默认渐变,其余主题保留纯色;局部缺失或非法写入被拒绝。读取补齐不自动写库,保存后写入版本 8;回退旧版本前应备份外观 JSON,旧版本不会呈现新渐变配置。
主题库初始包含: 主题库初始包含:
@@ -73,7 +77,9 @@ SEO 标题建议控制在 70 字符内,描述 200 字符内,关键词 300
## 6. 后台交互合同 ## 6. 后台交互合同
后台入口名称为“站点及外观”,继续复用系统设置页的页面框架、状态操作栏、`SettingsSectionCard`、Ant Form/Input/Switch 与统一保存模型。五个顺序固定为:品牌识别、登录页内容与媒体、SEO 信息、首页收尾与备案、皮肤主题。主题编辑器由主题库、身份编辑、浅/深模式切换、实时控件预览、语义颜色分组和组件参数分组组成;默认主题展示锁定原因,自定义主题显示复制与删除动作。 后台入口名称为“站点及外观”,继续复用系统设置页的页面框架、状态操作栏、`SettingsSectionCard`、Ant Form/Input/Switch 与统一保存模型。内容按六个 Tab 展示:品牌识别、登录页、欢迎页、SEO 信息、页尾与备案、皮肤主题。切换 Tab 保留页面草稿与待上传文件;统一保存校验失败时切回问题字段所在分类。欢迎页开关沿用独立接口,切换后立即保存,其余分类共用保存、撤销和未保存离开保护。主题编辑器由主题库、身份编辑、浅/深模式切换、实时控件预览、语义颜色分组和组件参数分组组成;默认主题展示锁定原因,自定义主题显示复制与删除动作。
用户工作台和后台的主按钮通过公共 Ant Design 主题及 `primary-buttons.css` 适配器消费皮肤参数,创作页复合按钮使用相同的 `--button-primary-*` 填充变量;页面不再硬编码渐变颜色。危险、幽灵和禁用按钮不套用渐变。后台路由不挂载用户工作台外壳和浮层样式;后台保留独立表面与控件密度。输入、数字输入、选择和日期控件关闭焦点阴影,按钮关闭点击波纹;键盘导航仍保留可见焦点,校验错误状态保留。
所有调整先形成页面草稿;只有点击“保存修改”才上传新资源并提交配置。保存响应成为新基线。离开、刷新覆盖和恢复内置品牌需要沿用现有未保存保护;恢复操作不删除已经上传的存储资源。皮肤卡必须可键盘操作,并以 radio/`aria-checked` 语义暴露选中状态。原生取色器只在点击颜色方块本身时打开;点击字段名称、说明或 HEX 输入不会代理触发系统取色器。取色器与 HEX 输入共享同一字段,非法中间值允许留在草稿中便于继续编辑,但前端保存校验和后端权威校验都会阻止其生效。 所有调整先形成页面草稿;只有点击“保存修改”才上传新资源并提交配置。保存响应成为新基线。离开、刷新覆盖和恢复内置品牌需要沿用现有未保存保护;恢复操作不删除已经上传的存储资源。皮肤卡必须可键盘操作,并以 radio/`aria-checked` 语义暴露选中状态。原生取色器只在点击颜色方块本身时打开;点击字段名称、说明或 HEX 输入不会代理触发系统取色器。取色器与 HEX 输入共享同一字段,非法中间值允许留在草稿中便于继续编辑,但前端保存校验和后端权威校验都会阻止其生效。
+1 -1
View File
@@ -39,7 +39,7 @@ export function AppProviders({ children }: { children: ReactNode }) {
const isolateDevRepro = import.meta.env.DEV && typeof window !== "undefined" && window.location.pathname === "/dev/director-repro"; const isolateDevRepro = import.meta.env.DEV && typeof window !== "undefined" && window.location.pathname === "/dev/director-repro";
return ( return (
<ConfigProvider locale={zhCN} theme={getAntThemeConfig(dark, appearance.activeSkin)}> <ConfigProvider locale={zhCN} theme={getAntThemeConfig(dark, appearance.activeSkin)} wave={{ disabled: true }}>
<App message={{ duration: 3, maxCount: 3 }} notification={{ duration: 4.5, maxCount: 3, placement: "topRight" }}> <App message={{ duration: 3, maxCount: 3 }} notification={{ duration: 4.5, maxCount: 3, placement: "topRight" }}>
<QueryClientProvider client={appQueryClient}> <QueryClientProvider client={appQueryClient}>
{isolateDevRepro ? ( {isolateDevRepro ? (
+6 -3
View File
@@ -13,13 +13,14 @@ const workspaceTheme = getWorkspaceAntThemeConfig();
export default function UserLayout({ children }: { children: ReactNode }) { export default function UserLayout({ children }: { children: ReactNode }) {
const { pathname } = useLocation(); const { pathname } = useLocation();
const adminWorkspace = pathname === "/admin" || pathname.startsWith("/admin/");
const spatialWorkbench = isSpatialWorkbenchPath(pathname); const spatialWorkbench = isSpatialWorkbenchPath(pathname);
const productWorkspace = !/^\/canvas\/[^/]+(?:\/|$)/.test(pathname); const productWorkspace = !adminWorkspace && !/^\/canvas\/[^/]+(?:\/|$)/.test(pathname);
useWorkspaceButtonFeedback(productWorkspace); useWorkspaceButtonFeedback(productWorkspace);
useLayoutEffect(() => { useLayoutEffect(() => {
// Ant Design 浮层挂载在 body,必须用路由级标记隔离用户工作台与画布编辑器、运营后台。 // Ant Design 浮层挂载在 body,必须用路由级标记隔离用户工作台与画布编辑器、运营后台。
document.body.classList.add("app-user-overlays"); document.body.classList.toggle("app-user-overlays", !adminWorkspace);
document.body.classList.toggle("app-spatial-overlays", spatialWorkbench); document.body.classList.toggle("app-spatial-overlays", spatialWorkbench);
document.body.classList.toggle("app-product-overlays", productWorkspace); document.body.classList.toggle("app-product-overlays", productWorkspace);
return () => { return () => {
@@ -27,7 +28,9 @@ export default function UserLayout({ children }: { children: ReactNode }) {
document.body.classList.remove("app-spatial-overlays"); document.body.classList.remove("app-spatial-overlays");
document.body.classList.remove("app-product-overlays"); document.body.classList.remove("app-product-overlays");
}; };
}, [spatialWorkbench, productWorkspace]); }, [adminWorkspace, spatialWorkbench, productWorkspace]);
if (adminWorkspace) return children;
return ( return (
<ConfigProvider theme={productWorkspace ? workspaceTheme : undefined}> <ConfigProvider theme={productWorkspace ? workspaceTheme : undefined}>
+8 -1
View File
@@ -164,6 +164,7 @@ export function getAntThemeConfig(dark: boolean, skinID: unknown = "classic"): T
colorLinkHover: color.solidHoverBg, colorLinkHover: color.solidHoverBg,
colorLinkActive: color.solidActiveBg, colorLinkActive: color.solidActiveBg,
colorTextLightSolid: color.solidFg, colorTextLightSolid: color.solidFg,
controlOutlineWidth: 0,
colorText: skin.text || undefined, colorText: skin.text || undefined,
colorTextSecondary: skin.textMuted || undefined, colorTextSecondary: skin.textMuted || undefined,
colorIcon: skin.icon || undefined, colorIcon: skin.icon || undefined,
@@ -196,6 +197,7 @@ export function getAntThemeConfig(dark: boolean, skinID: unknown = "classic"): T
}, },
components: { components: {
Button: { Button: {
defaultShadow: "none",
primaryShadow: "none", primaryShadow: "none",
dangerShadow: "none", dangerShadow: "none",
dangerColor: color.dangerForeground, dangerColor: color.dangerForeground,
@@ -235,6 +237,11 @@ export function getAntThemeConfig(dark: boolean, skinID: unknown = "classic"): T
hoverBorderColor: interactiveBorder, hoverBorderColor: interactiveBorder,
activeShadow: focusShadow, activeShadow: focusShadow,
}, },
DatePicker: {
activeShadow: focusShadow,
activeBorderColor: interactiveBorder,
hoverBorderColor: interactiveBorder,
},
Switch: { Switch: {
handleBg: color.switchOffHandle, handleBg: color.switchOffHandle,
handleShadow: dark ? "0 1px 4px rgba(0, 0, 0, 0.42)" : "0 1px 2px rgba(0, 0, 0, 0.2)", handleShadow: dark ? "0 1px 4px rgba(0, 0, 0, 0.42)" : "0 1px 2px rgba(0, 0, 0, 0.2)",
@@ -394,7 +401,7 @@ export function getWorkspaceAntThemeConfig(): ThemeConfig {
defaultShadow: "none", primaryShadow: "none", dangerShadow: "none", defaultShadow: "none", primaryShadow: "none", dangerShadow: "none",
paddingInline: 14, paddingInlineSM: 10, paddingInline: 14, paddingInlineSM: 10,
}, },
Input: { borderRadius: 12, activeShadow: "0 0 0 2px var(--user-accent-soft)", paddingInline: 12 }, Input: { borderRadius: 12, paddingInline: 12 },
Select: { borderRadius: 12, optionSelectedBg: "var(--user-accent-soft)", optionSelectedColor: "var(--user-ink)", optionActiveBg: "var(--user-surface-muted)", optionPadding: "9px 12px" }, Select: { borderRadius: 12, optionSelectedBg: "var(--user-accent-soft)", optionSelectedColor: "var(--user-ink)", optionActiveBg: "var(--user-surface-muted)", optionPadding: "9px 12px" },
Dropdown: { borderRadiusLG: 16, controlItemBgHover: "var(--user-surface-muted)", paddingBlock: 6 }, Dropdown: { borderRadiusLG: 16, controlItemBgHover: "var(--user-surface-muted)", paddingBlock: 6 },
Modal: { borderRadiusLG: 20 }, Modal: { borderRadiusLG: 20 },
+64 -3
View File
@@ -1,6 +1,32 @@
export type SkinThemeMode = "light" | "dark"; export type SkinThemeMode = "light" | "dark";
export type SkinShadowStyle = "none" | "soft" | "strong"; export type SkinShadowStyle = "none" | "soft" | "strong";
export type SkinButtonFill = {
mode: "solid" | "gradient";
angle: number;
start: string;
end: string;
hoverStart: string;
hoverEnd: string;
activeStart: string;
activeEnd: string;
foreground: string;
};
export const DEFAULT_BUTTON_GRADIENT: SkinButtonFill = {
mode: "gradient", angle: 115,
start: "#6554df", end: "#386fbc",
hoverStart: "#5744cf", hoverEnd: "#356bbb",
activeStart: "#4938b8", activeEnd: "#2c5da5", foreground: "#ffffff",
};
export const SKIN_BUTTON_COLOR_FIELDS = [
{ key: "start", label: "渐变起色" }, { key: "end", label: "渐变终色" },
{ key: "hoverStart", label: "悬停起色" }, { key: "hoverEnd", label: "悬停终色" },
{ key: "activeStart", label: "按下起色" }, { key: "activeEnd", label: "按下终色" },
{ key: "foreground", label: "渐变按钮文字" },
] as const;
export type SkinModeTokens = { export type SkinModeTokens = {
canvas: string; canvas: string;
surface: string; surface: string;
@@ -78,6 +104,7 @@ export type SkinTokens = {
light: SkinModeTokens; light: SkinModeTokens;
dark: SkinModeTokens; dark: SkinModeTokens;
components: SkinComponentTokens; components: SkinComponentTokens;
buttons: Record<SkinThemeMode, SkinButtonFill>;
}; };
export type SkinDefinition = { export type SkinDefinition = {
@@ -197,7 +224,7 @@ export const SKIN_COLOR_GROUPS: readonly SkinColorGroup[] = [
{ key: "switchUnchecked", label: "开关关闭", help: "Switch 关闭轨道" }, { key: "switchUnchecked", label: "开关关闭", help: "Switch 关闭轨道" },
{ key: "switchUncheckedHover", label: "关闭悬停", help: "关闭状态 hover 轨道" }, { key: "switchUncheckedHover", label: "关闭悬停", help: "关闭状态 hover 轨道" },
{ key: "switchUncheckedHandle", label: "关闭滑块", help: "关闭状态圆形滑块" }, { key: "switchUncheckedHandle", label: "关闭滑块", help: "关闭状态圆形滑块" },
{ key: "primary", label: "主操作", help: "主要按钮、链接和开关" }, { key: "primary", label: "主操作", help: "纯色主按钮与链接;开关使用独立颜色" },
{ key: "primaryHover", label: "主操作悬停", help: "主要操作 hover" }, { key: "primaryHover", label: "主操作悬停", help: "主要操作 hover" },
{ key: "primaryActive", label: "主操作按下", help: "主要操作 active" }, { key: "primaryActive", label: "主操作按下", help: "主要操作 active" },
{ key: "primaryForeground", label: "主操作前景", help: "主按钮上的文字和图标" }, { key: "primaryForeground", label: "主操作前景", help: "主按钮上的文字和图标" },
@@ -371,6 +398,7 @@ export const DEFAULT_CLASSIC_SKIN: SkinDefinition = {
authAccent: "#93c5fd", authAccent: "#93c5fd",
authMuted: "#8a8b91", authMuted: "#8a8b91",
}, },
buttons: { light: { ...DEFAULT_BUTTON_GRADIENT }, dark: { ...DEFAULT_BUTTON_GRADIENT } },
components: { components: {
buttonRadius: 6, buttonRadius: 6,
inputRadius: 6, inputRadius: 6,
@@ -395,6 +423,7 @@ export const DEFAULT_CLASSIC_SKIN: SkinDefinition = {
const HEX_COLOR = /^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i; const HEX_COLOR = /^#[0-9a-f]{6}(?:[0-9a-f]{2})?$/i;
const MANAGED_VARIABLES = [ const MANAGED_VARIABLES = [
"--button-primary-bg", "--button-primary-hover-bg", "--button-primary-active-bg", "--button-primary-fg",
"--background", "--background",
"--foreground", "--foreground",
"--card", "--card",
@@ -504,7 +533,10 @@ export function normalizeSkinDefinition(value: unknown, fallback: SkinDefinition
name: typeof candidate.name === "string" && candidate.name.trim() ? candidate.name.trim().slice(0, 40) : fallback.name, name: typeof candidate.name === "string" && candidate.name.trim() ? candidate.name.trim().slice(0, 40) : fallback.name,
description: typeof candidate.description === "string" ? candidate.description.trim().slice(0, 100) : fallback.description, description: typeof candidate.description === "string" ? candidate.description.trim().slice(0, 100) : fallback.description,
locked: id === "classic", locked: id === "classic",
tokens: { light, dark, components: { ...modes.components } }, tokens: { light, dark, components: { ...modes.components }, buttons: {
light: normalizeButtonFill(modes.buttons?.light, id),
dark: normalizeButtonFill(modes.buttons?.dark, id),
} },
}; };
} }
@@ -662,9 +694,37 @@ export function applySkinTheme(skinValue: unknown, mode: SkinThemeMode, targetDo
const values = skinCSSVariables(skin, mode); const values = skinCSSVariables(skin, mode);
for (const [property, value] of Object.entries(values)) root.style.setProperty(property, value); for (const [property, value] of Object.entries(values)) root.style.setProperty(property, value);
} }
for (const [property, value] of Object.entries(skinButtonCSSVariables(skin, mode))) root.style.setProperty(property, value);
root.dataset.skin = skin.id; root.dataset.skin = skin.id;
} }
export function isSkinButtonFill(value: unknown): value is SkinButtonFill {
if (!value || typeof value !== "object") return false;
const fill = value as SkinButtonFill;
return ["solid", "gradient"].includes(fill.mode) && Number.isInteger(fill.angle) && fill.angle >= 0 && fill.angle <= 360
&& SKIN_BUTTON_COLOR_FIELDS.every(({ key }) => typeof fill[key] === "string" && HEX_COLOR.test(fill[key]));
}
function normalizeButtonFill(value: unknown, skinID: string): SkinButtonFill {
return isSkinButtonFill(value) ? { ...value } : { ...DEFAULT_BUTTON_GRADIENT, mode: skinID === "classic" ? "gradient" : "solid" };
}
export function getSkinButtonAppearance(skin: SkinDefinition, mode: SkinThemeMode) {
const fill = normalizeButtonFill(skin.tokens.buttons?.[mode], skin.id);
const color = skin.tokens[mode];
const gradient = (start: string, end: string) => `linear-gradient(${fill.angle}deg, ${start}, ${end})`;
return fill.mode === "gradient" ? {
background: gradient(fill.start, fill.end), hover: gradient(fill.hoverStart, fill.hoverEnd),
active: gradient(fill.activeStart, fill.activeEnd), foreground: fill.foreground,
} : { background: color.primary, hover: color.primaryHover, active: color.primaryActive, foreground: color.primaryForeground };
}
function skinButtonCSSVariables(skin: SkinDefinition, mode: SkinThemeMode) {
const button = getSkinButtonAppearance(skin, mode);
return { "--button-primary-bg": button.background, "--button-primary-hover-bg": button.hover,
"--button-primary-active-bg": button.active, "--button-primary-fg": button.foreground };
}
export function skinCSSVariables(skin: SkinDefinition, mode: SkinThemeMode): Record<string, string> { export function skinCSSVariables(skin: SkinDefinition, mode: SkinThemeMode): Record<string, string> {
const color = skin.tokens[mode]; const color = skin.tokens[mode];
const component = skin.tokens.components; const component = skin.tokens.components;
@@ -777,7 +837,8 @@ function skinShadowVariables(style: SkinShadowStyle, mode: SkinThemeMode) {
} }
function cloneSkinTokens(tokens: SkinTokens): SkinTokens { function cloneSkinTokens(tokens: SkinTokens): SkinTokens {
return { light: { ...tokens.light }, dark: { ...tokens.dark }, components: { ...tokens.components } }; return { light: { ...tokens.light }, dark: { ...tokens.dark }, components: { ...tokens.components },
buttons: { light: { ...tokens.buttons.light }, dark: { ...tokens.buttons.dark } } };
} }
function isSkinMode(value: unknown): value is SkinModeTokens { function isSkinMode(value: unknown): value is SkinModeTokens {
@@ -139,7 +139,7 @@ export function AdminShell() {
}; };
return ( return (
<ConfigProvider theme={getIsolatedAdminAntTheme(dark)} getPopupContainer={(node) => adminPopupContainer(node)}> <ConfigProvider theme={getIsolatedAdminAntTheme(dark, appearance.activeSkin)} getPopupContainer={(node) => adminPopupContainer(node)}>
<App> <App>
<main id="admin-root" data-admin-root className="admin-shell flex h-full min-h-0 overflow-hidden"> <main id="admin-root" data-admin-root className="admin-shell flex h-full min-h-0 overflow-hidden">
<aside className={cn("admin-sidebar hidden shrink-0 flex-col overflow-hidden lg:flex", collapsed && "is-collapsed")}> <aside className={cn("admin-sidebar hidden shrink-0 flex-col overflow-hidden lg:flex", collapsed && "is-collapsed")}>
+1 -17
View File
@@ -1,17 +1 @@
.admin-list-toolbar .ant-btn.admin-toolbar-primary-action { /* Primary toolbar actions inherit the shared site button fill and disabled state. */
border-color: var(--btn-solid-bg) !important;
background: var(--btn-solid-bg) !important;
color: var(--btn-solid-fg) !important;
}
.admin-list-toolbar .ant-btn.admin-toolbar-primary-action:not(:disabled):hover {
border-color: var(--btn-solid-hover-bg) !important;
background: var(--btn-solid-hover-bg) !important;
color: var(--btn-solid-fg) !important;
}
.admin-list-toolbar .ant-btn.admin-toolbar-primary-action:not(:disabled):active {
border-color: var(--btn-solid-active-bg) !important;
background: var(--btn-solid-active-bg) !important;
color: var(--btn-solid-fg) !important;
}
@@ -1,4 +1,4 @@
import { App, Button, Form, Input, Skeleton } from "antd"; import { App, Button, Form, Input, Skeleton, Tabs } from "antd";
import { Switch } from "@/pages/admin/ui/controls"; import { Switch } from "@/pages/admin/ui/controls";
import { Copyright, Globe2, Image as ImageIcon, MonitorPlay, Moon, Palette, RefreshCw, RotateCcw, Save, Search, Sun, Type, Undo2, Upload } from "lucide-react"; 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 { useCallback, useEffect, useMemo, useRef, useState, type ReactNode, type RefObject } from "react";
@@ -7,7 +7,7 @@ import { useBlocker } from "react-router";
import { AdminPageFrame } from "@/pages/admin/components/admin-shell"; import { AdminPageFrame } from "@/pages/admin/components/admin-shell";
import { AdminStatusBadge, SettingsSectionCard } from "@/pages/admin/components/admin-ui"; import { AdminStatusBadge, SettingsSectionCard } from "@/pages/admin/components/admin-ui";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { cloneSkinDefinition, DEFAULT_CLASSIC_SKIN, duplicateSkinDefinition, normalizeSkinDefinition, type SkinDefinition } from "@/lib/skin-themes"; import { cloneSkinDefinition, DEFAULT_CLASSIC_SKIN, duplicateSkinDefinition, isSkinButtonFill, normalizeSkinDefinition, type SkinDefinition } from "@/lib/skin-themes";
import { SkinThemeEditor } from "@/pages/admin/settings/components/skin-theme-editor"; import { SkinThemeEditor } from "@/pages/admin/settings/components/skin-theme-editor";
import { WelcomeSetting } from "@/pages/admin/settings/components/welcome-setting"; import { WelcomeSetting } from "@/pages/admin/settings/components/welcome-setting";
import { deleteAdminResources } from "@/services/api/admin-storage"; import { deleteAdminResources } from "@/services/api/admin-storage";
@@ -28,6 +28,7 @@ const FILE_RULES: Record<AppearanceAssetSlot, { accept: string; maxBytes: number
export default function AppearanceSettingsPage() { export default function AppearanceSettingsPage() {
const { message, modal } = App.useApp(); const { message, modal } = App.useApp();
const [activeTab, setActiveTab] = useState("brand");
const [setting, setSetting] = useState<AdminAppearance | null>(null); const [setting, setSetting] = useState<AdminAppearance | null>(null);
const [brandName, setBrandName] = useState(""); const [brandName, setBrandName] = useState("");
const [brandSlug, setBrandSlug] = useState(""); const [brandSlug, setBrandSlug] = useState("");
@@ -79,16 +80,17 @@ export default function AppearanceSettingsPage() {
const blocker = useBlocker(dirty && !saving && !restoring); const blocker = useBlocker(dirty && !saving && !restoring);
const applySetting = useCallback((value: AdminAppearance) => { const applySetting = useCallback((value: AdminAppearance) => {
setSetting(value); const themes = value.skinThemes.length ? value.skinThemes.map((theme) => normalizeSkinDefinition(theme)) : [cloneSkinDefinition(DEFAULT_CLASSIC_SKIN)];
const selectedID = themes.some((theme) => theme.id === value.skinId) ? value.skinId : "classic";
setSetting({ ...value, skinThemes: themes, skinId: selectedID });
setBrandName(value.brandName); setBrandName(value.brandName);
setBrandSlug(value.brandSlug); setBrandSlug(value.brandSlug);
setAuthHeroTitle(value.authHeroTitle); setAuthHeroTitle(value.authHeroTitle);
setAuthHeroDescription(value.authHeroDescription); setAuthHeroDescription(value.authHeroDescription);
setAuthVideoAutoplay(value.authVideoAutoplay); setAuthVideoAutoplay(value.authVideoAutoplay);
setLogoFrameEnabled(value.logoFrameEnabled); setLogoFrameEnabled(value.logoFrameEnabled);
const themes = value.skinThemes.map((theme) => normalizeSkinDefinition(theme)); setSkinThemes(themes);
setSkinThemes(themes.length ? themes : [cloneSkinDefinition(DEFAULT_CLASSIC_SKIN)]); setSkinId(selectedID);
setSkinId(themes.some((theme) => theme.id === value.skinId) ? value.skinId : "classic");
setSeoTitle(value.seoTitle); setSeoTitle(value.seoTitle);
setSeoDescription(value.seoDescription); setSeoDescription(value.seoDescription);
setSeoKeywords(value.seoKeywords); setSeoKeywords(value.seoKeywords);
@@ -268,39 +270,46 @@ export default function AppearanceSettingsPage() {
const nextFooterCopyright = normalizeSingleLine(footerCopyright); const nextFooterCopyright = normalizeSingleLine(footerCopyright);
const nextIcpFilingNumber = normalizeSingleLine(icpFilingNumber); const nextIcpFilingNumber = normalizeSingleLine(icpFilingNumber);
if (!nextBrandName || Array.from(nextBrandName).length > 40) { if (!nextBrandName || Array.from(nextBrandName).length > 40) {
setActiveTab("brand");
message.error("品牌名称必须为 1 到 40 个字符"); message.error("品牌名称必须为 1 到 40 个字符");
return; return;
} }
if (!/^[a-z0-9](?:[a-z0-9-]{0,46}[a-z0-9])?$/.test(nextBrandSlug)) { if (!/^[a-z0-9](?:[a-z0-9-]{0,46}[a-z0-9])?$/.test(nextBrandSlug)) {
setActiveTab("brand");
message.error("英文品牌标识须为 1 到 48 位小写字母、数字或连字符"); message.error("英文品牌标识须为 1 到 48 位小写字母、数字或连字符");
return; return;
} }
if (!nextAuthHeroTitle || Array.from(nextAuthHeroTitle).length > 80 || hasUnsupportedControlCharacter(nextAuthHeroTitle)) { if (!nextAuthHeroTitle || Array.from(nextAuthHeroTitle).length > 80 || hasUnsupportedControlCharacter(nextAuthHeroTitle)) {
setActiveTab("auth");
message.error("登录页主标题必须为 1 到 80 个字符,可使用换行"); message.error("登录页主标题必须为 1 到 80 个字符,可使用换行");
return; return;
} }
if (Array.from(nextAuthHeroDescription).length > 160 || hasUnsupportedControlCharacter(nextAuthHeroDescription)) { if (Array.from(nextAuthHeroDescription).length > 160 || hasUnsupportedControlCharacter(nextAuthHeroDescription)) {
setActiveTab("auth");
message.error("登录页说明文案不能超过 160 个字符,可使用换行"); message.error("登录页说明文案不能超过 160 个字符,可使用换行");
return; return;
} }
for (const [value, label, max] of [ for (const [value, label, max, tab] of [
[nextSeoTitle, "SEO 标题", 70], [nextSeoTitle, "SEO 标题", 70, "seo"],
[nextSeoDescription, "SEO 描述", 200], [nextSeoDescription, "SEO 描述", 200, "seo"],
[nextSeoKeywords, "SEO 关键词", 300], [nextSeoKeywords, "SEO 关键词", 300, "seo"],
[nextFooterCopyright, "版权信息", 160], [nextFooterCopyright, "版权信息", 160, "footer"],
[nextIcpFilingNumber, "备案号", 64], [nextIcpFilingNumber, "备案号", 64, "footer"],
] as const) { ] as const) {
if (Array.from(value).length > max || hasUnsupportedControlCharacter(value)) { if (Array.from(value).length > max || hasUnsupportedControlCharacter(value)) {
setActiveTab(tab);
message.error(`${label}不能超过 ${max} 个字符,且不能包含控制字符`); message.error(`${label}不能超过 ${max} 个字符,且不能包含控制字符`);
return; return;
} }
} }
if (icpFilingEnabled && !nextIcpFilingNumber) { if (icpFilingEnabled && !nextIcpFilingNumber) {
setActiveTab("footer");
message.error("显示备案号前请先填写备案号"); message.error("显示备案号前请先填写备案号");
return; return;
} }
const skinError = validateSkinDrafts(skinThemes, skinId); const skinError = validateSkinDrafts(skinThemes, skinId);
if (skinError) { if (skinError) {
setActiveTab("skins");
message.error(skinError); message.error(skinError);
return; return;
} }
@@ -429,7 +438,7 @@ export default function AppearanceSettingsPage() {
<strong>{dirty ? "站点配置有调整待保存" : "站点及外观已与服务端同步"}</strong> <strong>{dirty ? "站点配置有调整待保存" : "站点及外观已与服务端同步"}</strong>
<AdminStatusBadge label={dirty ? "尚未生效" : "服务端当前值"} tone={dirty ? "warning" : "neutral"} /> <AdminStatusBadge label={dirty ? "尚未生效" : "服务端当前值"} tone={dirty ? "warning" : "neutral"} />
</div> </div>
<p>{dirty ? "品牌、SEO、备案、皮肤和媒体只在本页预览;保存后才会应用。" : "公开页面会在应用渲染前读取品牌与皮肤,不会先闪现旧站点身份。"}</p> <p>{dirty ? "切换分类保留草稿;保存修改会一次应用品牌、登录页、SEO、备案和皮肤调整。" : "按分类管理站点配置;欢迎页开关独立即时保存,其余修改统一保存。"}</p>
</div> </div>
</div> </div>
<div className="admin-appearance-command-actions"> <div className="admin-appearance-command-actions">
@@ -450,254 +459,303 @@ export default function AppearanceSettingsPage() {
</div> </div>
</div> </div>
<SettingsSectionCard <Tabs
className="admin-appearance-section admin-appearance-brand-section" className="admin-appearance-tabs"
icon={<Palette className="size-4" aria-hidden="true" />} activeKey={activeTab}
title="1. 设置品牌识别" onChange={setActiveTab}
description="中文品牌名用于主要界面,英文品牌标识用于英文角标和可安全品牌化的路径建议;不会改动代码包、数据库或部署标识。" items={[
status={status} {
> key: "brand",
<div className="admin-appearance-brand-layout"> label: "品牌识别",
<Form className="admin-appearance-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}> children: (
<Form.Item label="品牌名称" extra="1–40 个字符。保存后同步到登录页、工作台、管理后台与浏览器标题。"> <SettingsSectionCard
<Input value={brandName} maxLength={40} showCount placeholder="输入品牌名称" onChange={(event) => setBrandName(event.target.value)} /> className="admin-appearance-section admin-appearance-brand-section"
</Form.Item> icon={<Palette className="size-4" aria-hidden="true" />}
<Form.Item label="英文品牌标识" extra="1–48 位小写字母、数字或连字符,例如 hima-studio。对象存储可一键采用该值作为路径前缀。"> title="品牌识别"
<Input description="中文品牌名用于主要界面,英文品牌标识用于英文角标和可安全品牌化的路径建议;不会改动代码包、数据库或部署标识。"
value={brandSlug} status={status}
maxLength={48} >
showCount <div className="admin-appearance-brand-layout">
autoCapitalize="none" <Form className="admin-appearance-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
autoCorrect="off" <Form.Item label="品牌名称" extra="1–40 个字符。保存后同步到登录页、工作台、管理后台与浏览器标题。">
spellCheck={false} <Input value={brandName} maxLength={40} showCount placeholder="输入品牌名称" onChange={(event) => setBrandName(event.target.value)} />
placeholder="例如:hima-studio" </Form.Item>
onChange={(event) => setBrandSlug(event.target.value.toLocaleLowerCase().replace(/[^a-z0-9-]/g, ""))} <Form.Item label="英文品牌标识" extra="1–48 位小写字母、数字或连字符,例如 hima-studio。对象存储可一键采用该值作为路径前缀。">
/> <Input
</Form.Item> value={brandSlug}
<WelcomeSetting /> maxLength={48}
</Form> showCount
<div className="admin-appearance-brand-logo admin-appearance-logo-stack"> autoCapitalize="none"
<AssetPicker autoCorrect="off"
slot="logo" spellCheck={false}
title="浅色模式 Logo" placeholder="例如:hima-studio"
description="用于浅色界面;建议透明背景 PNG 或 WebP。" onChange={(event) => setBrandSlug(event.target.value.toLocaleLowerCase().replace(/[^a-z0-9-]/g, ""))}
configured={Boolean(setting.logoResourceId) && !resets.logo} />
file={files.logo} </Form.Item>
inputRef={inputRefs.logo} </Form>
onSelect={selectFile} <div className="admin-appearance-brand-logo admin-appearance-logo-stack">
onReset={resetAsset} <AssetPicker
disabled={saving || refreshing || restoring} slot="logo"
emptyLabel={darkLogoSelected ? "将自动复用深色模式 Logo" : "未上传时使用项目原始 Logo"} title="浅色模式 Logo"
/> description="用于浅色界面;建议透明背景 PNG 或 WebP。"
<AssetPicker configured={Boolean(setting.logoResourceId) && !resets.logo}
slot="logo-dark" file={files.logo}
title="深色模式 Logo(可选)" inputRef={inputRefs.logo}
description="用于深色界面;不上传时自动复用浅色模式 Logo。" onSelect={selectFile}
configured={Boolean(setting.darkLogoResourceId) && !resets["logo-dark"]} onReset={resetAsset}
file={files["logo-dark"]} disabled={saving || refreshing || restoring}
inputRef={inputRefs["logo-dark"]} emptyLabel={darkLogoSelected ? "将自动复用深色模式 Logo" : "未上传时使用项目原始 Logo"}
onSelect={selectFile} />
onReset={resetAsset} <AssetPicker
disabled={saving || refreshing || restoring} slot="logo-dark"
emptyLabel={lightLogoSelected ? "将自动复用浅色模式 Logo" : "未上传时使用项目原始 Logo"} title="深色模式 Logo(可选)"
/> description="用于深色界面;不上传时自动复用浅色模式 Logo。"
<div className="admin-appearance-logo-frame-option"> configured={Boolean(setting.darkLogoResourceId) && !resets["logo-dark"]}
<div className="admin-appearance-logo-frame-copy"> file={files["logo-dark"]}
<strong>禁用 Logo 后面的圆角矩形外框</strong> inputRef={inputRefs["logo-dark"]}
<p id="appearance-logo-frame-help">开启后,工作台和管理后台导航只显示 Logo 本身;Logo 会等比放大到原外框的可用区域,导航占位保持不变。</p> onSelect={selectFile}
</div> onReset={resetAsset}
<div className="admin-appearance-logo-frame-control"> disabled={saving || refreshing || restoring}
<span>{logoFrameEnabled ? "保留外框" : "已禁用外框"}</span> emptyLabel={lightLogoSelected ? "将自动复用浅色模式 Logo" : "未上传时使用项目原始 Logo"}
<Switch />
checked={!logoFrameEnabled} <div className="admin-appearance-logo-frame-option">
<div className="admin-appearance-logo-frame-copy">
<strong>禁用 Logo 后面的圆角矩形外框</strong>
<p id="appearance-logo-frame-help">开启后,工作台和管理后台导航只显示 Logo 本身;Logo 会等比放大到原外框的可用区域,导航占位保持不变。</p>
</div>
<div className="admin-appearance-logo-frame-control">
<span>{logoFrameEnabled ? "保留外框" : "已禁用外框"}</span>
<Switch
checked={!logoFrameEnabled}
disabled={saving || refreshing || restoring}
aria-label="禁用 Logo 后面的圆角矩形外框"
aria-describedby="appearance-logo-frame-help"
onChange={(checked) => setLogoFrameEnabled(!checked)}
/>
</div>
</div>
<div className="admin-appearance-logo-preview-grid" aria-label="深浅模式 Logo 预览">
<LogoThemePreview label="浅色界面" icon={<Sun />} src={previews.logoLight} dark={false} frameEnabled={logoFrameEnabled} />
<LogoThemePreview label="深色界面" icon={<Moon />} src={previews.logoDark} dark frameEnabled={logoFrameEnabled} />
</div>
</div>
</div>
</SettingsSectionCard>
),
},
{
key: "auth",
label: "登录页",
destroyOnHidden: true,
children: (
<SettingsSectionCard
className="admin-appearance-section admin-appearance-auth-section"
icon={<MonitorPlay className="size-4" aria-hidden="true" />}
title="登录页内容与媒体"
description="登录、注册与找回密码共享左侧品牌文案和影片;更换视频会同时取消旧封面,避免品牌串帧。"
status={
<AdminStatusBadge
label={copyCustomized || setting.authVideoResourceId || setting.authVideoPosterResourceId ? "已配置" : "使用原始内容"}
tone={copyCustomized || setting.authVideoResourceId || setting.authVideoPosterResourceId ? "success" : "neutral"}
/>
}
>
<div className="admin-appearance-auth-layout">
<div className="admin-appearance-auth-controls">
<Form className="admin-appearance-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
<Form.Item label="登录页主标题" extra="1–80 个字符,可换行;登录、注册和找回密码页面共用。">
<Input.TextArea value={authHeroTitle} maxLength={80} showCount autoSize={{ minRows: 2, maxRows: 4 }} placeholder="输入登录页主标题" onChange={(event) => setAuthHeroTitle(event.target.value)} />
</Form.Item>
<Form.Item label="登录页说明文案(可选)" extra="最多 160 个字符,可换行;留空时不显示说明。">
<Input.TextArea
value={authHeroDescription}
maxLength={160}
showCount
autoSize={{ minRows: 2, maxRows: 5 }}
placeholder="补充一句品牌介绍或产品定位"
onChange={(event) => setAuthHeroDescription(event.target.value)}
/>
</Form.Item>
</Form>
<div className="admin-appearance-media-list">
<div className="admin-appearance-video-autoplay-option">
<span className="admin-appearance-video-autoplay-copy">
<strong>登录页视频自动播放</strong>
<small>默认开启并静音循环播放;访客启用“减少动态效果”时仍尊重其系统偏好。</small>
</span>
<span className="admin-appearance-video-autoplay-control">
<span>{authVideoAutoplay ? "已开启" : "已关闭"}</span>
<Switch checked={authVideoAutoplay} disabled={saving || refreshing || restoring} aria-label="登录页视频自动播放" onChange={setAuthVideoAutoplay} />
</span>
</div>
<AssetPicker
slot="video"
title="品牌视频"
description="支持 MP4 或 WebM,最多 256MB;服务器运行时上传配额仍会同时生效。"
configured={Boolean(setting.authVideoResourceId) && !resets.video}
file={files.video}
inputRef={inputRefs.video}
onSelect={selectFile}
onReset={resetAsset}
disabled={saving || refreshing || restoring}
/>
<AssetPicker
slot="poster"
title="视频封面(可选)"
description="自定义视频未设置封面时保持中性背景,不显示原品牌封面。"
configured={Boolean(setting.authVideoPosterResourceId) && !resets.poster}
file={files.poster}
inputRef={inputRefs.poster}
onSelect={selectFile}
onReset={resetAsset}
disabled={saving || refreshing || restoring}
/>
</div>
</div>
<div className="admin-appearance-preview" aria-label="登录页实时预览">
<div className="admin-appearance-preview-heading">
<div>
<span>登录页实时预览</span>
<strong>{brandName.trim() || "未命名品牌"}</strong>
</div>
<AdminStatusBadge label={dirty ? "未保存" : "线上版本"} tone={dirty ? "warning" : "success"} />
</div>
<div className="admin-appearance-preview-stage">
<video key={`${previews.video}-${authVideoAutoplay}`} src={previews.video} poster={previews.poster || undefined} muted loop playsInline autoPlay={authVideoAutoplay} preload="metadata" />
<span className="admin-appearance-preview-shade" />
<span className="admin-appearance-preview-brand">
<img src={previews.logoDark} alt="" />
<strong>{brandName.trim() || "未命名品牌"}</strong>
</span>
<span className="admin-appearance-preview-copy">
<small>{(brandSlug.trim() || "brand-studio").replace(/-+/g, " ").toLocaleUpperCase()}</small>
<strong>{normalizeDraftCopy(authHeroTitle) || "请输入登录页主标题"}</strong>
{normalizeDraftCopy(authHeroDescription) ? <span>{normalizeDraftCopy(authHeroDescription)}</span> : null}
</span>
</div>
<p>预览与正式登录页使用同一文案和媒体。正式页面会先解析公开配置,再渲染品牌内容。</p>
</div>
</div>
</SettingsSectionCard>
),
},
{
key: "welcome",
label: "欢迎页",
children: (
<SettingsSectionCard
className="admin-appearance-section"
icon={<Globe2 className="size-4" aria-hidden="true" />}
title="欢迎页"
description="控制访客是否可以访问欢迎页,开关修改后立即保存。"
>
<div className="admin-appearance-section-form">
<WelcomeSetting />
</div>
</SettingsSectionCard>
),
},
{
key: "seo",
label: "SEO 信息",
children: (
<SettingsSectionCard
className="admin-appearance-section"
icon={<Search className="size-4" aria-hidden="true" />}
title="SEO 信息"
description="配置浏览器标题、搜索摘要和关键词;留空时标题与描述会自动跟随当前站点名称。"
status={<AdminStatusBadge label={seoTitle || seoDescription || seoKeywords ? "已自定义" : "自动跟随品牌"} tone={seoTitle || seoDescription || seoKeywords ? "success" : "neutral"} />}
>
<Form className="admin-appearance-form admin-appearance-section-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
<div className="admin-appearance-form-grid">
<Form.Item label="SEO 标题" extra="建议简洁描述站点用途;留空时使用站点名称。">
<Input value={seoTitle} maxLength={70} showCount placeholder={draftBrandName} onChange={(event) => setSeoTitle(event.target.value)} />
</Form.Item>
<Form.Item label="SEO 关键词" extra="以逗号分隔;Google 不使用该标签排名,仍可供其他工具读取。">
<Input value={seoKeywords} maxLength={300} showCount placeholder="AI 影视, AI 短剧, 创作工作台" onChange={(event) => setSeoKeywords(event.target.value)} />
</Form.Item>
</div>
<Form.Item label="SEO 描述" extra="建议用一到两句话准确概括站点,避免重复堆砌关键词;留空时自动生成品牌描述。">
<Input.TextArea
value={seoDescription}
maxLength={200}
showCount
autoSize={{ minRows: 3, maxRows: 5 }}
placeholder={`${draftBrandName},面向 AI 影视与短剧创作的工作台。`}
onChange={(event) => setSeoDescription(event.target.value)}
/>
</Form.Item>
</Form>
</SettingsSectionCard>
),
},
{
key: "footer",
label: "页尾与备案",
children: (
<SettingsSectionCard
className="admin-appearance-section"
icon={<Globe2 className="size-4" aria-hidden="true" />}
title="首页页尾与备案"
description="配置公开登录首页底部的版权和备案信息;备案号启用后固定链接工信部备案管理系统。"
status={<AdminStatusBadge label={icpFilingEnabled ? "展示备案号" : "未展示备案号"} tone={icpFilingEnabled ? "success" : "neutral"} />}
>
<div className="admin-appearance-section-form admin-appearance-footer-settings">
<Form className="admin-appearance-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
<Form.Item label="版权信息" extra="留空时自动使用当前年份和站点名称。">
<Input
prefix={<Copyright className="size-3.5" aria-hidden="true" />}
value={footerCopyright}
maxLength={160}
showCount
placeholder={`© ${new Date().getFullYear()} ${draftBrandName}. All rights reserved.`}
onChange={(event) => setFooterCopyright(event.target.value)}
/>
</Form.Item>
<Form.Item label="备案号" extra="请填写真实备案号,例如“蜀ICP备XXXXXXXX号”;系统不会替你申请或核验备案。">
<Input value={icpFilingNumber} maxLength={64} showCount placeholder="例如:蜀ICP备XXXXXXXX号" onChange={(event) => setIcpFilingNumber(event.target.value)} />
</Form.Item>
</Form>
<div className="admin-appearance-logo-frame-option">
<div className="admin-appearance-logo-frame-copy">
<strong>在首页底部显示备案号</strong>
<p id="appearance-icp-help">启用后,备案号会显示在登录、注册和找回密码页底部,并链接至 https://beian.miit.gov.cn/ 供公众查询。</p>
</div>
<div className="admin-appearance-logo-frame-control">
<span>{icpFilingEnabled ? "已显示" : "未显示"}</span>
<Switch checked={icpFilingEnabled} disabled={saving || refreshing || restoring} aria-label="在首页底部显示备案号" aria-describedby="appearance-icp-help" onChange={setIcpFilingEnabled} />
</div>
</div>
</div>
</SettingsSectionCard>
),
},
{
key: "skins",
label: "皮肤主题",
children: (
<SettingsSectionCard
className="admin-appearance-section"
icon={<Type className="size-4" aria-hidden="true" />}
title="皮肤主题"
description="经典黑白采用黑白底色与紫蓝渐变主按钮;复制后可调整浅色、深色、按钮填充及控件参数,所有修改统一保存。"
status={<AdminStatusBadge label={selectedSkin.name} tone="info" />}
>
<SkinThemeEditor
themes={skinThemes}
selectedID={skinId}
disabled={saving || refreshing || restoring} disabled={saving || refreshing || restoring}
aria-label="禁用 Logo 后面的圆角矩形外框" onSelect={setSkinId}
aria-describedby="appearance-logo-frame-help" onCreate={() => duplicateSkin("classic")}
onChange={(checked) => setLogoFrameEnabled(!checked)} onDuplicate={duplicateSkin}
onDelete={deleteSkin}
onChange={changeSkin}
/> />
</div> </SettingsSectionCard>
</div> ),
<div className="admin-appearance-logo-preview-grid" aria-label="深浅模式 Logo 预览"> },
<LogoThemePreview label="浅色界面" icon={<Sun />} src={previews.logoLight} dark={false} frameEnabled={logoFrameEnabled} /> ]}
<LogoThemePreview label="深色界面" icon={<Moon />} src={previews.logoDark} dark frameEnabled={logoFrameEnabled} /> />
</div>
</div>
</div>
</SettingsSectionCard>
<SettingsSectionCard
className="admin-appearance-section admin-appearance-auth-section"
icon={<MonitorPlay className="size-4" aria-hidden="true" />}
title="2. 设置登录页内容与媒体"
description="登录、注册与找回密码共享左侧品牌文案和影片;更换视频会同时取消旧封面,避免品牌串帧。"
status={
<AdminStatusBadge
label={copyCustomized || setting.authVideoResourceId || setting.authVideoPosterResourceId ? "已配置" : "使用原始内容"}
tone={copyCustomized || setting.authVideoResourceId || setting.authVideoPosterResourceId ? "success" : "neutral"}
/>
}
>
<div className="admin-appearance-auth-layout">
<div className="admin-appearance-auth-controls">
<Form className="admin-appearance-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
<Form.Item label="登录页主标题" extra="1–80 个字符,可换行;登录、注册和找回密码页面共用。">
<Input.TextArea value={authHeroTitle} maxLength={80} showCount autoSize={{ minRows: 2, maxRows: 4 }} placeholder="输入登录页主标题" onChange={(event) => setAuthHeroTitle(event.target.value)} />
</Form.Item>
<Form.Item label="登录页说明文案(可选)" extra="最多 160 个字符,可换行;留空时不显示说明。">
<Input.TextArea
value={authHeroDescription}
maxLength={160}
showCount
autoSize={{ minRows: 2, maxRows: 5 }}
placeholder="补充一句品牌介绍或产品定位"
onChange={(event) => setAuthHeroDescription(event.target.value)}
/>
</Form.Item>
</Form>
<div className="admin-appearance-media-list">
<div className="admin-appearance-video-autoplay-option">
<span className="admin-appearance-video-autoplay-copy">
<strong>登录页视频自动播放</strong>
<small>默认开启并静音循环播放;访客启用“减少动态效果”时仍尊重其系统偏好。</small>
</span>
<span className="admin-appearance-video-autoplay-control">
<span>{authVideoAutoplay ? "已开启" : "已关闭"}</span>
<Switch checked={authVideoAutoplay} disabled={saving || refreshing || restoring} aria-label="登录页视频自动播放" onChange={setAuthVideoAutoplay} />
</span>
</div>
<AssetPicker
slot="video"
title="品牌视频"
description="支持 MP4 或 WebM,最多 256MB;服务器运行时上传配额仍会同时生效。"
configured={Boolean(setting.authVideoResourceId) && !resets.video}
file={files.video}
inputRef={inputRefs.video}
onSelect={selectFile}
onReset={resetAsset}
disabled={saving || refreshing || restoring}
/>
<AssetPicker
slot="poster"
title="视频封面(可选)"
description="自定义视频未设置封面时保持中性背景,不显示原品牌封面。"
configured={Boolean(setting.authVideoPosterResourceId) && !resets.poster}
file={files.poster}
inputRef={inputRefs.poster}
onSelect={selectFile}
onReset={resetAsset}
disabled={saving || refreshing || restoring}
/>
</div>
</div>
<div className="admin-appearance-preview" aria-label="登录页实时预览">
<div className="admin-appearance-preview-heading">
<div>
<span>登录页实时预览</span>
<strong>{brandName.trim() || "未命名品牌"}</strong>
</div>
<AdminStatusBadge label={dirty ? "未保存" : "线上版本"} tone={dirty ? "warning" : "success"} />
</div>
<div className="admin-appearance-preview-stage">
<video key={`${previews.video}-${authVideoAutoplay}`} src={previews.video} poster={previews.poster || undefined} muted loop playsInline autoPlay={authVideoAutoplay} preload="metadata" />
<span className="admin-appearance-preview-shade" />
<span className="admin-appearance-preview-brand">
<img src={previews.logoDark} alt="" />
<strong>{brandName.trim() || "未命名品牌"}</strong>
</span>
<span className="admin-appearance-preview-copy">
<small>{(brandSlug.trim() || "brand-studio").replace(/-+/g, " ").toLocaleUpperCase()}</small>
<strong>{normalizeDraftCopy(authHeroTitle) || "请输入登录页主标题"}</strong>
{normalizeDraftCopy(authHeroDescription) ? <span>{normalizeDraftCopy(authHeroDescription)}</span> : null}
</span>
</div>
<p>预览与正式登录页使用同一文案和媒体。正式页面会先解析公开配置,再渲染品牌内容。</p>
</div>
</div>
</SettingsSectionCard>
<SettingsSectionCard
className="admin-appearance-section"
icon={<Search className="size-4" aria-hidden="true" />}
title="3. SEO 信息"
description="配置浏览器标题、搜索摘要和关键词;留空时标题与描述会自动跟随当前站点名称。"
status={<AdminStatusBadge label={seoTitle || seoDescription || seoKeywords ? "已自定义" : "自动跟随品牌"} tone={seoTitle || seoDescription || seoKeywords ? "success" : "neutral"} />}
>
<Form className="admin-appearance-form admin-appearance-section-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
<div className="admin-appearance-form-grid">
<Form.Item label="SEO 标题" extra="建议简洁描述站点用途;留空时使用站点名称。">
<Input value={seoTitle} maxLength={70} showCount placeholder={draftBrandName} onChange={(event) => setSeoTitle(event.target.value)} />
</Form.Item>
<Form.Item label="SEO 关键词" extra="以逗号分隔;Google 不使用该标签排名,仍可供其他工具读取。">
<Input value={seoKeywords} maxLength={300} showCount placeholder="AI 影视, AI 短剧, 创作工作台" onChange={(event) => setSeoKeywords(event.target.value)} />
</Form.Item>
</div>
<Form.Item label="SEO 描述" extra="建议用一到两句话准确概括站点,避免重复堆砌关键词;留空时自动生成品牌描述。">
<Input.TextArea
value={seoDescription}
maxLength={200}
showCount
autoSize={{ minRows: 3, maxRows: 5 }}
placeholder={`${draftBrandName},面向 AI 影视与短剧创作的工作台。`}
onChange={(event) => setSeoDescription(event.target.value)}
/>
</Form.Item>
</Form>
</SettingsSectionCard>
<SettingsSectionCard
className="admin-appearance-section"
icon={<Globe2 className="size-4" aria-hidden="true" />}
title="4. 首页页尾与备案"
description="配置公开登录首页底部的版权和备案信息;备案号启用后固定链接工信部备案管理系统。"
status={<AdminStatusBadge label={icpFilingEnabled ? "展示备案号" : "未展示备案号"} tone={icpFilingEnabled ? "success" : "neutral"} />}
>
<div className="admin-appearance-section-form admin-appearance-footer-settings">
<Form className="admin-appearance-form" layout="vertical" requiredMark={false} disabled={saving || refreshing || restoring}>
<Form.Item label="版权信息" extra="留空时自动使用当前年份和站点名称。">
<Input
prefix={<Copyright className="size-3.5" aria-hidden="true" />}
value={footerCopyright}
maxLength={160}
showCount
placeholder={`© ${new Date().getFullYear()} ${draftBrandName}. All rights reserved.`}
onChange={(event) => setFooterCopyright(event.target.value)}
/>
</Form.Item>
<Form.Item label="备案号" extra="请填写真实备案号,例如“蜀ICP备XXXXXXXX号”;系统不会替你申请或核验备案。">
<Input value={icpFilingNumber} maxLength={64} showCount placeholder="例如:蜀ICP备XXXXXXXX号" onChange={(event) => setIcpFilingNumber(event.target.value)} />
</Form.Item>
</Form>
<div className="admin-appearance-logo-frame-option">
<div className="admin-appearance-logo-frame-copy">
<strong>在首页底部显示备案号</strong>
<p id="appearance-icp-help">启用后,备案号会显示在登录、注册和找回密码页底部,并链接至 https://beian.miit.gov.cn/ 供公众查询。</p>
</div>
<div className="admin-appearance-logo-frame-control">
<span>{icpFilingEnabled ? "已显示" : "未显示"}</span>
<Switch checked={icpFilingEnabled} disabled={saving || refreshing || restoring} aria-label="在首页底部显示备案号" aria-describedby="appearance-icp-help" onChange={setIcpFilingEnabled} />
</div>
</div>
</div>
</SettingsSectionCard>
<SettingsSectionCard
className="admin-appearance-section"
icon={<Type className="size-4" aria-hidden="true" />}
title="5. 皮肤主题"
description="默认主题保持项目原始样式且不可更改;其他主题可新建、复制、改名、删除,并分别定义浅色、深色、控件样式与交互反馈。"
status={<AdminStatusBadge label={selectedSkin.name} tone="info" />}
>
<SkinThemeEditor
themes={skinThemes}
selectedID={skinId}
disabled={saving || refreshing || restoring}
onSelect={setSkinId}
onCreate={() => duplicateSkin("classic")}
onDuplicate={duplicateSkin}
onDelete={deleteSkin}
onChange={changeSkin}
/>
</SettingsSectionCard>
</div> </div>
)} )}
</AdminPageFrame> </AdminPageFrame>
@@ -831,6 +889,7 @@ function validateSkinDrafts(themes: SkinDefinition[], selectedID: string) {
if (Array.from(theme.description.trim()).length > 100) return "皮肤主题说明不能超过 100 个字符"; if (Array.from(theme.description.trim()).length > 100) return "皮肤主题说明不能超过 100 个字符";
const invalidColor = [...Object.values(theme.tokens.light), ...Object.values(theme.tokens.dark)].some((color) => !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color)); const invalidColor = [...Object.values(theme.tokens.light), ...Object.values(theme.tokens.dark)].some((color) => !/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(color));
if (invalidColor) return `主题“${theme.name}”存在无效颜色,请使用 6 或 8 位十六进制色值`; if (invalidColor) return `主题“${theme.name}”存在无效颜色,请使用 6 或 8 位十六进制色值`;
if (!isSkinButtonFill(theme.tokens.buttons.light) || !isSkinButtonFill(theme.tokens.buttons.dark)) return `主题“${theme.name}”的主按钮参数无效,请检查颜色和渐变角度(0–360°)`;
if (theme.tokens.components.controlHeightSmall > theme.tokens.components.controlHeight || theme.tokens.components.controlHeight > theme.tokens.components.controlHeightLarge) return `主题“${theme.name}”的控件高度顺序无效`; if (theme.tokens.components.controlHeightSmall > theme.tokens.components.controlHeight || theme.tokens.components.controlHeight > theme.tokens.components.controlHeightLarge) return `主题“${theme.name}”的控件高度顺序无效`;
if (theme.tokens.components.motionFast > theme.tokens.components.motionNormal) return `主题“${theme.name}”的快速动效不能慢于常规动效`; if (theme.tokens.components.motionFast > theme.tokens.components.motionNormal) return `主题“${theme.name}”的快速动效不能慢于常规动效`;
} }
@@ -3,7 +3,7 @@ import { IconButton, SegmentedControl, Select, Tooltip } from "@/pages/admin/ui/
import { Check, Copy, LockKeyhole, Moon, Plus, Sparkles, Sun, Trash2 } from "lucide-react"; import { Check, Copy, LockKeyhole, Moon, Plus, Sparkles, Sun, Trash2 } from "lucide-react";
import { useMemo, useState } from "react"; import { useMemo, useState } from "react";
import { SKIN_COLOR_GROUPS, SKIN_COMPONENT_NUMBER_FIELDS, skinSwatches, type SkinComponentTokens, type SkinDefinition, type SkinModeTokens, type SkinThemeMode } from "@/lib/skin-themes"; import { SKIN_COLOR_GROUPS, SKIN_COMPONENT_NUMBER_FIELDS, SKIN_BUTTON_COLOR_FIELDS, getSkinButtonAppearance, skinSwatches, type SkinButtonFill, type SkinComponentTokens, type SkinDefinition, type SkinModeTokens, type SkinThemeMode } from "@/lib/skin-themes";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { AdminStatusBadge } from "@/pages/admin/components/admin-ui"; import { AdminStatusBadge } from "@/pages/admin/components/admin-ui";
@@ -30,6 +30,10 @@ export function SkinThemeEditor({
const selected = useMemo(() => themes.find((theme) => theme.id === selectedID) || themes[0], [selectedID, themes]); const selected = useMemo(() => themes.find((theme) => theme.id === selectedID) || themes[0], [selectedID, themes]);
if (!selected) return null; if (!selected) return null;
const editorDisabled = disabled || selected.locked; const editorDisabled = disabled || selected.locked;
const buttonFill = selected.tokens.buttons[mode];
const updateButton = (patch: Partial<SkinButtonFill>) => onChange({ ...selected, tokens: { ...selected.tokens,
buttons: { ...selected.tokens.buttons, [mode]: { ...buttonFill, ...patch } },
} });
const updateIdentity = (patch: Partial<Pick<SkinDefinition, "name" | "description">>) => onChange({ ...selected, ...patch }); const updateIdentity = (patch: Partial<Pick<SkinDefinition, "name" | "description">>) => onChange({ ...selected, ...patch });
const updateColor = (key: keyof SkinModeTokens, value: string) => const updateColor = (key: keyof SkinModeTokens, value: string) =>
@@ -115,7 +119,7 @@ export function SkinThemeEditor({
{selected.locked ? ( {selected.locked ? (
<div className="admin-skin-locked-note"> <div className="admin-skin-locked-note">
<LockKeyhole className="size-4" aria-hidden="true" /> <LockKeyhole className="size-4" aria-hidden="true" />
<span>经典黑白始终保留项目原始视觉,不能改名、修改或删除。点击“从默认新建”即可复制全部参数后自由调整。</span> <span>经典黑白采用黑白基础配色与紫蓝渐变主按钮,不能改名、修改或删除。点击“从默认新建”即可复制全部参数后自由调整。</span>
</div> </div>
) : null} ) : null}
@@ -164,6 +168,27 @@ export function SkinThemeEditor({
<SkinThemePreview theme={selected} mode={mode} /> <SkinThemePreview theme={selected} mode={mode} />
<details className="admin-skin-token-group" open>
<summary><span>主按钮填充</span><small>{mode === "light" ? "浅色" : "深色"}模式</small></summary>
<div className="admin-skin-component-grid">
<label className="admin-skin-number-field">
<span>填充方式</span>
<Select value={buttonFill.mode} disabled={editorDisabled}
options={[{ label: "纯色(使用主操作颜色)", value: "solid" }, { label: "渐变", value: "gradient" }]}
onChange={(value) => updateButton({ mode: value })} />
</label>
{buttonFill.mode === "gradient" ? <label className="admin-skin-number-field">
<span>渐变角度</span>
<InputNumber aria-label="渐变角度" value={buttonFill.angle} min={0} max={360} precision={0} addonAfter="°" disabled={editorDisabled}
onChange={(value) => { if (typeof value === "number") updateButton({ angle: value }); }} />
</label> : null}
</div>
{buttonFill.mode === "gradient" ? <div className="admin-skin-color-grid">
{SKIN_BUTTON_COLOR_FIELDS.map(({ key, label }) => <ColorTokenField key={key} label={label} help="仅影响主按钮,不改变选中态、开关和危险操作" value={buttonFill[key]} disabled={editorDisabled}
onChange={(value) => updateButton({ [key]: value.trim().toLowerCase() })} />)}
</div> : null}
</details>
<div className="admin-skin-color-groups"> <div className="admin-skin-color-groups">
{SKIN_COLOR_GROUPS.map((group, index) => ( {SKIN_COLOR_GROUPS.map((group, index) => (
<details key={group.key} className="admin-skin-token-group" open={index < 2}> <details key={group.key} className="admin-skin-token-group" open={index < 2}>
@@ -240,6 +265,7 @@ function ColorTokenField({ label, help, value, disabled, onChange }: { label: st
function SkinThemePreview({ theme, mode }: { theme: SkinDefinition; mode: SkinThemeMode }) { function SkinThemePreview({ theme, mode }: { theme: SkinDefinition; mode: SkinThemeMode }) {
const color = theme.tokens[mode]; const color = theme.tokens[mode];
const button = getSkinButtonAppearance(theme, mode);
const component = theme.tokens.components; const component = theme.tokens.components;
const shadow = component.shadowStyle === "none" ? "none" : component.shadowStyle === "strong" ? "0 18px 44px #0000003d" : "0 10px 28px #00000024"; const shadow = component.shadowStyle === "none" ? "none" : component.shadowStyle === "strong" ? "0 18px 44px #0000003d" : "0 10px 28px #00000024";
return ( return (
@@ -264,7 +290,7 @@ function SkinThemePreview({ theme, mode }: { theme: SkinDefinition; mode: SkinTh
> >
输入框状态 输入框状态
</span> </span>
<span className="admin-skin-live-preview-button" style={{ height: component.controlHeight, background: color.primary, color: color.primaryForeground, borderRadius: component.buttonRadius, fontWeight: component.buttonFontWeight }}> <span className="admin-skin-live-preview-button" style={{ height: component.controlHeight, background: button.background, color: button.foreground, borderRadius: component.buttonRadius, fontWeight: component.buttonFontWeight }}>
主要操作 主要操作
</span> </span>
<span className="admin-skin-live-preview-switches" aria-label="开关开启与关闭状态预览"> <span className="admin-skin-live-preview-switches" aria-label="开关开启与关闭状态预览">
+17 -6
View File
@@ -1,18 +1,20 @@
import type { ThemeConfig } from "antd"; import type { ThemeConfig } from "antd";
import { theme as antdTheme } from "antd"; import { theme as antdTheme } from "antd";
import { getSkinAntOverrides } from "@/lib/skin-themes";
/** Isolated Ant Design theme for the admin console. Does not read product skins. */ /** 后台保留独立密度与表面,主操作颜色继承站点皮肤。 */
export function getIsolatedAdminAntTheme(dark: boolean): ThemeConfig { export function getIsolatedAdminAntTheme(dark: boolean, skinID: unknown = "classic"): ThemeConfig {
const skin = getSkinAntOverrides(skinID, dark ? "dark" : "light");
const text = dark ? "#f5f5f5" : "#111111"; const text = dark ? "#f5f5f5" : "#111111";
const textSecondary = dark ? "#c4c4c4" : "#525252"; const textSecondary = dark ? "#c4c4c4" : "#525252";
const canvas = dark ? "#0f0f0f" : "#f5f5f5"; const canvas = dark ? "#0f0f0f" : "#f5f5f5";
const surface = dark ? "#181818" : "#ffffff"; const surface = dark ? "#181818" : "#ffffff";
const surfaceMuted = dark ? "#222222" : "#f6f6f6"; const surfaceMuted = dark ? "#222222" : "#f6f6f6";
const border = dark ? "rgba(245, 245, 245, 0.12)" : "rgba(17, 17, 17, 0.12)"; const border = dark ? "rgba(245, 245, 245, 0.12)" : "rgba(17, 17, 17, 0.12)";
const primary = dark ? "#f5f5f5" : "#111111"; const primary = skin.primary || (dark ? "#f5f5f5" : "#171717");
const primaryFg = dark ? "#0f0f0f" : "#ffffff"; const primaryFg = skin.primaryForeground || (dark ? "#171717" : "#ffffff");
const hover = dark ? "#ffffff" : "#2a2a2a"; const hover = skin.primaryHover || (dark ? "#ffffff" : "#303030");
const active = dark ? "#d4d4d4" : "#404040"; const active = skin.primaryActive || (dark ? "#e5e5e5" : "#404040");
const danger = dark ? "#f87171" : "#dc2626"; const danger = dark ? "#f87171" : "#dc2626";
const success = dark ? "#4ade80" : "#15803d"; const success = dark ? "#4ade80" : "#15803d";
const warning = dark ? "#fbbf24" : "#b45309"; const warning = dark ? "#fbbf24" : "#b45309";
@@ -34,6 +36,7 @@ export function getIsolatedAdminAntTheme(dark: boolean): ThemeConfig {
controlHeightSM: 28, controlHeightSM: 28,
controlHeightLG: 36, controlHeightLG: 36,
lineWidth: 1, lineWidth: 1,
controlOutlineWidth: 0,
colorPrimary: primary, colorPrimary: primary,
colorPrimaryHover: hover, colorPrimaryHover: hover,
colorPrimaryActive: active, colorPrimaryActive: active,
@@ -65,7 +68,11 @@ export function getIsolatedAdminAntTheme(dark: boolean): ThemeConfig {
paddingInline: 12, paddingInline: 12,
paddingInlineSM: 8, paddingInlineSM: 8,
primaryShadow: "none", primaryShadow: "none",
defaultShadow: "none",
dangerShadow: "none", dangerShadow: "none",
colorPrimary: primary,
colorPrimaryHover: hover,
colorPrimaryActive: active,
defaultBg: surface, defaultBg: surface,
defaultColor: text, defaultColor: text,
defaultBorderColor: border, defaultBorderColor: border,
@@ -89,10 +96,14 @@ export function getIsolatedAdminAntTheme(dark: boolean): ThemeConfig {
}, },
Select: { Select: {
borderRadius: 6, borderRadius: 6,
activeOutlineColor: "transparent",
optionPadding: "7px 10px", optionPadding: "7px 10px",
optionSelectedBg: surfaceMuted, optionSelectedBg: surfaceMuted,
optionActiveBg: surfaceMuted, optionActiveBg: surfaceMuted,
}, },
DatePicker: {
activeShadow: "none",
},
Switch: { Switch: {
colorPrimary: switchOn, colorPrimary: switchOn,
colorPrimaryHover: switchOn, colorPrimaryHover: switchOn,
@@ -195,7 +195,6 @@
top: 50%; top: 50%;
left: calc(var(--admin-sidebar-width) - 11px); left: calc(var(--admin-sidebar-width) - 11px);
z-index: 4; z-index: 4;
display: grid;
width: 22px; width: 22px;
height: 36px; height: 36px;
place-items: center; place-items: center;
+3 -3
View File
@@ -45,15 +45,15 @@
.creation-submit-cost svg { width: 14px; height: 14px; } .creation-submit-cost svg { width: 14px; height: 14px; }
@layer utilities { @layer utilities {
.app-product-workspace .creation-home .creation-submit.ant-btn { height: auto; min-height: 40px; padding: 0; border: 0; background: transparent !important; box-shadow: none; border-radius: 999px; opacity: 1; } .app-product-workspace .creation-home .creation-submit.ant-btn { height: auto; min-height: 40px; padding: 0; border: 0; background: transparent !important; box-shadow: none; border-radius: 999px; opacity: 1; }
.app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 8px; width: auto; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--user-action-gradient); color: var(--user-action-foreground); transition: background var(--user-motion), box-shadow var(--user-motion), transform var(--user-motion); } .app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 8px; width: auto; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--button-primary-bg); color: var(--button-primary-fg); transition: background var(--user-motion), box-shadow var(--user-motion), transform var(--user-motion); }
.app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 28%, rgb(255 255 255 / .28) 48%, transparent 68%); transform: translateX(-120%); pointer-events: none; } .app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 28%, rgb(255 255 255 / .28) 48%, transparent 68%); transform: translateX(-120%); pointer-events: none; }
.app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action span { font-size: 13px; font-weight: 600; } .app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action span { font-size: 13px; font-weight: 600; }
.app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action svg { width: 17px; height: 17px; color: currentColor; transition: transform var(--user-motion); } .app-product-workspace .creation-home .creation-submit.ant-btn .creation-submit-action svg { width: 17px; height: 17px; color: currentColor; transition: transform var(--user-motion); }
.app-product-workspace .creation-home .creation-submit.ant-btn:disabled .creation-submit-action { background: var(--user-surface-hover); color: var(--user-ink-muted); } .app-product-workspace .creation-home .creation-submit.ant-btn:disabled .creation-submit-action { background: var(--user-surface-hover); color: var(--user-ink-muted); }
.app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):hover .creation-submit-action { box-shadow: 0 8px 22px color-mix(in srgb, var(--user-accent) 28%, transparent); transform: translateY(-1px); } .app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):hover .creation-submit-action { background: var(--button-primary-hover-bg); transform: translateY(-1px); }
.app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):hover .creation-submit-action::after { animation: creation-submit-sheen 640ms cubic-bezier(.16, 1, .3, 1); } .app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):hover .creation-submit-action::after { animation: creation-submit-sheen 640ms cubic-bezier(.16, 1, .3, 1); }
.app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):hover .creation-submit-action svg { transform: translateY(-1px); } .app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):hover .creation-submit-action svg { transform: translateY(-1px); }
.app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):active .creation-submit-action { transform: scale(.97); } .app-product-workspace .creation-home .creation-submit.ant-btn:not(:disabled):active .creation-submit-action { background: var(--button-primary-active-bg); transform: scale(.97); }
.app-product-workspace .creation-home .creation-chat-composer.is-thread .creation-submit.ant-btn .creation-submit-action { height: 34px; padding: 0 14px; } .app-product-workspace .creation-home .creation-chat-composer.is-thread .creation-submit.ant-btn .creation-submit-action { height: 34px; padding: 0 14px; }
} }
.creation-inspiration-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; } .creation-inspiration-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
+2 -2
View File
@@ -4,7 +4,7 @@ import type { PublicAppearance } from "@/services/api/appearance";
import { applySkinTheme, DEFAULT_CLASSIC_SKIN, normalizeSkinDefinition } from "@/lib/skin-themes"; import { applySkinTheme, DEFAULT_CLASSIC_SKIN, normalizeSkinDefinition } from "@/lib/skin-themes";
export const DEFAULT_PUBLIC_APPEARANCE: PublicAppearance = { export const DEFAULT_PUBLIC_APPEARANCE: PublicAppearance = {
schemaVersion: 7, schemaVersion: 8,
brandName: "影策", brandName: "影策",
brandSlug: "open-ai-canvas", brandSlug: "open-ai-canvas",
authHeroTitle: "让一个故事,\n从文字走向银幕。", authHeroTitle: "让一个故事,\n从文字走向银幕。",
@@ -60,7 +60,7 @@ export function normalizePublicAppearance(value?: Partial<PublicAppearance> | nu
return { return {
...DEFAULT_PUBLIC_APPEARANCE, ...DEFAULT_PUBLIC_APPEARANCE,
...value, ...value,
schemaVersion: 7, schemaVersion: 8,
brandName: resolvedBrandName, brandName: resolvedBrandName,
brandSlug, brandSlug,
authHeroTitle, authHeroTitle,
+38 -55
View File
@@ -1,6 +1,7 @@
@import "tailwindcss"; @import "tailwindcss";
@import "tw-animate-css"; @import "tw-animate-css";
@import "shadcn/tailwind.css"; @import "shadcn/tailwind.css";
@import "./primary-buttons.css";
@source "../../node_modules/streamdown/dist/*.js"; @source "../../node_modules/streamdown/dist/*.js";
@custom-variant dark (&:is(.dark *)); @custom-variant dark (&:is(.dark *));
@@ -2013,7 +2014,7 @@
.canvas-project-sidebar-search:focus-within { .canvas-project-sidebar-search:focus-within {
border-color: color-mix(in srgb, var(--workspace-accent) 42%, transparent) !important; border-color: color-mix(in srgb, var(--workspace-accent) 42%, transparent) !important;
background: var(--background) !important; background: var(--background) !important;
box-shadow: 0 0 0 3px color-mix(in srgb, var(--workspace-accent) 10%, transparent); box-shadow: none;
} }
.canvas-project-sidebar-chapter-scroll { .canvas-project-sidebar-chapter-scroll {
@@ -4366,7 +4367,7 @@ html:not(.dark) .creation-studio-control:hover,
.canvas-library-search:focus-within { .canvas-library-search:focus-within {
background: color-mix(in srgb, var(--foreground) 9%, transparent); background: color-mix(in srgb, var(--foreground) 9%, transparent);
color: var(--workspace-accent); color: var(--workspace-accent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--workspace-accent) 10%, transparent); box-shadow: none;
} }
.canvas-library-search > svg { width: 17px; height: 17px; flex: 0 0 auto; } .canvas-library-search > svg { width: 17px; height: 17px; flex: 0 0 auto; }
@@ -4705,7 +4706,7 @@ html:not(.dark) .creation-studio-control:hover,
.app-user-workspace .library-page .library-toolbar:focus-within { .app-user-workspace .library-page .library-toolbar:focus-within {
border-color: color-mix(in srgb, var(--workspace-accent) 20%, transparent); border-color: color-mix(in srgb, var(--workspace-accent) 20%, transparent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--workspace-accent) 7%, transparent), 0 8px 24px color-mix(in srgb, var(--foreground) 3%, transparent); box-shadow: none;
} }
.app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper, .app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper,
@@ -4715,9 +4716,9 @@ html:not(.dark) .creation-studio-control:hover,
} }
.app-user-workspace .library-page .library-toolbar .ant-btn:focus-visible, .app-user-workspace .library-page .library-toolbar .ant-btn:focus-visible,
.app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper:focus-within, .app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper:focus-visible,
.app-user-workspace .library-page .library-toolbar .ant-select-focused .ant-select-selector, .app-user-workspace .library-page .library-toolbar .ant-select:focus-visible,
.app-user-workspace .library-page .library-toolbar .ant-segmented:focus-within { .app-user-workspace .library-page .library-toolbar .ant-segmented:focus-visible {
outline: 2px solid color-mix(in srgb, var(--workspace-accent) 28%, transparent); outline: 2px solid color-mix(in srgb, var(--workspace-accent) 28%, transparent);
outline-offset: 2px; outline-offset: 2px;
} }
@@ -5599,7 +5600,7 @@ html:not(.dark) .creation-studio-control:hover,
.settings-page :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector) { .settings-page :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector) {
border-color: color-mix(in srgb, var(--workspace-accent) 46%, transparent) !important; border-color: color-mix(in srgb, var(--workspace-accent) 46%, transparent) !important;
box-shadow: 0 0 0 3px color-mix(in srgb, var(--workspace-accent) 10%, transparent) !important; box-shadow: none !important;
} }
.settings-page .ant-btn { .settings-page .ant-btn {
@@ -5648,7 +5649,7 @@ html:not(.dark) .creation-studio-control:hover,
} }
.canvas-library-page .canvas-library-search:focus-within { .canvas-library-page .canvas-library-search:focus-within {
box-shadow: 0 0 0 3px color-mix(in srgb, var(--workspace-accent) 10%, transparent); box-shadow: none;
} }
.canvas-library-page .app-canvas-project-card.is-library { .canvas-library-page .app-canvas-project-card.is-library {
@@ -5786,7 +5787,7 @@ html:not(.dark) .creation-studio-control:hover,
.library-toolbar .ant-input, .library-toolbar .ant-input,
.library-toolbar .ant-select { color: var(--foreground) !important; } .library-toolbar .ant-select { color: var(--foreground) !important; }
.library-toolbar .ant-segmented { border-radius: var(--r-xl); } .library-toolbar .ant-segmented { border-radius: var(--r-xl); }
.library-toolbar .ant-btn { border: 0; background: transparent; color: color-mix(in srgb, var(--foreground) 52%, transparent); } .library-toolbar .ant-btn:not(.ant-btn-primary):not(.ant-btn-dangerous) { border: 0; background: transparent; color: color-mix(in srgb, var(--foreground) 52%, transparent); }
.library-toolbar .ant-btn:hover { background: color-mix(in srgb, var(--foreground) 7%, transparent); color: var(--foreground); } .library-toolbar .ant-btn:hover { background: color-mix(in srgb, var(--foreground) 7%, transparent); color: var(--foreground); }
.library-grid { display: grid; align-items: start; gap: 26px 18px; } .library-grid { display: grid; align-items: start; gap: 26px 18px; }
.library-card { position: relative; min-width: 0; overflow: hidden; cursor: pointer; border: 0; border-radius: var(--r-2xl); background: transparent; color: var(--foreground); transition: transform var(--motion-state) var(--motion-ease-out), background-color var(--motion-state) ease-out; } .library-card { position: relative; min-width: 0; overflow: hidden; cursor: pointer; border: 0; border-radius: var(--r-2xl); background: transparent; color: var(--foreground); transition: transform var(--motion-state) var(--motion-ease-out), background-color var(--motion-state) ease-out; }
@@ -12892,7 +12893,7 @@ html:not(.dark) .creation-history-drawer-root {
.canvas-shortcuts-search:focus-within { .canvas-shortcuts-search:focus-within {
border-color: color-mix(in srgb, var(--ring) 48%, transparent); border-color: color-mix(in srgb, var(--ring) 48%, transparent);
background: color-mix(in srgb, var(--foreground) 7%, transparent); background: color-mix(in srgb, var(--foreground) 7%, transparent);
box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 18%, transparent); box-shadow: none;
} }
.canvas-shortcuts-search > svg { .canvas-shortcuts-search > svg {
width: 15px; width: 15px;
@@ -13200,7 +13201,7 @@ html:not(.dark) .creation-history-drawer-root {
.asset-picker-source-menu-label { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; } .asset-picker-source-menu-label { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 8px; }
.asset-picker-source-menu-label em { color: color-mix(in srgb, currentColor 58%, transparent); font-size: var(--fs-micro); font-style: normal; } .asset-picker-source-menu-label em { color: color-mix(in srgb, currentColor 58%, transparent); font-size: var(--fs-micro); font-style: normal; }
.asset-picker-search { display: flex; height: 38px; min-width: 0; align-items: center; gap: 9px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--foreground) 6%, transparent); padding: 0 12px; transition: background-color var(--motion-state) ease, box-shadow var(--motion-state) ease; } .asset-picker-search { display: flex; height: 38px; min-width: 0; align-items: center; gap: 9px; border-radius: var(--r-sm); background: color-mix(in srgb, var(--foreground) 6%, transparent); padding: 0 12px; transition: background-color var(--motion-state) ease, box-shadow var(--motion-state) ease; }
.asset-picker-search:focus-within { background: color-mix(in srgb, var(--foreground) 8%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 54%, transparent); } .asset-picker-search:focus-within { background: color-mix(in srgb, var(--foreground) 8%, transparent); box-shadow: none; }
.asset-picker-search svg { width: 16px; height: 16px; flex-shrink: 0; color: color-mix(in srgb, var(--foreground) 42%, transparent); } .asset-picker-search svg { width: 16px; height: 16px; flex-shrink: 0; color: color-mix(in srgb, var(--foreground) 42%, transparent); }
.asset-picker-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--foreground); font-size: var(--fs-label); } .asset-picker-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--foreground); font-size: var(--fs-label); }
.asset-picker-count { justify-self: end; color: color-mix(in srgb, var(--foreground) 42%, transparent); font-size: var(--fs-micro); } .asset-picker-count { justify-self: end; color: color-mix(in srgb, var(--foreground) 42%, transparent); font-size: var(--fs-micro); }
@@ -13329,9 +13330,7 @@ html:not(.dark) .creation-history-drawer-root {
.library-modal :where(.ant-input:hover, .ant-input-affix-wrapper:hover, .ant-select-selector:hover) { border-color: color-mix(in srgb, var(--foreground) 26%, transparent) !important; } .library-modal :where(.ant-input:hover, .ant-input-affix-wrapper:hover, .ant-select-selector:hover) { border-color: color-mix(in srgb, var(--foreground) 26%, transparent) !important; }
/* 聚焦态:--workspace-accent 暗色下是 #f5f5f5,直接描边会形成刺眼白圈,降到半透明。 */ /* 聚焦态:--workspace-accent 暗色下是 #f5f5f5,直接描边会形成刺眼白圈,降到半透明。 */
.library-modal :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector) { border-color: var(--control-focus-ring) !important; box-shadow: none !important; } .library-modal :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector) { border-color: var(--control-focus-ring) !important; box-shadow: none !important; }
.library-modal .ant-btn-primary { border: 1px solid var(--btn-outline-border); border-radius: var(--r-md); background: transparent; color: var(--foreground); box-shadow: none; font-weight: 560; } .library-modal .ant-btn-primary { border-radius: var(--r-md); box-shadow: none; font-weight: 560; }
.library-modal .ant-btn-primary:not(:disabled):hover { border-color: var(--btn-outline-hover-border); background: var(--btn-outline-hover-bg); color: var(--foreground); }
.library-modal .ant-btn-primary:not(:disabled):active { background: var(--btn-outline-active-bg); color: var(--foreground); }
.library-modal .ant-btn-default { border-color: var(--btn-outline-border); border-radius: var(--r-md); background: transparent; } .library-modal .ant-btn-default { border-color: var(--btn-outline-border); border-radius: var(--r-md); background: transparent; }
/* 短剧创作:AI 创建入口面板与创建弹窗来源/画风选择 */ /* 短剧创作:AI 创建入口面板与创建弹窗来源/画风选择 */
@@ -13981,12 +13980,12 @@ html:not(.dark) .creation-history-drawer-root {
.library-drawer .ant-drawer-close { width: 34px; height: 34px; margin-inline-end: 6px; border-radius: var(--r-full); color: color-mix(in srgb, var(--foreground) 42%, transparent); } .library-drawer .ant-drawer-close { width: 34px; height: 34px; margin-inline-end: 6px; border-radius: var(--r-full); color: color-mix(in srgb, var(--foreground) 42%, transparent); }
.library-drawer .ant-drawer-close:hover { background: color-mix(in srgb, var(--foreground) 8%, transparent); color: var(--foreground); } .library-drawer .ant-drawer-close:hover { background: color-mix(in srgb, var(--foreground) 8%, transparent); color: var(--foreground); }
.library-drawer .ant-drawer-body { padding: 22px 28px 30px; } .library-drawer .ant-drawer-body { padding: 22px 28px 30px; }
.library-drawer .ant-drawer-extra .ant-btn { border: 1px solid var(--btn-outline-border); border-radius: var(--r-md); background: transparent; color: var(--foreground); font-weight: 560; box-shadow: none; } .library-drawer .ant-drawer-extra .ant-btn:not(.ant-btn-primary):not(.ant-btn-dangerous) { border: 1px solid var(--btn-outline-border); border-radius: var(--r-md); background: transparent; color: var(--foreground); font-weight: 560; box-shadow: none; }
.library-drawer .ant-drawer-extra .ant-btn:not(:disabled):hover { border-color: var(--btn-outline-hover-border); background: var(--btn-outline-hover-bg); color: var(--foreground); } .library-drawer .ant-drawer-extra .ant-btn:not(.ant-btn-primary):not(.ant-btn-dangerous):not(:disabled):hover { border-color: var(--btn-outline-hover-border); background: var(--btn-outline-hover-bg); color: var(--foreground); }
.library-drawer .ant-form-item-label > label { color: color-mix(in srgb, var(--foreground) 68%, transparent); font-size: var(--fs-caption); font-weight: 560; } .library-drawer .ant-form-item-label > label { color: color-mix(in srgb, var(--foreground) 68%, transparent); font-size: var(--fs-caption); font-weight: 560; }
.library-drawer :where(.ant-input, .ant-input-affix-wrapper, .ant-select-selector) { border-color: color-mix(in srgb, var(--foreground) 15%, transparent) !important; border-radius: var(--r-md) !important; background: color-mix(in srgb, var(--foreground) 3%, transparent) !important; box-shadow: none !important; } .library-drawer :where(.ant-input, .ant-input-affix-wrapper, .ant-select-selector) { border-color: color-mix(in srgb, var(--foreground) 15%, transparent) !important; border-radius: var(--r-md) !important; background: color-mix(in srgb, var(--foreground) 3%, transparent) !important; box-shadow: none !important; }
.library-drawer :where(.ant-input:hover, .ant-input-affix-wrapper:hover, .ant-select-selector:hover) { border-color: color-mix(in srgb, var(--foreground) 26%, transparent) !important; } .library-drawer :where(.ant-input:hover, .ant-input-affix-wrapper:hover, .ant-select-selector:hover) { border-color: color-mix(in srgb, var(--foreground) 26%, transparent) !important; }
.library-drawer :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector) { border-color: color-mix(in srgb, var(--workspace-accent) 46%, transparent) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--workspace-accent) 10%, transparent) !important; } .library-drawer :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector) { border-color: color-mix(in srgb, var(--workspace-accent) 46%, transparent) !important; box-shadow: none !important; }
.library-drawer .border-border\/70 { border-color: color-mix(in srgb, var(--foreground) 10%, transparent); } .library-drawer .border-border\/70 { border-color: color-mix(in srgb, var(--foreground) 10%, transparent); }
.library-drawer .asset-drawer-content { border-color: color-mix(in srgb, var(--foreground) 10%, transparent) !important; background: color-mix(in srgb, var(--foreground) 3%, transparent); } .library-drawer .asset-drawer-content { border-color: color-mix(in srgb, var(--foreground) 10%, transparent) !important; background: color-mix(in srgb, var(--foreground) 3%, transparent); }
@@ -14819,9 +14818,7 @@ html:not(.dark) .creation-history-drawer-root {
.asset-archive-section-title { display: block; margin-bottom: 8px; color: color-mix(in srgb, var(--foreground) 40%, transparent); font-size: var(--fs-tiny); font-weight: 560; letter-spacing: .05em; } .asset-archive-section-title { display: block; margin-bottom: 8px; color: color-mix(in srgb, var(--foreground) 40%, transparent); font-size: var(--fs-tiny); font-weight: 560; letter-spacing: .05em; }
.asset-archive-section-body { margin: 0; color: color-mix(in srgb, var(--foreground) 74%, transparent); font-size: var(--fs-label); line-height: 1.7; white-space: pre-wrap; } .asset-archive-section-body { margin: 0; color: color-mix(in srgb, var(--foreground) 74%, transparent); font-size: var(--fs-label); line-height: 1.7; white-space: pre-wrap; }
.asset-archive-actions { display: flex; gap: 8px; flex-wrap: wrap; } .asset-archive-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.library-drawer .ant-btn-primary { border: 1px solid var(--btn-outline-border); background: transparent; color: var(--foreground); box-shadow: none; font-weight: 560; } .library-drawer .ant-btn-primary { box-shadow: none; font-weight: 560; }
.library-drawer .ant-btn-primary:not(:disabled):hover { border-color: var(--btn-outline-hover-border); background: var(--btn-outline-hover-bg); color: var(--foreground); }
.library-drawer .ant-btn-primary:not(:disabled):active { background: var(--btn-outline-active-bg); color: var(--foreground); }
@media (max-width: 680px) { @media (max-width: 680px) {
.assets-empty-cards { grid-template-columns: 1fr; } .assets-empty-cards { grid-template-columns: 1fr; }
@@ -17340,7 +17337,7 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
/* 模型下拉:选中项与当前 hover/focus 项展示说明,其他项保持安静。 */ /* 模型下拉:选中项与当前 hover/focus 项展示说明,其他项保持安静。 */
.canvas-model-picker-option { .canvas-model-picker-option {
transition: min-height 180ms cubic-bezier(.16, 1, .3, 1), background-color 160ms ease, transform 160ms cubic-bezier(.16, 1, .3, 1) !important; transition: background-color 160ms ease !important;
} }
.canvas-model-picker-option.is-previewed:not(:disabled) { .canvas-model-picker-option.is-previewed:not(:disabled) {
@@ -17348,24 +17345,16 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
} }
.canvas-model-picker-description { .canvas-model-picker-description {
max-height: 0; height: 16px;
margin-top: 0 !important; line-height: 16px;
margin-top: 5px !important;
visibility: hidden;
opacity: 0; opacity: 0;
transform: translateY(-2px);
transition: max-height 180ms cubic-bezier(.16, 1, .3, 1), margin-top 180ms cubic-bezier(.16, 1, .3, 1), opacity 130ms ease, transform 180ms cubic-bezier(.16, 1, .3, 1);
} }
.canvas-model-picker-description.is-visible { .canvas-model-picker-description.is-visible {
max-height: 32px; visibility: visible;
margin-top: 5px !important;
opacity: 1; opacity: 1;
transform: translateY(0);
}
.creation-model-picker-menu .canvas-model-picker-option.is-previewed,
.creation-model-picker-menu .canvas-model-picker-option[aria-selected="true"] {
min-height: 58px;
border-radius: 12px;
} }
/* 顶栏积分中心:真实余额、充值、兑换与流水集中在一个消费型弹窗中。 */ /* 顶栏积分中心:真实余额、充值、兑换与流水集中在一个消费型弹窗中。 */
@@ -18178,7 +18167,7 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
.app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper, .app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper,
.app-user-workspace .library-page .library-toolbar .ant-select-selector, .app-user-workspace .library-page .library-toolbar .ant-select-selector,
.app-user-workspace .library-page .library-toolbar .ant-btn { .app-user-workspace .library-page .library-toolbar .ant-btn:not(.ant-btn-primary):not(.ant-btn-dangerous) {
min-height: 38px; min-height: 38px;
border-color: transparent !important; border-color: transparent !important;
border-radius: 10px !important; border-radius: 10px !important;
@@ -18189,9 +18178,9 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
.app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper:hover, .app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper:hover,
.app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper:focus-within, .app-user-workspace .library-page .library-toolbar .ant-input-affix-wrapper:focus-within,
.app-user-workspace .library-page .library-toolbar .ant-select-focused .ant-select-selector { .app-user-workspace .library-page .library-toolbar .ant-select-focused .ant-select-selector {
border-color: rgba(95, 85, 217, .32) !important; border-color: var(--user-border-strong) !important;
background: var(--user-surface) !important; background: var(--user-surface) !important;
box-shadow: 0 0 0 3px rgba(95, 85, 217, .08) !important; box-shadow: none !important;
} }
.app-user-workspace .skills-hero { .app-user-workspace .skills-hero {
@@ -18623,11 +18612,8 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
--user-ink: #1d1d21; --user-ink: #1d1d21;
--user-ink-muted: #686872; --user-ink-muted: #686872;
--user-ink-soft: #85858e; --user-ink-soft: #85858e;
--user-accent: #695df0; --user-accent: var(--workspace-accent);
--user-accent-soft: #eeecff; --user-accent-soft: var(--control-selected-bg);
--user-action-gradient: linear-gradient(115deg, #6554df, #386fbc);
--user-action-gradient-hover: linear-gradient(115deg, #5744cf, #356bbb);
--user-action-foreground: #ffffff;
--user-shadow-card: none; --user-shadow-card: none;
--user-shadow-hover: none; --user-shadow-hover: none;
--user-radius-card: 16px; --user-radius-card: 16px;
@@ -18654,8 +18640,6 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
--user-ink: #f3f3f5; --user-ink: #f3f3f5;
--user-ink-muted: #b4b4bc; --user-ink-muted: #b4b4bc;
--user-ink-soft: #9797a1; --user-ink-soft: #9797a1;
--user-accent: #a69cff;
--user-accent-soft: rgba(126, 113, 255, .16);
--user-shadow-card: none; --user-shadow-card: none;
--user-shadow-hover: none; --user-shadow-hover: none;
} }
@@ -18928,11 +18912,9 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brands { display: grid; gap: 5px; } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brands { display: grid; gap: 5px; }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-subheading { display: flex; align-items: baseline; justify-content: space-between; padding: 3px 5px 8px; color: var(--user-ink); font-size: 12px; font-weight: 650; } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-subheading { display: flex; align-items: baseline; justify-content: space-between; padding: 3px 5px 8px; color: var(--user-ink); font-size: 12px; font-weight: 650; }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-subheading small { color: var(--user-ink-soft); font-size: 10px; font-weight: 500; } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-subheading small { color: var(--user-ink-soft); font-size: 10px; font-weight: 500; }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand { display: flex; min-height: 58px; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 13px; padding: 8px 10px; background: transparent; color: var(--user-ink); text-align: left; transition: background-color 160ms ease, border-color 160ms ease, transform 160ms cubic-bezier(.16,1,.3,1); } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand { display: flex; min-height: 58px; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 13px; padding: 8px 10px; background: transparent; color: var(--user-ink); text-align: left; transition: background-color 160ms ease, border-color 160ms ease; }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand:hover { border-color: var(--user-border); background: var(--user-surface-hover); transform: translateX(2px); } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand:hover { border-color: var(--user-border); background: var(--user-surface-hover); }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 11px; background: var(--user-surface-muted); color: var(--user-ink-muted); } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 11px; background: var(--user-surface-muted); color: var(--user-ink-muted); }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand:nth-child(3n) .canvas-model-picker-brand-icon,
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand:nth-child(4n) .canvas-model-picker-brand-icon { background: var(--user-surface-muted); color: var(--user-ink-muted); }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-copy { display: grid; min-width: 0; flex: 1; gap: 4px; } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-copy { display: grid; min-width: 0; flex: 1; gap: 4px; }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-copy small { color: var(--user-ink-muted); font-size: 10px; } .app-user-workspace .creation-model-picker-menu .canvas-model-picker-brand-copy small { color: var(--user-ink-muted); font-size: 10px; }
@@ -19216,7 +19198,11 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
box-shadow: none !important; box-shadow: none !important;
} }
.app-user-workspace :where(.ant-input:hover, .ant-input-affix-wrapper:hover, .ant-select-selector:hover, .ant-picker:hover) { border-color: var(--user-border-strong) !important; } .app-user-workspace :where(.ant-input:hover, .ant-input-affix-wrapper:hover, .ant-select-selector:hover, .ant-picker:hover) { border-color: var(--user-border-strong) !important; }
.app-user-workspace :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector, .ant-picker-focused) { border-color: var(--user-accent) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--user-accent) 14%, transparent) !important; } .app-user-workspace :where(.ant-input:focus, .ant-input-affix-wrapper-focused, .ant-select-focused .ant-select-selector, .ant-picker-focused) { border-color: var(--user-border-strong) !important; box-shadow: none !important; }
.app-user-workspace .ant-select:has(input:focus-visible) {
outline: var(--focus-ring-width, 2px) solid var(--control-focus-ring);
outline-offset: 2px;
}
.creation-model-picker-surface .creation-model-picker-menu { .creation-model-picker-surface .creation-model-picker-menu {
max-height: none !important; max-height: none !important;
overflow: visible !important; overflow: visible !important;
@@ -19226,12 +19212,9 @@ html:not(.dark) .creation-home .creation-user-message-copy-wrap { box-shadow: 0
.creation-model-picker-surface .canvas-model-picker-brands { display: grid; gap: 5px; } .creation-model-picker-surface .canvas-model-picker-brands { display: grid; gap: 5px; }
.creation-model-picker-surface .canvas-model-picker-subheading { display: flex; align-items: baseline; justify-content: space-between; padding: 3px 5px 8px; color: var(--foreground); font-size: 12px; font-weight: 650; } .creation-model-picker-surface .canvas-model-picker-subheading { display: flex; align-items: baseline; justify-content: space-between; padding: 3px 5px 8px; color: var(--foreground); font-size: 12px; font-weight: 650; }
.creation-model-picker-surface .canvas-model-picker-subheading small { color: color-mix(in srgb, var(--foreground) 52%, transparent); font-size: 10px; font-weight: 500; } .creation-model-picker-surface .canvas-model-picker-subheading small { color: color-mix(in srgb, var(--foreground) 52%, transparent); font-size: 10px; font-weight: 500; }
.creation-model-picker-surface .canvas-model-picker-brand { display: flex; min-height: 58px; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 13px; padding: 8px 10px; background: transparent; color: var(--foreground); text-align: left; transition: background-color 160ms ease, border-color 160ms ease, transform 160ms cubic-bezier(.16,1,.3,1); } .creation-model-picker-surface .canvas-model-picker-brand { display: flex; min-height: 58px; align-items: center; gap: 10px; border: 1px solid transparent; border-radius: 13px; padding: 8px 10px; background: transparent; color: var(--foreground); text-align: left; transition: background-color 160ms ease, border-color 160ms ease; }
.creation-model-picker-surface .canvas-model-picker-brand:hover { border-color: var(--workspace-border); background: var(--workspace-surface-hover); transform: translateX(2px); } .creation-model-picker-surface .canvas-model-picker-brand:hover { border-color: var(--workspace-border); background: var(--workspace-surface-hover); }
.creation-model-picker-surface .canvas-model-picker-brand-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 11px; background: linear-gradient(135deg, color-mix(in srgb, var(--workspace-accent) 20%, var(--workspace-surface-strong)), color-mix(in srgb, var(--workspace-accent) 6%, var(--workspace-surface-strong))); color: var(--workspace-accent); } .creation-model-picker-surface .canvas-model-picker-brand-icon { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 11px; background: var(--workspace-surface-hover); color: var(--foreground); }
.creation-model-picker-surface .canvas-model-picker-brand-icon svg { color: currentColor !important; opacity: 1 !important; }
.creation-model-picker-surface .canvas-model-picker-brand:nth-child(3n) .canvas-model-picker-brand-icon { color: #d57b16; }
.creation-model-picker-surface .canvas-model-picker-brand:nth-child(4n) .canvas-model-picker-brand-icon { color: #25845d; }
.creation-model-picker-surface .canvas-model-picker-brand-copy { display: grid; min-width: 0; flex: 1; gap: 4px; } .creation-model-picker-surface .canvas-model-picker-brand-copy { display: grid; min-width: 0; flex: 1; gap: 4px; }
.creation-model-picker-surface .canvas-model-picker-brand-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; } .creation-model-picker-surface .canvas-model-picker-brand-copy strong { overflow: hidden; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.creation-model-picker-surface .canvas-model-picker-brand-copy small { color: color-mix(in srgb, var(--foreground) 55%, transparent); font-size: 10px; } .creation-model-picker-surface .canvas-model-picker-brand-copy small { color: color-mix(in srgb, var(--foreground) 55%, transparent); font-size: 10px; }
+14
View File
@@ -0,0 +1,14 @@
/* AntD accepts solid color tokens; button fills also support validated gradients. */
:root[data-skin] .ant-btn.ant-btn-primary:where(:not(.ant-btn-dangerous, .ant-btn-color-danger, .ant-btn-background-ghost, :disabled, .ant-btn-disabled)) {
background: var(--button-primary-bg) !important;
border-color: transparent !important;
color: var(--button-primary-fg) !important;
}
:root[data-skin] .ant-btn.ant-btn-primary:where(:not(.ant-btn-dangerous, .ant-btn-color-danger, .ant-btn-background-ghost, :disabled, .ant-btn-disabled)):hover {
background: var(--button-primary-hover-bg) !important;
}
:root[data-skin] .ant-btn.ant-btn-primary:where(:not(.ant-btn-dangerous, .ant-btn-color-danger, .ant-btn-background-ghost, :disabled, .ant-btn-disabled)):active {
background: var(--button-primary-active-bg) !important;
}
+2 -10
View File
@@ -195,13 +195,6 @@
.app-product-workspace .ant-btn-sm { height: 30px; border-radius: 8px; font-size: 12px; } .app-product-workspace .ant-btn-sm { height: 30px; border-radius: 8px; font-size: 12px; }
.app-product-workspace .ant-btn > .ant-btn-icon svg, .app-product-workspace .ant-btn > .ant-btn-icon svg,
.app-product-overlays .ant-btn > .ant-btn-icon svg { width: var(--user-icon-size); height: var(--user-icon-size); stroke-width: 1.7; } .app-product-overlays .ant-btn > .ant-btn-icon svg { width: var(--user-icon-size); height: var(--user-icon-size); stroke-width: 1.7; }
.app-product-workspace .ant-btn-primary:not(.ant-btn-dangerous):not([aria-pressed="true"]),
.app-product-overlays .ant-btn-primary:not(.ant-btn-dangerous):not([aria-pressed="true"]) {
background: var(--user-action-gradient) !important;
color: var(--user-action-foreground) !important;
}
.app-product-workspace .ant-btn-primary:not(.ant-btn-dangerous):not([aria-pressed="true"]):not(:disabled):hover,
.app-product-overlays .ant-btn-primary:not(.ant-btn-dangerous):not([aria-pressed="true"]):not(:disabled):hover { background: var(--user-action-gradient-hover) !important; }
.app-product-workspace .ant-btn:disabled, .app-product-workspace .ant-btn:disabled,
.app-product-overlays .ant-btn:disabled { opacity: .42; } .app-product-overlays .ant-btn:disabled { opacity: .42; }
.app-user-workspace .collection-toolbar .ant-input-affix-wrapper, .app-user-workspace .collection-toolbar .ant-input-affix-wrapper,
@@ -213,7 +206,6 @@
background: var(--user-surface-muted) !important; background: var(--user-surface-muted) !important;
box-shadow: none !important; box-shadow: none !important;
} }
.app-user-workspace .collection-toolbar .ant-input-affix-wrapper:focus-within { outline: 2px solid var(--user-accent-soft); }
.app-user-workspace .collection-toolbar .ant-input-affix-wrapper svg { width: var(--user-icon-size); height: var(--user-icon-size); color: var(--user-ink-soft); } .app-user-workspace .collection-toolbar .ant-input-affix-wrapper svg { width: var(--user-icon-size); height: var(--user-icon-size); color: var(--user-ink-soft); }
} }
@@ -269,7 +261,7 @@
--product-state: 180ms; --product-state: 180ms;
--product-enter: 360ms; --product-enter: 360ms;
--product-content-max: 1480px; --product-content-max: 1480px;
--product-focus-ring: color-mix(in srgb, var(--user-accent) 22%, transparent); --product-focus-ring: var(--control-focus-ring);
--product-accent-blue: #4167bf; --product-accent-blue: #4167bf;
--product-accent-green: #287f65; --product-accent-green: #287f65;
--product-accent-orange: #a46524; --product-accent-orange: #a46524;
@@ -403,7 +395,7 @@
.app-product-workspace .story-launcher-input.ant-input:focus { .app-product-workspace .story-launcher-input.ant-input:focus {
background: var(--user-surface) !important; background: var(--user-surface) !important;
box-shadow: 0 0 0 3px var(--product-focus-ring) !important; box-shadow: none !important;
} }
.app-product-workspace .skills-navigation { .app-product-workspace .skills-navigation {
+41
View File
@@ -0,0 +1,41 @@
import { describe, expect, test } from "bun:test";
import { getAntThemeConfig, getWorkspaceAntThemeConfig } from "../src/lib/app-theme";
import { DEFAULT_CLASSIC_SKIN, duplicateSkinDefinition } from "../src/lib/skin-themes";
import { getIsolatedAdminAntTheme } from "../src/pages/admin/theme/admin-ant-theme";
describe("shared action colors and focus feedback", () => {
for (const dark of [false, true]) {
test(`classic solid tokens remain monochrome beneath the button fill adapter in ${dark ? "dark" : "light"} mode`, () => {
const product = getAntThemeConfig(dark, DEFAULT_CLASSIC_SKIN);
const admin = getIsolatedAdminAntTheme(dark, DEFAULT_CLASSIC_SKIN);
expect(product.components?.Button?.colorPrimary).toBe(dark ? "#f5f5f5" : "#171717");
expect(admin.components?.Button?.colorPrimary).toBe(product.components?.Button?.colorPrimary);
expect(admin.components?.Button?.primaryColor).toBe(product.components?.Button?.primaryColor);
});
test(`custom primary action states reach product and admin in ${dark ? "dark" : "light"} mode`, () => {
const skin = duplicateSkinDefinition(DEFAULT_CLASSIC_SKIN, ["classic"]);
Object.assign(skin.tokens[dark ? "dark" : "light"], {
primary: "#123456", primaryHover: "#234567", primaryActive: "#345678", primaryForeground: "#abcdef",
});
for (const theme of [getAntThemeConfig(dark, skin), getIsolatedAdminAntTheme(dark, skin)]) {
expect(theme.components?.Button).toMatchObject({
colorPrimary: "#123456", colorPrimaryHover: "#234567", colorPrimaryActive: "#345678", primaryColor: "#abcdef",
});
expect(theme.token?.controlOutlineWidth).toBe(0);
expect(theme.components?.Input?.activeShadow).toBe("none");
expect(theme.components?.InputNumber?.activeShadow).toBe("none");
expect(theme.components?.DatePicker?.activeShadow).toBe("none");
expect(theme.components?.Select?.activeOutlineColor).toBe("transparent");
}
});
}
test("workspace density overrides inherit action colors and shadow-free focus", () => {
const theme = getWorkspaceAntThemeConfig();
expect(theme.components?.Button?.colorPrimary).toBeUndefined();
expect(theme.components?.Button?.primaryColor).toBeUndefined();
expect(theme.components?.Input?.activeShadow).toBeUndefined();
});
});
+5 -3
View File
@@ -4,7 +4,7 @@ import { applySkinTheme, DEFAULT_CLASSIC_SKIN, duplicateSkinDefinition, getSkinA
import { normalizePublicAppearance } from "../src/stores/use-appearance-store"; import { normalizePublicAppearance } from "../src/stores/use-appearance-store";
describe("site appearance and editable skin library", () => { describe("site appearance and editable skin library", () => {
test("classic is immutable and keeps the existing runtime token system unchanged", () => { test("classic preserves foundation tokens and applies only primary button fills", () => {
expect(DEFAULT_CLASSIC_SKIN.locked).toBe(true); expect(DEFAULT_CLASSIC_SKIN.locked).toBe(true);
expect(getSkinAntOverrides(DEFAULT_CLASSIC_SKIN, "light")).toEqual({}); expect(getSkinAntOverrides(DEFAULT_CLASSIC_SKIN, "light")).toEqual({});
expect(getSkinAntOverrides(DEFAULT_CLASSIC_SKIN, "dark")).toEqual({}); expect(getSkinAntOverrides(DEFAULT_CLASSIC_SKIN, "dark")).toEqual({});
@@ -22,7 +22,9 @@ describe("site appearance and editable skin library", () => {
} as unknown as Document; } as unknown as Document;
applySkinTheme(DEFAULT_CLASSIC_SKIN, "light", target); applySkinTheme(DEFAULT_CLASSIC_SKIN, "light", target);
expect(removed.length).toBeGreaterThan(60); expect(removed.length).toBeGreaterThan(60);
expect(assigned.size).toBe(0); expect(assigned.size).toBe(4);
expect(assigned.get("--button-primary-bg")).toBe("linear-gradient(115deg, #6554df, #386fbc)");
expect(assigned.has("--background")).toBe(false);
expect(target.documentElement.dataset.skin).toBe("classic"); expect(target.documentElement.dataset.skin).toBe("classic");
}); });
@@ -142,7 +144,7 @@ describe("site appearance and editable skin library", () => {
expect(storeSource).toContain('setMeta(targetDocument, "property", "og:title"'); expect(storeSource).toContain('setMeta(targetDocument, "property", "og:title"');
expect(footerSource).toContain("https://beian.miit.gov.cn/"); expect(footerSource).toContain("https://beian.miit.gov.cn/");
expect(footerSource).toContain('rel="noopener noreferrer"'); expect(footerSource).toContain('rel="noopener noreferrer"');
expect(pageSource).toContain('title="5. 皮肤主题"'); expect(pageSource).toContain('title="皮肤主题"');
expect(editorSource).toContain("从默认新建"); expect(editorSource).toContain("从默认新建");
expect(editorSource).toContain("复制当前"); expect(editorSource).toContain("复制当前");
expect(editorSource).toContain("删除这套主题"); expect(editorSource).toContain("删除这套主题");
+55
View File
@@ -0,0 +1,55 @@
import { describe, expect, test } from "bun:test";
import { applySkinTheme, DEFAULT_CLASSIC_SKIN, duplicateSkinDefinition, getSkinButtonAppearance, isSkinButtonFill, normalizeSkinDefinition } from "../src/lib/skin-themes";
describe("theme primary button fills", () => {
test("classic uses the reference gradient in both modes without changing selection colors", () => {
for (const mode of ["light", "dark"] as const) {
expect(getSkinButtonAppearance(DEFAULT_CLASSIC_SKIN, mode)).toEqual({
background: "linear-gradient(115deg, #6554df, #386fbc)",
hover: "linear-gradient(115deg, #5744cf, #356bbb)",
active: "linear-gradient(115deg, #4938b8, #2c5da5)", foreground: "#ffffff",
});
}
expect(DEFAULT_CLASSIC_SKIN.tokens.light.selected).toBe("#e8e8e8");
});
test("copies have independent fills and switching to solid clears every gradient state", () => {
const skin = duplicateSkinDefinition(DEFAULT_CLASSIC_SKIN, ["classic"]);
skin.tokens.buttons.light.angle = 45;
skin.tokens.buttons.light.start = "#123456";
expect(DEFAULT_CLASSIC_SKIN.tokens.buttons.light.angle).toBe(115);
expect(skin.tokens.buttons.dark.angle).toBe(115);
expect(getSkinButtonAppearance(skin, "light").background).toBe("linear-gradient(45deg, #123456, #386fbc)");
const values = new Map<string, string>();
const doc = { documentElement: { dataset: {}, style: {
removeProperty: (key: string) => values.delete(key), setProperty: (key: string, value: string) => values.set(key, value),
} } } as unknown as Document;
applySkinTheme(skin, "light", doc);
skin.tokens.buttons.light.mode = "solid";
Object.assign(skin.tokens.light, { primary: "#123456", primaryHover: "#234567", primaryActive: "#345678", primaryForeground: "#ffffff" });
applySkinTheme(skin, "light", doc);
expect(values.get("--button-primary-bg")).toBe("#123456");
expect(values.get("--button-primary-hover-bg")).toBe("#234567");
expect(values.get("--button-primary-active-bg")).toBe("#345678");
applySkinTheme(DEFAULT_CLASSIC_SKIN, "dark", doc);
expect(values.has("--background")).toBe(false);
expect(values.get("--button-primary-fg")).toBe("#ffffff");
});
test("legacy custom themes retain solid actions; legacy classic gains its default gradient", () => {
for (const original of [DEFAULT_CLASSIC_SKIN, duplicateSkinDefinition(DEFAULT_CLASSIC_SKIN, ["classic"])]) {
const legacy = JSON.parse(JSON.stringify(original));
delete legacy.tokens.buttons;
expect(normalizeSkinDefinition(legacy).tokens.buttons.light.mode).toBe(original.id === "classic" ? "gradient" : "solid");
}
});
test("invalid modes, angles and CSS injection cannot become runtime gradients", () => {
for (const patch of [{ mode: "url(x)" }, { angle: 361 }, { angle: -1 }, { angle: 1.5 }, { angle: NaN }, { start: "red; background:url(x)" }, { foreground: "white" }]) {
const skin = duplicateSkinDefinition(DEFAULT_CLASSIC_SKIN, ["classic"]);
Object.assign(skin.tokens.buttons.light, patch);
expect(isSkinButtonFill(skin.tokens.buttons.light)).toBe(false);
expect(getSkinButtonAppearance(normalizeSkinDefinition(skin), "light").background).toBe(skin.tokens.light.primary);
}
});
});