外观设置改为半屏布局;背景图仅保存后生效,并支持媒体库选用。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
// ===== 板块(客户端,供角色授权弹窗勾选) =====
|
||||
|
||||
Reference in New Issue
Block a user