improves password prompt validation

This commit is contained in:
oiov
2025-04-07 16:46:02 +08:00
parent 2e82d5fc42
commit 185ebd2910
6 changed files with 2565 additions and 7 deletions
+6 -5
View File
@@ -53,10 +53,9 @@ export default function PasswordPrompt() {
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (slug && !isLoading) {
// 防止重复提交
setIsLoading(true); // 开始加载
const fullPassword = password.join("");
const fullPassword = password.join("");
if (slug && !isLoading && fullPassword.length === 6) {
setIsLoading(true);
router.push(`/s/${slug}?password=${encodeURIComponent(fullPassword)}`);
}
};
@@ -131,7 +130,9 @@ export default function PasswordPrompt() {
type="submit"
variant={"default"}
className="flex items-center gap-2"
disabled={isLoading} // 禁用按钮防止重复点击
disabled={
!(slug && !isLoading && password.join("").length === 6)
}
>
{isLoading ? (
<Icons.spinner className="size-4 animate-spin" />
+101 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long