From 4ddea65f1eeb60ca804c14ee89f99696819fc6e1 Mon Sep 17 00:00:00 2001 From: henry yo Date: Sat, 27 Jun 2026 00:58:24 +0800 Subject: [PATCH] fix: chage api string --- src/Pages/Accounts/Show.vue | 22 +++++++++++----------- src/Pages/Dashboard.vue | 4 ++-- src/Pages/Expenses/Import.vue | 2 +- src/Pages/Expenses/Index.vue | 22 +++++++++++----------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Pages/Accounts/Show.vue b/src/Pages/Accounts/Show.vue index 28622c8..7e05179 100644 --- a/src/Pages/Accounts/Show.vue +++ b/src/Pages/Accounts/Show.vue @@ -45,7 +45,7 @@ const accountTrendData = ref([]); const fetchAccountTrend = async () => { try { - const res = await api.get(`/api/accounts/${accountId}/holdings-trend`); + const res = await api.get(`/v1/accounts/${accountId}/holdings-trend`); accountTrendData.value = res.data; } catch (e) { console.error("無法撈取帳戶多線趨勢圖", e); @@ -53,12 +53,12 @@ const fetchAccountTrend = async () => { }; const fetchAccount = async () => { - const res = await api.get(`/api/accounts/${accountId}`); + const res = await api.get(`/v1/accounts/${accountId}`); account.value = res.data; }; const fetchHoldings = async () => { - const res = await api.get(`/api/accounts/${accountId}/holdings`); + const res = await api.get(`/v1/accounts/${accountId}/holdings`); holdings.value = res.data; // 🟢 修正:直接從大列表的內建數據裡,把最新價格和現值綁定給前端變數 @@ -68,7 +68,7 @@ const fetchHoldings = async () => { }; const loadTransactions = async (holding) => { - const res = await api.get(`/api/holdings/${holding.id}/transactions`); + const res = await api.get(`/v1/holdings/${holding.id}/transactions`); transactions.value[holding.id] = res.data; }; @@ -86,7 +86,7 @@ const toggleHolding = async (holding) => { const loadHistory = async (holding) => { try { - const res = await api.get(`/api/holdings/${holding.id}/history`); + const res = await api.get(`/v1/holdings/${holding.id}/history`); investmentHistory.value[holding.id] = res.data; } catch (e) { console.error("取得歷史資料失敗", e); @@ -94,7 +94,7 @@ const loadHistory = async (holding) => { }; const submitHolding = async () => { - await api.post(`/api/accounts/${accountId}/holdings`, holdingForm.value); + await api.post(`/v1/accounts/${accountId}/holdings`, holdingForm.value); showHoldingModal.value = false; holdingForm.value = { type: "stock", symbol: "", name: "" }; await fetchHoldings(); @@ -102,13 +102,13 @@ const submitHolding = async () => { const deleteHolding = async (id) => { if (!confirm("確定要刪除這筆持倉嗎?")) return; - await api.delete(`/api/holdings/delete/${accountId}/${id}`); + await api.delete(`/v1/holdings/delete/${accountId}/${id}`); fetchHoldings(); }; const submitTransaction = async (holding) => { await api.post( - `/api/holdings/${holding.id}/transactions`, + `/v1/holdings/${holding.id}/transactions`, transactionForm.value, ); transactionForm.value = { @@ -129,7 +129,7 @@ const submitTransaction = async (holding) => { const deleteTransaction = async (holding, txId) => { if (!confirm("確定要刪除這筆交易嗎?")) return; - await api.delete(`/api/holdings/${holding.id}/transactions/${txId}`); + await api.delete(`/v1/holdings/${holding.id}/transactions/${txId}`); await fetchHoldings(); await loadTransactions(holding); }; @@ -152,7 +152,7 @@ const calcAmount = (tx, holding) => { const fetchPrice = async (holding) => { try { - const res = await api.get(`/api/holdings/${holding.id}/realtime`); + const res = await api.get(`/v1/holdings/${holding.id}/realtime`); currentPrices.value[holding.id] = res.data.price; } catch (e) { currentPrices.value[holding.id] = null; @@ -186,7 +186,7 @@ const searchSecurities = async (keyword) => { securityOptions.value = []; return; } - const { data } = await api.get("/api/securities/search", { + const { data } = await api.get("/v1/securities/search", { params: { type: holdingForm.value.type, keyword }, }); securityOptions.value = data; diff --git a/src/Pages/Dashboard.vue b/src/Pages/Dashboard.vue index 62d56d1..672fa08 100644 --- a/src/Pages/Dashboard.vue +++ b/src/Pages/Dashboard.vue @@ -1,6 +1,6 @@