From c87ec77543c6d73bfb6286abe02f074ecfc17342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Fri, 15 Nov 2024 16:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20loading=E5=87=BD=E6=95=B0=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/func/geetest.vue | 45 +++--- src/components/func/loading.ts | 73 ++++++++++ src/components/func/loading.vue | 192 ++++++++++++++++++++++++++ src/components/overlay/to-loading.vue | 22 +-- 4 files changed, 294 insertions(+), 38 deletions(-) create mode 100644 src/components/func/loading.ts create mode 100644 src/components/func/loading.vue diff --git a/src/components/func/geetest.vue b/src/components/func/geetest.vue index 0c35750a..253d7744 100644 --- a/src/components/func/geetest.vue +++ b/src/components/func/geetest.vue @@ -23,21 +23,18 @@ const showInner = ref(false); const geetestEl = useTemplateRef("geetestRef"); -watch(show, () => { - if (show.value) { - showOuter.value = true; - setTimeout(() => { - showInner.value = true; - }, 100); - } else { - setTimeout(() => { - showInner.value = false; - }, 100); - setTimeout(() => { - showOuter.value = false; - }, 300); - } -}); +watch( + () => show.value, + () => { + if (show.value) { + showOuter.value = true; + setTimeout(() => (showInner.value = true), 100); + } else { + setTimeout(() => (showInner.value = false), 100); + setTimeout(() => (showOuter.value = false), 300); + } + }, +); async function displayBox( props: TGApp.Plugins.Mys.Geetest.reqResp, @@ -58,24 +55,18 @@ async function displayBox( if (geetestEl.value === null) return; geetestEl.value.innerHTML = ""; captchaObj.appendTo("#geetest"); - captchaObj.onReady(() => { - show.value = true; - }); - captchaObj.onSuccess(async () => { + captchaObj.onReady(() => (show.value = true)); + captchaObj.onSuccess(() => { const validate = captchaObj.getValidate(); resolve(validate); }); - captchaObj.onClose(() => { - show.value = false; - }); + captchaObj.onClose(() => (show.value = false)); }, ); }); } -defineExpose({ - displayBox, -}); +defineExpose({ displayBox }); diff --git a/src/components/overlay/to-loading.vue b/src/components/overlay/to-loading.vue index a39edb27..52b1f881 100644 --- a/src/components/overlay/to-loading.vue +++ b/src/components/overlay/to-loading.vue @@ -1,19 +1,19 @@