fix: 移除所有硬编码的localhost:8080,使用相对路径

- 创建utils/config.ts集中管理API_BASE和文件URL
- 删除.env文件(VITE_SERVER_API_URL=http://localhost:8080)
- env.ts默认API前缀改为/api/v1匹配后端路由
- 替换16处硬编码的localhost:8080引用
This commit is contained in:
2026-05-03 19:48:07 +08:00
parent 6d5d1922f5
commit fbc2e5ac91
17 changed files with 32 additions and 37 deletions
@@ -3,6 +3,8 @@ import { ref } from 'vue'
import type { Team } from './types'
import { getFileUrl } from '@/utils/config'
const { teams } = defineProps<{
teams: Team[]
}>()
@@ -10,11 +12,7 @@ const { teams } = defineProps<{
const activeTeam = ref<Team>(teams[0])
function getAssetUrl(path: string) {
if (!path)
return ''
if (path.startsWith('http'))
return path
return `${import.meta.env.VITE_API_BASE || 'http://localhost:8080'}${path}`
return getFileUrl(path)
}
</script>
@@ -7,6 +7,7 @@ import { useRoute, useRouter } from 'vue-router'
import ThemePopover from '@/components/custom-theme/theme-popover.vue'
import LanguageChange from '@/components/language-change.vue'
import { getFileUrl } from '@/utils/config'
const { t } = useI18n()
const mode = useColorMode()
@@ -31,20 +32,11 @@ const siteSettings = ref({
const siteName = computed(() => siteSettings.value.siteName)
const userAvatar = computed(() => {
const avatar = currentUser.value?.avatar
if (!avatar)
return ''
if (avatar.startsWith('http'))
return avatar
return `${import.meta.env.VITE_API_BASE || 'http://localhost:8080'}${avatar}`
return getFileUrl(currentUser.value?.avatar)
})
function getAssetUrl(path: string) {
if (!path)
return ''
if (path.startsWith('http'))
return path
return `${import.meta.env.VITE_API_BASE || 'http://localhost:8080'}${path}`
return getFileUrl(path)
}
const logoSrc = computed(() => {