站点背景功能优化、页脚上边距调整

This commit is contained in:
2026-09-18 23:11:07 +08:00
parent d784b0ea7a
commit a8efb9ecef
6 changed files with 151 additions and 54 deletions

View File

@@ -6,25 +6,18 @@ import type { CSSProperties } from "react";
export type BgSurface = "site" | "admin";
export type BgMode =
| "cover"
| "contain"
| "repeat"
| "repeat-x"
| "repeat-y"
| "stretch"
| "center";
export type BgMode = "cover" | "contain" | "repeat" | "stretch";
export const DEFAULT_BG_MODE: BgMode = "cover";
/** 预览框按常见 PC 显示器 16:9(1920×1080)等比例缩放 */
export const BG_PREVIEW_ASPECT = "16 / 9";
export const BG_MODE_OPTIONS: { key: BgMode; label: string; hint: string }[] = [
{ key: "cover", label: "覆盖铺满", hint: "裁切以铺满视口" },
{ key: "contain", label: "完整显示", hint: "完整放入,两侧留底色" },
{ key: "stretch", label: "拉伸填满", hint: "变形拉伸至视口" },
{ key: "repeat", label: "平铺", hint: "按原尺寸重复铺满" },
{ key: "repeat-x", label: "横向平铺", hint: "只沿水平方向重复" },
{ key: "repeat-y", label: "纵向平铺", hint: "只沿垂直方向重复" },
{ key: "center", label: "居中原图", hint: "不缩放,居中显示" },
{ key: "cover", label: "填充", hint: "裁切铺满,适合照片" },
{ key: "contain", label: "适应", hint: "整图可见,可能留边" },
{ key: "repeat", label: "平铺", hint: "原尺寸重复,适合纹理" },
{ key: "stretch", label: "拉伸", hint: "拉满屏幕,可能变形" },
];
export interface SiteBgConfig {
@@ -72,14 +65,8 @@ function modeCSS(mode: BgMode): { size: string; repeat: string; position: string
return { size: "contain", repeat: "no-repeat", position: "center" };
case "repeat":
return { size: "auto", repeat: "repeat", position: "0 0" };
case "repeat-x":
return { size: "auto", repeat: "repeat-x", position: "center top" };
case "repeat-y":
return { size: "auto", repeat: "repeat-y", position: "center top" };
case "stretch":
return { size: "100% 100%", repeat: "no-repeat", position: "center" };
case "center":
return { size: "auto", repeat: "no-repeat", position: "center" };
default:
return { size: "cover", repeat: "no-repeat", position: "center" };
}