Skip to content

Commit

Permalink
refactor: baseURL and build base (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZonaHex authored Jan 10, 2025
1 parent 6987c68 commit 6518e13
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/vite.config.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import configStyleImportPlugin from './plugin/styleImport'

export default mergeConfig(
{
base: '',
mode: 'production',
plugins: [
configCompressPlugin('gzip'),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dev": "vite --config ./config/vite.config.dev.ts",
"cloud": "VITE_ROLE=cloud vite --config ./config/vite.config.dev.ts",
"build": "vite build --config ./config/vite.config.prod.ts",
"build:docker": "vite build --config ./config/vite.config.prod.ts --base /dashboard/",
"build:docker": "vite build --config ./config/vite.config.prod.ts",
"build:test": "vite build --config ./config/vite.config.prod.ts --mode test --base /dashboard/ && vue-tsc --noEmit",
"build:staging": "vite build --config ./config/vite.config.prod.ts --mode staging --base /dashboard/ && vue-tsc --noEmit",
"report": "cross-env REPORT=true pnpm run build",
Expand Down Expand Up @@ -147,4 +147,4 @@
"gifsicle": "5.2.0"
},
"packageManager": "[email protected]"
}
}
6 changes: 2 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
})
const { setRole } = useUserStore()
const { host } = storeToRefs(useAppStore())
const { updateSettings } = useAppStore()
host.value = window.location.origin
const role = import.meta.env.VITE_ROLE || 'admin'
setRole(role)
Expand All @@ -41,11 +38,12 @@
if (import.meta.env.MODE === 'development' || import.meta.env.MODE === 'production') {
// Assuming local greptimeDB is up and running
const { username, password, database }: any = useStorage('config', {}).value
const { username, password, database, host }: any = useStorage('config', {}).value
updateSettings({
username,
password,
database,
host,
})
}
</script>
3 changes: 3 additions & 0 deletions src/components/global-setting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ a-drawer.settings-drawer(
})
onMounted(() => {
if (!host.value) {
host.value = window.location.href.replace(/\/dashboard(?!.*\/dashboard).*/, '')
}
axios.defaults.baseURL = host.value
})
</script>
Expand Down

0 comments on commit 6518e13

Please sign in to comment.