This commit is contained in:
zxr
2026-09-15 23:37:59 +08:00
parent 781d1af337
commit 6395911954
168 changed files with 11207 additions and 6738 deletions

View File

@@ -0,0 +1,33 @@
import { computed, readonly, ref } from 'vue'
import { fetchPublicSystemBranding, type SystemBranding } from '@/api/ops/systemSettings'
const branding = ref<SystemBranding | null>(null)
let pending: Promise<SystemBranding> | null = null
export async function loadSystemBranding(force = false): Promise<SystemBranding> {
if (!force && branding.value) return branding.value
if (!force && pending) return pending
pending = fetchPublicSystemBranding()
.then((response: any) => {
if (response.code !== 0 || !response.details?.system_name) {
throw new Error(response.message || '系统品牌配置无效')
}
branding.value = response.details as SystemBranding
document.title = branding.value.system_name
return branding.value
})
.finally(() => {
pending = null
})
return pending
}
export function useSystemBranding() {
return {
branding: readonly(branding),
systemName: computed(() => branding.value?.system_name || ''),
logoURL: computed(() => branding.value?.logo?.url || ''),
loginBackgroundURLs: computed(() => (branding.value?.login_backgrounds || []).map((item) => item.url)),
loadSystemBranding,
}
}