diff --git a/frontend/src/pages/install/index.vue b/frontend/src/pages/install/index.vue index efb7055..7e78933 100644 --- a/frontend/src/pages/install/index.vue +++ b/frontend/src/pages/install/index.vue @@ -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('/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('/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('/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) {