feat(阶段1): 搬入 ojnext 为 apps/web,未改业务代码

This commit is contained in:
xuyue committed 2026-08-06 21:18:16 -06:00
1 parent 3c975e85ee
commit ae1fb329b5
258 files changed
+40490 -91

No files matched your search

@@ -0,0 +1,55 @@
<script lang="ts" setup>
import { editUser } from "admin/api"
import type { User } from "utils/types"
interface Props {
user: User
}
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
}>()
async function banUser() {
props.user.is_disabled = !props.user.is_disabled
await editUser(props.user)
emit("userBanned", props.user)
}
</script>
<template>
<n-flex>
<n-button
size="small"
type="error"
secondary
@click="$emit('resetPassword', props.user)"
>
重置密码
</n-button>
<n-button
size="small"
type="primary"
secondary
@click="$emit('openEditModal', props.user)"
>
编辑
</n-button>
<n-button
size="small"
secondary
:type="props.user.is_disabled ? 'info' : 'error'"
@click="banUser"
>
{{ props.user.is_disabled ? "解封" : "封号" }}
</n-button>
<n-popconfirm @positive-click="$emit('deleteUser', [props.user.id])">
<template #trigger>
<n-button size="small" secondary type="warning">删除</n-button>
</template>
确定删除这个用户吗?删除后无法恢复!
</n-popconfirm>
</n-flex>
</template>
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { PROBLEM_PERMISSION, USER_TYPE } from "utils/constants"
import { getUserRole } from "utils/functions"
import type { User } from "utils/types"
import TextCopy from "shared/components/TextCopy.vue"
interface Props {
user: User
}
const props = defineProps<Props>()
const isNotRegularUser = computed(
() => props.user.admin_type !== USER_TYPE.REGULAR_USER,
)
</script>
<template>
<n-flex align="center">
<n-tag v-if="props.user.is_disabled" type="error" size="small">
封号中
</n-tag>
<n-tag
v-if="isNotRegularUser"
:type="getUserRole(props.user.admin_type).type"
size="small"
>
{{ getUserRole(props.user.admin_type).label }}
</n-tag>
<n-tag
size="small"
v-if="
props.user.admin_type === USER_TYPE.STUDENT_ADMIN ||
props.user.admin_type === USER_TYPE.TEACHER_ADMIN
"
>
{{
props.user.problem_permission === PROBLEM_PERMISSION.ALL
? "全部"
: "仅自己"
}}
</n-tag>
<TextCopy>{{ props.user.username }}</TextCopy>
</n-flex>
</template>