fix(fc2c-i): router falls back to memory history when no window (vitest)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { createRouter, createWebHistory, createMemoryHistory } from 'vue-router'
|
||||
import PlaceholderView from './views/PlaceholderView.vue'
|
||||
import SettingsView from './views/SettingsView.vue'
|
||||
import GalleryView from './views/GalleryView.vue'
|
||||
@@ -28,8 +28,13 @@ const routes = [
|
||||
{ path: '/downloads', name: 'downloads', component: PlaceholderView, meta: { title: 'Downloads' } }
|
||||
]
|
||||
|
||||
// Browser uses HTML5 history; non-browser (Vitest/SSR) falls back to memory
|
||||
// history so the module is importable without `window`.
|
||||
const history =
|
||||
typeof window !== 'undefined' ? createWebHistory() : createMemoryHistory()
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
history,
|
||||
routes
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user