feat(theme): 接入云海子主题通道(A 类免插件,规范 v1.12 §2/§3)
build / build (push) Successful in 8m45s

This commit is contained in:
2026-10-21 18:06:56 +08:00
parent 05e4e48eaf
commit 3882a63298
+21 -2
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onBeforeMount, onMounted, onUnmounted, watch, computed, inject } from "vue";
import { ref, onBeforeMount, onMounted, onUnmounted, watch, computed, inject, onBeforeUnmount } from "vue";
import { useRoute, useRouter } from "vue-router";
import { Message } from "view-ui-plus";
import { normalizeModList, flattenMenuNodes } from "@/utils/menuRoute";
@@ -20,6 +20,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 || []);
@@ -269,7 +288,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>