fix: 安装页面API路径重复问题

api.ts的BASE_URL=/api/v1,安装页面调用api.get('/api/install/status')
导致实际请求路径为/api/v1/api/install/status(404)。
改为fetch直接请求避免baseURL前缀叠加。
This commit is contained in:
2026-05-03 17:44:17 +08:00
parent 3023b4f52e
commit ef41235b07
+24 -9
View File
@@ -4,8 +4,6 @@ import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { toast } from 'vue-sonner'
import api from '@/services/api'
const router = useRouter()
const loading = ref(false)
@@ -41,9 +39,10 @@ const dbTypes = [
async function checkInstallStatus() {
checkingStatus.value = true
try {
const data = await api.get<any>('/api/install/status')
installStatus.value = data
if (data?.installed) {
const res = await fetch('/api/install/status')
const data = await res.json()
installStatus.value = data?.data
if (data?.data?.installed) {
router.push('/auth/login')
}
}
@@ -68,8 +67,16 @@ async function testDatabase() {
payload.username = form.value.db_username
payload.password = form.value.db_password
}
const data = await api.post<any>('/api/install/test-db', payload)
toast.success(data?.message || '数据库连接成功')
const res = await fetch('/api/install/test-db', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
})
const result = await res.json()
if (!res.ok || result.code !== 200) {
throw new Error(result.message || '数据库连接失败')
}
toast.success(result.data?.message || '数据库连接成功')
}
catch (error: any) {
toast.error(error.message || '数据库连接失败')
@@ -130,8 +137,16 @@ async function handleInstall() {
payload.redis_db = form.value.redis_db
}
const data = await api.post<any>('/api/install/setup', payload)
toast.success(data?.message || '安装成功')
const res = await fetch('/api/install/setup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
})
const result = await res.json()
if (!res.ok || result.code !== 200) {
throw new Error(result.message || '安装失败')
}
toast.success(result.data?.message || '安装成功')
step.value = 4
}
catch (error: any) {