feat(boot): use boot-loader as splash with cached tenant logo
Remove the Vue splash overlay and unused duplicate public logos from dist output. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -62,8 +62,29 @@ export function readCachedAppConfig(): AppConfig | null {
|
||||
}
|
||||
}
|
||||
|
||||
function persistBootLogo(config: AppConfig) {
|
||||
try {
|
||||
const nested = (config as {user?: Record<string, unknown>})?.user
|
||||
const root = (config || {}) as Record<string, unknown>
|
||||
const avatar = String(nested?.avatar || root.avatar || '').trim()
|
||||
const version = String(localStorage.getItem(VERSION_STORAGE_KEY) || '').trim()
|
||||
const cachedUrl = localStorage.getItem('BOOT_LOGO_URL') || ''
|
||||
const cachedVer = localStorage.getItem('BOOT_LOGO_VERSION') || ''
|
||||
const cacheFresh = !!(cachedUrl && version && cachedVer && version === cachedVer)
|
||||
if (!cacheFresh && avatar) localStorage.setItem('BOOT_LOGO_URL', avatar)
|
||||
if (version) localStorage.setItem('BOOT_LOGO_VERSION', version)
|
||||
const apply = (window as Window & {__APPLY_BOOT_BRANDING__?: (c: unknown) => void})
|
||||
.__APPLY_BOOT_BRANDING__
|
||||
if (typeof apply === 'function') apply(config)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export function writeCachedAppConfig(config: AppConfig) {
|
||||
try {
|
||||
persistBootLogo(config)
|
||||
|
||||
const payload: CachedConfigPayload = {
|
||||
cached_at: Date.now(),
|
||||
config
|
||||
@@ -206,12 +227,22 @@ export async function clearBrowserRuntimeCaches() {
|
||||
|
||||
function clearLocalStorageExceptToken() {
|
||||
const token = localStorage.getItem(tokenName)
|
||||
let bootLogo = ''
|
||||
let bootLogoVer = ''
|
||||
try {
|
||||
bootLogo = localStorage.getItem('BOOT_LOGO_URL') || ''
|
||||
bootLogoVer = localStorage.getItem('BOOT_LOGO_VERSION') || ''
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
localStorage.clear()
|
||||
|
||||
if (token) {
|
||||
localStorage.setItem(tokenName, token)
|
||||
}
|
||||
if (bootLogo) localStorage.setItem('BOOT_LOGO_URL', bootLogo)
|
||||
if (bootLogoVer) localStorage.setItem('BOOT_LOGO_VERSION', bootLogoVer)
|
||||
}
|
||||
|
||||
export function clearAppStorageExceptToken() {
|
||||
@@ -254,6 +285,11 @@ export async function refreshConfigCacheForVersion(
|
||||
|
||||
writeCachedAppConfig(freshConfig)
|
||||
finishVersionUpdateBeforeReload(normalizedVersion)
|
||||
try {
|
||||
localStorage.setItem('BOOT_LOGO_VERSION', normalizedVersion)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
return freshConfig
|
||||
}
|
||||
@@ -275,6 +311,11 @@ export async function resetAppAndRefreshConfig(
|
||||
|
||||
if (normalizedVersion) {
|
||||
writeStoredAppVersion(normalizedVersion)
|
||||
try {
|
||||
localStorage.setItem('BOOT_LOGO_VERSION', normalizedVersion)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
return freshConfig
|
||||
|
||||
Reference in New Issue
Block a user