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:
+4
-61
@@ -2,7 +2,6 @@
|
||||
<div class="desktopConfig w-full right-0 left-0">
|
||||
<transition mode="out-in" name="fade">
|
||||
<AConfigProvider
|
||||
v-if="!showSplash"
|
||||
:theme="{
|
||||
token: {
|
||||
colorPrimary: colors.primary,
|
||||
@@ -19,34 +18,10 @@
|
||||
</transition>
|
||||
</router-view>
|
||||
</AConfigProvider>
|
||||
|
||||
<div v-else class="app-splash-screen flex items-center justify-center bg-white">
|
||||
<div class="app-splash-screen__gradient app-splash-screen__gradient--top h-1/3 flex">
|
||||
<img :src="img_topGradiant" alt="" class="absolute z-10 w-full h-full object-cover" />
|
||||
<img :src="img_pattern" alt="" class="absolute w-full h-full object-none" />
|
||||
</div>
|
||||
<div class="app-splash-screen__gradient app-splash-screen__gradient--bottom h-1/3">
|
||||
<img
|
||||
:src="img_bottomGradiant"
|
||||
alt=""
|
||||
class="absolute z-10 w-full h-full object-cover"
|
||||
/>
|
||||
<img :src="img_pattern" alt="" class="absolute w-full h-full object-none" />
|
||||
</div>
|
||||
<div class="splash_appear_fade_in relative z-10">
|
||||
<img :src="logoFull" class="h-[20vh] max-h-[180px] w-auto object-contain" alt="" />
|
||||
</div>
|
||||
<div class="app-splash-screen__version home_appear_fade_in_up">
|
||||
<div class="text-center text-xs">نسخه: {{ displayVersion }}</div>
|
||||
</div>
|
||||
<div class="app-splash-screen__spinner">
|
||||
<a-spin :indicator="indicator" size="small" />
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<div
|
||||
v-if="showSupportButton && !showSplash && route.name !== 'support' && !hideAppChrome"
|
||||
v-if="showSupportButton && route.name !== 'support' && !hideAppChrome"
|
||||
id="support-button"
|
||||
ref="supportButtonEl"
|
||||
class="draggable-support-button"
|
||||
@@ -87,7 +62,7 @@
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="!showSplash && !hideAppChrome && !isDesktop"
|
||||
v-if="!hideAppChrome && !isDesktop"
|
||||
class="app-credit-footer app-credit-footer--mobile"
|
||||
:class="{ 'app-credit-footer--login': isLoginRoute }"
|
||||
>
|
||||
@@ -95,7 +70,7 @@
|
||||
<AppCreditLink variant="mobile" />
|
||||
</div>
|
||||
<div
|
||||
v-if="!showSplash && !hideAppChrome && showDesktopFloatingCredit"
|
||||
v-if="!hideAppChrome && showDesktopFloatingCredit"
|
||||
class="app-credit-footer app-credit-footer--desktop-float"
|
||||
:class="{ 'app-credit-footer--login': isLoginRoute }"
|
||||
>
|
||||
@@ -110,15 +85,10 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { colors } from './themeConfig'
|
||||
import pkg from '../package.json'
|
||||
import { getDisplayAppVersion } from '@/config/config-cache'
|
||||
import { computed, defineAsyncComponent, h, onMounted, ref, watch } from 'vue'
|
||||
import { computed, defineAsyncComponent, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { showBrowserNotification } from '@/utils/browserNotification'
|
||||
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
|
||||
import img_pattern from '@/views/login/assets/img/pattern.svg'
|
||||
import { LoadingOutlined } from '@ant-design/icons-vue'
|
||||
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
|
||||
import { useSupportMessenger } from '@/composables/useSupportMessenger'
|
||||
import { loadSupportMessengerFromSettings } from '@/utils/supportMessenger'
|
||||
@@ -137,29 +107,13 @@ import { useSettingsStore } from '@/store/settingsStore'
|
||||
import { connectChatIfExists, disconnectChat, isSettingFlagOn, unreadSupportCount, useChatService } from '@/utils/chat'
|
||||
import { getToken } from '@/utils'
|
||||
|
||||
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
|
||||
import logoFull from '@/assets/img/logo_full_.png'
|
||||
|
||||
const VersionUpdateModal = defineAsyncComponent(
|
||||
() => import('@/modules/version/VersionUpdateModal.vue')
|
||||
)
|
||||
|
||||
const indicator = h(LoadingOutlined, {
|
||||
style: {
|
||||
fontSize: '24px'
|
||||
},
|
||||
spin: true
|
||||
})
|
||||
const displayVersion = getDisplayAppVersion(pkg.version)
|
||||
const showSplash = ref(!isTvBoardPath())
|
||||
const route = useRoute()
|
||||
const hideAppChrome = computed(() => route.meta.hideChrome === true || route.name === 'tvMonitor')
|
||||
|
||||
function isTvBoardPath() {
|
||||
const path = window.location.pathname.replace(/\/+$/, '')
|
||||
return path.endsWith('/tv') || path.endsWith('/monitor')
|
||||
}
|
||||
|
||||
useApplyDesktopLayoutClass()
|
||||
|
||||
const isDesktop = useDesktopBreakpoint()
|
||||
@@ -224,17 +178,6 @@ function handleSupportPointerUp(event: PointerEvent) {
|
||||
|
||||
onMounted(async () => {
|
||||
await loadSupportMessengerFromSettings()
|
||||
if (hideAppChrome.value) {
|
||||
showSplash.value = false
|
||||
return
|
||||
}
|
||||
setTimeout(() => {
|
||||
showSplash.value = false
|
||||
}, 2000)
|
||||
})
|
||||
|
||||
watch(hideAppChrome, (hidden) => {
|
||||
if (hidden) showSplash.value = false
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -55,6 +55,13 @@ let appConfig: RawAppConfig | null = null
|
||||
export function setAppConfig(config: RawAppConfig) {
|
||||
appConfig = normalizeAppConfig(config || {})
|
||||
window.__APP_CONFIG__ = appConfig
|
||||
try {
|
||||
const apply = (window as Window & {__APPLY_BOOT_BRANDING__?: (c: unknown) => void})
|
||||
.__APPLY_BOOT_BRANDING__
|
||||
if (typeof apply === 'function') apply(appConfig)
|
||||
} catch {
|
||||
/* boot DOM ممکن است هنوز نباشد */
|
||||
}
|
||||
}
|
||||
|
||||
export function getRawAppConfig() {
|
||||
|
||||
@@ -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