fix(ai): 随机 UA 按钮可重复点击 (#11)

之前按钮在文本框有内容时被 disabled + onClick 拦截,导致只能生成
一次。移除禁用逻辑,每次点击都覆盖生成新的 UA,符合随机按钮语义。
This commit is contained in:
wshy
2026-06-25 10:54:15 +08:00
committed by GitHub
parent 7c81a03026
commit 3380f97b3a
+3 -4
View File
@@ -224,10 +224,9 @@ export function SettingsAIPanel() {
<input type="text" value={userAgent} onChange={e => setUserAgent(e.target.value)}
placeholder="留空点击「随机生成」或直接粘贴浏览器 UA"
className="flex-1 h-8 px-2.5 rounded-lg bg-base border-0 ring-1 ring-border/30 text-xs font-mono text-foreground placeholder:text-muted/30 focus:outline-none focus:ring-2 focus:ring-accent/30 transition-shadow" />
<button type="button" onClick={() => { if (!userAgent) genRandomUa() }}
title={userAgent ? '已存在内容,清空后可重新生成' : '随机生成浏览器 UA'}
className="h-8 px-2.5 rounded-lg border border-border/50 text-xs text-secondary hover:text-accent hover:border-accent/30 transition-all flex items-center gap-1.5 shrink-0 disabled:opacity-40"
disabled={!!userAgent}>
<button type="button" onClick={genRandomUa}
title="随机生成一条浏览器 UA"
className="h-8 px-2.5 rounded-lg border border-border/50 text-xs text-secondary hover:text-accent hover:border-accent/30 transition-all flex items-center gap-1.5 shrink-0">
<Shuffle className="h-3 w-3" />
</button>
</div>