diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 079e005..d983195 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -439,7 +439,8 @@ "capSecretKeyDes": "The secret key from your Cap server dashboard.", "capAssetServer": "Asset Server Source", "capAssetServerDes": "Choose the source for loading Cap captcha static assets. Using self-deployed server requires setting ENABLE_ASSETS_SERVER=true environment variable to <0>enable asset server.", - "capAssetServerCdn": "Default public CDN", + "capAssetServerJsdelivr": "jsDelivr CDN", + "capAssetServerUnpkg": "unpkg CDN", "capAssetServerInstance": "Self-deployed server", "captchaProvider": "Captcha provider", "captchaWidth": "Width", diff --git a/public/locales/ja-JP/dashboard.json b/public/locales/ja-JP/dashboard.json index 4b6ae0f..cec7090 100644 --- a/public/locales/ja-JP/dashboard.json +++ b/public/locales/ja-JP/dashboard.json @@ -437,7 +437,8 @@ "capSecretKeyDes": "Cap サーバーダッシュボードから取得したシークレットキー。", "capAssetServer": "静的リソースソース", "capAssetServerDes": "Cap認証コードの静的リソースの読み込みソースを選択します。自己デプロイサーバーを使用するにはサーバー側で環境変数 ENABLE_ASSETS_SERVER=true を設定して<0>静的リソースサービスを有効にする必要があります。", - "capAssetServerCdn": "デフォルト公共CDN", + "capAssetServerJsdelivr": "jsDelivr CDN", + "capAssetServerUnpkg": "unpkg CDN", "capAssetServerInstance": "自己デプロイサーバー", "captchaProvider": "認証コードタイプ", "captchaWidth": "幅", diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index 333bcea..f3210d3 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -437,7 +437,8 @@ "capSecretKeyDes": "从 Cap 服务器控制面板获取的私密密钥。", "capAssetServer": "静态资源服务源", "capAssetServerDes": "选择 Cap 验证码静态资源的加载源。使用自部署服务器需要在服务器端设置环境变量 ENABLE_ASSETS_SERVER=true <0>开启静态资源服务。", - "capAssetServerCdn": "默认境外 CDN", + "capAssetServerJsdelivr": "jsDelivr CDN", + "capAssetServerUnpkg": "unpkg CDN", "capAssetServerInstance": "自部署服务器", "captchaProvider": "验证码类型", "captchaWidth": "宽度", diff --git a/public/locales/zh-TW/dashboard.json b/public/locales/zh-TW/dashboard.json index 874644c..f2054eb 100644 --- a/public/locales/zh-TW/dashboard.json +++ b/public/locales/zh-TW/dashboard.json @@ -434,7 +434,8 @@ "capSecretKeyDes": "從 Cap 伺服器控制面板獲取的私密金鑰。", "capAssetServer": "靜態資源服務源", "capAssetServerDes": "選擇 Cap 驗證碼靜態資源的載入源。使用自部署伺服器需要在伺服器端設定環境變數 ENABLE_ASSETS_SERVER=true <0>開啟靜態資源服務。", - "capAssetServerCdn": "預設公共 CDN", + "capAssetServerJsdelivr": "jsDelivr CDN", + "capAssetServerUnpkg": "unpkg CDN", "capAssetServerInstance": "自部署伺服器", "captchaProvider": "驗證碼型別", "captchaWidth": "寬度", diff --git a/src/component/Admin/Settings/Captcha/CapCaptcha.tsx b/src/component/Admin/Settings/Captcha/CapCaptcha.tsx index f6c239a..eb839f5 100644 --- a/src/component/Admin/Settings/Captcha/CapCaptcha.tsx +++ b/src/component/Admin/Settings/Captcha/CapCaptcha.tsx @@ -82,20 +82,29 @@ const CapCaptcha = ({ values, setSettings }: CapCaptchaProps) => { setSettings({ captcha_cap_asset_server: e.target.value, }) } > - + - {t("settings.capAssetServerCdn")} + {t("settings.capAssetServerJsdelivr")} + + + + + {t("settings.capAssetServerUnpkg")} diff --git a/src/component/Common/Captcha/CapCaptcha.tsx b/src/component/Common/Captcha/CapCaptcha.tsx index 72d33cd..ac7eaf5 100644 --- a/src/component/Common/Captcha/CapCaptcha.tsx +++ b/src/component/Common/Captcha/CapCaptcha.tsx @@ -136,9 +136,12 @@ const CapCaptcha = ({ onStateChange, generation, fullWidth, ...rest }: CapProps // 根据配置设置WASM URL,保持资源加载的一致性 if (capAssetServer === "instance") { - (window as any).CAP_CUSTOM_WASM_URL = `${capInstanceURL.replace(/\/$/, "")}/assets/cap_wasm_bg.wasm`; + (window as any).CAP_CUSTOM_WASM_URL = `${capInstanceURL.replace(/\/$/, "")}/assets/cap_wasm.min.js`; + } else if (capAssetServer === "unpkg") { + (window as any).CAP_CUSTOM_WASM_URL = "https://unpkg.com/@cap.js/wasm@0.0.4/browser/cap_wasm.js"; } else { - (window as any).CAP_CUSTOM_WASM_URL = "https://cdn.jsdelivr.net/npm/@captcha/widget/dist/cap_wasm_bg.wasm"; + // jsdelivr - 默认CDN + (window as any).CAP_CUSTOM_WASM_URL = "https://cdn.jsdelivr.net/npm/@cap.js/wasm@0.0.4/browser/cap_wasm.min.js"; } // Add a small delay to ensure DOM is ready @@ -152,10 +155,15 @@ const CapCaptcha = ({ onStateChange, generation, fullWidth, ...rest }: CapProps script.id = scriptId; // 根据配置选择静态资源源 - const assetSource = - capAssetServer === "instance" - ? `${capInstanceURL.replace(/\/$/, "")}/assets/widget.js` - : "https://cdn.jsdelivr.net/npm/@captcha/widget/dist/widget.js"; + let assetSource; + if (capAssetServer === "instance") { + assetSource = `${capInstanceURL.replace(/\/$/, "")}/assets/widget.js`; + } else if (capAssetServer === "unpkg") { + assetSource = "https://unpkg.com/@cap.js/widget"; + } else { + // jsdelivr - 默认CDN + assetSource = "https://cdn.jsdelivr.net/npm/@cap.js/widget"; + } script.src = assetSource; script.async = true; @@ -163,6 +171,8 @@ const CapCaptcha = ({ onStateChange, generation, fullWidth, ...rest }: CapProps script.onerror = () => { if (capAssetServer === "instance") { console.error("Failed to load Cap widget script from instance server"); + } else if (capAssetServer === "unpkg") { + console.error("Failed to load Cap widget script from unpkg CDN"); } else { console.error("Failed to load Cap widget script from jsDelivr CDN"); }