Tea.context(function () { this.username = "" this.password = "" this.passwordMd5 = "" this.encodedFrom = window.encodeURIComponent(this.from) if (this.isDemo) { this.username = "admin" this.password = "123456" } this.isSubmitting = false this.refreshPlaceholders = function () { let usernameInput = document.querySelector("form input[name='username']") if (usernameInput != null) { usernameInput.setAttribute("placeholder", "\u8bf7\u8f93\u5165\u8d26\u53f7") } let passwordInput = document.querySelector("form input[type='password']") if (passwordInput != null) { passwordInput.setAttribute("placeholder", "\u8bf7\u8f93\u5165\u5bc6\u7801") } } this.$delay(function () { this.$find("form input[name='username']").focus() this.changePassword() this.refreshPlaceholders() // Some UI scripts mutate placeholders after mount; enforce once more. setTimeout(() => this.refreshPlaceholders(), 200) }); this.changeUsername = function () { } this.changePassword = function () { this.passwordMd5 = md5(this.password.trim()); }; // 更多选项 this.moreOptionsVisible = false; this.showMoreOptions = function () { this.moreOptionsVisible = !this.moreOptionsVisible; }; this.submitBefore = function () { this.isSubmitting = true; }; this.submitDone = function () { this.isSubmitting = false; }; this.submitSuccess = function (resp) { // store information to local localStorage.setItem("sid", resp.data.localSid) localStorage.setItem("ip", resp.data.ip) // redirect back this.$delay(function () { if (resp.data.requireOTP) { window.location = "/index/otp?sid=" + resp.data.sid + "&remember=" + (resp.data.remember ? 1 : 0) + "&from=" + window.encodeURIComponent(this.from) return } if (this.from.length == 0) { window.location = "/dashboard"; } else { window.location = this.from; } }) }; });