Update Local Permission Assignments

This commit is contained in:
2026-02-03 18:48:25 +08:00
parent 86b3e4402c
commit 47e1411390
13 changed files with 94 additions and 147 deletions

View File

@@ -29,6 +29,7 @@ const userFormSchema = z.object({
password: z.string().optional(),
is_active: z.boolean(),
is_superuser: z.boolean(),
can_use_local_model: z.boolean(),
})
type UserFormValues = z.infer<typeof userFormSchema>
@@ -58,6 +59,7 @@ export function UserDialog({
password: '',
is_active: true,
is_superuser: false,
can_use_local_model: false,
},
})
@@ -69,6 +71,7 @@ export function UserDialog({
password: '',
is_active: user.is_active,
is_superuser: user.is_superuser,
can_use_local_model: user.can_use_local_model,
})
} else {
form.reset({
@@ -77,6 +80,7 @@ export function UserDialog({
password: '',
is_active: true,
is_superuser: false,
can_use_local_model: false,
})
}
}, [user, form])
@@ -178,6 +182,27 @@ export function UserDialog({
)}
/>
<FormField
control={form.control}
name="can_use_local_model"
render={({ field }) => (
<FormItem className="flex flex-row items-start space-x-3 space-y-0">
<FormControl>
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
<div className="space-y-1 leading-none">
<FormLabel></FormLabel>
<p className="text-xs text-muted-foreground">
使 TTS
</p>
</div>
</FormItem>
)}
/>
<DialogFooter className="flex-col sm:flex-row gap-2">
<Button
type="button"

View File

@@ -38,6 +38,7 @@ export function UserTable({ users, isLoading, onEdit, onDelete }: UserTableProps
<th className="px-4 py-3 font-medium"></th>
<th className="px-4 py-3 font-medium"></th>
<th className="px-4 py-3 font-medium"></th>
<th className="px-4 py-3 font-medium"></th>
<th className="px-4 py-3 font-medium"></th>
<th className="px-4 py-3 font-medium text-right"></th>
</tr>
@@ -58,6 +59,11 @@ export function UserTable({ users, isLoading, onEdit, onDelete }: UserTableProps
{user.is_superuser ? '超级管理员' : '普通用户'}
</Badge>
</td>
<td className="px-4 py-3">
{(user.is_superuser || user.can_use_local_model) && (
<Badge variant="secondary"></Badge>
)}
</td>
<td className="px-4 py-3">
{new Date(user.created_at).toLocaleString('zh-CN')}
</td>
@@ -129,6 +135,14 @@ export function UserTable({ users, isLoading, onEdit, onDelete }: UserTableProps
{user.is_superuser ? '超级管理员' : '普通用户'}
</Badge>
</div>
<div className="flex justify-between items-center">
<span className="text-muted-foreground">:</span>
{(user.is_superuser || user.can_use_local_model) ? (
<Badge variant="secondary"></Badge>
) : (
<span className="text-xs text-muted-foreground"></span>
)}
</div>
<div className="flex justify-between">
<span className="text-muted-foreground">:</span>
<span className="text-xs">{new Date(user.created_at).toLocaleString('zh-CN')}</span>