样式修改
This commit is contained in:
1 parent
96947d7636
commit
f3511e5cd0
15 files changed
+933
-84
No files matched your search
@@ -18,6 +18,7 @@ import logging
|
||||
import threading
|
||||
from pathlib import Path
|
||||
from typing import Literal
|
||||
from uuid import uuid4
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
@@ -38,6 +39,60 @@ class PromptPrefixSettings(BaseModel):
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
class AppearanceRouteParam(BaseModel):
|
||||
"""Runtime query-param descriptor for top-bar shortcut buttons.
|
||||
|
||||
The frontend resolves login params from ``userInfo`` and theme params from
|
||||
the current UI theme, matching the light-app center's link builder.
|
||||
"""
|
||||
|
||||
key: str = Field(default="", description="Query parameter name appended to the shortcut URL")
|
||||
paramType: Literal["login", "theme"] = Field(default="login", description="Where the parameter value comes from")
|
||||
source: str | None = Field(default=None, description="login param source field in userInfo, or 'other'")
|
||||
customValue: str | None = Field(default=None, description="Literal value when source is 'other'")
|
||||
themeValue: str | None = Field(default=None, description="Theme-value mapping string, e.g. red=red;dark-blue=dark")
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
def _default_shortcut_route_params() -> list[AppearanceRouteParam]:
|
||||
return [
|
||||
AppearanceRouteParam(
|
||||
key="access_token",
|
||||
paramType="login",
|
||||
source="access_token",
|
||||
customValue="",
|
||||
themeValue="red=red;blue=blue;dark-blue=dark-blue",
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class CompactShortcutButton(BaseModel):
|
||||
"""Configurable shortcut shown in top bars before the theme switcher."""
|
||||
|
||||
id: str = Field(default_factory=lambda: uuid4().hex, description="Stable row id for editing")
|
||||
label: str = Field(default="快捷入口", description="Button text shown next to the icon")
|
||||
url: str = Field(default="", description="Target URL opened in a new tab")
|
||||
route_params: list[AppearanceRouteParam] = Field(
|
||||
default_factory=_default_shortcut_route_params,
|
||||
description="Query parameters resolved at launch time and appended to url",
|
||||
)
|
||||
enabled: bool = Field(default=True, description="Whether this shortcut is rendered")
|
||||
sort_order: int = Field(default=0, description="Display order in top bars")
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
def _default_compact_shortcut_buttons() -> list[CompactShortcutButton]:
|
||||
return [
|
||||
CompactShortcutButton(
|
||||
id="default-compact-shortcut",
|
||||
label="快捷入口",
|
||||
url="",
|
||||
enabled=True,
|
||||
sort_order=0,
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class AppearanceSettings(BaseModel):
|
||||
"""System-wide appearance defaults that any *new* user inherits.
|
||||
|
||||
@@ -63,6 +118,10 @@ class AppearanceSettings(BaseModel):
|
||||
default="full",
|
||||
description="Default interface layout for users who haven't picked their own — full (sidebar + header) / compact (hidden)",
|
||||
)
|
||||
compact_shortcut_buttons: list[CompactShortcutButton] = Field(
|
||||
default_factory=_default_compact_shortcut_buttons,
|
||||
description="Shortcut buttons rendered before the theme switcher in top bars",
|
||||
)
|
||||
model_config = ConfigDict(extra="ignore")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user