修复(#55): 修复前端 lint/build 失败阻塞质量门禁
Build and Release / Build (push) Has been cancelled

This commit is contained in:
2026-05-25 22:03:36 -07:00
parent 71aaa08230
commit 37ceb5adfc
13 changed files with 75 additions and 82 deletions
@@ -2,7 +2,12 @@ import { Button } from "@workspace/ui/components/button";
import { Input } from "@workspace/ui/components/input";
import { Icon } from "@workspace/ui/composed/icon";
import { generateCaptcha } from "@workspace/ui/services/common/auth";
import { useEffect, useImperativeHandle, useState } from "react";
import {
type RefObject,
useEffect,
useImperativeHandle,
useState,
} from "react";
import { useTranslation } from "react-i18next";
export interface LocalCaptchaRef {
@@ -10,7 +10,13 @@ import {
generateCaptcha,
verifyCaptchaSlider,
} from "@workspace/ui/services/common/auth";
import { useCallback, useImperativeHandle, useRef, useState } from "react";
import {
type RefObject,
useCallback,
useImperativeHandle,
useRef,
useState,
} from "react";
import { useTranslation } from "react-i18next";
export interface SliderCaptchaRef {
@@ -27,23 +27,52 @@ const FormSchema = z.object({
enable_balance_notify: z.boolean(),
enable_login_notify: z.boolean(),
enable_subscribe_notify: z.boolean(),
// enable_trade_notify: z.boolean(),
enable_trade_notify: z.boolean(),
});
type NotifyFormValues = z.infer<typeof FormSchema>;
const notificationFields = [
{
name: "enable_balance_notify",
labelKey: "notify.balanceChange",
fallbackLabel: "Balance Change",
},
{
name: "enable_login_notify",
labelKey: "notify.login",
fallbackLabel: "Login",
},
{
name: "enable_subscribe_notify",
labelKey: "notify.subscribe",
fallbackLabel: "Subscribe",
},
{
name: "enable_trade_notify",
labelKey: "notify.finance",
fallbackLabel: "Finance",
},
] satisfies Array<{
name: keyof NotifyFormValues;
labelKey: string;
fallbackLabel: string;
}>;
export default function NotifySettings() {
const { t } = useTranslation("profile");
const { user, getUserInfo } = useGlobalStore();
const form = useForm<z.infer<typeof FormSchema>>({
const form = useForm<NotifyFormValues>({
resolver: zodResolver(FormSchema),
defaultValues: {
enable_balance_notify: user?.enable_balance_notify ?? false,
enable_login_notify: user?.enable_login_notify ?? false,
enable_subscribe_notify: user?.enable_subscribe_notify ?? false,
// enable_trade_notify: user?.enable_trade_notify ?? false,
enable_trade_notify: user?.enable_trade_notify ?? false,
},
});
async function onSubmit(data: z.infer<typeof FormSchema>) {
async function onSubmit(data: NotifyFormValues) {
await updateUserNotify(data);
toast.success(t("notify.updateSuccess", "Update Successful"));
await getUserInfo();
@@ -67,32 +96,15 @@ export default function NotifySettings() {
onSubmit={form.handleSubmit(onSubmit)}
>
<div className="space-y-4">
{[
{
name: "enable_balance_notify",
label: t("notify.balanceChange", "Balance Change"),
},
{
name: "enable_login_notify",
label: t("notify.login", "Login"),
},
{
name: "enable_subscribe_notify",
label: t("notify.subscribe", "Subscribe"),
},
// {
// name: "enable_trade_notify",
// label: t("notify.finance", "Finance"),
// },
].map(({ name, label }) => (
{notificationFields.map(({ fallbackLabel, labelKey, name }) => (
<FormField
control={form.control}
key={name}
name={name as any}
name={name}
render={({ field }) => (
<FormItem className="flex items-center justify-between space-x-4">
<FormLabel className="text-muted-foreground">
{label}
{t(labelKey, fallbackLabel)}
</FormLabel>
<FormControl>
<Switch