外观设置改为半屏布局;背景图仅保存后生效,并支持媒体库选用。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-20 10:51:20 +08:00
parent e598782279
commit 68e90ff6ff
7 changed files with 953 additions and 481 deletions

View File

@@ -2268,10 +2268,11 @@ export async function apiBrandFromMedia(slot: BrandSlot, attachmentId: number):
}
/** 上传站点背景并立即绑定前台或后台 */
/** 超管上传站点背景图:只落盘返回 URL,需再 PUT settings 才绑定并广播 */
export async function apiUploadSiteBackground(
surface: "site" | "admin",
file: File
): Promise<PublicSettings> {
): Promise<string> {
const form = new FormData();
form.append("surface", surface);
form.append("file", file, file.name || "background.jpg");
@@ -2282,7 +2283,26 @@ export async function apiUploadSiteBackground(
});
const data = await res.json().catch(() => ({}));
if (!res.ok) throw new Error(data.error || "上传背景图失败");
return normalizePublicSettings(data as Partial<PublicSettings>);
const url = String(data.url || "");
if (!url) throw new Error("上传背景图失败");
return url;
}
/** 把本人媒体库图片复制进 backgrounds,不写入站点设置 */
export async function apiBackgroundFromMedia(
surface: "site" | "admin",
attachmentId: number
): Promise<string> {
const res = await fetchWithRefresh("/api/admin/upload/background/from-media", {
method: "POST",
headers: clientHeaders({ "Content-Type": "application/json" }),
body: JSON.stringify({ attachment_id: attachmentId, surface }),
});
const data = await res.json().catch(() => ({}));
if (!res.ok) throw new Error(data.error || "选用媒体库图片失败");
const url = String(data.url || "");
if (!url) throw new Error("选用媒体库图片失败");
return url;
}
// ===== 板块(客户端,供角色授权弹窗勾选) =====

View File

@@ -50,6 +50,11 @@ export function normalizeBgMode(raw: string | null | undefined): BgMode {
return MODE_SET.has(m) ? m : DEFAULT_BG_MODE;
}
/** 媒体库条目是否可作为背景图(JPEG / PNG / WebP) */
export function mediaURLFitsBackground(url: string): boolean {
return /\.(jpe?g|png|webp)(\?|$)/i.test(url);
}
export function bgConfigFromSettings(s: SiteBgInput | null | undefined): SiteBgConfig {
return {
bg_site_url: normalizeBgURL(s?.bg_site_url),