fix: 修复前端切换页面时logo跟标题闪烁的问题

This commit is contained in:
shaw
2025-12-19 22:33:36 +08:00
parent 14b155c66b
commit 22414326cc
5 changed files with 103 additions and 44 deletions

View File

@@ -156,7 +156,6 @@ import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useAppStore, useAuthStore } from '@/stores';
import { authAPI } from '@/api';
import LocaleSwitcher from '@/components/common/LocaleSwitcher.vue';
import SubscriptionProgressMini from '@/components/common/SubscriptionProgressMini.vue';
@@ -169,7 +168,7 @@ const authStore = useAuthStore();
const user = computed(() => authStore.user);
const dropdownOpen = ref(false);
const dropdownRef = ref<HTMLElement | null>(null);
const contactInfo = ref('');
const contactInfo = computed(() => appStore.contactInfo);
const userInitials = computed(() => {
if (!user.value) return '';
@@ -230,14 +229,8 @@ function handleClickOutside(event: MouseEvent) {
}
}
onMounted(async () => {
onMounted(() => {
document.addEventListener('click', handleClickOutside);
try {
const settings = await authAPI.getPublicSettings();
contactInfo.value = settings.contact_info || '';
} catch (error) {
console.error('Failed to load contact info:', error);
}
});
onBeforeUnmount(() => {

View File

@@ -131,11 +131,10 @@
</template>
<script setup lang="ts">
import { computed, h, ref, onMounted } from 'vue';
import { computed, h, ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useAppStore, useAuthStore } from '@/stores';
import { getPublicSettings } from '@/api/auth';
import VersionBadge from '@/components/common/VersionBadge.vue';
const { t } = useI18n();
@@ -149,21 +148,10 @@ const mobileOpen = computed(() => appStore.mobileOpen);
const isAdmin = computed(() => authStore.isAdmin);
const isDark = ref(document.documentElement.classList.contains('dark'));
// Site settings
const siteName = ref('Sub2API');
const siteLogo = ref('');
const siteVersion = ref('');
onMounted(async () => {
try {
const settings = await getPublicSettings();
siteName.value = settings.site_name || 'Sub2API';
siteLogo.value = settings.site_logo || '';
siteVersion.value = settings.version || '';
} catch (error) {
console.error('Failed to load public settings:', error);
}
});
// Site settings from appStore (cached, no flicker)
const siteName = computed(() => appStore.siteName);
const siteLogo = computed(() => appStore.siteLogo);
const siteVersion = computed(() => appStore.siteVersion);
// SVG Icon Components
const DashboardIcon = {