mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 08:46:00 +00:00
Merge branch 'master' into feature/duckdb-2
This commit is contained in:
@@ -184,7 +184,7 @@ export async function exportQuickExportFile(dataName, reader, format: QuickExpor
|
||||
|
||||
export async function saveFileToDisk(
|
||||
filePathFunc,
|
||||
options: any = { formatLabel: 'HTML page', formatExtension: 'html' }
|
||||
options: any = { formatLabel: 'HTML page', formatExtension: 'html', defaultFileName: null }
|
||||
) {
|
||||
const { formatLabel, formatExtension } = options;
|
||||
const electron = getElectron();
|
||||
@@ -193,7 +193,7 @@ export async function saveFileToDisk(
|
||||
const filters = [{ name: formatLabel, extensions: [formatExtension] }];
|
||||
const filePath = await electron.showSaveDialog({
|
||||
filters,
|
||||
defaultPath: `file.${formatExtension}`,
|
||||
defaultPath: options.defaultFileName ?? `file.${formatExtension}`,
|
||||
properties: ['showOverwriteConfirmation'],
|
||||
});
|
||||
if (!filePath) return;
|
||||
@@ -202,7 +202,7 @@ export async function saveFileToDisk(
|
||||
} else {
|
||||
const resp = await apiCall('files/generate-uploads-file');
|
||||
await filePathFunc(resp.filePath);
|
||||
await downloadFromApi(`uploads/get?file=${resp.fileName}`, `file.${formatExtension}`);
|
||||
await downloadFromApi(`uploads/get?file=${resp.fileName}`, options.defaultFileName ?? `file.${formatExtension}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export default function formatFileSize(size) {
|
||||
if (size > 1000000000) return `${Math.round(size / 10000000000) * 10} GB`;
|
||||
if (size > 1000000) return `${Math.round(size / 10000000) * 10} MB`;
|
||||
if (size > 1000) return `${Math.round(size / 10000) * 10} KB`;
|
||||
if (size > 1000000000) return `${Math.round(size / 100000000) / 10} GB`;
|
||||
if (size > 1000000) return `${Math.round(size / 100000) / 10} MB`;
|
||||
if (size > 1000) return `${Math.round(size / 100) / 10} KB`;
|
||||
return `${size} bytes`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user