feat: 采集任务可以立刻运行一次
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import { computed, h, onMounted, ref } from "vue";
|
||||
import { NButton, NIcon, NInput, NInputNumber, NModal, NSelect, NSwitch, NTimePicker, NTooltip, useDialog } from "naive-ui";
|
||||
import type { SelectRenderLabel, SelectRenderTag } from "naive-ui";
|
||||
import { CreateOutline, InformationCircleOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import { CreateOutline, InformationCircleOutline, PlayOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import { api } from "../../shared/http";
|
||||
import { useToast } from "../../shared/toast";
|
||||
@@ -58,6 +58,7 @@ const weekday = ref(1);
|
||||
const monthDay = ref(1);
|
||||
const clock = ref("08:00");
|
||||
const catalogLoading = ref(false);
|
||||
const runningId = ref<number | null>(null);
|
||||
const dialog = useDialog();
|
||||
const toast = useToast();
|
||||
const timeOptions = [
|
||||
@@ -271,6 +272,18 @@ async function remove(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
async function runNow(source: Source) {
|
||||
runningId.value = source.id;
|
||||
try {
|
||||
await api(`/api/admin/sources/${source.id}/run`, { method: "POST" });
|
||||
toast.success("已开始运行");
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : "运行失败");
|
||||
} finally {
|
||||
runningId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function confirmRemove(source: Source) {
|
||||
dialog.warning({
|
||||
title: "删除采集",
|
||||
@@ -322,6 +335,14 @@ onMounted(load);
|
||||
</td>
|
||||
<td class="col-actions">
|
||||
<div class="row-actions">
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="立刻运行" :loading="runningId === source.id" @click="runNow(source)">
|
||||
<template #icon><n-icon :component="PlayOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
立刻运行
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="编辑" @click="reset(source)">
|
||||
|
||||
Reference in New Issue
Block a user