From ca494e5b6e8128740ecb6059ce57c77e08638a09 Mon Sep 17 00:00:00 2001 From: guo zebin Date: Thu, 18 Dec 2025 00:43:52 +0800 Subject: [PATCH] =?UTF-8?q?chat=20gui=E4=BF=9D=E6=8C=81=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=BB=E4=BA=BA=E7=9A=84=E8=81=8A=E5=A4=A9=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=8C=89=E9=92=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/static/js/index.js | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/gui/static/js/index.js b/gui/static/js/index.js index c49db97..fe65542 100644 --- a/gui/static/js/index.js +++ b/gui/static/js/index.js @@ -529,23 +529,16 @@ new Vue({ loadUserList() { this.fayService.getUserList().then((response) => { if (response && response.list) { - if (response.list.length == 0){ - // 检查是否已经有默认用户 - const defaultUserExists = this.userList.some(user => user[1] === 'User'); - if (!defaultUserExists) { - // 只有在不存在默认用户时才添加 - const info = []; - info[0] = 1; - info[1] = 'User'; - this.userList.push(info); - this.selectUser(info); - console.log('添加默认用户: User'); - } - } else { - this.userList = response.list; - if (!this.selectedUser) { - this.selectUser(this.userList[0]); - } + let list = response.list || []; + // 始终确保 "User"(主人)存在于列表中 + const defaultUserExists = list.some(user => user[1] === 'User'); + if (!defaultUserExists) { + // 将主人添加到列表开头 + list = [[1, 'User'], ...list]; + } + this.userList = list; + if (!this.selectedUser) { + this.selectUser(this.userList[0]); } } });