refactor: batch 3

This commit is contained in:
鲁树人 committed 2025-05-18 02:41:20 +09:00
1 parent 75b43e1e84
commit 2e4e57be45
52 files changed
+933 -1136

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
export function applyTemplate(tpl: string, values: Record<string, unknown>) {
return tpl.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, key) => (Object.hasOwn(values, key) ? String(values[key]) : ''));
}
+28
View File
@@ -0,0 +1,28 @@
import { toast } from 'react-toastify';
export function toastImportResult(name: string, keys: unknown[] | null) {
if (keys?.length === 0) {
toast.warning(() => (
<div className="flex flex-col">
<h3 className="text-lg font-bold">未导入密钥</h3>
<div>选择的密钥数据库文件未发现任何可用的密钥。</div>
</div>
));
} else if (keys) {
toast.success(() => (
<div className="flex flex-col">
<h3 className="text-lg font-bold">成功导入 {keys.length} 个密钥。</h3>
<div>记得按下「保存」来应用。</div>
</div>
));
} else {
toast.error(() => (
<div className="flex flex-col">
<h3 className="text-lg font-bold">未导入密钥</h3>
<div>
不支持从提供的密钥文件 <code>{name}</code> 导入密钥。
</div>
</div>
));
}
}