feat: enhance player login validation and update betting preview

- Added username and password validation to the player login screen, improving user feedback for input errors.
- Updated the betting preview dialog to conditionally display rebate information based on the applied instant rebate status.
- Enhanced documentation in AGENTS.md to clarify credit flow and settlement processes.
- Modified .env.example to provide clearer instructions for multi-site deployment configurations.
This commit is contained in:
2026-06-14 21:13:24 +08:00
parent 7c283627d3
commit 0b14e77f64
6 changed files with 73 additions and 8 deletions

View File

@@ -15,10 +15,12 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { usePlayerSessionStore } from "@/stores/player-session-store";
import {
validatePlayerLoginPassword,
validatePlayerLoginUsername,
} from "@/lib/player-input-validation";
import { LotteryApiBizError } from "@/types/api/errors";
const DEPLOY_SITE_CODE = process.env.NEXT_PUBLIC_PLAYER_SITE_CODE?.trim() ?? "";
function stripSearchParamFromBrowserUrl(name: string): void {
if (typeof window === "undefined") return;
const url = new URL(window.location.href);
@@ -58,10 +60,27 @@ export function PlayerLoginScreen(): React.ReactElement {
return;
}
const usernameIssue = validatePlayerLoginUsername(username);
if (usernameIssue === "invalid_charset") {
toast.error(
t("login.usernameInvalidCharset", {
defaultValue: "账号只能使用字母、数字、点(.)、下划线和连字符",
}),
);
return;
}
const passwordIssue = validatePlayerLoginPassword(password);
if (passwordIssue === "too_short") {
toast.error(
t("login.passwordMinLength", { defaultValue: "密码至少需要 6 个字符" }),
);
return;
}
setLoading(true);
try {
const data = await postPlayerAuthLogin({
...(DEPLOY_SITE_CODE !== "" ? { site_code: DEPLOY_SITE_CODE } : {}),
username: username.trim(),
password,
});