From a5299b52d47c0602bb90b528be992d5dd6c80b6e Mon Sep 17 00:00:00 2001 From: RockYang Date: Sun, 31 Mar 2024 17:45:22 +0800 Subject: [PATCH] opt: change the relative path with absolute path for midjourney image uploading --- api/handler/mj_handler.go | 7 +++++++ web/src/views/ChatPlus.vue | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/api/handler/mj_handler.go b/api/handler/mj_handler.go index d2f9a107..f1b5e3e1 100644 --- a/api/handler/mj_handler.go +++ b/api/handler/mj_handler.go @@ -145,6 +145,13 @@ func (h *MidJourneyHandler) Image(c *gin.Context) { prompt = fmt.Sprintf("%s:%s", data.TaskType, strings.Join(data.ImgArr, ",")) } + // 如果本地图片上传的是相对地址,处理成绝对地址 + for k, v := range data.ImgArr { + if !strings.HasPrefix(v, "http") { + data.ImgArr[k] = fmt.Sprintf("http://localhost:5678/%s", strings.TrimLeft(v, "/")) + } + } + idValue, _ := c.Get(types.LoginUserID) userId := utils.IntValue(utils.InterfaceToString(idValue), 0) // generate task id diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue index 0914358f..8dfdcd63 100644 --- a/web/src/views/ChatPlus.vue +++ b/web/src/views/ChatPlus.vue @@ -479,9 +479,15 @@ const changeChat = (chat) => { } const loadChat = function (chat) { + if (!isLogin.value) { + showLoginDialog.value = true + return; + } + if (activeChat.value['chat_id'] === chat.chat_id) { return; } + activeChat.value = chat newChatItem.value = null; roleId.value = chat.role_id;