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:
@@ -4,8 +4,6 @@ import { computed, onMounted, ref } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { toast } from 'vue-sonner'
|
import { toast } from 'vue-sonner'
|
||||||
|
|
||||||
import api from '@/services/api'
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@@ -41,9 +39,10 @@ const dbTypes = [
|
|||||||
async function checkInstallStatus() {
|
async function checkInstallStatus() {
|
||||||
checkingStatus.value = true
|
checkingStatus.value = true
|
||||||
try {
|
try {
|
||||||
const data = await api.get<any>('/api/install/status')
|
const res = await fetch('/api/install/status')
|
||||||
installStatus.value = data
|
const data = await res.json()
|
||||||
if (data?.installed) {
|
installStatus.value = data?.data
|
||||||
|
if (data?.data?.installed) {
|
||||||
router.push('/auth/login')
|
router.push('/auth/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,8 +67,16 @@ async function testDatabase() {
|
|||||||
payload.username = form.value.db_username
|
payload.username = form.value.db_username
|
||||||
payload.password = form.value.db_password
|
payload.password = form.value.db_password
|
||||||
}
|
}
|
||||||
const data = await api.post<any>('/api/install/test-db', payload)
|
const res = await fetch('/api/install/test-db', {
|
||||||
toast.success(data?.message || '数据库连接成功')
|
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) {
|
catch (error: any) {
|
||||||
toast.error(error.message || '数据库连接失败')
|
toast.error(error.message || '数据库连接失败')
|
||||||
@@ -130,8 +137,16 @@ async function handleInstall() {
|
|||||||
payload.redis_db = form.value.redis_db
|
payload.redis_db = form.value.redis_db
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await api.post<any>('/api/install/setup', payload)
|
const res = await fetch('/api/install/setup', {
|
||||||
toast.success(data?.message || '安装成功')
|
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
|
step.value = 4
|
||||||
}
|
}
|
||||||
catch (error: any) {
|
catch (error: any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user