diff --git a/src/App.vue b/src/App.vue index c1e4a9d..7f4dc32 100644 --- a/src/App.vue +++ b/src/App.vue @@ -62,6 +62,7 @@ mittBus.on("openBschIframePage", async (params: IframePageParmas) => { const [r1, r2] = await Promise.all([p1, p2]); store.$state.userInfo = userinfo; loadSchThemeDefault(); + loadSchAvatarDefault(); if (r1.length == 0) { store.$state.userRoleList = [ { @@ -103,6 +104,21 @@ function loadSchThemeDefault() { .catch(() => undefined); } +/** 拉学校默认头像样式写键(默认头像轮 2026-09-30;与 loadSchThemeDefault 同构:失败/404/空 → 不写、不报错、不阻塞登录流程) */ +function loadSchAvatarDefault() { + BaseApi.getSchAvatarStyle() + .then((res: any) => { + if (res && res.avatarStyle) { + try { + localStorage.setItem("yh-avatar-sch-default", res.avatarStyle); + } catch (e) { + /* 隐私模式写失败静默 */ + } + } + }) + .catch(() => undefined); +} + /**切换角色 */ async function switchRole() { await loadUserMenuBarList(); diff --git a/src/api/BaseApi.ts b/src/api/BaseApi.ts index c8bf3ba..dd382f9 100644 --- a/src/api/BaseApi.ts +++ b/src/api/BaseApi.ts @@ -213,6 +213,29 @@ class Base extends Abstract { return this.postRequest({ url }); } + // ===== 学校默认头像样式(默认头像轮 2026-09-30;后端契约见 SchSettingsController#schAvatarStyle)===== + + /** + * 读本校默认头像样式(已登录可读):{avatarStyle: "text"|"silhouette"|null}—— + * null 表示未配置(前端"不写键、不报错"),登录后调一次写 localStorage["yh-avatar-sch-default"] + */ + getSchAvatarStyle() { + const url = path + "/schAvatarStyle"; + return this.getRequest<{ avatarStyle: string | null; schId: number }>({ url }); + } + + /** 保存本校默认头像样式(仅学校管理员):avatarStyle = "text" | "silhouette" */ + saveSchAvatarStyle(avatarStyle: string) { + const url = path + "/saveSchAvatarStyle"; + return this.postRequest({ url, params: { avatarStyle } }); + } + + /** 清空本校默认头像样式(仅学校管理员;置空后读侧返回 null) */ + clearSchAvatarStyle() { + const url = path + "/clearSchAvatarStyle"; + return this.postRequest({ url }); + } + savUserRole(info: any) { const url = path + "/user/savUserRole"; return this.postRequest({ url, data: info as any }); diff --git a/src/components/AppHeader.vue b/src/components/AppHeader.vue index 9094304..59c5c94 100644 --- a/src/components/AppHeader.vue +++ b/src/components/AppHeader.vue @@ -8,7 +8,7 @@

{{ appName }}

- + Hi {{ userInfo.name }} @@ -27,6 +27,7 @@ import { useDefaultStore } from "@/store"; import { computed } from "vue"; import SvgIcon from "@/components/SvgIcon.vue"; +import UserAvatar from "@/components/UserAvatar.vue"; import mittBus from "@/utils/mitt"; import { StateEnum } from "@/types"; import { useRouter } from "vue-router"; diff --git a/src/components/UserInfoModal.vue b/src/components/UserInfoModal.vue index 7613116..2ce0226 100644 --- a/src/components/UserInfoModal.vue +++ b/src/components/UserInfoModal.vue @@ -15,7 +15,7 @@ :headers="uploadHeaders" >
- +
更换头像
@@ -67,8 +67,8 @@