feat: 全球地图、暗黑模式适配、用户总数修复

This commit is contained in:
2026-05-03 05:07:39 +08:00
parent c653ed071d
commit 34844870ac
8 changed files with 419 additions and 148 deletions
+46 -1
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, onMounted } from 'vue'
import { computed, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import AdminSidebar from '@/components/admin-sidebar/index.vue'
@@ -71,9 +71,49 @@ const breadcrumbs = computed(() => {
return crumbs
})
function getAssetUrl(path: string) {
if (!path)
return ''
if (path.startsWith('http'))
return path
return `${import.meta.env.VITE_API_BASE || 'http://localhost:8080'}${path}`
}
function updateFavicon(favicon: string) {
if (!favicon)
return
const link: HTMLLinkElement = document.querySelector('link[rel*=\'icon\']') || document.createElement('link')
link.type = 'image/x-icon'
link.rel = 'shortcut icon'
link.href = getAssetUrl(favicon)
document.getElementsByTagName('head')[0].appendChild(link)
}
function updateSiteName(name: string) {
if (name)
document.title = name
}
function applySettings(settings: { site_name?: string, site_logo?: string, site_favicon?: string }) {
if (settings.site_favicon)
updateFavicon(settings.site_favicon)
if (settings.site_name)
updateSiteName(settings.site_name)
}
function handleSettingsChange(event: CustomEvent) {
applySettings(event.detail)
}
async function loadSystemSettings() {
const storedSettings = localStorage.getItem('systemSettings')
if (storedSettings) {
try {
applySettings(JSON.parse(storedSettings))
}
catch (e) {
console.error('Failed to parse systemSettings', e)
}
return
}
@@ -96,6 +136,11 @@ async function loadSystemSettings() {
onMounted(() => {
loadSystemSettings()
window.addEventListener('system-settings-changed', handleSettingsChange as EventListener)
})
onUnmounted(() => {
window.removeEventListener('system-settings-changed', handleSettingsChange as EventListener)
})
</script>