mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-25 14:56:58 +00:00
refactor: batch 3
This commit is contained in:
1 parent
75b43e1e84
commit
2e4e57be45
52 files changed
+933
-1136
No files matched your search
@@ -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]) : ''));
|
||||
}
|
||||
@@ -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>
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user