From ee1593c93bc951aebd2ba34e78688c21deb35128 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Sun, 9 Apr 2023 17:28:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20fix(ck):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=A1=A8=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Config.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pages/Config.vue b/src/pages/Config.vue index 07580ad8..33fa7d30 100644 --- a/src/pages/Config.vue +++ b/src/pages/Config.vue @@ -329,8 +329,20 @@ function submitHome () { // 获取 Cookie async function readCookie () { - const cookie = await tauri.invoke("read_cookie"); - alert(cookie); + // todo 验证 cookie 是否有效 + const cookie = await tauri.invoke("read_cookie") as string || document.cookie; + if (cookie === null || cookie === "") { + snackbarText.value = "Cookie 为空!"; + snackbarColor.value = "error"; + snackbar.value = true; + } else { + snackbarText.value = "Cookie 获取成功!"; + snackbarColor.value = "success"; + snackbar.value = true; + alert(cookie); + } + // 将 cookie 保存到本地 + document.cookie = cookie; }