From a7ab26d08d3066ed7bdbe9f7a524f77410bfcab3 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sat, 27 Sep 2025 01:19:32 +0800 Subject: [PATCH] chore: --- .../src/components/captcha/captcha-input.vue | 10 +- .../captcha/captchas/geetest_captcha.vue | 8 +- .../src/locales/langs/en-US/certd.ts | 1 + .../src/locales/langs/zh-CN/certd.ts | 1 + .../src/views/sys/settings/index.vue | 5 + .../src/views/sys/settings/tabs/base.vue | 60 --------- .../src/views/sys/settings/tabs/captcha.vue | 125 ++++++++++++++++++ 7 files changed, 142 insertions(+), 68 deletions(-) create mode 100644 packages/ui/certd-client/src/views/sys/settings/tabs/captcha.vue diff --git a/packages/ui/certd-client/src/components/captcha/captcha-input.vue b/packages/ui/certd-client/src/components/captcha/captcha-input.vue index ca84f252..bf0e308d 100644 --- a/packages/ui/certd-client/src/components/captcha/captcha-input.vue +++ b/packages/ui/certd-client/src/components/captcha/captcha-input.vue @@ -12,6 +12,14 @@ const props = defineProps({ type: Object, default: () => ({}), }, + type: { + type: String, + default: "image", + }, + addonId: { + type: Number, + default: 0, + }, }); const captchaRef = ref(null); const settingStore = useSettingStore(); @@ -23,7 +31,7 @@ const captchaAddonId = computed(() => { return settingStore.sysPublic.captchaAddonId ?? 0; }); const captchaComponent = computed(() => { - let type: any = "image"; + let type: any = props.type ?? "image"; if (settingStore.sysPublic.captchaAddonId && settingStore.sysPublic.captchaType) { type = settingStore.sysPublic.captchaType; } diff --git a/packages/ui/certd-client/src/components/captcha/captchas/geetest_captcha.vue b/packages/ui/certd-client/src/components/captcha/captchas/geetest_captcha.vue index 0ea7b12e..675295c1 100644 --- a/packages/ui/certd-client/src/components/captcha/captchas/geetest_captcha.vue +++ b/packages/ui/certd-client/src/components/captcha/captchas/geetest_captcha.vue @@ -14,7 +14,6 @@ async function loadCaptchaScript() { await loadScript("https://static.geetest.com/v4/gt4.js"); loaded.value = true; } -loadCaptchaScript(); defineOptions({ name: "GeetestCaptcha", @@ -25,15 +24,10 @@ const props = defineProps<{ captchaGet: () => Promise; }>(); const captchaRef = ref(null); -// const addonApi = createAddonApi(); -const settingStore = useSettingStore(); const captchaInstanceRef: Ref = ref({}); async function init() { - // if (!initGeetest4) { - // await import("https://static.geetest.com/v4/gt4.js"); - // } - + await loadCaptchaScript(); const { captchaId } = await props.captchaGet(); // @ts-ignore initGeetest4( diff --git a/packages/ui/certd-client/src/locales/langs/en-US/certd.ts b/packages/ui/certd-client/src/locales/langs/en-US/certd.ts index 0b8cb4b0..3edf746d 100644 --- a/packages/ui/certd-client/src/locales/langs/en-US/certd.ts +++ b/packages/ui/certd-client/src/locales/langs/en-US/certd.ts @@ -730,6 +730,7 @@ export default { registerSetting: "Register Settings", safeSetting: "Safe Settings", paymentSetting: "Payment Settings", + captchaSetting: "Captcha Setting", }, }, modal: { diff --git a/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts b/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts index 896e799b..45a4384e 100644 --- a/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts +++ b/packages/ui/certd-client/src/locales/langs/zh-CN/certd.ts @@ -731,6 +731,7 @@ export default { registerSetting: "注册设置", safeSetting: "安全设置", paymentSetting: "支付设置", + captchaSetting: "验证码设置", }, }, modal: { diff --git a/packages/ui/certd-client/src/views/sys/settings/index.vue b/packages/ui/certd-client/src/views/sys/settings/index.vue index f78d125d..6579f74d 100644 --- a/packages/ui/certd-client/src/views/sys/settings/index.vue +++ b/packages/ui/certd-client/src/views/sys/settings/index.vue @@ -17,6 +17,9 @@ + + + @@ -27,6 +30,8 @@ import SettingBase from "/@/views/sys/settings/tabs/base.vue"; import SettingRegister from "/@/views/sys/settings/tabs/register.vue"; import SettingPayment from "/@/views/sys/settings/tabs/payment.vue"; import SettingSafe from "/@/views/sys/settings/tabs/safe.vue"; +import SettingCaptcha from "/@/views/sys/settings/tabs/captcha.vue"; + import { useRoute, useRouter } from "vue-router"; import { ref } from "vue"; import { useSettingStore } from "/@/store/settings"; diff --git a/packages/ui/certd-client/src/views/sys/settings/tabs/base.vue b/packages/ui/certd-client/src/views/sys/settings/tabs/base.vue index fa6b83e4..196edebb 100644 --- a/packages/ui/certd-client/src/views/sys/settings/tabs/base.vue +++ b/packages/ui/certd-client/src/views/sys/settings/tabs/base.vue @@ -47,24 +47,6 @@
- - -
-
- - - - -
- - 后端验证 -
-
- - - {{ t("certd.saveButton") }} @@ -89,25 +71,6 @@ defineOptions({ name: "SettingBase", }); -const captchaTestForm = reactive({ - captcha: null, - pass: false, -}); - -async function doCaptchaValidate() { - if (!captchaTestForm.captcha) { - notification.error({ - message: "请进行验证码验证", - }); - return; - } - await api.TestCaptcha(captchaTestForm.captcha); - notification.success({ - message: "校验通过", - }); - captchaTestForm.pass = true; -} - const formState = reactive>({ public: { icpNo: "", @@ -133,13 +96,6 @@ const onFinish = async (form: any) => { try { saveLoading.value = true; - if (form.public.captchaEnabled && !captchaTestForm.pass) { - notification.error({ - message: "请先通过验证码测试之后再开启登录验证码", - }); - return; - } - await api.SysSettingsSave(form); await settingsStore.loadSysSettings(); notification.success({ @@ -147,25 +103,9 @@ const onFinish = async (form: any) => { }); } finally { saveLoading.value = false; - captchaTestForm.pass = false; } }; -const onFinishFailed = (errorInfo: any) => { - // console.log("Failed:", errorInfo); -}; - -async function stopOtherUserTimer() { - await api.stopOtherUserTimer(); - notification.success({ - message: t("certd.stopSuccess"), - }); -} - -function onAddonChanged(target: any) { - formState.public.captchaType = target.type; -} - const testProxyLoading = ref(false); async function testProxy() { testProxyLoading.value = true; diff --git a/packages/ui/certd-client/src/views/sys/settings/tabs/captcha.vue b/packages/ui/certd-client/src/views/sys/settings/tabs/captcha.vue new file mode 100644 index 00000000..32933c45 --- /dev/null +++ b/packages/ui/certd-client/src/views/sys/settings/tabs/captcha.vue @@ -0,0 +1,125 @@ + + + +