This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onBeforeMount, watch, computed, inject } from "vue";
|
||||
import { ref, onBeforeMount, watch, computed, inject, onMounted, onBeforeUnmount } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { Message } from "view-ui-plus";
|
||||
import { normalizeModList, flattenMenuNodes } from "@/utils/menuRoute";
|
||||
@@ -19,6 +19,25 @@ const ssoHost = computed(() => props.layoutData?.ssoHost || "");
|
||||
const appName = computed(() => props.layoutData?.appName || "家校活动");
|
||||
const appList = computed(() => props.layoutData?.appList || []);
|
||||
const userInfo = computed(() => props.layoutData?.userInfo || { name: "管理员", avatar: "" });
|
||||
/* 头像:平台键 yh-avatar(yh-theme-init 外观补齐段写入)优先,本仓 userInfo 兜底;
|
||||
监听平台事件重读,不轮询、不手写清理(清键归 init,规范 §3) */
|
||||
const yhAvatar = ref("");
|
||||
const readYhAvatar = () => {
|
||||
let v: string | null = null;
|
||||
try {
|
||||
v = localStorage.getItem("yh-avatar");
|
||||
} catch {
|
||||
v = null;
|
||||
}
|
||||
yhAvatar.value = v || "";
|
||||
};
|
||||
onMounted(() => {
|
||||
readYhAvatar();
|
||||
document.addEventListener("yh-appearance-updated", readYhAvatar);
|
||||
});
|
||||
onBeforeUnmount(() => document.removeEventListener("yh-appearance-updated", readYhAvatar));
|
||||
const avatarUrl = computed(() => yhAvatar.value || userInfo.value?.avatar || "");
|
||||
|
||||
const isAlone = computed(() => props.layoutData?.isAlone ?? false);
|
||||
const modList = computed(() => props.layoutData?.modList || []);
|
||||
|
||||
@@ -240,7 +259,7 @@ function linkHomePage() {
|
||||
<h4 class="fl align-middle">{{ appName }}</h4>
|
||||
<div class="school-bg"></div>
|
||||
<div class="header-aside fr">
|
||||
<img :src="userInfo.avatar" class="fl align-middle" @click="linkUserInfo" />
|
||||
<img :src="avatarUrl" class="fl align-middle" @click="linkUserInfo" />
|
||||
<a class="name fl align-middle text-ellipsis" href="javascript:void(0);" @click="linkUserInfo">
|
||||
{{ userInfo.name }}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user