diff --git a/api/go/handler/chat_handler.go b/api/go/handler/chat_handler.go
index 698a9954..ccea19a7 100644
--- a/api/go/handler/chat_handler.go
+++ b/api/go/handler/chat_handler.go
@@ -69,7 +69,7 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
session.ChatId = chatId
session.Model = chatModel
- logger.Infof("New websocket connected, IP: %s, UserId: %s", c.Request.RemoteAddr, session.Username)
+ logger.Infof("New websocket connected, IP: %s, Username: %s", c.Request.RemoteAddr, session.Username)
client := core.NewWsClient(ws)
var chatRole model.ChatRole
res = h.db.First(&chatRole, roleId)
diff --git a/web/src/components/ConfigDialog.vue b/web/src/components/ConfigDialog.vue
index 10f2e059..62413bc5 100644
--- a/web/src/components/ConfigDialog.vue
+++ b/web/src/components/ConfigDialog.vue
@@ -73,6 +73,7 @@ import {ElMessage} from "element-plus";
const props = defineProps({
show: Boolean,
+ user: Object,
models: Array,
});
@@ -102,6 +103,8 @@ const save = function () {
appendTo: document.getElementById('user-info'),
onClose: () => emits('update:show', false)
})
+ // 更新用户数据
+ emits('update-user', {nickname:form.value['nickname'], avatar: form.value['avatar']});
}).catch(() => {
ElMessage.error({
message: '更新失败',
diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue
index 60ed22bc..5569f1a2 100644
--- a/web/src/views/ChatPlus.vue
+++ b/web/src/views/ChatPlus.vue
@@ -169,7 +169,7 @@
-
+
@@ -213,29 +213,28 @@ const mainWinHeight = ref(0); // 主窗口高度
const chatBoxHeight = ref(0); // 聊天内容框高度
const leftBoxHeight = ref(0);
const loading = ref(true);
-const user = getLoginUser();
+const user = ref(getLoginUser());
const roles = ref([]);
const roleId = ref(0)
const newChatItem = ref(null);
const router = useRouter();
const showConfigDialog = ref(false);
-if (!user) {
+if (!user.value) {
router.push("login");
} else {
onMounted(() => {
resizeElement();
checkSession().then(() => {
// 加载角色列表
- httpGet(`/api/chat/role/list?user_id=${user.id}`).then((res) => {
+ httpGet(`/api/chat/role/list?user_id=${user.value.id}`).then((res) => {
roles.value = res.data;
roleId.value = roles.value[0]['id'];
// 获取会话列表
loadChats();
// 创建新的会话
newChat();
- }).catch((e) => {
- console.log(e)
+ }).catch(() => {
ElMessage.error('获取聊天角色失败')
})
}).catch(() => {
@@ -247,8 +246,7 @@ if (!user) {
ElMessage.success('复制成功!');
})
- clipboard.on('error', (e) => {
- console.log(e)
+ clipboard.on('error', () => {
ElMessage.error('复制失败!');
})
});
@@ -274,7 +272,7 @@ const checkSession = function () {
// 加载会话
const loadChats = function () {
- httpGet("/api/chat/list?user_id=" + user.id).then((res) => {
+ httpGet("/api/chat/list?user_id=" + user.value.id).then((res) => {
if (res.data) {
chatList.value = res.data;
allChats.value = res.data;
@@ -355,7 +353,6 @@ const editChatTitle = function (event, chat) {
// 确认修改
const confirm = function (event, chat) {
- console.log(chat)
event.stopPropagation();
if (curOpt.value === 'edit') {
if (tmpChatTitle.value === '') {
@@ -556,7 +553,7 @@ const sendMessage = function () {
chatData.value.push({
type: "prompt",
id: randString(32),
- icon: user['avatar'],
+ icon: user.value.avatar,
content: renderInputText(prompt.value),
created_at: new Date().getTime(),
});
@@ -596,6 +593,7 @@ const clearAllChats = function () {
ElMessage.success("操作成功!");
chatData.value = [];
chatList.value = [];
+ newChat();
}).catch(e => {
ElMessage.error("操作失败:" + e.message)
})
@@ -687,6 +685,11 @@ const searchChat = function () {
}
chatList.value = roles;
}
+
+const updateUser = function (data) {
+ user.value.avatar = data.avatar;
+ user.value.nickname = data.nickname;
+}