feat: auto login

parent 022e66bc
...@@ -120,34 +120,39 @@ export class CleftbarComponent implements OnInit { ...@@ -120,34 +120,39 @@ export class CleftbarComponent implements OnInit {
const that = this; const that = this;
if (host.system_users_granted.length > 1) { if (host.system_users_granted.length > 1) {
let options = ''; let options = '';
for (let u of host.system_users_granted) { user = this.checkPriority(host.system_users_granted);
options += '<option value="' + u.id + '">' + u.username + '</option>'; if (user) {
} this.login(host, user);
layer.open({ } else {
title: 'Please Choose a User', for (let u of host.system_users_granted) {
scrollbar: false, options += '<option value="' + u.id + '">' + u.username + '</option>';
moveOut: true, }
moveType: 1, layer.open({
btn: ['确定', '取消'], title: 'Please Choose a User',
content: '<select id="selectuser">' + options + '</select>', scrollbar: false,
yes: function (index, layero) { moveOut: true,
let userid = jQuery('#selectuser').val(); moveType: 1,
for (let i of host.system_users_granted) { btn: ['确定', '取消'],
if (i.id.toString() === userid.toString()) { content: '<select id="selectuser">' + options + '</select>',
user = i; yes: function (index, layero) {
break; const userid = jQuery('#selectuser').val();
for (let i of host.system_users_granted) {
if (i.id.toString() === userid.toString()) {
user = i;
break;
}
} }
that.login(host, user);
layer.close(index);
},
btn2: function (index, layero) {
},
cancel: function () {
// 右上角关闭回调
// return false 开启该代码可禁止点击该按钮关闭
} }
that.login(host, user); });
layer.close(index); }
},
btn2: function (index, layero) {
},
cancel: function () {
// 右上角关闭回调
// return false 开启该代码可禁止点击该按钮关闭
}
});
} else if (host.system_users_granted.length === 1) { } else if (host.system_users_granted.length === 1) {
user = host.system_users_granted[0]; user = host.system_users_granted[0];
this.login(host, user); this.login(host, user);
...@@ -183,6 +188,20 @@ export class CleftbarComponent implements OnInit { ...@@ -183,6 +188,20 @@ export class CleftbarComponent implements OnInit {
// } // }
} }
checkPriority(sysUsers) {
let priority: number = -1;
let user: any;
for (let u of sysUsers) {
if (u.priority > priority) {
user = u;
priority = u.priority;
} else if (u.priority === priority) {
return null;
}
}
return user;
}
Search(q) { Search(q) {
this._search.Search(q); this._search.Search(q);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment