refactor: 合并多语言支持的显示名称字段,优化奖池手动爆发功能的返回数据结构,增强管理端权限控制
This commit is contained in:
@@ -32,16 +32,16 @@ export function AccountSettingsConsole() {
|
||||
|
||||
async function handleUpdateProfile() {
|
||||
if (!nickname.trim()) {
|
||||
toast.error(t("validation.required", { field: t("fields.nickname", { defaultValue: "昵称" }) }));
|
||||
toast.error(t("validation.required", { field: t("fields.nickname") }));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
await putAdminMe({ nickname: nickname.trim() });
|
||||
toast.success(t("actions.updateSuccess", { defaultValue: "更新成功" }));
|
||||
toast.success(t("actions.updateSuccess"));
|
||||
void refreshAdminProfile();
|
||||
} catch (err) {
|
||||
toast.error(err instanceof LotteryApiBizError ? err.message : t("actions.updateFailed", { defaultValue: "更新失败" }));
|
||||
toast.error(err instanceof LotteryApiBizError ? err.message : t("actions.updateFailed"));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -49,21 +49,21 @@ export function AccountSettingsConsole() {
|
||||
|
||||
async function handleUpdatePassword() {
|
||||
if (!password) {
|
||||
toast.error(t("validation.required", { field: t("fields.newPassword", { defaultValue: "新密码" }) }));
|
||||
toast.error(t("validation.required", { field: t("fields.newPassword") }));
|
||||
return;
|
||||
}
|
||||
if (password !== confirmPassword) {
|
||||
toast.error(t("validation.passwordMismatch", { defaultValue: "两次输入的密码不一致" }));
|
||||
toast.error(t("validation.passwordMismatch"));
|
||||
return;
|
||||
}
|
||||
setLoading(true);
|
||||
try {
|
||||
await putAdminMe({ password });
|
||||
toast.success(t("actions.updateSuccess", { defaultValue: "更新成功" }));
|
||||
toast.success(t("actions.updateSuccess"));
|
||||
setPassword("");
|
||||
setConfirmPassword("");
|
||||
} catch (err) {
|
||||
toast.error(err instanceof LotteryApiBizError ? err.message : t("actions.updateFailed", { defaultValue: "更新失败" }));
|
||||
toast.error(err instanceof LotteryApiBizError ? err.message : t("actions.updateFailed"));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -73,68 +73,68 @@ export function AccountSettingsConsole() {
|
||||
<div className="mx-auto flex w-full max-w-4xl flex-col gap-6 p-4 md:p-6 lg:p-8">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h1 className="text-xl font-semibold tracking-tight text-[#13315f]">
|
||||
{t("accountSettings", { defaultValue: "账号设置" })}
|
||||
{t("accountSettings")}
|
||||
</h1>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
{t("accountSettingsDesc", { defaultValue: "管理您的基本账号资料及安全设置。" })}
|
||||
{t("accountSettingsDesc")}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">{t("profileSettings", { defaultValue: "基本资料" })}</CardTitle>
|
||||
<CardTitle className="text-base">{t("profileSettings")}</CardTitle>
|
||||
<CardDescription>
|
||||
{t("profileSettingsDesc", { defaultValue: "更新您的显示名称。" })}
|
||||
{t("profileSettingsDesc")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4 max-w-md">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="nickname">{t("fields.nickname", { defaultValue: "昵称" })}</Label>
|
||||
<Label htmlFor="nickname">{t("fields.nickname")}</Label>
|
||||
<Input
|
||||
id="nickname"
|
||||
value={nickname}
|
||||
onChange={(e) => setNickname(e.target.value)}
|
||||
placeholder={t("placeholders.nickname", { defaultValue: "请输入昵称" })}
|
||||
placeholder={t("placeholders.nickname")}
|
||||
/>
|
||||
</div>
|
||||
<Button onClick={handleUpdateProfile} disabled={loading}>
|
||||
{loading && <Loader2 className="mr-2 size-4 animate-spin" />}
|
||||
{t("actions.save", { defaultValue: "保存修改" })}
|
||||
{t("actions.save")}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">{t("securitySettings", { defaultValue: "安全设置" })}</CardTitle>
|
||||
<CardTitle className="text-base">{t("securitySettings")}</CardTitle>
|
||||
<CardDescription>
|
||||
{t("securitySettingsDesc", { defaultValue: "修改您的登录密码。如不修改请留空。" })}
|
||||
{t("securitySettingsDesc")}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4 max-w-md">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="password">{t("fields.newPassword", { defaultValue: "新密码" })}</Label>
|
||||
<Label htmlFor="password">{t("fields.newPassword")}</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder={t("placeholders.password", { defaultValue: "请输入新密码" })}
|
||||
placeholder={t("placeholders.password")}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="confirm-password">{t("fields.confirmPassword", { defaultValue: "确认密码" })}</Label>
|
||||
<Label htmlFor="confirm-password">{t("fields.confirmPassword")}</Label>
|
||||
<Input
|
||||
id="confirm-password"
|
||||
type="password"
|
||||
value={confirmPassword}
|
||||
onChange={(e) => setConfirmPassword(e.target.value)}
|
||||
placeholder={t("placeholders.confirmPassword", { defaultValue: "请再次输入新密码" })}
|
||||
placeholder={t("placeholders.confirmPassword")}
|
||||
/>
|
||||
</div>
|
||||
<Button onClick={handleUpdatePassword} disabled={loading || !password}>
|
||||
{loading && <Loader2 className="mr-2 size-4 animate-spin" />}
|
||||
{t("actions.updatePassword", { defaultValue: "更新密码" })}
|
||||
{t("actions.updatePassword")}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user