fix contest conflict.
This commit is contained in:
15
src/admin/user/components/Actions.vue
Normal file
15
src/admin/user/components/Actions.vue
Normal file
@@ -0,0 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import { User } from "~/utils/types"
|
||||
|
||||
interface Props {
|
||||
user: User
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
</script>
|
||||
<template>
|
||||
<n-space align="center">
|
||||
<n-button size="small" secondary type="primary">编辑</n-button>
|
||||
<n-button size="small" secondary type="error">封号</n-button>
|
||||
<n-button size="small" secondary type="default">删除</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
25
src/admin/user/components/Name.vue
Normal file
25
src/admin/user/components/Name.vue
Normal file
@@ -0,0 +1,25 @@
|
||||
<script setup lang="ts">
|
||||
import { User } from "~/utils/types"
|
||||
import { getUserRole } from "~/utils/functions"
|
||||
|
||||
interface Props {
|
||||
user: User
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const isAdmin = computed(() => props.user.admin_type !== "Regular User")
|
||||
</script>
|
||||
<template>
|
||||
<n-space align="center">
|
||||
<n-tag v-if="props.user.is_disabled" type="error" size="small">
|
||||
封号中
|
||||
</n-tag>
|
||||
<n-tag
|
||||
v-if="isAdmin"
|
||||
:type="getUserRole(props.user.admin_type).type"
|
||||
size="small"
|
||||
>
|
||||
{{ getUserRole(props.user.admin_type).tagString }}
|
||||
</n-tag>
|
||||
{{ props.user.username }}
|
||||
</n-space>
|
||||
</template>
|
||||
@@ -1,7 +1,75 @@
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { DataTableColumn } from "naive-ui"
|
||||
import Pagination from "~/shared/Pagination.vue"
|
||||
import { parseTime } from "~/utils/functions"
|
||||
import { User } from "~/utils/types"
|
||||
import { getUserList } from "../api"
|
||||
import Actions from "./components/Actions.vue"
|
||||
import Name from "./components/Name.vue"
|
||||
|
||||
const total = ref(0)
|
||||
const users = ref<User[]>([])
|
||||
const query = reactive({
|
||||
limit: 10,
|
||||
page: 1,
|
||||
keyword: "",
|
||||
})
|
||||
|
||||
const columns: DataTableColumn<User>[] = [
|
||||
{ title: "ID", key: "id", width: 60 },
|
||||
{
|
||||
title: "用户名",
|
||||
key: "username",
|
||||
width: 150,
|
||||
render: (row) => h(Name, { user: row }),
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
key: "create_time",
|
||||
width: 200,
|
||||
render: (row) => parseTime(row.create_time, "YYYY-MM-DD hh:mm:ss"),
|
||||
},
|
||||
{
|
||||
title: "上次登录",
|
||||
key: "last_login",
|
||||
width: 200,
|
||||
render: (row) =>
|
||||
row.last_login
|
||||
? parseTime(row.last_login, "YYYY-MM-DD hh:mm:ss")
|
||||
: "从未登录",
|
||||
},
|
||||
{ title: "真名", key: "real_name", width: 100 },
|
||||
{ title: "邮箱", key: "email", width: 200 },
|
||||
{
|
||||
key: "edit",
|
||||
width: 200,
|
||||
render: (row) => h(Actions, { user: row }),
|
||||
},
|
||||
]
|
||||
|
||||
async function listUsers() {
|
||||
const offset = (query.page - 1) * query.limit
|
||||
const res = await getUserList(offset, query.limit, query.keyword)
|
||||
total.value = res.data.total
|
||||
users.value = res.data.results
|
||||
}
|
||||
|
||||
onMounted(listUsers)
|
||||
watch(query, listUsers, { deep: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>user list</div>
|
||||
<n-form inline label-placement="left">
|
||||
<n-form-item>
|
||||
<n-input placeholder="请输入关键字搜索" v-model:value="query.keyword" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<n-data-table :data="users" :columns="columns" size="small" striped />
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:limit="query.limit"
|
||||
v-model:page="query.page"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user