fix: warn when 0 keys imported (#38)

This commit is contained in:
鲁树人 2023-07-02 15:39:14 +01:00
parent f089f92930
commit 60547f0a0a
2 changed files with 16 additions and 4 deletions

View File

@ -49,8 +49,14 @@ export function PanelKWMv2Key() {
const fileBuffer = await file.arrayBuffer();
keys = MMKVParser.parseKuwoEKey(new DataView(fileBuffer));
}
if (keys) {
if (keys?.length === 0) {
toast({
title: '未导入密钥',
description: '选择的密钥数据库文件未发现任何可用的密钥。',
isClosable: true,
status: 'warning',
});
} else if (keys) {
dispatch(kwm2ImportKeys(keys));
setShowImportModal(false);
toast({

View File

@ -71,14 +71,20 @@ export function PanelQMCv2Key() {
qmc2Keys = Array.from(map.entries(), ([name, ekey]) => ({ name: getFileName(name), ekey }));
}
if (qmc2Keys) {
if (qmc2Keys?.length === 0) {
toast({
title: '未导入密钥',
description: '选择的密钥数据库文件未发现任何可用的密钥。',
isClosable: true,
status: 'warning',
});
} else if (qmc2Keys) {
dispatch(qmc2ImportKeys(qmc2Keys));
setShowImportModal(false);
toast({
title: `导入成功 (${qmc2Keys.length})`,
description: '记得保存更改来应用。',
isClosable: true,
duration: 5000,
status: 'success',
});
} else {