fix: 管理页改成和 EunivTools 一样的页头和表格
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { NButton, NDataTable, NModal, NSelect } from "naive-ui";
|
||||
import { NButton, NModal, NSelect } from "naive-ui";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import LoginView from "../auth/LoginView.vue";
|
||||
import { api } from "../../shared/http";
|
||||
@@ -8,21 +8,10 @@ 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 ? "未退出" : "已退出",
|
||||
}));
|
||||
accounts.value = result.accounts;
|
||||
}
|
||||
|
||||
async function setRole(id: number, role: string) {
|
||||
@@ -40,18 +29,41 @@ onMounted(load);
|
||||
|
||||
<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>
|
||||
<section class="page admin-page">
|
||||
<header class="page-head">
|
||||
<h2>账号池</h2>
|
||||
<n-button type="primary" @click="show = true">添加账号</n-button>
|
||||
</header>
|
||||
<div class="admin-scroll">
|
||||
<table v-if="accounts.length" class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>账号</th>
|
||||
<th>姓名</th>
|
||||
<th>地市</th>
|
||||
<th>凭证</th>
|
||||
<th>登录</th>
|
||||
<th>角色</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="account in accounts" :key="account.id">
|
||||
<td>{{ account.loginId }}</td>
|
||||
<td>{{ account.userName }}</td>
|
||||
<td>{{ account.cityName }}</td>
|
||||
<td>{{ account.credentialValid ? "有效" : "失效" }}</td>
|
||||
<td>{{ account.sessionOpen ? "未退出" : "已退出" }}</td>
|
||||
<td>
|
||||
<n-select :value="account.role" size="small" style="width: 120px" :options="[{ label: '用户', value: 'user' }, { label: '管理员', value: 'admin' }]" @update:value="(value) => setRole(account.id, value)" />
|
||||
</td>
|
||||
<td><n-button size="small" quaternary @click="remove(account.id)">删除</n-button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-else class="admin-status">没有账号</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<n-modal v-model:show="show" preset="card" title="添加账号" style="width: 520px">
|
||||
<LoginView purpose="pool" @done="show = false; load()" />
|
||||
</n-modal>
|
||||
|
||||
Reference in New Issue
Block a user