diff options
| author | 灵谦 <miqilin18@gmail.com> | 2022-04-12 22:38:58 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-12 07:38:58 -0700 |
| commit | 127feaaecaa72259645ca14a9d29c3dd829cd304 (patch) | |
| tree | f42a988aeeb5a39f73b5fffb140aad409ec9d6ce /src/App.js | |
| parent | 85539dbe891f84d87f769f322d74d7d1ce50d784 (diff) | |
refactor: optimize some codes (#238)
Diffstat (limited to 'src/App.js')
| -rw-r--r-- | src/App.js | 34 |
1 files changed, 15 insertions, 19 deletions
| @@ -49,26 +49,22 @@ function App() { | |||
| 49 | }); | 49 | }); |
| 50 | return; | 50 | return; |
| 51 | } | 51 | } |
| 52 | 52 | if (settings.password.length < 8 && settings.encryptionMode === 'WPA') { | |
| 53 | if (settings.ssid.length > 0) { | 53 | setErrors({ |
| 54 | if (settings.password.length < 8 && settings.encryptionMode === 'WPA') { | 54 | ...errors, |
| 55 | setErrors({ | 55 | passwordError: t('wifi.alert.password.length.8'), |
| 56 | ...errors, | 56 | }); |
| 57 | passwordError: t('wifi.alert.password.length.8'), | 57 | return; |
| 58 | }); | 58 | } |
| 59 | } else if ( | 59 | if (settings.password.length < 5 && settings.encryptionMode === 'WEP') { |
| 60 | settings.password.length < 5 && | 60 | setErrors({ |
| 61 | settings.encryptionMode === 'WEP' | 61 | ...errors, |
| 62 | ) { | 62 | passwordError: t('wifi.alert.password.length.5'), |
| 63 | setErrors({ | 63 | }); |
| 64 | ...errors, | 64 | return; |
| 65 | passwordError: t('wifi.alert.password.length.5'), | ||
| 66 | }); | ||
| 67 | } else { | ||
| 68 | document.title = 'WiFi Card - ' + settings.ssid; | ||
| 69 | window.print(); | ||
| 70 | } | ||
| 71 | } | 65 | } |
| 66 | document.title = 'WiFi Card - ' + settings.ssid; | ||
| 67 | window.print(); | ||
| 72 | }; | 68 | }; |
| 73 | 69 | ||
| 74 | const onSSIDChange = (ssid) => { | 70 | const onSSIDChange = (ssid) => { |
