(event)
| 52 | }; |
| 53 | |
| 54 | const handleFileChange = async (event) => { |
| 55 | const file = event.target.files[0]; |
| 56 | if (!file) return; |
| 57 | |
| 58 | try { |
| 59 | const importedConfig = await importConfig(file); |
| 60 | |
| 61 | Modal.confirm({ |
| 62 | title: t('确认导入配置'), |
| 63 | content: t('导入的配置将覆盖当前设置,是否继续?'), |
| 64 | okText: t('确定导入'), |
| 65 | cancelText: t('取消'), |
| 66 | onOk: () => { |
| 67 | onConfigImport(importedConfig); |
| 68 | Toast.success({ |
| 69 | content: t('配置导入成功'), |
| 70 | duration: 3, |
| 71 | }); |
| 72 | }, |
| 73 | }); |
| 74 | } catch (error) { |
| 75 | Toast.error({ |
| 76 | content: t('导入配置失败: ') + error.message, |
| 77 | duration: 3, |
| 78 | }); |
| 79 | } finally { |
| 80 | // 重置文件输入,允许重复选择同一文件 |
| 81 | event.target.value = ''; |
| 82 | } |
| 83 | }; |
| 84 | |
| 85 | const handleReset = () => { |
| 86 | Modal.confirm({ |
nothing calls this directly
no test coverage detected