feat: 重做管理后台的导航、表单和登录页
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, h, onMounted, ref } from "vue";
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import type { DataTableColumns } from "naive-ui";
|
||||
import {
|
||||
NButton,
|
||||
@@ -16,6 +16,7 @@ import LoadFailed from "@/components/LoadFailed.vue";
|
||||
import SecretOnceAlert from "@/components/SecretOnceAlert.vue";
|
||||
import { createToken, deleteToken, listTokens, patchToken, type ApiToken } from "@/api/admin";
|
||||
import { formatLocalMs } from "@/utils/time";
|
||||
import { renderRowActions } from "@/utils/rowActions";
|
||||
import { message } from "@/utils/notify";
|
||||
|
||||
const dialog = useDialog();
|
||||
@@ -68,27 +69,12 @@ const columns = computed<DataTableColumns<ApiToken>>(() => [
|
||||
{
|
||||
title: "操作",
|
||||
key: "actions",
|
||||
width: 200,
|
||||
width: 140,
|
||||
fixed: "right",
|
||||
render: (r) =>
|
||||
h(NSpace, { size: 4 }, () => [
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: "tiny",
|
||||
onClick: () => void onToggle(r),
|
||||
},
|
||||
() => (r.enabled ? "停用" : "启用"),
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
size: "tiny",
|
||||
type: "error",
|
||||
secondary: true,
|
||||
onClick: () => onDelete(r),
|
||||
},
|
||||
() => "删除",
|
||||
),
|
||||
renderRowActions([
|
||||
{ label: r.enabled ? "停用" : "启用", key: "toggle", onSelect: () => void onToggle(r) },
|
||||
{ label: "删除", key: "delete", danger: true, onSelect: () => onDelete(r) },
|
||||
]),
|
||||
},
|
||||
]);
|
||||
@@ -133,7 +119,7 @@ function onDelete(r: ApiToken) {
|
||||
|
||||
<template>
|
||||
<div class="page">
|
||||
<PageHeader title="API 令牌" help="令牌明文只在创建时显示一次;列表不含明文。">
|
||||
<PageHeader title="API 令牌">
|
||||
<template #actions>
|
||||
<n-button type="primary" data-testid="token-create-open" @click="createOpen = true; createName = ''">
|
||||
创建令牌
|
||||
@@ -155,11 +141,13 @@ function onDelete(r: ApiToken) {
|
||||
</div>
|
||||
<div class="page-table">
|
||||
<n-data-table
|
||||
style="height: 100%"
|
||||
flex-height
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:row-key="(r: ApiToken) => r.id"
|
||||
:scroll-x="860"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -204,5 +192,6 @@ function onDelete(r: ApiToken) {
|
||||
.page-table {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user