fix: 增加下载完成提示弹窗
This commit is contained in:
@@ -231,6 +231,7 @@ import {
|
||||
|
||||
import { apiGet, apiPost, download } from '../api/client';
|
||||
import type { ApiMessage, DatabaseInfo, TableData, TableInfo } from '../types';
|
||||
import { showDownloadCompleteDialog } from '../composables/downloadFeedback';
|
||||
import { resetPageHeader, setPageHeader } from '../composables/pageHeader';
|
||||
|
||||
type RowData = Record<string, unknown>;
|
||||
@@ -483,14 +484,18 @@ async function downloadSelectedCsv() {
|
||||
if (!selectedCsvTable.value) return;
|
||||
if (downloadingFormat.value) return;
|
||||
|
||||
const filename = `${selectedCsvTable.value}.csv`;
|
||||
downloadingFormat.value = 'csv';
|
||||
try {
|
||||
await download(
|
||||
const completed = await download(
|
||||
'/api/download',
|
||||
{ table_name: selectedCsvTable.value, format: 'csv' },
|
||||
`${selectedCsvTable.value}.csv`
|
||||
filename
|
||||
);
|
||||
csvDialogVisible.value = false;
|
||||
if (completed) {
|
||||
csvDialogVisible.value = false;
|
||||
showDownloadCompleteDialog(dialog, filename);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '导出失败');
|
||||
} finally {
|
||||
@@ -503,13 +508,17 @@ async function downloadSelectedXlsx() {
|
||||
if (downloadingFormat.value) return;
|
||||
|
||||
downloadingFormat.value = 'xlsx';
|
||||
const filename = selectedXlsxTables.value.length === 1 ? `${selectedXlsxTables.value[0]}.xlsx` : 'tables.xlsx';
|
||||
try {
|
||||
await download(
|
||||
const completed = await download(
|
||||
'/api/download',
|
||||
{ table_names: selectedXlsxTables.value, format: 'xlsx' },
|
||||
selectedXlsxTables.value.length === 1 ? `${selectedXlsxTables.value[0]}.xlsx` : 'tables.xlsx'
|
||||
filename
|
||||
);
|
||||
xlsxDialogVisible.value = false;
|
||||
if (completed) {
|
||||
xlsxDialogVisible.value = false;
|
||||
showDownloadCompleteDialog(dialog, filename);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '导出失败');
|
||||
} finally {
|
||||
|
||||
@@ -100,6 +100,7 @@ import { CopyOutline, DownloadOutline, FileTrayOutline, RefreshOutline, TrashOut
|
||||
|
||||
import { apiGet, apiPost, download as downloadFile } from '../api/client';
|
||||
import type { CacheSize, HistoryDetail, HistoryRecord } from '../types';
|
||||
import { showDownloadCompleteDialog } from '../composables/downloadFeedback';
|
||||
import { resetPageHeader, setPageHeader } from '../composables/pageHeader';
|
||||
|
||||
type LogLevel = 'default' | 'info' | 'success' | 'warning' | 'error';
|
||||
@@ -184,8 +185,11 @@ async function downloadHistory(record: HistoryRecord) {
|
||||
|
||||
downloadingRecordId.value = record.id;
|
||||
try {
|
||||
await downloadFile('/api/history/download', { record_id: record.id }, `${record.id}.zip`);
|
||||
message.success('历史数据下载已开始');
|
||||
const filename = `${record.id}.zip`;
|
||||
const completed = await downloadFile('/api/history/download', { record_id: record.id }, filename);
|
||||
if (completed) {
|
||||
showDownloadCompleteDialog(dialog, filename);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '下载历史数据失败');
|
||||
} finally {
|
||||
|
||||
@@ -312,11 +312,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue';
|
||||
import { useMessage, type SelectOption } from 'naive-ui';
|
||||
import { useDialog, useMessage, type SelectOption } from 'naive-ui';
|
||||
import { CloseOutline, CloudDownloadOutline, CloudUploadOutline } from '@vicons/ionicons5';
|
||||
|
||||
import { apiGet, apiPost, downloadGet, upload } from '../api/client';
|
||||
import type { ApiMessage, AppConfig, HistoryRetentionConfig, RemoteDataConfig } from '../types';
|
||||
import { showDownloadCompleteDialog } from '../composables/downloadFeedback';
|
||||
import { resetPageHeader, setPageHeader } from '../composables/pageHeader';
|
||||
|
||||
interface ExtractFieldConfig {
|
||||
@@ -327,6 +328,7 @@ interface ExtractFieldConfig {
|
||||
}
|
||||
|
||||
const message = useMessage();
|
||||
const dialog = useDialog();
|
||||
const configInput = ref<HTMLInputElement | null>(null);
|
||||
const configUpdate = ref('');
|
||||
const loading = ref(false);
|
||||
@@ -661,7 +663,11 @@ async function changePassword() {
|
||||
|
||||
async function downloadConfig() {
|
||||
try {
|
||||
await downloadGet('/api/config/download', 'Configure.json');
|
||||
const filename = 'Configure.json';
|
||||
const completed = await downloadGet('/api/config/download', filename);
|
||||
if (completed) {
|
||||
showDownloadCompleteDialog(dialog, filename);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error(error instanceof Error ? error.message : '下载配置失败');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user