diff --git a/src/shared/components/Header.vue b/src/shared/components/Header.vue index d9fc2c1..d7df508 100644 --- a/src/shared/components/Header.vue +++ b/src/shared/components/Header.vue @@ -4,7 +4,6 @@ import { RouterLink } from "vue-router" import { isDesktop, isMobile } from "shared/composables/breakpoints" import { toggleLogin, toggleSignup } from "shared/composables/modal" import { screenMode, switchScreenMode } from "shared/composables/switchScreen" -import { avatar } from "utils/constants" import { logout } from "../api" import { useConfigStore } from "../store/config" import { useUserStore } from "../store/user" @@ -16,6 +15,36 @@ const configStore = useConfigStore() const route = useRoute() const router = useRouter() +const names = [ + "man-with-chinese-cap-1", + "cat-face", + "china", + "chicken", + "eyes", + "elephant", + "hear-no-evil-monkey", + "panda-face", + "penguin-1", + "rooster", + "star-struck-1", + "tomato", + "rocket", + "sparkles", + "money-bag", + "ghost", + "game-dice", + "ewe-1", + "artist-palette", + "baby-bottle", +] + +function getRandomAvatar() { + const name = names[Math.floor(Math.random() * names.length)] + return `streamline-emojis:${name}` +} + +const avatar = ref(getRandomAvatar()) + const envVersion = computed(() => { if (import.meta.env.PUBLIC_ENV === "test") { return "测试版" diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 0ce3073..097d011 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -228,35 +228,6 @@ export enum ScreenMode { problem = "仅题目", } -const AVATARS = [ - "streamline-emojis:man-with-chinese-cap-1", - "streamline-emojis:cat-face", - "streamline-emojis:china", - "streamline-emojis:chicken", - "streamline-emojis:eyes", - "streamline-emojis:elephant", - "streamline-emojis:hear-no-evil-monkey", - "streamline-emojis:panda-face", - "streamline-emojis:penguin-1", - "streamline-emojis:rooster", - "streamline-emojis:star-struck-1", - "streamline-emojis:tomato", - "streamline-emojis:rocket", - "streamline-emojis:sparkles", - "streamline-emojis:money-bag", - "streamline-emojis:ghost", - "streamline-emojis:game-dice", - "streamline-emojis:ewe-1", - "streamline-emojis:artist-palette", - "streamline-emojis:baby-bottle", -] - -export const avatar = ref(AVATARS[Math.floor(Math.random() * AVATARS.length)]) - -export function getRandomAvatar() { - avatar.value = AVATARS[Math.floor(Math.random() * AVATARS.length)] -} - export enum ChartType { Rank, Activity,