head 인라인 스크립트로 data-theme 선적용, 로고 캐시 스플래시 추가. 메인 커버는 업로드 후 저장 버튼에서 이미지·텍스트 일괄 반영. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
1.8 KiB
JavaScript
69 lines
1.8 KiB
JavaScript
import {
|
|
SITE_BRAND_LOGO_TEXT_KEY,
|
|
SITE_BRAND_LOGO_URL_KEY,
|
|
SITE_THEME_STORAGE_KEY,
|
|
resolveSiteTheme
|
|
} from '../lib/site-theme-init.js'
|
|
|
|
const siteSettingsFetchKey = 'site-settings-public'
|
|
|
|
/**
|
|
* 공개 사이트 설정에서 스플래시용 브랜드를 localStorage에 캐시한다.
|
|
* @param {Object|null|undefined} settings - 사이트 설정
|
|
* @returns {void}
|
|
*/
|
|
const cacheSiteBrandForSplash = (settings) => {
|
|
if (!settings?.logoUrl && !settings?.logoText) {
|
|
return
|
|
}
|
|
|
|
if (settings.logoUrl) {
|
|
localStorage.setItem(SITE_BRAND_LOGO_URL_KEY, settings.logoUrl)
|
|
}
|
|
|
|
if (settings.logoText) {
|
|
localStorage.setItem(SITE_BRAND_LOGO_TEXT_KEY, settings.logoText)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 스플래시를 숨기고 본문을 표시한다.
|
|
* @returns {void}
|
|
*/
|
|
const finishSiteSplash = () => {
|
|
document.documentElement.classList.add('site-app-ready')
|
|
}
|
|
|
|
/**
|
|
* 인증·관리자 경로는 스플래시 없이 즉시 본문을 연다.
|
|
* @returns {boolean}
|
|
*/
|
|
const shouldSkipSiteSplash = () => /^\/(admin|signin|signup|forgot-password)(\/|$)/.test(window.location.pathname)
|
|
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
const theme = useState('site-theme-mode', () => 'light')
|
|
|
|
const savedTheme = localStorage.getItem(SITE_THEME_STORAGE_KEY)
|
|
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
theme.value = resolveSiteTheme(savedTheme, prefersDark)
|
|
|
|
if (shouldSkipSiteSplash()) {
|
|
finishSiteSplash()
|
|
return
|
|
}
|
|
|
|
const { data: siteSettings } = useNuxtData(siteSettingsFetchKey)
|
|
|
|
watch(siteSettings, (settings) => {
|
|
cacheSiteBrandForSplash(settings)
|
|
}, { immediate: true })
|
|
|
|
nuxtApp.hook('app:mounted', () => {
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
finishSiteSplash()
|
|
})
|
|
})
|
|
})
|
|
})
|