From 5d5fecde1ba141e91b9eb5f5e0a4741117b5589e Mon Sep 17 00:00:00 2001 From: YeomaiPC Date: Sun, 18 Oct 2026 19:51:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pages/storage.vue | 49 ++++++++++++++++++ i18n/locales/en.json | 5 ++ i18n/locales/zh-CN.json | 5 ++ server/api/admin/export/csv.get.ts | 81 ++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 server/api/admin/export/csv.get.ts diff --git a/app/pages/storage.vue b/app/pages/storage.vue index df35171..c5dc202 100644 --- a/app/pages/storage.vue +++ b/app/pages/storage.vue @@ -310,6 +310,30 @@ watch(isAuthenticated, async (authed) => { await loadStorage() } }) + +const exportingCsv = ref(false) + +async function exportDatabaseCsv() { + if (exportingCsv.value) return + exportingCsv.value = true + try { + const blob = await $fetch('/api/admin/export/csv', { + credentials: 'include', + responseType: 'blob' + }) + const url = URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = url + link.download = `pichost-db-${new Date().toISOString().slice(0, 10)}.tar.gz` + link.click() + URL.revokeObjectURL(url) + toast.add({ title: t('storage.exportCsvStarted'), color: 'success' }) + } catch { + toast.add({ title: t('storage.exportCsvFailed'), color: 'error' }) + } finally { + exportingCsv.value = false + } +}