refactor: 一批名不副实的命名改掉(只动一端,不碰契约)
后端: - getUserByToken → authenticateToken:它会删会话、续 TTL、记在线,不是纯读 - todayStart → dayStart(instant):本来就接受任意时刻,不只是「今天」 - objectValue → asRecord,删掉 4 份一模一样的私有拷贝和 `as toObject` 别名 - 报错文案 "does not exists" / "Already be a public problem" 改通顺 前端: - utils/types 里 Contest / User / Problem 三个别名删掉:Contest 原来指后台 比赛、契约里同名的却是学生侧。现在 Contest = 学生侧、AdminContest = 后台, 后台用户表单叫 AdminUserForm,题目详情直接用 ProblemDetail - SubmissionInfo → ContestSubmissionInfo,免得和 submission.info 撞名 - utoa / atou → compressToBase64 / decompressFromBase64(实际是 zlib + base64), encode / decode → base64EncodeUtf8 / base64DecodeUtf8 - filterResult → toProblemRow、toProblemListItem → toAdminProblemRow, 行字段 submission / rate → submissionCount / acRate - 组件:Modal → AddFromLibraryModal、Form → EditorToolbar、 ContestEditor → BasicEditor(题单也在用它)、rank 的 Index → RankMedal、 Name → UserNameCell、Password → PasswordCell、ContestType → ContestAccessTag Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
572a818d49
commit
5ae830a7f9
62 files changed
+284
-320
No files matched your search
@@ -1,16 +1,16 @@
|
||||
<script lang="ts" setup>
|
||||
import { editUser } from "admin/api"
|
||||
import type { User } from "utils/types"
|
||||
import type { AdminUserForm } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
user: User
|
||||
user: AdminUserForm
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
(e: "deleteUser", value: number[]): void
|
||||
(e: "userBanned", value: User): void
|
||||
(e: "openEditModal", value: User): void
|
||||
(e: "resetPassword", value: User): void
|
||||
(e: "userBanned", value: AdminUserForm): void
|
||||
(e: "openEditModal", value: AdminUserForm): void
|
||||
(e: "resetPassword", value: AdminUserForm): void
|
||||
}>()
|
||||
|
||||
async function banUser() {
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<script lang="ts" setup>
|
||||
import TextCopy from "shared/components/TextCopy.vue"
|
||||
import { USER_TYPE } from "utils/constants"
|
||||
import type { User } from "utils/types"
|
||||
import type { AdminUserForm } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
user: User
|
||||
user: AdminUserForm
|
||||
revealed: boolean
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { PROBLEM_PERMISSION, USER_TYPE } from "utils/constants"
|
||||
import { getUserRole } from "utils/functions"
|
||||
import type { User } from "utils/types"
|
||||
import type { AdminUserForm } from "utils/types"
|
||||
import TextCopy from "shared/components/TextCopy.vue"
|
||||
|
||||
interface Props {
|
||||
user: User
|
||||
user: AdminUserForm
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
const isNotRegularUser = computed(
|
||||
const hasRoleTag = computed(
|
||||
() => props.user.adminType !== USER_TYPE.REGULAR_USER,
|
||||
)
|
||||
</script>
|
||||
@@ -18,7 +18,7 @@ const isNotRegularUser = computed(
|
||||
封号中
|
||||
</n-tag>
|
||||
<n-tag
|
||||
v-if="isNotRegularUser"
|
||||
v-if="hasRoleTag"
|
||||
:type="getUserRole(props.user.adminType).type"
|
||||
size="small"
|
||||
>
|
||||
@@ -4,7 +4,7 @@ import { DataTableRowKey, NFlex, NTag, SelectOption } from "naive-ui"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { usePagination } from "shared/composables/pagination"
|
||||
import { parseTime } from "utils/functions"
|
||||
import type { User } from "utils/types"
|
||||
import type { AdminUserForm } from "utils/types"
|
||||
import {
|
||||
deleteUsers,
|
||||
editUser,
|
||||
@@ -13,8 +13,8 @@ import {
|
||||
resetPassword,
|
||||
} from "../api"
|
||||
import Actions from "./components/Actions.vue"
|
||||
import Name from "./components/Name.vue"
|
||||
import Password from "./components/Password.vue"
|
||||
import UserNameCell from "./components/UserNameCell.vue"
|
||||
import PasswordCell from "./components/PasswordCell.vue"
|
||||
import { PROBLEM_PERMISSION, USER_TYPE } from "utils/constants"
|
||||
import { useRouteQuery } from "@vueuse/router"
|
||||
import TextCopy from "shared/components/TextCopy.vue"
|
||||
@@ -35,8 +35,8 @@ const { query, clearQuery } = usePagination<UserQuery>({
|
||||
})
|
||||
|
||||
const total = ref(0)
|
||||
const users = ref<User[]>([])
|
||||
const userEditing = ref<User | null>(null)
|
||||
const users = ref<AdminUserForm[]>([])
|
||||
const userEditing = ref<AdminUserForm | null>(null)
|
||||
|
||||
const adminOptions = [
|
||||
{ label: "全部用户", value: "" },
|
||||
@@ -57,16 +57,16 @@ const password = ref("")
|
||||
const revealedPasswords = ref(new Set<number>())
|
||||
const userIDs = ref<DataTableRowKey[]>([])
|
||||
|
||||
const rowKey = (row: User) => row.id
|
||||
const rowKey = (row: AdminUserForm) => row.id
|
||||
|
||||
const columns: DataTableColumn<User>[] = [
|
||||
const columns: DataTableColumn<AdminUserForm>[] = [
|
||||
{ type: "selection" },
|
||||
{ title: "ID", key: "id", width: 80 },
|
||||
{
|
||||
title: "用户名",
|
||||
key: "username",
|
||||
width: 220,
|
||||
render: (row) => h(Name, { user: row }),
|
||||
render: (row) => h(UserNameCell, { user: row }),
|
||||
},
|
||||
{
|
||||
// 显示出来的密码后面还跟着「隐藏」按钮,150 挤得下点点、挤不下密码
|
||||
@@ -74,7 +74,7 @@ const columns: DataTableColumn<User>[] = [
|
||||
key: "raw_password",
|
||||
width: 180,
|
||||
render: (row) =>
|
||||
h(Password, {
|
||||
h(PasswordCell, {
|
||||
user: row,
|
||||
revealed: revealedPasswords.value.has(row.id),
|
||||
onToggle: (id: number) => {
|
||||
@@ -165,7 +165,7 @@ async function onDeleteUsers(userIDs: DataTableRowKey[] | Ref<number[]>) {
|
||||
listUsers()
|
||||
}
|
||||
|
||||
async function onResetPassword(user: User) {
|
||||
async function onResetPassword(user: AdminUserForm) {
|
||||
const res = await resetPassword(user.id)
|
||||
message.success(`【${user.username}】的密码已重置成【${res}】`)
|
||||
users.value = users.value.map((it) => {
|
||||
@@ -176,7 +176,7 @@ async function onResetPassword(user: User) {
|
||||
})
|
||||
}
|
||||
|
||||
async function onUserBanned(user: User) {
|
||||
async function onUserBanned(user: AdminUserForm) {
|
||||
users.value = users.value.map((it) => {
|
||||
if (it.id === user.id) {
|
||||
it.isDisabled = user.isDisabled
|
||||
@@ -209,7 +209,7 @@ function createNewUser() {
|
||||
password.value = ""
|
||||
}
|
||||
|
||||
function onOpenEditModal(user: User) {
|
||||
function onOpenEditModal(user: AdminUserForm) {
|
||||
userEditing.value = user
|
||||
password.value = ""
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user