mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 21:24:10 +00:00
Fix turnstile tab re-render and bump version
This commit is contained in:
parent
8a43a516ac
commit
8e9e36e1b8
3 changed files with 32 additions and 6 deletions
|
|
@ -1 +1 @@
|
|||
2.8.11
|
||||
v1.3.4-beta
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@
|
|||
this.animationStarted = true;
|
||||
this.initHeadline();
|
||||
}
|
||||
if (this.turnstileSiteKey) {
|
||||
if (this.turnstileSiteKey && this.activeTab === 'register') {
|
||||
this.ensureTurnstileRendered();
|
||||
}
|
||||
});
|
||||
|
|
@ -191,11 +191,22 @@
|
|||
},
|
||||
methods: {
|
||||
switchTab(key) {
|
||||
if (key !== 'register') {
|
||||
this.destroyTurnstile();
|
||||
}
|
||||
this.activeTab = key;
|
||||
if (key === 'register') {
|
||||
this.$nextTick(() => this.ensureTurnstileRendered());
|
||||
}
|
||||
},
|
||||
destroyTurnstile() {
|
||||
turnstileToken = '';
|
||||
turnstileContainer = null;
|
||||
if (window.turnstile && turnstileWidgetId !== null) {
|
||||
turnstile.remove(turnstileWidgetId);
|
||||
}
|
||||
turnstileWidgetId = null;
|
||||
},
|
||||
async doLogin() {
|
||||
this.loadingStates.spinning = true;
|
||||
const msg = await HttpUtil.post('/login', this.user);
|
||||
|
|
@ -224,13 +235,18 @@
|
|||
this.activeTab = 'login';
|
||||
this.user.username = this.regUser.username;
|
||||
this.regUser = { username: "", password: "", confirmPassword: "" };
|
||||
turnstileToken = '';
|
||||
if (window.turnstile && turnstileWidgetId !== null) {
|
||||
turnstile.reset(turnstileWidgetId);
|
||||
}
|
||||
this.destroyTurnstile();
|
||||
}
|
||||
this.loadingStates.registerSpinning = false;
|
||||
},
|
||||
isTurnstileContainerVisible(container) {
|
||||
var pane = container.closest('.ant-tabs-tabpane');
|
||||
if (!pane) {
|
||||
return true;
|
||||
}
|
||||
var paneStyle = window.getComputedStyle(pane);
|
||||
return paneStyle.display !== 'none' && paneStyle.visibility !== 'hidden';
|
||||
},
|
||||
ensureTurnstileRendered(retries = 20) {
|
||||
if (!this.turnstileSiteKey) {
|
||||
return;
|
||||
|
|
@ -242,6 +258,12 @@
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (!this.isTurnstileContainerVisible(container)) {
|
||||
if (retries > 0) {
|
||||
setTimeout(() => this.ensureTurnstileRendered(retries - 1), 150);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (
|
||||
turnstileWidgetId !== null &&
|
||||
(turnstileContainer !== container || container.childElementCount === 0)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ func TestLoginTemplateRebuildsTurnstileAfterTabSwitch(t *testing.T) {
|
|||
"turnstile.remove(turnstileWidgetId);",
|
||||
"turnstileContainer !== container",
|
||||
"turnstileToken = '';",
|
||||
"this.activeTab === 'register'",
|
||||
"!this.isTurnstileContainerVisible(container)",
|
||||
"if (key !== 'register') {",
|
||||
"this.destroyTurnstile();",
|
||||
}
|
||||
|
||||
for _, check := range checks {
|
||||
|
|
|
|||
Loading…
Reference in a new issue