浏览代码

fix(nginx-status): improve error handling

0xJacky 7 小时之前
父节点
当前提交
59b5fa6a69
共有 2 个文件被更改,包括 27 次插入17 次删除
  1. 4 0
      app/src/components/NginxControl/NginxControl.vue
  2. 23 17
      app/src/views/other/Login.vue

+ 4 - 0
app/src/components/NginxControl/NginxControl.vue

@@ -51,6 +51,10 @@ watch(visible, v => {
   if (v)
     getStatus()
 })
+
+onMounted(() => {
+  getStatus()
+})
 </script>
 
 <template>

+ 23 - 17
app/src/views/other/Login.vue

@@ -183,26 +183,32 @@ const passkeyLoginLoading = ref(false)
 async function handlePasskeyLogin() {
   passkeyLoginLoading.value = true
 
-  const begin = await auth.begin_passkey_login()
-  const asseResp = await startAuthentication({ optionsJSON: begin.options.publicKey })
+  try {
+    const begin = await auth.begin_passkey_login()
+    const asseResp = await startAuthentication({ optionsJSON: begin.options.publicKey })
 
-  const r = await auth.finish_passkey_login({
-    session_id: begin.session_id,
-    options: asseResp,
-  })
-
-  if (r.token) {
-    await handleLoginSuccess({
-      token: r.token,
-      shortToken: r.short_token,
-      secureSessionId: r.secure_session_id,
-      loginType: 'passkey',
-      passkeyRawId: asseResp.rawId,
-      showSuccessMessage: false,
+    const r = await auth.finish_passkey_login({
+      session_id: begin.session_id,
+      options: asseResp,
     })
-  }
 
-  passkeyLoginLoading.value = false
+    if (r.token) {
+      await handleLoginSuccess({
+        token: r.token,
+        shortToken: r.short_token,
+        secureSessionId: r.secure_session_id,
+        loginType: 'passkey',
+        passkeyRawId: asseResp.rawId,
+        showSuccessMessage: false,
+      })
+    }
+  }
+  catch (e) {
+    console.error(e)
+  }
+  finally {
+    passkeyLoginLoading.value = false
+  }
 }
 </script>