09e3db5b34
Frontend CI / Frontend (push) Has been cancelled
Port admin-web's chunk-reload guard to ops-web (vite:preloadError + router.onError) so a stale tab landing on a lazy-loaded route triggers a single reload instead of a hard 404. Also force index.html through revalidation on both apps so the reload actually fetches a fresh entry referencing the new chunk hashes; hashed asset URLs keep their long immutable cache. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
111 lines
1.7 KiB
TypeScript
111 lines
1.7 KiB
TypeScript
import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
|
|
import {
|
|
Alert,
|
|
App as AntApp,
|
|
Avatar,
|
|
Badge,
|
|
Button,
|
|
Card,
|
|
Checkbox,
|
|
ConfigProvider,
|
|
DatePicker,
|
|
Descriptions,
|
|
Drawer,
|
|
Dropdown,
|
|
Empty,
|
|
Form,
|
|
Input,
|
|
InputNumber,
|
|
Layout,
|
|
Menu,
|
|
Modal,
|
|
Pagination,
|
|
Popconfirm,
|
|
Radio,
|
|
Result,
|
|
Select,
|
|
Space,
|
|
Spin,
|
|
Statistic,
|
|
Switch,
|
|
Table,
|
|
Tabs,
|
|
Tag,
|
|
Tooltip,
|
|
message,
|
|
} from 'ant-design-vue'
|
|
import { createApp } from 'vue'
|
|
|
|
import { registerChunkReloadHandlers } from '@/lib/chunk-reload'
|
|
import { bindUnauthorizedHandler } from '@/lib/http'
|
|
import { router } from '@/router'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import { pinia } from '@/stores/pinia'
|
|
import 'ant-design-vue/dist/reset.css'
|
|
import App from './App.vue'
|
|
import './styles.css'
|
|
|
|
registerChunkReloadHandlers()
|
|
|
|
const queryClient = new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
staleTime: 30000,
|
|
refetchOnWindowFocus: false,
|
|
retry: false,
|
|
},
|
|
},
|
|
})
|
|
|
|
const app = createApp(App)
|
|
|
|
message.config({
|
|
maxCount: 1,
|
|
})
|
|
|
|
bindUnauthorizedHandler(() => {
|
|
const auth = useAuthStore(pinia)
|
|
auth.logout()
|
|
void router.replace({ name: 'login' })
|
|
message.destroy()
|
|
message.warning('登录已过期,请重新登录')
|
|
})
|
|
;[
|
|
Alert,
|
|
AntApp,
|
|
Avatar,
|
|
Badge,
|
|
Button,
|
|
Card,
|
|
Checkbox,
|
|
ConfigProvider,
|
|
DatePicker,
|
|
Descriptions,
|
|
Drawer,
|
|
Dropdown,
|
|
Empty,
|
|
Form,
|
|
Input,
|
|
InputNumber,
|
|
Layout,
|
|
Menu,
|
|
Modal,
|
|
Pagination,
|
|
Popconfirm,
|
|
Radio,
|
|
Result,
|
|
Select,
|
|
Space,
|
|
Spin,
|
|
Statistic,
|
|
Switch,
|
|
Table,
|
|
Tabs,
|
|
Tag,
|
|
Tooltip,
|
|
].forEach((component) => {
|
|
app.use(component)
|
|
})
|
|
|
|
app.use(pinia).use(router).use(VueQueryPlugin, { queryClient }).mount('#app')
|