fix(webui): 替换uuid依赖,解决http环境下无法生成密钥的问题。

原生的`crypto.randomUUID()`只支持https和localhost的安全上下文环境。
This commit is contained in:
topkill
2026-04-25 19:19:17 +08:00
parent e4a4b0ac0b
commit c4cdce46c2
3 changed files with 19 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import { X } from 'lucide-react'
import { v4 as uuidv4 } from 'uuid'
export default function AddKeyModal({ show, t, editingKey, newKey, setNewKey, loading, onClose, onAdd }) {
if (!show) {
@@ -32,7 +33,7 @@ export default function AddKeyModal({ show, t, editingKey, newKey, setNewKey, lo
{!isEditing && (
<button
type="button"
onClick={() => setNewKey({ ...newKey, key: 'sk-' + crypto.randomUUID().replace(/-/g, '') })}
onClick={() => setNewKey({ ...newKey, key: 'sk-' + uuidv4().replace(/-/g, '') })}
className="px-3 py-2 bg-secondary text-secondary-foreground rounded-lg hover:bg-secondary/80 transition-colors text-sm font-medium border border-border whitespace-nowrap"
>
{t('accountManager.generate')}