mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 16:46:37 +08:00
fix(frontend): keep browser API on same-origin rewrites in dev
Document that NEXT_PUBLIC_WAVELET_BACKEND_URL must stay unset for local next dev so axios hits /api/* and Next rewrites proxy to the backend.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -31,6 +32,7 @@ export function CreateUserModal({
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}) {
|
||||
const t = useTranslations('admin.users');
|
||||
const { createUser } = useAdminUsers();
|
||||
const [form, setForm] = useState<CreateUserRequest>(emptyForm);
|
||||
const [saving, setSaving] = useState(false);
|
||||
@@ -48,21 +50,21 @@ export function CreateUserModal({
|
||||
const validate = () => {
|
||||
const newErrors: Record<string, string> = {};
|
||||
if (!form.username.trim()) {
|
||||
newErrors.username = '用户名不能为空';
|
||||
newErrors.username = t('validation.usernameRequired');
|
||||
} else if (form.username.trim().length < 3) {
|
||||
newErrors.username = '用户名长度不能少于 3 位';
|
||||
newErrors.username = t('validation.usernameTooShort');
|
||||
}
|
||||
|
||||
if (!form.email.trim()) {
|
||||
newErrors.email = '邮箱不能为空';
|
||||
newErrors.email = t('validation.emailRequired');
|
||||
} else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email.trim())) {
|
||||
newErrors.email = '邮箱格式不正确';
|
||||
newErrors.email = t('validation.emailInvalid');
|
||||
}
|
||||
|
||||
if (!form.password) {
|
||||
newErrors.password = '密码不能为空';
|
||||
newErrors.password = t('validation.passwordRequired');
|
||||
} else if (form.password.length < 8) {
|
||||
newErrors.password = '密码长度不能少于 8 位';
|
||||
newErrors.password = t('validation.passwordTooShort');
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
@@ -93,22 +95,20 @@ export function CreateUserModal({
|
||||
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
|
||||
<DialogContent className='max-w-md'>
|
||||
<DialogHeader>
|
||||
<DialogTitle>新增用户</DialogTitle>
|
||||
<DialogDescription>
|
||||
直接创建一个本地密码登录的新账户。
|
||||
</DialogDescription>
|
||||
<DialogTitle>{t('createTitle')}</DialogTitle>
|
||||
<DialogDescription>{t('createDesc')}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<form onSubmit={handleSave} className='space-y-4 pt-2'>
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='username'>用户名</Label>
|
||||
<Label htmlFor='username'>{t('username')}</Label>
|
||||
<Input
|
||||
id='username'
|
||||
value={form.username}
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, username: e.target.value }))
|
||||
}
|
||||
placeholder='请输入用户名 (至少 3 位)'
|
||||
placeholder={t('usernamePlaceholder')}
|
||||
/>
|
||||
{errors.username && (
|
||||
<p className='text-xs text-destructive'>{errors.username}</p>
|
||||
@@ -116,19 +116,19 @@ export function CreateUserModal({
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='nickname'>昵称 (选填)</Label>
|
||||
<Label htmlFor='nickname'>{t('nicknameOptional')}</Label>
|
||||
<Input
|
||||
id='nickname'
|
||||
value={form.nickname}
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, nickname: e.target.value }))
|
||||
}
|
||||
placeholder='请输入昵称'
|
||||
placeholder={t('nicknamePlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='email'>邮箱</Label>
|
||||
<Label htmlFor='email'>{t('email')}</Label>
|
||||
<Input
|
||||
id='email'
|
||||
type='email'
|
||||
@@ -136,7 +136,7 @@ export function CreateUserModal({
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, email: e.target.value }))
|
||||
}
|
||||
placeholder='请输入邮箱地址'
|
||||
placeholder={t('emailPlaceholder')}
|
||||
/>
|
||||
{errors.email && (
|
||||
<p className='text-xs text-destructive'>{errors.email}</p>
|
||||
@@ -144,7 +144,7 @@ export function CreateUserModal({
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='password'>密码</Label>
|
||||
<Label htmlFor='password'>{t('password')}</Label>
|
||||
<Input
|
||||
id='password'
|
||||
type='password'
|
||||
@@ -152,7 +152,7 @@ export function CreateUserModal({
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, password: e.target.value }))
|
||||
}
|
||||
placeholder='请输入登录密码 (至少 8 位)'
|
||||
placeholder={t('passwordPlaceholder')}
|
||||
/>
|
||||
{errors.password && (
|
||||
<p className='text-xs text-destructive'>{errors.password}</p>
|
||||
@@ -161,9 +161,11 @@ export function CreateUserModal({
|
||||
|
||||
<div className='flex items-center justify-between rounded-lg border border-dashed p-3 bg-muted/10'>
|
||||
<div>
|
||||
<div className='font-medium text-sm'>启用账户</div>
|
||||
<div className='font-medium text-sm'>
|
||||
{t('enableAccountLabel')}
|
||||
</div>
|
||||
<div className='text-xs text-muted-foreground'>
|
||||
禁用后此账号将无法登录系统。
|
||||
{t('enableAccountDesc')}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
@@ -176,9 +178,9 @@ export function CreateUserModal({
|
||||
|
||||
<div className='flex items-center justify-between rounded-lg border border-dashed p-3 bg-muted/10'>
|
||||
<div>
|
||||
<div className='font-medium text-sm'>管理员权限</div>
|
||||
<div className='font-medium text-sm'>{t('adminPermission')}</div>
|
||||
<div className='text-xs text-muted-foreground'>
|
||||
开启后此账号将拥有后台管理权限。
|
||||
{t('adminPermissionDesc')}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
@@ -191,10 +193,10 @@ export function CreateUserModal({
|
||||
|
||||
<div className='flex justify-end gap-2 pt-2 border-t mt-2'>
|
||||
<Button variant='outline' type='button' onClick={onClose}>
|
||||
取消
|
||||
{t('cancel')}
|
||||
</Button>
|
||||
<Button type='submit' disabled={saving} variant='secondary'>
|
||||
{saving ? '创建中...' : '创建'}
|
||||
{saving ? t('creating') : t('create')}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -43,6 +44,7 @@ export function EditUserModal({
|
||||
onClose: () => void;
|
||||
user: AdminUser | null;
|
||||
}) {
|
||||
const t = useTranslations('admin.users');
|
||||
const { updateUser, deleteUser, getUserDetail } = useAdminUsers();
|
||||
const { user: currentUser } = useAuth();
|
||||
|
||||
@@ -96,13 +98,13 @@ export function EditUserModal({
|
||||
const newErrors: Record<string, string> = {};
|
||||
|
||||
if (!form.email.trim()) {
|
||||
newErrors.email = '邮箱不能为空';
|
||||
newErrors.email = t('validation.emailRequired');
|
||||
} else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email.trim())) {
|
||||
newErrors.email = '邮箱格式不正确';
|
||||
newErrors.email = t('validation.emailInvalid');
|
||||
}
|
||||
|
||||
if (form.password && form.password.length < 8) {
|
||||
newErrors.password = '密码长度不能少于 8 位';
|
||||
newErrors.password = t('validation.passwordTooShort');
|
||||
}
|
||||
|
||||
setErrors(newErrors);
|
||||
@@ -150,10 +152,8 @@ export function EditUserModal({
|
||||
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
|
||||
<DialogContent className='max-w-md'>
|
||||
<DialogHeader>
|
||||
<DialogTitle>编辑用户</DialogTitle>
|
||||
<DialogDescription>
|
||||
修改用户档案、授予/撤销管理权限或重置其密码。
|
||||
</DialogDescription>
|
||||
<DialogTitle>{t('editTitle')}</DialogTitle>
|
||||
<DialogDescription>{t('editDesc')}</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<form onSubmit={handleSave} className='space-y-4 pt-2'>
|
||||
@@ -162,7 +162,7 @@ export function EditUserModal({
|
||||
htmlFor='username'
|
||||
className='text-xs text-muted-foreground'
|
||||
>
|
||||
用户名 (不可修改)
|
||||
{t('usernameImmutable')}
|
||||
</Label>
|
||||
<Input
|
||||
id='username'
|
||||
@@ -173,19 +173,19 @@ export function EditUserModal({
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='nickname'>昵称 (选填)</Label>
|
||||
<Label htmlFor='nickname'>{t('nicknameOptional')}</Label>
|
||||
<Input
|
||||
id='nickname'
|
||||
value={form.nickname}
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, nickname: e.target.value }))
|
||||
}
|
||||
placeholder='请输入昵称'
|
||||
placeholder={t('nicknamePlaceholder')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='email'>邮箱</Label>
|
||||
<Label htmlFor='email'>{t('email')}</Label>
|
||||
<Input
|
||||
id='email'
|
||||
type='email'
|
||||
@@ -193,7 +193,7 @@ export function EditUserModal({
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, email: e.target.value }))
|
||||
}
|
||||
placeholder='请输入邮箱地址'
|
||||
placeholder={t('emailPlaceholder')}
|
||||
/>
|
||||
{errors.email && (
|
||||
<p className='text-xs text-destructive'>{errors.email}</p>
|
||||
@@ -201,7 +201,7 @@ export function EditUserModal({
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<Label htmlFor='password'>重置密码 (选填)</Label>
|
||||
<Label htmlFor='password'>{t('resetPasswordOptional')}</Label>
|
||||
<Input
|
||||
id='password'
|
||||
type='password'
|
||||
@@ -209,7 +209,7 @@ export function EditUserModal({
|
||||
onChange={(e) =>
|
||||
setForm((prev) => ({ ...prev, password: e.target.value }))
|
||||
}
|
||||
placeholder='留空表示保持当前密码,输入则重置 (至少 8 位)'
|
||||
placeholder={t('resetPasswordPlaceholder')}
|
||||
/>
|
||||
{errors.password && (
|
||||
<p className='text-xs text-destructive'>{errors.password}</p>
|
||||
@@ -218,11 +218,13 @@ export function EditUserModal({
|
||||
|
||||
<div className='flex items-center justify-between rounded-lg border border-dashed p-3 bg-muted/10'>
|
||||
<div>
|
||||
<div className='font-medium text-sm'>管理员权限</div>
|
||||
<div className='font-medium text-sm'>
|
||||
{t('adminPermission')}
|
||||
</div>
|
||||
<div className='text-xs text-muted-foreground'>
|
||||
{isSelf
|
||||
? '不能撤销当前登录用户的管理员权限。'
|
||||
: '开启后此账号将拥有后台管理权限。'}
|
||||
? t('cannotRevokeSelfAdmin')
|
||||
: t('adminPermissionDesc')}
|
||||
</div>
|
||||
</div>
|
||||
<Switch
|
||||
@@ -255,7 +257,7 @@ export function EditUserModal({
|
||||
onClick={() => setShowDeleteConfirm(true)}
|
||||
disabled={saving}
|
||||
>
|
||||
删除用户
|
||||
{t('deleteUser')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -266,10 +268,10 @@ export function EditUserModal({
|
||||
onClick={onClose}
|
||||
disabled={saving}
|
||||
>
|
||||
取消
|
||||
{t('cancel')}
|
||||
</Button>
|
||||
<Button type='submit' disabled={saving} variant='secondary'>
|
||||
{saving ? '保存中...' : '保存'}
|
||||
{saving ? t('saving') : t('save')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -280,14 +282,15 @@ export function EditUserModal({
|
||||
<AlertDialog open={showDeleteConfirm} onOpenChange={setShowDeleteConfirm}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>确认删除用户</AlertDialogTitle>
|
||||
<AlertDialogTitle>{t('deleteConfirmTitle')}</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
确定要删除用户 {user.nickname || user.username}{' '}
|
||||
吗?该操作会移除用户账号,删除后无法撤销。
|
||||
{t('deleteConfirmDesc', { name: user.nickname || user.username })}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel disabled={saving}>取消</AlertDialogCancel>
|
||||
<AlertDialogCancel disabled={saving}>
|
||||
{t('cancel')}
|
||||
</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
@@ -296,7 +299,7 @@ export function EditUserModal({
|
||||
disabled={saving}
|
||||
>
|
||||
{saving && <Loader2 className='size-3 animate-spin mr-1' />}
|
||||
确认删除
|
||||
{t('confirmDelete')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import {
|
||||
Globe,
|
||||
Loader2,
|
||||
@@ -33,13 +34,14 @@ export function UserDetailSheet({
|
||||
detailLoading,
|
||||
onStatusToggle,
|
||||
}: UserDetailSheetProps) {
|
||||
const t = useTranslations('admin.users');
|
||||
const displayValue = (value?: string) =>
|
||||
value && value.trim() ? value : '-';
|
||||
|
||||
return (
|
||||
<Sheet open={isOpen} onOpenChange={onOpenChange}>
|
||||
<SheetContent className='sm:max-w-[400px] w-full p-0 flex flex-col gap-0'>
|
||||
<SheetTitle className='px-5 py-3'>用户档案</SheetTitle>
|
||||
<SheetTitle className='px-5 py-3'>{t('userProfile')}</SheetTitle>
|
||||
|
||||
{selectedUser && (
|
||||
<>
|
||||
@@ -79,14 +81,14 @@ export function UserDetailSheet({
|
||||
{detailLoading && (
|
||||
<div className='flex items-center gap-1 text-[10px] text-muted-foreground'>
|
||||
<Loader2 className='size-3 animate-spin' />
|
||||
正在刷新详情
|
||||
{t('refreshingDetail')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='gap-4 w-full max-w-[240px] mt-1 pt-4 border-t border-border/50'>
|
||||
<div className='flex flex-col gap-0.5'>
|
||||
<span className='text-[9px] uppercase tracking-widest text-muted-foreground font-medium'>
|
||||
注册时间
|
||||
{t('registeredAt')}
|
||||
</span>
|
||||
<span className='font-mono text-xs font-semibold'>
|
||||
{
|
||||
@@ -103,13 +105,13 @@ export function UserDetailSheet({
|
||||
<div className='p-6 space-y-6'>
|
||||
<div className='space-y-4'>
|
||||
<h4 className='text-xs font-semibold text-muted-foreground uppercase tracking-wider px-1'>
|
||||
个人资料
|
||||
{t('personalInfo')}
|
||||
</h4>
|
||||
<div className='rounded-lg border divide-y bg-background/50'>
|
||||
<div className='flex items-center justify-between gap-4 p-3.5 text-sm'>
|
||||
<span className='flex items-center gap-2 text-[10px] text-muted-foreground'>
|
||||
<Mail className='size-3' />
|
||||
邮箱
|
||||
{t('email')}
|
||||
</span>
|
||||
<span className='min-w-0 truncate text-right text-[10px]'>
|
||||
{displayValue(selectedUser.email)}
|
||||
@@ -118,7 +120,7 @@ export function UserDetailSheet({
|
||||
<div className='flex items-center justify-between gap-4 p-3.5 text-sm'>
|
||||
<span className='flex items-center gap-2 text-[10px] text-muted-foreground'>
|
||||
<Smartphone className='size-3' />
|
||||
手机
|
||||
{t('phone')}
|
||||
</span>
|
||||
<span className='min-w-0 truncate text-right text-[10px]'>
|
||||
{displayValue(selectedUser.phone)}
|
||||
@@ -129,7 +131,7 @@ export function UserDetailSheet({
|
||||
<span className='size-3 flex items-center justify-center font-bold text-[9px]'>
|
||||
⚧
|
||||
</span>
|
||||
性别
|
||||
{t('gender')}
|
||||
</span>
|
||||
<span className='min-w-0 truncate text-right text-[10px]'>
|
||||
{displayValue(selectedUser.gender)}
|
||||
@@ -138,7 +140,7 @@ export function UserDetailSheet({
|
||||
<div className='flex items-center justify-between gap-4 p-3.5 text-sm'>
|
||||
<span className='flex items-center gap-2 text-[10px] text-muted-foreground'>
|
||||
<MapPin className='size-3' />
|
||||
所在地
|
||||
{t('location')}
|
||||
</span>
|
||||
<span className='min-w-0 truncate text-right text-[10px]'>
|
||||
{displayValue(selectedUser.location)}
|
||||
@@ -147,7 +149,7 @@ export function UserDetailSheet({
|
||||
<div className='flex items-center justify-between gap-4 p-3.5 text-sm'>
|
||||
<span className='flex items-center gap-2 text-[10px] text-muted-foreground'>
|
||||
<Globe className='size-3' />
|
||||
网站
|
||||
{t('website')}
|
||||
</span>
|
||||
<span className='min-w-0 truncate text-right text-[10px]'>
|
||||
{displayValue(selectedUser.website)}
|
||||
@@ -155,7 +157,7 @@ export function UserDetailSheet({
|
||||
</div>
|
||||
<div className='flex flex-col gap-2 p-3.5 text-sm'>
|
||||
<span className='text-[10px] text-muted-foreground'>
|
||||
简介
|
||||
{t('bio')}
|
||||
</span>
|
||||
<span className='break-words text-[10px] leading-5'>
|
||||
{displayValue(selectedUser.bio)}
|
||||
@@ -166,40 +168,44 @@ export function UserDetailSheet({
|
||||
|
||||
<div className='space-y-4'>
|
||||
<h4 className='text-xs font-semibold text-muted-foreground uppercase tracking-wider px-1'>
|
||||
系统记录
|
||||
{t('systemRecords')}
|
||||
</h4>
|
||||
<div className='rounded-lg border divide-y bg-background/50'>
|
||||
<div className='flex items-center justify-between p-3.5 text-sm'>
|
||||
<span className='text-[10px]'>账户状态</span>
|
||||
<span className='text-[10px]'>
|
||||
{t('accountStatus')}
|
||||
</span>
|
||||
<Badge
|
||||
variant={
|
||||
selectedUser.is_active ? 'secondary' : 'outline'
|
||||
}
|
||||
className='text-[10px]'
|
||||
>
|
||||
{selectedUser.is_active ? '正常' : '禁用'}
|
||||
{selectedUser.is_active
|
||||
? t('statusActive')
|
||||
: t('statusDisabled')}
|
||||
</Badge>
|
||||
</div>
|
||||
<div className='flex items-center justify-between p-3.5 text-sm'>
|
||||
<span className='text-[10px]'>管理员</span>
|
||||
<span className='text-[10px]'>{t('isAdmin')}</span>
|
||||
<span className='font-mono text-[10px]'>
|
||||
{selectedUser.is_admin ? '是' : '否'}
|
||||
{selectedUser.is_admin ? t('yes') : t('no')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center justify-between p-3.5 text-sm'>
|
||||
<span className='text-[10px]'>最后登录</span>
|
||||
<span className='text-[10px]'>{t('lastLogin')}</span>
|
||||
<span className='font-mono text-[10px]'>
|
||||
{formatDateTime(selectedUser.last_login_at)}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center justify-between p-3.5 text-sm'>
|
||||
<span className='text-[10px]'>注册时间</span>
|
||||
<span className='text-[10px]'>{t('registeredAt')}</span>
|
||||
<span className='font-mono text-[10px]'>
|
||||
{formatDateTime(selectedUser.created_at)}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center justify-between p-3.5 text-sm'>
|
||||
<span className='text-[10px]'>最后更新</span>
|
||||
<span className='text-[10px]'>{t('lastUpdate')}</span>
|
||||
<span className='font-mono text-[10px]'>
|
||||
{formatDateTime(selectedUser.updated_at)}
|
||||
</span>
|
||||
@@ -219,12 +225,12 @@ export function UserDetailSheet({
|
||||
{selectedUser.is_active ? (
|
||||
<>
|
||||
<ShieldCheck className='size-3 mr-1' />
|
||||
封禁账户
|
||||
{t('banAccount')}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<UserCheck className='size-3 mr-1' />
|
||||
解除封禁
|
||||
{t('unbanAccount')}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import {
|
||||
ChevronDown,
|
||||
ChevronLeft,
|
||||
@@ -24,6 +25,7 @@ import { useAdminUsers } from '@/contexts/admin-users-context';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
export function UserFilterBar() {
|
||||
const t = useTranslations('admin.users');
|
||||
const {
|
||||
total,
|
||||
loading,
|
||||
@@ -61,7 +63,7 @@ export function UserFilterBar() {
|
||||
)}
|
||||
>
|
||||
<Search className='size-3 mr-1' />
|
||||
搜索
|
||||
{t('search')}
|
||||
{hasSearchFilter && (
|
||||
<>
|
||||
<Separator orientation='vertical' className='mx-1' />
|
||||
@@ -79,19 +81,19 @@ export function UserFilterBar() {
|
||||
<div className='space-y-2.5'>
|
||||
<input
|
||||
className='w-full h-7 px-2 text-xs border border-dashed rounded-md outline-none focus:border-primary bg-background'
|
||||
placeholder='输入用户 ID...'
|
||||
placeholder={t('searchUserIdPlaceholder')}
|
||||
value={searchUserId}
|
||||
onChange={(e) => setSearchUserId(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
className='w-full h-7 px-2 text-xs border border-dashed rounded-md outline-none focus:border-primary bg-background'
|
||||
placeholder='输入 username...'
|
||||
placeholder={t('searchUsernamePlaceholder')}
|
||||
value={searchUsername}
|
||||
onChange={(e) => setSearchUsername(e.target.value)}
|
||||
/>
|
||||
<input
|
||||
className='w-full h-7 px-2 text-xs border border-dashed rounded-md outline-none focus:border-primary bg-background'
|
||||
placeholder='输入邮箱...'
|
||||
placeholder={t('searchEmailPlaceholder')}
|
||||
value={searchEmail}
|
||||
onChange={(e) => setSearchEmail(e.target.value)}
|
||||
/>
|
||||
@@ -106,7 +108,7 @@ export function UserFilterBar() {
|
||||
setSearchEmail('');
|
||||
}}
|
||||
>
|
||||
清除
|
||||
{t('clear')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
@@ -124,7 +126,7 @@ export function UserFilterBar() {
|
||||
)}
|
||||
>
|
||||
<Filter className='size-3' />
|
||||
状态
|
||||
{t('status')}
|
||||
{statusFilter !== 'all' && (
|
||||
<>
|
||||
<Separator orientation='vertical' className='mx-1' />
|
||||
@@ -153,7 +155,7 @@ export function UserFilterBar() {
|
||||
: 'opacity-50',
|
||||
)}
|
||||
/>
|
||||
<span className='text-xs'>全部状态</span>
|
||||
<span className='text-xs'>{t('statusAll')}</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onSelect={(e) => {
|
||||
@@ -169,7 +171,7 @@ export function UserFilterBar() {
|
||||
: 'opacity-50',
|
||||
)}
|
||||
/>
|
||||
<span className='text-xs'>正常</span>
|
||||
<span className='text-xs'>{t('statusActive')}</span>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem
|
||||
onSelect={(e) => {
|
||||
@@ -185,7 +187,7 @@ export function UserFilterBar() {
|
||||
: 'opacity-50',
|
||||
)}
|
||||
/>
|
||||
<span className='text-xs'>禁用</span>
|
||||
<span className='text-xs'>{t('statusDisabled')}</span>
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
@@ -205,7 +207,7 @@ export function UserFilterBar() {
|
||||
className='h-5 px-2 lg:px-3 text-[11px] font-medium text-muted-foreground hover:text-foreground'
|
||||
>
|
||||
<X className='size-3' />
|
||||
清空筛选
|
||||
{t('clearFilters')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
@@ -215,7 +217,7 @@ export function UserFilterBar() {
|
||||
|
||||
<div className='flex items-center gap-1.5 self-end lg:self-auto'>
|
||||
<span className='text-[10px] text-muted-foreground whitespace-nowrap'>
|
||||
{total} 条记录
|
||||
{t('totalRecords', { count: total })}
|
||||
</span>
|
||||
<div className='flex items-center border border-dashed rounded-md shadow-none'>
|
||||
<Button
|
||||
@@ -249,7 +251,7 @@ export function UserFilterBar() {
|
||||
className='h-6 border-dashed text-[10px] px-2 font-mono shadow-none'
|
||||
disabled={loading}
|
||||
>
|
||||
{pageSize}条/页
|
||||
{t('perPage', { count: pageSize })}
|
||||
<ChevronDown className='size-3 opacity-50' />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
@@ -263,7 +265,7 @@ export function UserFilterBar() {
|
||||
pageSize === size && 'bg-accent',
|
||||
)}
|
||||
>
|
||||
{size}条/页
|
||||
{t('perPage', { count: size })}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
@@ -275,7 +277,7 @@ export function UserFilterBar() {
|
||||
className='h-6 w-6 border-dashed shadow-none'
|
||||
onClick={() => fetchUsers(true)}
|
||||
disabled={loading}
|
||||
title='刷新数据'
|
||||
title={t('refreshData')}
|
||||
>
|
||||
<Loader2 className={cn('size-3', loading && 'animate-spin')} />
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user