2023-10-10 09:24:49 +08:00
|
|
|
|
<template>
|
2023-10-12 12:14:56 +08:00
|
|
|
|
<el-descriptions border size="small" :title="`${progress.sqlFileName}`">
|
2023-10-10 09:24:49 +08:00
|
|
|
|
<el-descriptions-item label="时间">{{ state.elapsedTime }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="已处理">{{ progress.executedStatements }}</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-10-12 12:14:56 +08:00
|
|
|
|
import { onMounted, onUnmounted, reactive } from 'vue';
|
|
|
|
|
|
import { formatTime } from 'element-plus/es/components/countdown/src/utils';
|
|
|
|
|
|
import { buildProgressProps } from './progress-notify';
|
2023-10-10 09:24:49 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps(buildProgressProps());
|
|
|
|
|
|
|
|
|
|
|
|
const state = reactive({
|
2023-10-12 12:14:56 +08:00
|
|
|
|
elapsedTime: '00:00:00',
|
2023-10-10 09:24:49 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2023-10-12 12:14:56 +08:00
|
|
|
|
let timer: any = undefined;
|
|
|
|
|
|
const startTime = Date.now();
|
2023-10-10 09:24:49 +08:00
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2023-10-12 12:14:56 +08:00
|
|
|
|
timer = setInterval(() => {
|
|
|
|
|
|
const elapsed = Date.now() - startTime;
|
|
|
|
|
|
state.elapsedTime = formatTime(elapsed, 'HH:mm:ss');
|
|
|
|
|
|
}, 1000);
|
2023-10-10 09:24:49 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(async () => {
|
2023-10-12 12:14:56 +08:00
|
|
|
|
if (timer != undefined) {
|
|
|
|
|
|
clearInterval(timer); // 在Vue实例销毁前,清除我们的定时器
|
|
|
|
|
|
timer = undefined;
|
|
|
|
|
|
}
|
2023-10-10 09:24:49 +08:00
|
|
|
|
});
|
2023-10-12 12:14:56 +08:00
|
|
|
|
</script>
|