feat: 完成登录与栅格下载桌面端
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { NAlert, NButton, NIcon, NInput, NSpin, NTooltip } from "naive-ui";
|
||||
import { HelpCircleOutline, MoonOutline, SunnyOutline } from "@vicons/ionicons5";
|
||||
import { ApiError } from "../../shared/http";
|
||||
import { loadCaptcha, login, refreshCaptcha, sendSms, type UserInfo } from "./api";
|
||||
import { isDark, toggleTheme } from "../../shared/theme";
|
||||
|
||||
const emit = defineEmits<{ success: [user: UserInfo] }>();
|
||||
|
||||
const ready = ref(false);
|
||||
const offline = ref("");
|
||||
const sessionId = ref("");
|
||||
const captchaUrl = ref("");
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
const captcha = ref("");
|
||||
const smsCode = ref("");
|
||||
const smsRequired = ref(false);
|
||||
const sending = ref(false);
|
||||
const submitting = ref(false);
|
||||
const errorText = ref("");
|
||||
const smsHint = ref("");
|
||||
const countdown = ref(0);
|
||||
let timer = 0;
|
||||
|
||||
onMounted(() => {
|
||||
void connect();
|
||||
});
|
||||
|
||||
async function connect() {
|
||||
offline.value = "";
|
||||
ready.value = false;
|
||||
for (let attempt = 0; attempt < 20; attempt += 1) {
|
||||
try {
|
||||
const result = await loadCaptcha();
|
||||
sessionId.value = result.sessionId;
|
||||
captchaUrl.value = result.captcha;
|
||||
ready.value = true;
|
||||
return;
|
||||
} catch (error) {
|
||||
const failedLocally = !(error instanceof ApiError) || error.status === 0;
|
||||
offline.value = error instanceof ApiError ? error.message : "连接失败";
|
||||
if (!failedLocally) {
|
||||
ready.value = true;
|
||||
return;
|
||||
}
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadCaptcha() {
|
||||
errorText.value = "";
|
||||
try {
|
||||
if (!sessionId.value) {
|
||||
await connect();
|
||||
return;
|
||||
}
|
||||
const result = await refreshCaptcha(sessionId.value);
|
||||
captchaUrl.value = result.captcha;
|
||||
captcha.value = "";
|
||||
} catch (error) {
|
||||
errorText.value = error instanceof ApiError ? error.message : "验证码刷新失败";
|
||||
await connect();
|
||||
}
|
||||
}
|
||||
|
||||
async function requestSms() {
|
||||
if (!sessionId.value || countdown.value > 0) return;
|
||||
sending.value = true;
|
||||
smsHint.value = "";
|
||||
try {
|
||||
const result = await sendSms(sessionId.value);
|
||||
smsHint.value = result.message || "短信已发送";
|
||||
countdown.value = 60;
|
||||
timer = window.setInterval(() => {
|
||||
countdown.value -= 1;
|
||||
if (countdown.value <= 0) window.clearInterval(timer);
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
errorText.value = error instanceof ApiError ? error.message : "短信发送失败";
|
||||
} finally {
|
||||
sending.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
errorText.value = "";
|
||||
submitting.value = true;
|
||||
try {
|
||||
const result = await login({
|
||||
sessionId: sessionId.value,
|
||||
username: username.value.trim(),
|
||||
password: password.value,
|
||||
captcha: captcha.value.trim(),
|
||||
smsCode: smsCode.value.trim(),
|
||||
});
|
||||
if (result.status === "sms_required") {
|
||||
smsRequired.value = true;
|
||||
smsHint.value = result.message || "请获取并填写短信验证码";
|
||||
return;
|
||||
}
|
||||
if (result.user) emit("success", result.user);
|
||||
} catch (error) {
|
||||
errorText.value = error instanceof ApiError ? error.message : "登录失败";
|
||||
smsRequired.value = false;
|
||||
await reloadCaptcha();
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="gate">
|
||||
<n-button class="theme-switch" quaternary circle :aria-label="isDark ? '切换到日间' : '切换到夜间'" @click="toggleTheme">
|
||||
<template #icon><n-icon><MoonOutline v-if="!isDark" /><SunnyOutline v-else /></n-icon></template>
|
||||
</n-button>
|
||||
<section class="gate-card">
|
||||
<div class="brand">
|
||||
<div class="brand-mark" aria-hidden="true">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M4 16.5 12 4l8 12.5" stroke="currentColor" stroke-width="1.8" />
|
||||
<path d="M7.2 16.5h9.6M9.2 13.2h5.6" stroke="currentColor" stroke-width="1.8" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h1>NqiTools</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<n-spin :show="!ready && !offline">
|
||||
<n-alert v-if="!ready" type="warning" style="margin-bottom: 12px">连接失败,正在重试。</n-alert>
|
||||
<n-alert v-else-if="offline" type="warning" style="margin-bottom: 12px">{{ offline }}</n-alert>
|
||||
<n-alert v-if="errorText" type="error" style="margin-bottom: 12px">{{ errorText }}</n-alert>
|
||||
<form @submit.prevent="submit">
|
||||
<div class="form-row">
|
||||
<label for="username">账号</label>
|
||||
<n-input id="username" v-model:value="username" placeholder="账号" autocomplete="username" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="password">密码</label>
|
||||
<n-input id="password" v-model:value="password" type="password" show-password-on="click" placeholder="密码" autocomplete="current-password" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="captcha">
|
||||
验证码
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-icon class="hint" :size="15"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
点击图片刷新。
|
||||
</n-tooltip>
|
||||
</label>
|
||||
<div class="captcha-line">
|
||||
<n-input id="captcha" v-model:value="captcha" placeholder="验证码" />
|
||||
<img v-if="captchaUrl" :src="captchaUrl" alt="验证码" title="点击刷新" @click="reloadCaptcha" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="smsRequired" class="form-row">
|
||||
<label for="sms">短信</label>
|
||||
<div class="captcha-line">
|
||||
<n-input id="sms" v-model:value="smsCode" placeholder="短信验证码" />
|
||||
<n-button :disabled="sending || countdown > 0" @click="requestSms">
|
||||
{{ countdown > 0 ? `${countdown}s` : "获取短信" }}
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="smsHint" class="file-name" style="margin: 0 0 8px 96px">{{ smsHint }}</p>
|
||||
<div class="gate-actions">
|
||||
<n-button type="primary" attr-type="submit" :loading="submitting" :disabled="!ready">登录</n-button>
|
||||
</div>
|
||||
</form>
|
||||
</n-spin>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,43 @@
|
||||
import { api } from "../../shared/http";
|
||||
|
||||
export interface UserInfo {
|
||||
loginId: string;
|
||||
userName: string;
|
||||
cityName: string;
|
||||
orgName: string;
|
||||
}
|
||||
|
||||
export function loadCaptcha() {
|
||||
return api<{ sessionId: string; captcha: string }>("/api/auth/captcha", { method: "POST" });
|
||||
}
|
||||
|
||||
export function refreshCaptcha(sessionId: string) {
|
||||
return api<{ sessionId: string; captcha: string }>("/api/auth/captcha/refresh", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ sessionId }),
|
||||
});
|
||||
}
|
||||
|
||||
export function sendSms(sessionId: string) {
|
||||
return api<{ message: string }>("/api/auth/sms", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ sessionId }),
|
||||
});
|
||||
}
|
||||
|
||||
export function login(body: {
|
||||
sessionId: string;
|
||||
username: string;
|
||||
password: string;
|
||||
captcha: string;
|
||||
smsCode?: string;
|
||||
}) {
|
||||
return api<{ status: string; message?: string; user?: UserInfo }>("/api/auth/login", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
return api<{ ok: boolean }>("/api/auth/logout", { method: "POST" });
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
||||
import { NButton, NEmpty, NIcon, NProgress, NTag, useMessage } from "naive-ui";
|
||||
import { FolderOpenOutline, PlayOutline, StopCircleOutline } from "@vicons/ionicons5";
|
||||
import { ApiError, openLocal } from "../../shared/http";
|
||||
import { cancelJob, loadJobs, resumeJob, type DownloadJob } from "./api";
|
||||
|
||||
const props = defineProps<{ focusId: string }>();
|
||||
const message = useMessage();
|
||||
const jobs = ref<DownloadJob[]>([]);
|
||||
const tab = ref<"active" | "done">("active");
|
||||
let timer = 0;
|
||||
|
||||
const activeJobs = computed(() => jobs.value.filter((job) => job.status !== "done"));
|
||||
const doneJobs = computed(() => jobs.value.filter((job) => job.status === "done"));
|
||||
const visible = computed(() => (tab.value === "active" ? activeJobs.value : doneJobs.value));
|
||||
|
||||
const statusText: Record<string, string> = {
|
||||
queued: "等待中",
|
||||
running: "下载中",
|
||||
cancelled: "已停止",
|
||||
error: "出错",
|
||||
done_with_errors: "部分失败",
|
||||
done: "已完成",
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void refresh();
|
||||
timer = window.setInterval(() => void refresh(), 1000);
|
||||
});
|
||||
|
||||
onUnmounted(() => window.clearInterval(timer));
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
const result = await loadJobs();
|
||||
jobs.value = result.jobs;
|
||||
} catch (error) {
|
||||
if (error instanceof ApiError && error.status !== 0) message.error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function percent(job: DownloadJob) {
|
||||
if (!job.total) return 0;
|
||||
return Math.min(100, Math.round((job.completed / job.total) * 100));
|
||||
}
|
||||
|
||||
async function stop(job: DownloadJob) {
|
||||
try {
|
||||
await cancelJob(job.id);
|
||||
await refresh();
|
||||
} catch (error) {
|
||||
message.error(error instanceof ApiError ? error.message : "停止失败");
|
||||
}
|
||||
}
|
||||
|
||||
async function resume(job: DownloadJob) {
|
||||
try {
|
||||
await resumeJob(job.id);
|
||||
tab.value = "active";
|
||||
await refresh();
|
||||
} catch (error) {
|
||||
message.error(error instanceof ApiError ? error.message : "继续失败");
|
||||
}
|
||||
}
|
||||
|
||||
async function openFile(job: DownloadJob) {
|
||||
const opened = await openLocal(job.csvPath).catch(() => false);
|
||||
if (!opened) message.info(job.csvPath);
|
||||
}
|
||||
|
||||
async function openDir(job: DownloadJob) {
|
||||
const index = Math.max(job.csvPath.lastIndexOf("\\"), job.csvPath.lastIndexOf("/"));
|
||||
const folder = index > 0 ? job.csvPath.slice(0, index) : job.csvPath;
|
||||
const opened = await openLocal(folder).catch(() => false);
|
||||
if (!opened) message.info(folder);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h2>下载管理</h2>
|
||||
</div>
|
||||
</header>
|
||||
<div class="tabs">
|
||||
<button class="tab" :class="{ on: tab === 'active' }" type="button" @click="tab = 'active'">
|
||||
正在下载<em>{{ activeJobs.length }}</em>
|
||||
</button>
|
||||
<button class="tab" :class="{ on: tab === 'done' }" type="button" @click="tab = 'done'">
|
||||
已完成<em>{{ doneJobs.length }}</em>
|
||||
</button>
|
||||
</div>
|
||||
<div class="task-list">
|
||||
<article
|
||||
v-for="job in visible"
|
||||
:key="job.id"
|
||||
class="task"
|
||||
:class="{ focus: job.id === props.focusId }"
|
||||
>
|
||||
<div class="task-top">
|
||||
<div>
|
||||
<h3>{{ job.name }}</h3>
|
||||
<div class="sub">{{ job.completed }}/{{ job.total }} 个栅格 · 已写入 {{ job.writtenRows }} 行</div>
|
||||
</div>
|
||||
<div class="task-actions">
|
||||
<n-tag size="small" :type="job.status === 'running' ? 'info' : job.status === 'done' ? 'success' : 'warning'">
|
||||
{{ statusText[job.status] || job.status }}
|
||||
</n-tag>
|
||||
<n-button v-if="job.status === 'running' || job.status === 'queued'" size="small" @click="stop(job)">
|
||||
<template #icon><n-icon><StopCircleOutline /></n-icon></template>
|
||||
停止
|
||||
</n-button>
|
||||
<n-button v-else-if="job.status !== 'done'" size="small" type="primary" secondary @click="resume(job)">
|
||||
<template #icon><n-icon><PlayOutline /></n-icon></template>
|
||||
继续
|
||||
</n-button>
|
||||
<n-button size="small" quaternary @click="openFile(job)">打开</n-button>
|
||||
<n-button size="small" quaternary @click="openDir(job)">
|
||||
<template #icon><n-icon><FolderOpenOutline /></n-icon></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<n-progress
|
||||
style="margin-top: 10px"
|
||||
:percentage="percent(job)"
|
||||
:show-indicator="true"
|
||||
:processing="job.status === 'running'"
|
||||
/>
|
||||
<div class="task-foot">
|
||||
<span class="sub">{{ job.message }}</span>
|
||||
<span class="sub">失败 {{ job.failed }}</span>
|
||||
</div>
|
||||
<ul v-if="job.failures?.length" class="fail-list">
|
||||
<li v-for="item in job.failures.slice(0, 3)" :key="item.id">{{ item.id }}:{{ item.message }}</li>
|
||||
</ul>
|
||||
</article>
|
||||
<n-empty v-if="visible.length === 0" class="empty" :description="tab === 'active' ? '没有正在下载的任务' : '还没有完成的任务'" />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,197 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import {
|
||||
NButton,
|
||||
NCheckbox,
|
||||
NCheckboxGroup,
|
||||
NIcon,
|
||||
NInput,
|
||||
NInputNumber,
|
||||
NSelect,
|
||||
NTooltip,
|
||||
useMessage,
|
||||
} from "naive-ui";
|
||||
import { FolderOpenOutline, HelpCircleOutline } from "@vicons/ionicons5";
|
||||
import { ApiError, chooseDirectory } from "../../shared/http";
|
||||
import { createJob, loadMeta, type Meta } from "./api";
|
||||
|
||||
const emit = defineEmits<{ started: [id: string] }>();
|
||||
const message = useMessage();
|
||||
|
||||
const meta = ref<Meta | null>(null);
|
||||
const network = ref("NR");
|
||||
const cityCode = ref("JM");
|
||||
const month = ref(previousMonth());
|
||||
const concurrency = ref(8);
|
||||
const groups = ref<string[]>([]);
|
||||
const outputDir = ref("");
|
||||
const file = ref<File | null>(null);
|
||||
const submitting = ref(false);
|
||||
|
||||
const networkOptions = [
|
||||
{ label: "5G", value: "NR" },
|
||||
{ label: "4G", value: "LTE" },
|
||||
];
|
||||
|
||||
function previousMonth() {
|
||||
const date = new Date();
|
||||
date.setDate(1);
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
meta.value = await loadMeta();
|
||||
syncGroups();
|
||||
} catch (error) {
|
||||
message.error(error instanceof ApiError ? error.message : "读取下载项目失败");
|
||||
}
|
||||
});
|
||||
|
||||
watch(network, syncGroups);
|
||||
|
||||
function syncGroups() {
|
||||
groups.value = (meta.value?.groups[network.value] || []).map((item) => item.id);
|
||||
}
|
||||
|
||||
function onFile(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
file.value = input.files?.[0] ?? null;
|
||||
}
|
||||
|
||||
async function pickDir() {
|
||||
const selected = await chooseDirectory();
|
||||
if (selected) outputDir.value = selected;
|
||||
}
|
||||
|
||||
async function start() {
|
||||
if (!file.value) {
|
||||
message.warning("请先选择栅格 ID 表");
|
||||
return;
|
||||
}
|
||||
if (!/^\d{4}-(0[1-9]|1[0-2])$/.test(month.value)) {
|
||||
message.warning("月份格式应为 YYYY-MM");
|
||||
return;
|
||||
}
|
||||
const form = new FormData();
|
||||
form.append("file", file.value);
|
||||
form.append("network", network.value);
|
||||
form.append("city_code", cityCode.value);
|
||||
form.append("month", month.value);
|
||||
form.append("groups", JSON.stringify(groups.value));
|
||||
form.append("concurrency", String(concurrency.value || 8));
|
||||
form.append("output_dir", outputDir.value.trim());
|
||||
submitting.value = true;
|
||||
try {
|
||||
const job = await createJob(form);
|
||||
message.success("已开始下载");
|
||||
emit("started", job.id);
|
||||
} catch (error) {
|
||||
message.error(error instanceof ApiError ? error.message : "创建下载失败");
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="page">
|
||||
<div class="page-scroll">
|
||||
<header class="page-head">
|
||||
<div>
|
||||
<h2>栅格下载</h2>
|
||||
</div>
|
||||
<div class="head-actions">
|
||||
<n-button type="primary" :loading="submitting" @click="start">开始下载</n-button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="panel">
|
||||
<div class="form-row">
|
||||
<label>网络</label>
|
||||
<n-select v-model:value="network" :options="networkOptions" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>地市</label>
|
||||
<n-select
|
||||
v-model:value="cityCode"
|
||||
:options="(meta?.cities || []).map((city) => ({ label: city.name, value: city.code }))"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>
|
||||
月份
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-icon class="hint" :size="15"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
例如 2026-09。
|
||||
</n-tooltip>
|
||||
</label>
|
||||
<n-input v-model:value="month" placeholder="YYYY-MM" />
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>
|
||||
并发
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-icon class="hint" :size="15"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
同时下载的栅格数量。
|
||||
</n-tooltip>
|
||||
</label>
|
||||
<n-input-number v-model:value="concurrency" :min="1" :max="32" />
|
||||
</div>
|
||||
<div class="form-row" style="align-items: start">
|
||||
<label>
|
||||
项目
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-icon class="hint" :size="15"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
选择要导出的指标。
|
||||
</n-tooltip>
|
||||
</label>
|
||||
<n-checkbox-group v-model:value="groups">
|
||||
<div v-for="item in meta?.groups[network] || []" :key="item.id" style="margin-bottom: 6px">
|
||||
<n-checkbox :value="item.id">{{ item.label }}</n-checkbox>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-icon class="hint" :size="14" style="margin-left: 4px"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
{{ item.columns.join("、") }}
|
||||
</n-tooltip>
|
||||
</div>
|
||||
</n-checkbox-group>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>
|
||||
区域表
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-icon class="hint" :size="15"><HelpCircleOutline /></n-icon>
|
||||
</template>
|
||||
支持 CSV、TXT、XLSX。
|
||||
</n-tooltip>
|
||||
</label>
|
||||
<div class="captcha-line">
|
||||
<label class="n-button n-button--default-type" style="padding: 0 12px; line-height: 32px; border: 1px solid #d5e0ea; border-radius: 6px; cursor: pointer">
|
||||
选择文件
|
||||
<input type="file" accept=".csv,.txt,.xlsx" hidden @change="onFile" />
|
||||
</label>
|
||||
<span class="file-name">{{ file?.name || "尚未选择" }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>保存到</label>
|
||||
<div class="captcha-line">
|
||||
<n-input v-model:value="outputDir" placeholder="默认目录" />
|
||||
<n-button @click="pickDir">
|
||||
<template #icon><n-icon><FolderOpenOutline /></n-icon></template>
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,51 @@
|
||||
import { api } from "../../shared/http";
|
||||
|
||||
export interface GroupOption {
|
||||
id: string;
|
||||
label: string;
|
||||
columns: string[];
|
||||
}
|
||||
|
||||
export interface Meta {
|
||||
networks: { value: string; label: string }[];
|
||||
cities: { name: string; code: string }[];
|
||||
groups: Record<string, GroupOption[]>;
|
||||
fixed: { grid: string[]; cell: Record<string, string[]> };
|
||||
}
|
||||
|
||||
export interface DownloadJob {
|
||||
id: string;
|
||||
name: string;
|
||||
status: string;
|
||||
message: string;
|
||||
network: string;
|
||||
cityName: string;
|
||||
month: string;
|
||||
total: number;
|
||||
completed: number;
|
||||
failed: number;
|
||||
writtenRows: number;
|
||||
csvPath: string;
|
||||
failures: { id: string; message: string }[];
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export function loadMeta() {
|
||||
return api<Meta>("/api/download/meta");
|
||||
}
|
||||
|
||||
export function loadJobs() {
|
||||
return api<{ jobs: DownloadJob[] }>("/api/download/jobs");
|
||||
}
|
||||
|
||||
export function createJob(form: FormData) {
|
||||
return api<DownloadJob>("/api/download/jobs", { method: "POST", body: form });
|
||||
}
|
||||
|
||||
export function cancelJob(id: string) {
|
||||
return api<DownloadJob>(`/api/download/jobs/${id}/cancel`, { method: "POST" });
|
||||
}
|
||||
|
||||
export function resumeJob(id: string) {
|
||||
return api<DownloadJob>(`/api/download/jobs/${id}/resume`, { method: "POST" });
|
||||
}
|
||||
Reference in New Issue
Block a user