fix(stage-tamagotchi): register router hot updates (#2211)
This commit is contained in:
@@ -12,7 +12,7 @@ import { createPinia } from 'pinia'
|
||||
import { setupLayouts } from 'virtual:generated-layouts'
|
||||
import { createApp } from 'vue'
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { routes } from 'vue-router/auto-routes'
|
||||
import { handleHotUpdate, routes } from 'vue-router/auto-routes'
|
||||
|
||||
import App from './App.vue'
|
||||
|
||||
@@ -51,6 +51,14 @@ const router = createRouter({
|
||||
routes: setupLayouts(routes as RouteRecordRaw[]),
|
||||
})
|
||||
|
||||
if (import.meta.hot) {
|
||||
handleHotUpdate(router, (updatedRoutes) => {
|
||||
router.clearRoutes()
|
||||
for (const route of setupLayouts(updatedRoutes))
|
||||
router.addRoute(route)
|
||||
})
|
||||
}
|
||||
|
||||
createApp(App)
|
||||
.use(MotionPlugin)
|
||||
// TODO: Fix autoAnimatePlugin type error
|
||||
|
||||
Reference in New Issue
Block a user