Skip to content

Commit

Permalink
feat: add support for base url (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Jun 9, 2024
1 parent 6b625ac commit 113d079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ Vue.use(VueResize)

const initLoad = async () => {
try {
// get base url. by default, it is '/'
const base = import.meta.env.BASE_URL ?? '/'

//load config.json
const res = await fetch('/config.json')
const res = await fetch(`${base}config.json`)
const file = (await res.json()) as Record<string, unknown>

window.console.debug('Loaded config.json')
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import Vue from 'vue'
import routes from '@/routes'

Vue.use(VueRouter)
const router = new VueRouter({ mode: 'history', routes })
const router = new VueRouter({
base: import.meta.env.BASE_URL,
mode: 'history',
routes,
})

export default router

0 comments on commit 113d079

Please sign in to comment.