// 基本认证用户配置 Vue.component("http-auth-basic-auth-user-box", { props: ["v-users"], data: function () { let users = this.vUsers if (users == null) { users = [] } return { users: users, isAdding: false, updatingIndex: -1, username: "", password: "" } }, methods: { add: function () { this.isAdding = true this.username = "" this.password = "" let that = this setTimeout(function () { that.$refs.username.focus() }, 100) }, cancel: function () { this.isAdding = false this.updatingIndex = -1 }, confirm: function () { let that = this if (this.username.length == 0) { teaweb.warn("请输入用户名", function () { that.$refs.username.focus() }) return } if (this.password.length == 0) { teaweb.warn("请输入密码", function () { that.$refs.password.focus() }) return } if (this.updatingIndex < 0) { this.users.push({ username: this.username, password: this.password }) } else { this.users[this.updatingIndex].username = this.username this.users[this.updatingIndex].password = this.password } this.cancel() }, update: function (index, user) { this.updatingIndex = index this.isAdding = true this.username = user.username this.password = user.password let that = this setTimeout(function () { that.$refs.username.focus() }, 100) }, remove: function (index) { this.users.$remove(index) } }, template: `
` })