From e1aab3de6b3ce4de584f05f55b2e54373373617b Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 6 Jul 2023 18:01:28 +0800 Subject: [PATCH] fix --- src/components/cards/SiteCard.vue | 115 +++++++++++++++++++++++------- 1 file changed, 91 insertions(+), 24 deletions(-) diff --git a/src/components/cards/SiteCard.vue b/src/components/cards/SiteCard.vue index 9a2b9d4d..59cd4718 100644 --- a/src/components/cards/SiteCard.vue +++ b/src/components/cards/SiteCard.vue @@ -25,6 +25,15 @@ const updateButtonText = ref("更新"); // 更新按钮可用性 const updateButtonDisable = ref(false); +// 更新站点Cookie UA弹窗 +const siteCookieDialog = ref(false); + +// 用户名密码表单 +const userPwForm = ref({ + username: "", + password: "", +}); + // 查询站点图标 const getSiteIcon = async () => { try { @@ -52,20 +61,31 @@ const testSite = async () => { } }; -// 更新站点Cookie UA -const updateSite = async () => { +// 打开更新站点Cookie UA弹窗 +const handleSiteUpdate = async () => { + siteCookieDialog.value = true; +}; + +// 调用API,更新站点Cookie UA +const updateSiteCookie = async () => { try { + if (!userPwForm.value.username || !userPwForm.value.password) { + return; + } + + // 用户名密码 + const formData = new FormData(); + formData.append("username", userPwForm.value.username); + formData.append("password", userPwForm.value.password); + + // 更新按钮状态 + siteCookieDialog.value = false; updateButtonText.value = "更新中 ..."; updateButtonDisable.value = true; - // TODO 弹窗输入用户名密码 - const result: { [key: string]: any } = await api.get( + + const result: { [key: string]: any } = await api.put( "site/cookie/" + props.site?.id, - { - params: { - username: "", - password: "", - }, - } + formData ); if (result.success) { $toast.success(`${props.site?.name} 更新Cookie & UA 成功!`); @@ -86,7 +106,12 @@ onMounted(() => { + {{ testButtonText }} + + + + + + + + + + + + + + + + + + + + + + + 开始更新 + + + + +