perf(export): optimize SQL export performance
This commit is contained in:
1 parent
7fd4aef060
commit
605d20dd4f
14 files changed
+665
-293
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from "vue";
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -8,11 +8,22 @@ import { useToast } from "@/composables/useToast";
|
||||
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
|
||||
import * as api from "@/lib/backend/api";
|
||||
import { translateBackendError } from "@/i18n/backend-errors";
|
||||
import { formatDataTransferDuration } from "@/composables/useExportTracker";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { toast } = useToast();
|
||||
const open = defineModel<boolean>("open", { default: false });
|
||||
const isRevealing = ref(false);
|
||||
const currentTime = ref(Date.now());
|
||||
let elapsedTimer: ReturnType<typeof setInterval> | undefined;
|
||||
onMounted(() => {
|
||||
elapsedTimer = setInterval(() => {
|
||||
currentTime.value = Date.now();
|
||||
}, 1000);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
if (elapsedTimer) clearInterval(elapsedTimer);
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
title: string;
|
||||
@@ -23,6 +34,8 @@ const props = defineProps<{
|
||||
status: string;
|
||||
errorMessage: string | null;
|
||||
filePath?: string | null;
|
||||
startedAt?: number;
|
||||
finishedAt?: number;
|
||||
disableCancel?: boolean;
|
||||
canMinimize?: boolean;
|
||||
}>();
|
||||
@@ -50,6 +63,10 @@ const rowsText = computed(() => {
|
||||
}
|
||||
return t("exportProgress.rowsExported", { count: props.rowsExported.toLocaleString() });
|
||||
});
|
||||
const elapsedText = computed(() => {
|
||||
if (props.startedAt === undefined) return "";
|
||||
return formatDataTransferDuration((props.finishedAt ?? currentTime.value) - props.startedAt);
|
||||
});
|
||||
|
||||
async function revealExportFile() {
|
||||
if (!props.filePath || isRevealing.value) return;
|
||||
@@ -120,6 +137,7 @@ async function revealExportFile() {
|
||||
<!-- Row count -->
|
||||
<div class="text-xs text-muted-foreground tabular-nums">
|
||||
{{ rowsText }}
|
||||
<span v-if="elapsedText" class="ml-2">{{ t("exportProgress.elapsed", { duration: elapsedText }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user