refactor(app): 优化应用加载性能
- 将桌面端模态框组件提取为独立模块 desktop-modal-host.tsx - 将移动端模态框组件提取为独立模块 mobile-modal-host.tsx - 使用懒加载和 Suspense 包装入口页面和模态框组件 - 将 React Query Devtools 改为按需加载 - 配置 Vite 构建优化,设置第三方库分包策略 - 替换 lottie-web 为轻量级版本以减少包体积
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 99 KiB After Width: | Height: | Size: 9.2 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 938 B |
|
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 200 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 521 KiB After Width: | Height: | Size: 100 KiB |
|
Before Width: | Height: | Size: 388 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 301 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 404 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 593 KiB After Width: | Height: | Size: 140 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 267 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 301 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 802 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 546 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1006 B |
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 268 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 262 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 446 KiB After Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 240 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.1 KiB |
18
src/main.tsx
@@ -1,7 +1,6 @@
|
|||||||
import { QueryClientProvider } from '@tanstack/react-query'
|
import { QueryClientProvider } from '@tanstack/react-query'
|
||||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
||||||
import { RouterProvider } from '@tanstack/react-router'
|
import { RouterProvider } from '@tanstack/react-router'
|
||||||
import { StrictMode } from 'react'
|
import { lazy, StrictMode, Suspense } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import { getCurrentUserProfile, refreshAuthSession } from '@/api'
|
import { getCurrentUserProfile, refreshAuthSession } from '@/api'
|
||||||
import { AppBootResourceGate } from '@/components/app-boot-resource-gate'
|
import { AppBootResourceGate } from '@/components/app-boot-resource-gate'
|
||||||
@@ -23,6 +22,15 @@ const rootElement = document.getElementById(APP_ROOT_ELEMENT_ID)
|
|||||||
const shouldShowQueryDevtools =
|
const shouldShowQueryDevtools =
|
||||||
import.meta.env.VITE_APP_ENV === 'development' &&
|
import.meta.env.VITE_APP_ENV === 'development' &&
|
||||||
import.meta.env.VITE_ENABLE_QUERY_DEVTOOLS === 'true'
|
import.meta.env.VITE_ENABLE_QUERY_DEVTOOLS === 'true'
|
||||||
|
const QueryDevtools = shouldShowQueryDevtools
|
||||||
|
? lazy(async () => {
|
||||||
|
const { ReactQueryDevtools } = await import(
|
||||||
|
'@tanstack/react-query-devtools'
|
||||||
|
)
|
||||||
|
|
||||||
|
return { default: ReactQueryDevtools }
|
||||||
|
})
|
||||||
|
: null
|
||||||
|
|
||||||
if (!rootElement) {
|
if (!rootElement) {
|
||||||
throw new Error('Root element not found')
|
throw new Error('Root element not found')
|
||||||
@@ -46,8 +54,10 @@ createRoot(rootElement).render(
|
|||||||
<GlobalAudioController />
|
<GlobalAudioController />
|
||||||
<RouterProvider router={router} />
|
<RouterProvider router={router} />
|
||||||
<AppNotificationAlert />
|
<AppNotificationAlert />
|
||||||
{shouldShowQueryDevtools && (
|
{QueryDevtools && (
|
||||||
<ReactQueryDevtools initialIsOpen={false} />
|
<Suspense fallback={null}>
|
||||||
|
<QueryDevtools initialIsOpen={false} />
|
||||||
|
</Suspense>
|
||||||
)}
|
)}
|
||||||
</AppBootResourceGate>
|
</AppBootResourceGate>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
|
|||||||
31
src/main/desktop-modal-host.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { EntryNoticeGateModal } from '@/features/game/components/shared/entry-notice-gate-modal'
|
||||||
|
import DesktopAutoSettingModal from '@/modal/desktop/desktop-auto-setting-modal.tsx'
|
||||||
|
import DesktopLanguageModal from '@/modal/desktop/desktop-language-modal.tsx'
|
||||||
|
import DesktopLoginModal from '@/modal/desktop/desktop-login-modal.tsx'
|
||||||
|
import DesktopNoticeModal from '@/modal/desktop/desktop-notice-modal.tsx'
|
||||||
|
import { DesktopPeriodHistoryDrawer } from '@/modal/desktop/desktop-period-history-drawer.tsx'
|
||||||
|
import DesktopProceduresModal from '@/modal/desktop/desktop-procedures-modal.tsx'
|
||||||
|
import DesktopRegisterModal from '@/modal/desktop/desktop-register-modal.tsx'
|
||||||
|
import DesktopRulesModal from '@/modal/desktop/desktop-rules-modal.tsx'
|
||||||
|
import DesktopSupportModal from '@/modal/desktop/desktop-support-modal.tsx'
|
||||||
|
import DesktopUserInfoModal from '@/modal/desktop/desktop-userInfo-modal.tsx'
|
||||||
|
import DesktopWithdrawTopupModal from '@/modal/desktop/desktop-withdraw-topup-modal.tsx'
|
||||||
|
|
||||||
|
export default function DesktopModalHost() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<DesktopLoginModal />
|
||||||
|
<DesktopRegisterModal />
|
||||||
|
<DesktopLanguageModal />
|
||||||
|
<DesktopRulesModal />
|
||||||
|
<DesktopUserInfoModal />
|
||||||
|
<DesktopNoticeModal />
|
||||||
|
<DesktopAutoSettingModal />
|
||||||
|
<DesktopProceduresModal />
|
||||||
|
<DesktopWithdrawTopupModal />
|
||||||
|
<DesktopSupportModal />
|
||||||
|
<EntryNoticeGateModal />
|
||||||
|
<DesktopPeriodHistoryDrawer />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,102 +1,25 @@
|
|||||||
import { startTransition, useEffect, useState } from 'react'
|
import { lazy, Suspense, startTransition, useEffect, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { getGameLobbyInit } from '@/api'
|
import { getGameLobbyInit } from '@/api'
|
||||||
import { MOBILE_LAYOUT_BREAKPOINT_PX } from '@/constants'
|
import { MOBILE_LAYOUT_BREAKPOINT_PX } from '@/constants'
|
||||||
import {
|
|
||||||
EntryNoticeGateModal,
|
|
||||||
MobileEntryNoticeGateModal,
|
|
||||||
} from '@/features/game/components/shared/entry-notice-gate-modal'
|
|
||||||
import { useGameRealtimeSync } from '@/hooks/use-game-realtime-sync.ts'
|
import { useGameRealtimeSync } from '@/hooks/use-game-realtime-sync.ts'
|
||||||
import { useDocumentMetadata } from '@/lib/head/document-metadata.ts'
|
import { useDocumentMetadata } from '@/lib/head/document-metadata.ts'
|
||||||
import { notify } from '@/lib/notify.ts'
|
import { notify } from '@/lib/notify.ts'
|
||||||
import { MobileEntry } from '@/main/mobile-entry.tsx'
|
|
||||||
import { PcEntry } from '@/main/pc-entry.tsx'
|
|
||||||
import DesktopAutoSettingModal from '@/modal/desktop/desktop-auto-setting-modal.tsx'
|
|
||||||
import DesktopLanguageModal from '@/modal/desktop/desktop-language-modal.tsx'
|
|
||||||
import DesktopLoginModal from '@/modal/desktop/desktop-login-modal.tsx'
|
|
||||||
import DesktopNoticeModal from '@/modal/desktop/desktop-notice-modal.tsx'
|
|
||||||
import { DesktopPeriodHistoryDrawer } from '@/modal/desktop/desktop-period-history-drawer.tsx'
|
|
||||||
import DesktopProceduresModal from '@/modal/desktop/desktop-procedures-modal.tsx'
|
|
||||||
import DesktopRegisterModal from '@/modal/desktop/desktop-register-modal.tsx'
|
|
||||||
import DesktopRulesModal from '@/modal/desktop/desktop-rules-modal.tsx'
|
|
||||||
import DesktopSupportModal from '@/modal/desktop/desktop-support-modal.tsx'
|
|
||||||
import DesktopUserInfoModal from '@/modal/desktop/desktop-userInfo-modal.tsx'
|
|
||||||
import DesktopWithdrawTopupModal from '@/modal/desktop/desktop-withdraw-topup-modal.tsx'
|
|
||||||
import MobileAutoSettingModal from '@/modal/mobile/mobile-auto-setting-modal.tsx'
|
|
||||||
import MobileLanguageModal from '@/modal/mobile/mobile-language-modal.tsx'
|
|
||||||
import MobileLoginModal from '@/modal/mobile/mobile-login-modal.tsx'
|
|
||||||
import MobileNoticeModal from '@/modal/mobile/mobile-notice-modal.tsx'
|
|
||||||
import { MobilePeriodHistoryDrawer } from '@/modal/mobile/mobile-period-history-drawer.tsx'
|
|
||||||
import MobileProceduresModal from '@/modal/mobile/mobile-procedures-modal.tsx'
|
|
||||||
import MobileRegisterModal from '@/modal/mobile/mobile-register-modal.tsx'
|
|
||||||
import MobileRulesModal from '@/modal/mobile/mobile-rules-modal.tsx'
|
|
||||||
import MobileSupportModal from '@/modal/mobile/mobile-support-modal.tsx'
|
|
||||||
import MobileUserInfoModal from '@/modal/mobile/mobile-userInfo-modal.tsx'
|
|
||||||
import MobileWithdrawTopupModal from '@/modal/mobile/mobile-withdraw-topup-modal.tsx'
|
|
||||||
import { useAuthStore } from '@/store/auth'
|
import { useAuthStore } from '@/store/auth'
|
||||||
import { useGameRoundStore, useGameSessionStore } from '@/store/game'
|
import { useGameRoundStore, useGameSessionStore } from '@/store/game'
|
||||||
|
|
||||||
function DesktopModalHost() {
|
const DesktopModalHost = lazy(() => import('@/main/desktop-modal-host.tsx'))
|
||||||
return (
|
const MobileEntry = lazy(async () => {
|
||||||
<>
|
const { MobileEntry } = await import('@/main/mobile-entry.tsx')
|
||||||
{/* 桌面端登录弹窗:用于未登录用户进入登录流程 */}
|
|
||||||
<DesktopLoginModal />
|
|
||||||
{/* 桌面端注册弹窗:用于新用户注册账号 */}
|
|
||||||
<DesktopRegisterModal />
|
|
||||||
{/* 桌面端语言切换弹窗:用于选择当前站点展示语言 */}
|
|
||||||
<DesktopLanguageModal />
|
|
||||||
{/* 桌面端规则弹窗:展示当前游戏玩法、下注与结算规则 */}
|
|
||||||
<DesktopRulesModal />
|
|
||||||
{/* 桌面端用户信息弹窗:展示个人资料与站内消息 */}
|
|
||||||
<DesktopUserInfoModal />
|
|
||||||
{/* 桌面端公告弹窗:展示活动公告或运营通知内容 */}
|
|
||||||
<DesktopNoticeModal />
|
|
||||||
{/* 桌面端自动托管弹窗:配置自动托管相关条件 */}
|
|
||||||
<DesktopAutoSettingModal />
|
|
||||||
{/* 桌面端充值/提现前置选择弹窗:先选择进入充值还是提现 */}
|
|
||||||
<DesktopProceduresModal />
|
|
||||||
{/* 桌面端充值/提现业务弹窗:承载具体的充值或提现内容 */}
|
|
||||||
<DesktopWithdrawTopupModal />
|
|
||||||
{/* 桌面端客服弹窗:承载在线客服 iframe */}
|
|
||||||
<DesktopSupportModal />
|
|
||||||
{/* 强制弹窗 */}
|
|
||||||
<EntryNoticeGateModal />
|
|
||||||
{/* 历史开奖信息弹窗 */}
|
|
||||||
<DesktopPeriodHistoryDrawer />
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function MobileModalHost() {
|
return { default: MobileEntry }
|
||||||
return (
|
})
|
||||||
<>
|
const MobileModalHost = lazy(() => import('@/main/mobile-modal-host.tsx'))
|
||||||
{/* 移动端登录弹窗:用于未登录用户进入登录流程 */}
|
const PcEntry = lazy(async () => {
|
||||||
<MobileLoginModal />
|
const { PcEntry } = await import('@/main/pc-entry.tsx')
|
||||||
{/* 移动端注册弹窗:用于新用户注册账号 */}
|
|
||||||
<MobileRegisterModal />
|
return { default: PcEntry }
|
||||||
{/* 移动端语言切换弹窗:用于选择当前站点展示语言 */}
|
})
|
||||||
<MobileLanguageModal />
|
|
||||||
{/* 移动端规则弹窗:展示当前游戏玩法、下注与结算规则 */}
|
|
||||||
<MobileRulesModal />
|
|
||||||
{/* 移动端用户信息弹窗:展示个人资料与站内消息 */}
|
|
||||||
<MobileUserInfoModal />
|
|
||||||
{/* 移动端公告弹窗:展示活动公告或运营通知内容 */}
|
|
||||||
<MobileNoticeModal />
|
|
||||||
{/* 移动端自动托管弹窗:配置自动托管相关条件 */}
|
|
||||||
<MobileAutoSettingModal />
|
|
||||||
{/* 移动端充值/提现前置选择弹窗:先选择进入充值还是提现 */}
|
|
||||||
<MobileProceduresModal />
|
|
||||||
{/* 移动端充值/提现业务弹窗:承载具体的充值或提现内容 */}
|
|
||||||
<MobileWithdrawTopupModal />
|
|
||||||
{/* 移动端客服弹窗:承载在线客服 iframe */}
|
|
||||||
<MobileSupportModal />
|
|
||||||
{/* 强制弹窗 */}
|
|
||||||
<MobileEntryNoticeGateModal />
|
|
||||||
{/* 历史开奖信息弹窗 */}
|
|
||||||
<MobilePeriodHistoryDrawer />
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MainEntryPage() {
|
export function MainEntryPage() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -258,8 +181,12 @@ export function MainEntryPage() {
|
|||||||
isMobile ? 'flex w-full flex-col' : 'flex min-h-0 flex-1 flex-col'
|
isMobile ? 'flex w-full flex-col' : 'flex min-h-0 flex-1 flex-col'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isMobile ? <MobileEntry /> : <PcEntry />}
|
<Suspense fallback={null}>
|
||||||
{isMobile ? <MobileModalHost /> : <DesktopModalHost />}
|
{isMobile ? <MobileEntry /> : <PcEntry />}
|
||||||
|
</Suspense>
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
{isMobile ? <MobileModalHost /> : <DesktopModalHost />}
|
||||||
|
</Suspense>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/main/mobile-modal-host.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { MobileEntryNoticeGateModal } from '@/features/game/components/shared/entry-notice-gate-modal'
|
||||||
|
import MobileAutoSettingModal from '@/modal/mobile/mobile-auto-setting-modal.tsx'
|
||||||
|
import MobileLanguageModal from '@/modal/mobile/mobile-language-modal.tsx'
|
||||||
|
import MobileLoginModal from '@/modal/mobile/mobile-login-modal.tsx'
|
||||||
|
import MobileNoticeModal from '@/modal/mobile/mobile-notice-modal.tsx'
|
||||||
|
import { MobilePeriodHistoryDrawer } from '@/modal/mobile/mobile-period-history-drawer.tsx'
|
||||||
|
import MobileProceduresModal from '@/modal/mobile/mobile-procedures-modal.tsx'
|
||||||
|
import MobileRegisterModal from '@/modal/mobile/mobile-register-modal.tsx'
|
||||||
|
import MobileRulesModal from '@/modal/mobile/mobile-rules-modal.tsx'
|
||||||
|
import MobileSupportModal from '@/modal/mobile/mobile-support-modal.tsx'
|
||||||
|
import MobileUserInfoModal from '@/modal/mobile/mobile-userInfo-modal.tsx'
|
||||||
|
import MobileWithdrawTopupModal from '@/modal/mobile/mobile-withdraw-topup-modal.tsx'
|
||||||
|
|
||||||
|
export default function MobileModalHost() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<MobileLoginModal />
|
||||||
|
<MobileRegisterModal />
|
||||||
|
<MobileLanguageModal />
|
||||||
|
<MobileRulesModal />
|
||||||
|
<MobileUserInfoModal />
|
||||||
|
<MobileNoticeModal />
|
||||||
|
<MobileAutoSettingModal />
|
||||||
|
<MobileProceduresModal />
|
||||||
|
<MobileWithdrawTopupModal />
|
||||||
|
<MobileSupportModal />
|
||||||
|
<MobileEntryNoticeGateModal />
|
||||||
|
<MobilePeriodHistoryDrawer />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -5,10 +5,61 @@ import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
|||||||
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
|
import react, { reactCompilerPreset } from '@vitejs/plugin-react'
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
|
|
||||||
|
function resolveManualChunk(id: string) {
|
||||||
|
if (!id.includes('/node_modules/')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes('/node_modules/react/') ||
|
||||||
|
id.includes('/node_modules/react-dom/') ||
|
||||||
|
id.includes('/node_modules/scheduler/')
|
||||||
|
) {
|
||||||
|
return 'vendor-react'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes('/node_modules/@tanstack/')) {
|
||||||
|
return 'vendor-tanstack'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes('/node_modules/i18next/') ||
|
||||||
|
id.includes('/node_modules/react-i18next/')
|
||||||
|
) {
|
||||||
|
return 'vendor-i18n'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes('/node_modules/motion/') ||
|
||||||
|
id.includes('/node_modules/lottie-web/')
|
||||||
|
) {
|
||||||
|
return 'vendor-animation'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
id.includes('/node_modules/radix-ui/') ||
|
||||||
|
id.includes('/node_modules/@radix-ui/')
|
||||||
|
) {
|
||||||
|
return 'vendor-radix'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id.includes('/node_modules/lucide-react/')) {
|
||||||
|
return 'vendor-icons'
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'vendor'
|
||||||
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
|
'lottie-web': fileURLToPath(
|
||||||
|
new URL(
|
||||||
|
'./node_modules/lottie-web/build/player/lottie_light.js',
|
||||||
|
import.meta.url,
|
||||||
|
),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
@@ -33,5 +84,10 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
build: {
|
build: {
|
||||||
outDir: 'zihua-web',
|
outDir: 'zihua-web',
|
||||||
|
rolldownOptions: {
|
||||||
|
output: {
|
||||||
|
manualChunks: resolveManualChunk,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||