feat: MBTI头像与用户规则链路升级,三端页面与接口同步
Made-with: Cursor
This commit is contained in:
@@ -44,6 +44,12 @@ interface ListRes {
|
||||
error?: string
|
||||
}
|
||||
|
||||
function confirmDangerousDelete(entity: string): boolean {
|
||||
if (!confirm(`确定删除该${entity}?此操作不可恢复。`)) return false
|
||||
const verifyText = window.prompt(`请输入「删除」以确认删除${entity}`)
|
||||
return verifyText === '删除'
|
||||
}
|
||||
|
||||
export function AdminUsersPage() {
|
||||
const [records, setRecords] = useState<AdminUser[]>([])
|
||||
const [total, setTotal] = useState(0)
|
||||
@@ -72,7 +78,7 @@ export function AdminUsersPage() {
|
||||
pageSize: String(pageSize),
|
||||
})
|
||||
if (debouncedSearch.trim()) params.set('search', debouncedSearch.trim())
|
||||
const data = await get<ListRes>(`/api/admin/admin-users?${params}`)
|
||||
const data = await get<ListRes>(`/api/admin/users?${params}`)
|
||||
if (data?.success) {
|
||||
setRecords((data as ListRes).records || [])
|
||||
setTotal((data as ListRes).total ?? 0)
|
||||
@@ -130,7 +136,7 @@ export function AdminUsersPage() {
|
||||
setSaving(true)
|
||||
try {
|
||||
if (editingUser) {
|
||||
const data = await put<{ success?: boolean; error?: string }>('/api/admin/admin-users', {
|
||||
const data = await put<{ success?: boolean; error?: string }>('/api/admin/users', {
|
||||
id: editingUser.id,
|
||||
password: formPassword || undefined,
|
||||
name: formName.trim(),
|
||||
@@ -144,7 +150,7 @@ export function AdminUsersPage() {
|
||||
setError(data?.error || '保存失败')
|
||||
}
|
||||
} else {
|
||||
const data = await post<{ success?: boolean; error?: string }>('/api/admin/admin-users', {
|
||||
const data = await post<{ success?: boolean; error?: string }>('/api/admin/users', {
|
||||
username: formUsername.trim(),
|
||||
password: formPassword,
|
||||
name: formName.trim(),
|
||||
@@ -166,9 +172,12 @@ export function AdminUsersPage() {
|
||||
}
|
||||
|
||||
const handleDelete = async (id: number) => {
|
||||
if (!confirm('确定删除该管理员?')) return
|
||||
if (!confirmDangerousDelete('管理员')) {
|
||||
setError('已取消删除')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await del<{ success?: boolean; error?: string }>(`/api/admin/admin-users?id=${id}`)
|
||||
const data = await del<{ success?: boolean; error?: string }>(`/api/admin/users?id=${id}`)
|
||||
if (data?.success) loadList()
|
||||
else setError(data?.error || '删除失败')
|
||||
} catch (e: unknown) {
|
||||
|
||||
Reference in New Issue
Block a user