refactor: simplify captcha selector naming

Convert captcha vendor templates and DOM selectors from id-based tianai naming to class-based captcha naming.

Update the shared captcha container, common tips/loading helpers, and slider/rotate/concat/disable/image-click implementations so template markup, DOM queries, and less selectors stay aligned.

Keep captcha.js as the single style entry for the captcha module and remove per-component less imports from the submodule JavaScript files.
This commit is contained in:
2026-05-16 12:25:52 +08:00
parent e0f6175fed
commit 662b22576d
14 changed files with 136 additions and 139 deletions
+13 -13
View File
@@ -8,20 +8,20 @@ import WordImageClick from "./word_image_click/word_image_click";
import { CaptchaConfig, wrapConfig, wrapStyle } from "./config/config";
import { clearAllPreventDefault } from "./common/common";
const template = `
<div id="tianai-captcha-parent">
<div id="tianai-captcha-bg-img"></div>
<div id="tianai-captcha-box">
<div id="tianai-captcha-loading" class="loading"></div>
<div class="captcha-parent">
<div class="captcha-bg-img"></div>
<div class="captcha-box">
<div class="captcha-loading loading"></div>
</div>
<!-- 底部 -->
<div class="slider-bottom">
<div class="refresh-btn" id="tianai-captcha-slider-refresh-btn"></div>
<div class="close-btn" id="tianai-captcha-slider-close-btn"></div>
<div class="refresh-btn"></div>
<div class="close-btn"></div>
</div>
</div>
`;
function createCaptchaByType(type, tac) {
const box = tac.config.domBindEl.find("#tianai-captcha-box");
const box = tac.config.domBindEl.find(".captcha-box");
const styleConfig = tac.style;
switch (type) {
case "SLIDER":
@@ -55,17 +55,17 @@ class TianAiCaptcha {
init() {
this.destroyWindow();
this.config.domBindEl.append(template);
this.domTemplate = this.config.domBindEl.find("#tianai-captcha-parent");
this.domTemplate = this.config.domBindEl.find(".captcha-parent");
clearAllPreventDefault(this.domTemplate);
this.loadStyle();
// 绑定按钮事件
this.config.domBindEl
.find("#tianai-captcha-slider-refresh-btn")
.find(".refresh-btn")
.click((el) => {
this.btnRefreshFun(el, this);
});
this.config.domBindEl
.find("#tianai-captcha-slider-close-btn")
.find(".close-btn")
.click((el) => {
this.btnCloseFun(el, this);
});
@@ -88,13 +88,13 @@ class TianAiCaptcha {
}
showLoading() {
this.config.domBindEl
.find("#tianai-captcha-loading")
.find(".captcha-loading")
.css("display", "block");
}
closeLoading() {
this.config.domBindEl
.find("#tianai-captcha-loading")
.find(".captcha-loading")
.css("display", "none");
}
@@ -104,7 +104,7 @@ class TianAiCaptcha {
if (bgUrl) {
// 背景图片
this.config.domBindEl
.find("#tianai-captcha-bg-img")
.find(".captcha-bg-img")
.css("background-image", "url(" + bgUrl + ")");
}
}