From 5d828375fb5bb8426263ea5a45beb786c81b96cf Mon Sep 17 00:00:00 2001 From: jingrow Date: Sun, 24 Aug 2025 00:07:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0getRecordAttachments=E7=AB=AF?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/data.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/utils/data.js b/utils/data.js index 55d80cf..0fd22ce 100644 --- a/utils/data.js +++ b/utils/data.js @@ -306,4 +306,28 @@ export async function getSiteSettings() { site_name: "Jsite" }; } -} \ No newline at end of file +} + +export async function getRecordAttachments(pagetype, name) { + try { + const response = await axios.get( + `${BACKEND_SERVER_URL}/api/action/jsite.api.v1.get_record_attachments`, + { + params: { + pagetype, + name + } + } + ); + + const message = response.data.message; + if (message?.error) { + throw new Error(message.error.message || '获取附件失败'); + } + + return { data: message?.data || [] }; + } catch (error) { + console.error(`Error fetching attachments for ${pagetype}/${name}:`, error.message); + return { error: error.message, data: [] }; + } +} \ No newline at end of file