feat: 实现已确认的登录、采集和任务导出

This commit is contained in:
2026-10-29 18:11:15 +08:00
parent af91488934
commit 7ed299bbf6
44 changed files with 4546 additions and 2 deletions
+59
View File
@@ -0,0 +1,59 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { NButton, NDataTable, NModal, NSelect } from "naive-ui";
import Shell from "../../shell/Shell.vue";
import LoginView from "../auth/LoginView.vue";
import { api } from "../../shared/http";
interface Account { id: number; loginId: string; userName: string; cityName: string; role: string; sessionOpen: boolean; credentialValid: boolean }
const accounts = ref<Account[]>([]);
const show = ref(false);
const columns = [
{ title: "账号", key: "loginId" },
{ title: "姓名", key: "userName" },
{ title: "地市", key: "cityName" },
{ title: "凭证", key: "validLabel" },
{ title: "登录", key: "openLabel" },
];
async function load() {
const result = await api<{ accounts: Account[] }>("/api/admin/pool");
accounts.value = result.accounts.map((item) => ({
...item,
validLabel: item.credentialValid ? "有效" : "失效",
openLabel: item.sessionOpen ? "未退出" : "已退出",
}));
}
async function setRole(id: number, role: string) {
await api(`/api/admin/pool/${id}/role`, { method: "PUT", body: JSON.stringify({ role }) });
await load();
}
async function remove(id: number) {
await api(`/api/admin/pool/${id}`, { method: "DELETE" });
await load();
}
onMounted(load);
</script>
<template>
<Shell>
<header class="topbar">
<h1>账号池</h1>
<n-button type="primary" @click="show = true">添加账号</n-button>
</header>
<div class="content">
<n-data-table :columns="columns" :data="accounts" :bordered="false" />
<div v-for="account in accounts" :key="account.id" class="row-actions" style="margin-top: 8px">
<span>{{ account.loginId }}</span>
<n-select :value="account.role" size="small" style="width: 120px" :options="[{ label: '用户', value: 'user' }, { label: '管理员', value: 'admin' }]" @update:value="(value) => setRole(account.id, value)" />
<n-button size="small" @click="remove(account.id)">删除</n-button>
</div>
</div>
<n-modal v-model:show="show" preset="card" title="添加账号" style="width: 520px">
<LoginView purpose="pool" @done="show = false; load()" />
</n-modal>
</Shell>
</template>