From ad2f24707ae6361b38f1eb77336389b5dd7ca548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E8=8F=9C=E7=99=BD=E7=8E=89=E6=B1=A4?= <79054161+Azir-11@users.noreply.github.com> Date: Fri, 14 Jun 2024 18:24:56 +0800 Subject: [PATCH] optimize(utils): Reduce code indentation and improve readability (#496) --- src/plugins/app.ts | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/src/plugins/app.ts b/src/plugins/app.ts index edaeb752..c54601ca 100644 --- a/src/plugins/app.ts +++ b/src/plugins/app.ts @@ -12,40 +12,42 @@ export function setupAppVersionNotification() { const buildTime = await getHtmlBuildTime(); - if (buildTime !== BUILD_TIME) { - isShow = true; - - const n = window.$notification?.create({ - title: $t('system.updateTitle'), - content: $t('system.updateContent'), - action() { - return h('div', { style: { display: 'flex', justifyContent: 'end', gap: '12px', width: '325px' } }, [ - h( - NButton, - { - onClick() { - n?.destroy(); - } - }, - () => $t('system.updateCancel') - ), - h( - NButton, - { - type: 'primary', - onClick() { - location.reload(); - } - }, - () => $t('system.updateConfirm') - ) - ]); - }, - onClose() { - isShow = false; - } - }); + if (buildTime === BUILD_TIME) { + return; } + + isShow = true; + + const n = window.$notification?.create({ + title: $t('system.updateTitle'), + content: $t('system.updateContent'), + action() { + return h('div', { style: { display: 'flex', justifyContent: 'end', gap: '12px', width: '325px' } }, [ + h( + NButton, + { + onClick() { + n?.destroy(); + } + }, + () => $t('system.updateCancel') + ), + h( + NButton, + { + type: 'primary', + onClick() { + location.reload(); + } + }, + () => $t('system.updateConfirm') + ) + ]); + }, + onClose() { + isShow = false; + } + }); }); }