| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <template>
- <ConfigProvider :locale="zhCN">
- <router-view />
- </ConfigProvider>
- </template>
- <script setup>
- import { onMounted, nextTick } from 'vue'
- import { ConfigProvider } from 'ant-design-vue'
- import zhCN from 'ant-design-vue/es/locale/zh_CN'
- import useSettingsStore from '@/store/modules/settings'
- import { handleThemeStyle } from '@/utils/theme'
- onMounted(() => {
- nextTick(() => {
- const settingsStore = useSettingsStore()
-
- // 初始化主题样式
- handleThemeStyle(settingsStore.theme)
-
- // 初始化暗黑模式
- if (settingsStore.isDark) {
- document.documentElement.classList.add('dark')
- } else {
- document.documentElement.classList.remove('dark')
- }
-
- // 检查是否为分享页面
- const isSharePage = window.location.pathname.startsWith('/share/')
-
- // 移除 Loading 动画并显示 App
- const loader = document.querySelector('.app-loading')
- const app = document.getElementById('app')
-
- if (loader) {
- if (isSharePage) {
- // 分享页面立即移除加载动画,不延迟
- loader.style.opacity = '0'
- loader.style.visibility = 'hidden'
-
- // 停止星空动画,释放性能
- if (window.stopLoadingAnimation) {
- window.stopLoadingAnimation()
- }
-
- // 立即移除节点
- setTimeout(() => {
- loader.remove()
- }, 100)
-
- if (app) {
- app.classList.add('app-loaded')
- }
- } else {
- // 其他页面保持原有逻辑:强制延迟 1.5s 再开始淡出,让用户看清星空
- setTimeout(() => {
- loader.style.opacity = '0'
- loader.style.visibility = 'hidden'
-
- // 停止星空动画,释放性能
- if (window.stopLoadingAnimation) {
- window.stopLoadingAnimation()
- }
-
- // 动画结束后移除节点
- setTimeout(() => {
- loader.remove()
- }, 1200) // 对应 CSS 中的 1.2s transition
-
- if (app) {
- app.classList.add('app-loaded')
- }
- }, 1500)
- }
- } else {
- // 如果没有 loader(比如热更新),直接显示 app
- if (app) {
- app.classList.add('app-loaded')
- }
- }
- })
- })
- </script>
|