新增 lightblue 主题与外观设置联动,圆桌 Step3 看板/report 统一配色;工作区侧边栏、输入框与轻应用 iframe 主题参数同步更新。 Co-authored-by: Cursor <cursoragent@cursor.com>
282 lines
7.8 KiB
TypeScript
282 lines
7.8 KiB
TypeScript
import { apiFetch } from "@/core/api";
|
|
import { getBackendBaseURL } from "@/core/config";
|
|
|
|
export interface PromptPrefixSettings {
|
|
enabled: boolean;
|
|
switch_label: string;
|
|
prompt_prefix: string;
|
|
}
|
|
|
|
export interface PromptPrefixUpdate {
|
|
enabled?: boolean;
|
|
switch_label?: string;
|
|
prompt_prefix?: string;
|
|
}
|
|
|
|
export async function loadPromptPrefixSettings(): Promise<PromptPrefixSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/prompt-prefix`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to load prompt prefix settings: ${response.status}`);
|
|
}
|
|
return (await response.json()) as PromptPrefixSettings;
|
|
}
|
|
|
|
export async function updatePromptPrefixSettings(
|
|
body: PromptPrefixUpdate,
|
|
): Promise<PromptPrefixSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/prompt-prefix`,
|
|
{
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
},
|
|
);
|
|
if (!response.ok) {
|
|
const detail = await response
|
|
.json()
|
|
.catch(() => ({ detail: "Failed to update prompt prefix" }));
|
|
throw new Error(detail.detail ?? "Failed to update prompt prefix");
|
|
}
|
|
return (await response.json()) as PromptPrefixSettings;
|
|
}
|
|
|
|
export interface PrivateSquareStatus {
|
|
enabled: boolean;
|
|
password_set: boolean;
|
|
}
|
|
|
|
export interface PrivateSquareUpdate {
|
|
enabled?: boolean;
|
|
password?: string;
|
|
}
|
|
|
|
export interface CitationDisplaySettings {
|
|
cleanup_words: string[];
|
|
}
|
|
|
|
export interface CitationDisplayUpdate {
|
|
cleanup_words?: string[];
|
|
}
|
|
|
|
export interface LeaderboardSettings {
|
|
exclude_user_ids: string[];
|
|
include_scheduled: boolean;
|
|
include_admins: boolean;
|
|
include_failed: boolean;
|
|
cleanup_system_questions: boolean;
|
|
}
|
|
|
|
export interface LeaderboardSettingsUpdate {
|
|
exclude_user_ids?: string[];
|
|
include_scheduled?: boolean;
|
|
include_admins?: boolean;
|
|
include_failed?: boolean;
|
|
cleanup_system_questions?: boolean;
|
|
}
|
|
|
|
export async function loadPrivateSquareStatus(): Promise<PrivateSquareStatus> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/private-square`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(
|
|
`Failed to load private square settings: ${response.status}`,
|
|
);
|
|
}
|
|
return (await response.json()) as PrivateSquareStatus;
|
|
}
|
|
|
|
export interface PublishSquare {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
}
|
|
|
|
export interface PublishSquaresSettings {
|
|
squares: PublishSquare[];
|
|
default_square_id: string;
|
|
}
|
|
|
|
export interface PublishSquaresUpdate {
|
|
squares?: PublishSquare[];
|
|
default_square_id?: string;
|
|
}
|
|
|
|
export async function loadPublishSquares(): Promise<PublishSquaresSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/publish-squares`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to load publish squares: ${response.status}`);
|
|
}
|
|
return (await response.json()) as PublishSquaresSettings;
|
|
}
|
|
|
|
export async function updatePublishSquares(
|
|
body: PublishSquaresUpdate,
|
|
): Promise<PublishSquaresSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/publish-squares`,
|
|
{
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
},
|
|
);
|
|
if (!response.ok) {
|
|
const detail = await response
|
|
.json()
|
|
.catch(() => ({ detail: "Failed to update publish squares" }));
|
|
throw new Error(detail.detail ?? "Failed to update publish squares");
|
|
}
|
|
return (await response.json()) as PublishSquaresSettings;
|
|
}
|
|
|
|
export type ThemeMode = "light" | "dark" | "lightblue";
|
|
export type ViewMode = "card" | "list";
|
|
|
|
export interface AppearanceSettings {
|
|
default_theme: ThemeMode;
|
|
default_skill_view: ViewMode;
|
|
default_agent_view: ViewMode;
|
|
}
|
|
|
|
export interface AppearanceUpdate {
|
|
default_theme?: ThemeMode;
|
|
default_skill_view?: ViewMode;
|
|
default_agent_view?: ViewMode;
|
|
}
|
|
|
|
export async function loadAppearanceSettings(): Promise<AppearanceSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/appearance`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(
|
|
`Failed to load appearance settings: ${response.status}`,
|
|
);
|
|
}
|
|
return (await response.json()) as AppearanceSettings;
|
|
}
|
|
|
|
export async function updateAppearanceSettings(
|
|
body: AppearanceUpdate,
|
|
): Promise<AppearanceSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/appearance`,
|
|
{
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
},
|
|
);
|
|
if (!response.ok) {
|
|
const detail = await response
|
|
.json()
|
|
.catch(() => ({ detail: "Failed to update appearance" }));
|
|
throw new Error(detail.detail ?? "Failed to update appearance");
|
|
}
|
|
return (await response.json()) as AppearanceSettings;
|
|
}
|
|
|
|
export async function loadCitationDisplaySettings(): Promise<CitationDisplaySettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/citation-display`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(
|
|
`Failed to load citation display settings: ${response.status}`,
|
|
);
|
|
}
|
|
return (await response.json()) as CitationDisplaySettings;
|
|
}
|
|
|
|
export async function loadLeaderboardSettings(): Promise<LeaderboardSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/leaderboard`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to load leaderboard settings: ${response.status}`);
|
|
}
|
|
return (await response.json()) as LeaderboardSettings;
|
|
}
|
|
|
|
export async function updateLeaderboardSettings(
|
|
body: LeaderboardSettingsUpdate,
|
|
): Promise<LeaderboardSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/leaderboard`,
|
|
{
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
},
|
|
);
|
|
if (!response.ok) {
|
|
const detail = await response
|
|
.json()
|
|
.catch(() => ({ detail: "Failed to update leaderboard settings" }));
|
|
throw new Error(detail.detail ?? "Failed to update leaderboard settings");
|
|
}
|
|
return (await response.json()) as LeaderboardSettings;
|
|
}
|
|
|
|
export async function updateCitationDisplaySettings(
|
|
body: CitationDisplayUpdate,
|
|
): Promise<CitationDisplaySettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/citation-display`,
|
|
{
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
},
|
|
);
|
|
if (!response.ok) {
|
|
const detail = await response
|
|
.json()
|
|
.catch(() => ({ detail: "Failed to update citation display" }));
|
|
throw new Error(detail.detail ?? "Failed to update citation display");
|
|
}
|
|
return (await response.json()) as CitationDisplaySettings;
|
|
}
|
|
|
|
export interface LogSystemSettings {
|
|
enabled: boolean;
|
|
url: string;
|
|
label: string;
|
|
}
|
|
|
|
export async function loadLogSystemSettings(): Promise<LogSystemSettings> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/log-system`,
|
|
);
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to load log system settings: ${response.status}`);
|
|
}
|
|
return (await response.json()) as LogSystemSettings;
|
|
}
|
|
|
|
export async function updatePrivateSquareSettings(
|
|
body: PrivateSquareUpdate,
|
|
): Promise<PrivateSquareStatus> {
|
|
const response = await apiFetch(
|
|
`${getBackendBaseURL()}/api/system-settings/private-square`,
|
|
{
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
},
|
|
);
|
|
if (!response.ok) {
|
|
const detail = await response
|
|
.json()
|
|
.catch(() => ({ detail: "Failed to update private square" }));
|
|
throw new Error(detail.detail ?? "Failed to update private square");
|
|
}
|
|
return (await response.json()) as PrivateSquareStatus;
|
|
}
|