From f52ce4136ec7b77eb35ce64006987715da91e189 Mon Sep 17 00:00:00 2001 From: chenxing Date: Fri, 2 Oct 2026 08:45:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(settings):=20=E6=88=91=E7=9A=84=E5=A3=81?= =?UTF-8?q?=E7=BA=B8=20pane=EF=BC=88mywallpaper=EF=BC=8C=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=86=E7=BB=84=EF=BC=8C=E6=89=80=E6=9C=89=E4=BA=BA=E5=8F=AF?= =?UTF-8?q?=E8=A7=81=EF=BC=89=E2=80=94=E2=80=94=E8=83=BD=E5=8A=9B=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E8=87=AA=20Header=20=E8=AE=BE=E7=BD=AE=E5=A3=81?= =?UTF-8?q?=E7=BA=B8=E6=A8=A1=E6=80=81=E6=A1=86=EF=BC=88=E6=A8=A1=E6=80=81?= =?UTF-8?q?=E6=A1=86=E4=BF=9D=E7=95=99=E4=B8=8D=E5=8A=A8=EF=BC=89=EF=BC=9A?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F/=E6=A0=A1=E5=8C=BA/=E6=88=91=E7=9A=84?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=B8=89=E7=BB=84=E7=BD=91=E6=A0=BC=E7=82=B9?= =?UTF-8?q?=E9=80=89=E5=8D=B3=E4=BF=9D=E5=AD=98=EF=BC=88checkWallpaper?= =?UTF-8?q?=EF=BC=89=E3=80=81=E5=BD=93=E5=89=8D=E5=80=BC=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=20store=20=E7=94=A8=E6=88=B7=E8=AE=BE=E7=BD=AE=E3=80=81?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=B5=B0=20/api/wallpaperUpload=E3=80=81?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=A3=81=E7=BA=B8=E5=8F=AF=E5=88=A0=EF=BC=9B?= =?UTF-8?q?=E9=9B=B6=E6=96=B0=E6=8E=A5=E5=8F=A3=EF=BC=88=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Settings.vue | 134 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/src/views/Settings.vue b/src/views/Settings.vue index dd80893..b3bb459 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -203,6 +203,75 @@ + +
+
+

我的壁纸

+

选择桌面背景壁纸:系统与校区壁纸直接选用,也可上传个人壁纸;点击缩略图即保存生效。

+
+
+

系统壁纸 平台内置

+
+
暂无壁纸
+
+ ✓ +
+
+
+
+

校区壁纸 本校上传

+
+
暂无壁纸
+
+ ✓ +
+
+
+ +
+

我的上传 仅自己可见

+
+
+ × + ✓ +
+
+
+
+

上传壁纸

+
+ 选择图片 +
+ + + + 建议 1920×1080 以上,≤ 5MB;上传后进入「我的上传」可选 +
+
+
+
+
@@ -480,7 +549,7 @@ const isAdmin = computed(() => !!store.getIsAdmin); /** 普通用户不可用的管理 pane(导航隐藏;URL 直达渲染 noperm 黄条,不白屏不报错) */ const ADMIN_PANES = ["logo", "wallpaper", "sidebar", "sys", "statset", "backend", "schooltheme"]; -const ALL_PANES = ["profile", "password", "avatar", "mytheme", "schooltheme", "logo", "wallpaper", "sidebar", "sys", "statset", "backend", "noperm"]; +const ALL_PANES = ["profile", "password", "avatar", "mytheme", "mywallpaper", "schooltheme", "logo", "wallpaper", "sidebar", "sys", "statset", "backend", "noperm"]; const curPane = ref("profile"); @@ -522,6 +591,8 @@ const NAV_ACCOUNT: NavItem[] = [ ]; const NAV_THEME: NavItem[] = [ { key: "mytheme", name: "我的主题", icon: svgWrap('') }, + // 我的壁纸(2026-10-02 任务A):普通用户壁纸自选 pane,能力复制自 Header 设置壁纸模态框(模态框保留不动) + { key: "mywallpaper", name: "我的壁纸", icon: svgWrap('') }, { key: "schooltheme", name: "本校默认", icon: svgWrap(''), adminOnly: true }, ]; const NAV_APPEARANCE: NavItem[] = [ @@ -744,6 +815,67 @@ async function onApplyWallpaper() { } } +/* ===== mywallpaper:个人壁纸 pane(2026-10-02 任务A)===== + * 能力复制自 Header「设置壁纸」模态框(模态框保留不动):列表 getUserWallpaperList(type 0=系统/1=校区/2=个人)、 + * 点选即保存 checkWallpaper(与模态框 onClickWallpaper 同语义)、上传走 /api/wallpaperUpload(普通用户落 type=2 个人壁纸)、 + * 自己上传的可删(deleteWallById,isEdit 标记与模态框一致);选中态回显 store 用户设置 wallpaperUrl。 */ +const myWallpaperList = ref([]); +const myWallGroups = computed(() => { + const list = myWallpaperList.value || []; + return { + sys: list.filter(x => x.type === 0), + sch: list.filter(x => x.type === 1), + mine: list.filter(x => x.type === 2), + }; +}); +/** 当前生效壁纸(回显选中态,Header 模态框 getIsWallpaper 同源) */ +const myWallSelected = computed(() => store.getCurWallPaperUrl || ""); + +async function loadMyWallpaperList() { + try { + const list = (await UserSettingApi.getUserWallpaperList(store.getCurSchId)) || []; + // 与 Header 模态框同序:type 升序(系统→校区→个人),同 type 按 id 升序 + list.sort((a: any, b: any) => (a.type === b.type ? a.id - b.id : a.type - b.type)); + myWallpaperList.value = list; + } catch (e) { + myWallpaperList.value = []; + } +} + +/** 点选即保存(无保存按钮,与 Header 模态框行为一致);成功后同步 store 即时生效 */ +async function onPickMyWallpaper(w: any) { + if (myWallSelected.value === w.url) return; + await UserSettingApi.checkWallpaper(store.getCurSchId, w.url); + const userSetting = store.curUserSettingInfo; + if (!!userSetting) { + userSetting.wallpaperUrl = w.url; + store.setCurUserSettingsInfo(userSetting); + } + Message.success("壁纸已应用"); +} + +async function onDeleteMyWallpaper(w: any) { + await MyConfirm({ + title: "删除", + msg: "确定删除该壁纸吗?", + info: "删除后无法恢复!", + async onOk() { + await UserSettingApi.deleteWallById(w.id); + await loadMyWallpaperList(); + }, + }); +} + +function onMyWallpaperUploaded() { + Message.success("上传成功"); + loadMyWallpaperList(); +} + +// 打开我的壁纸 pane 时拉一次可选列表(所有人) +watch(curPane, pane => { + if (pane === "mywallpaper") loadMyWallpaperList(); +}); + // 首次切到 logo / wallpaper pane 时懒加载管理列表 watch(curPane, pane => { if ((pane === "logo" || pane === "wallpaper") && isAdmin.value && logoManageList.value.length === 0 && wallpaperManageList.value.length === 0) {