mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-08 14:14:19 +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.animationStarted = true;
|
||||||
this.initHeadline();
|
this.initHeadline();
|
||||||
}
|
}
|
||||||
if (this.turnstileSiteKey) {
|
if (this.turnstileSiteKey && this.activeTab === 'register') {
|
||||||
this.ensureTurnstileRendered();
|
this.ensureTurnstileRendered();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -191,11 +191,22 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
switchTab(key) {
|
switchTab(key) {
|
||||||
|
if (key !== 'register') {
|
||||||
|
this.destroyTurnstile();
|
||||||
|
}
|
||||||
this.activeTab = key;
|
this.activeTab = key;
|
||||||
if (key === 'register') {
|
if (key === 'register') {
|
||||||
this.$nextTick(() => this.ensureTurnstileRendered());
|
this.$nextTick(() => this.ensureTurnstileRendered());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
destroyTurnstile() {
|
||||||
|
turnstileToken = '';
|
||||||
|
turnstileContainer = null;
|
||||||
|
if (window.turnstile && turnstileWidgetId !== null) {
|
||||||
|
turnstile.remove(turnstileWidgetId);
|
||||||
|
}
|
||||||
|
turnstileWidgetId = null;
|
||||||
|
},
|
||||||
async doLogin() {
|
async doLogin() {
|
||||||
this.loadingStates.spinning = true;
|
this.loadingStates.spinning = true;
|
||||||
const msg = await HttpUtil.post('/login', this.user);
|
const msg = await HttpUtil.post('/login', this.user);
|
||||||
|
|
@ -224,13 +235,18 @@
|
||||||
this.activeTab = 'login';
|
this.activeTab = 'login';
|
||||||
this.user.username = this.regUser.username;
|
this.user.username = this.regUser.username;
|
||||||
this.regUser = { username: "", password: "", confirmPassword: "" };
|
this.regUser = { username: "", password: "", confirmPassword: "" };
|
||||||
turnstileToken = '';
|
this.destroyTurnstile();
|
||||||
if (window.turnstile && turnstileWidgetId !== null) {
|
|
||||||
turnstile.reset(turnstileWidgetId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.loadingStates.registerSpinning = false;
|
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) {
|
ensureTurnstileRendered(retries = 20) {
|
||||||
if (!this.turnstileSiteKey) {
|
if (!this.turnstileSiteKey) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -242,6 +258,12 @@
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!this.isTurnstileContainerVisible(container)) {
|
||||||
|
if (retries > 0) {
|
||||||
|
setTimeout(() => this.ensureTurnstileRendered(retries - 1), 150);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
turnstileWidgetId !== null &&
|
turnstileWidgetId !== null &&
|
||||||
(turnstileContainer !== container || container.childElementCount === 0)
|
(turnstileContainer !== container || container.childElementCount === 0)
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,10 @@ func TestLoginTemplateRebuildsTurnstileAfterTabSwitch(t *testing.T) {
|
||||||
"turnstile.remove(turnstileWidgetId);",
|
"turnstile.remove(turnstileWidgetId);",
|
||||||
"turnstileContainer !== container",
|
"turnstileContainer !== container",
|
||||||
"turnstileToken = '';",
|
"turnstileToken = '';",
|
||||||
|
"this.activeTab === 'register'",
|
||||||
|
"!this.isTurnstileContainerVisible(container)",
|
||||||
|
"if (key !== 'register') {",
|
||||||
|
"this.destroyTurnstile();",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, check := range checks {
|
for _, check := range checks {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue