diff --git a/api/core/types/web.go b/api/core/types/web.go index 08f5ee90..aecf8e61 100644 --- a/api/core/types/web.go +++ b/api/core/types/web.go @@ -22,6 +22,7 @@ type WsMessage struct { Type WsMsgType `json:"type"` // 消息类别,start, end, img Content interface{} `json:"content"` } + type WsMsgType string const ( diff --git a/api/handler/chatimpl/chat_handler.go b/api/handler/chatimpl/chat_handler.go index bd6ab8d3..a99c2897 100644 --- a/api/handler/chatimpl/chat_handler.go +++ b/api/handler/chatimpl/chat_handler.go @@ -348,7 +348,7 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session *types.ChatSessio } data = append(data, gin.H{ "type": "text", - "text": text, + "text": strings.TrimSpace(text), }) content = data } else { diff --git a/api/handler/upload_handler.go b/api/handler/upload_handler.go index af37f972..183606da 100644 --- a/api/handler/upload_handler.go +++ b/api/handler/upload_handler.go @@ -9,6 +9,7 @@ package handler import ( "geekai/core" + "geekai/core/types" "geekai/service/oss" "geekai/store/model" "geekai/store/vo" @@ -35,6 +36,12 @@ func (h *UploadHandler) Upload(c *gin.Context) { return } + logger.Info("upload file: %s", file.Name) + // cut the file name if it's too long + if len(file.Name) > 100 { + file.Name = file.Name[:90] + file.Ext + } + userId := h.GetLoginUserId(c) res := h.DB.Create(&model.File{ UserId: int(userId), @@ -54,10 +61,24 @@ func (h *UploadHandler) Upload(c *gin.Context) { } func (h *UploadHandler) List(c *gin.Context) { + var data struct { + Urls []string `json:"urls"` + } + if err := c.ShouldBindJSON(&data); err != nil { + resp.ERROR(c, types.InvalidArgs) + return + } + logger.Info(data) + userId := h.GetLoginUserId(c) var items []model.File var files = make([]vo.File, 0) - h.DB.Where("user_id = ?", userId).Find(&items) + session := h.DB.Session(&gorm.Session{}) + session = session.Where("user_id = ?", userId) + if len(data.Urls) > 0 { + session = session.Where("url IN ?", data.Urls) + } + session.Find(&items) if len(items) > 0 { for _, v := range items { var file vo.File diff --git a/api/main.go b/api/main.go index e26d07ff..b2c40dd6 100644 --- a/api/main.go +++ b/api/main.go @@ -255,7 +255,7 @@ func main() { }), fx.Invoke(func(s *core.AppServer, h *handler.UploadHandler) { s.Engine.POST("/api/upload", h.Upload) - s.Engine.GET("/api/upload/list", h.List) + s.Engine.POST("/api/upload/list", h.List) s.Engine.GET("/api/upload/remove", h.Remove) }), fx.Invoke(func(s *core.AppServer, h *handler.SmsHandler) { diff --git a/web/.env.development b/web/.env.development index ec9467e1..5a9770cd 100644 --- a/web/.env.development +++ b/web/.env.development @@ -6,4 +6,4 @@ VUE_APP_ADMIN_USER=admin VUE_APP_ADMIN_PASS=admin123 VUE_APP_KEY_PREFIX=ChatPLUS_DEV_ VUE_APP_TITLE="Geek-AI 创作系统" -VUE_APP_VERSION=v4.0.9 +VUE_APP_VERSION=v4.1.0 diff --git a/web/.env.production b/web/.env.production index 74545d1d..8afbdcae 100644 --- a/web/.env.production +++ b/web/.env.production @@ -2,4 +2,4 @@ VUE_APP_API_HOST= VUE_APP_WS_HOST= VUE_APP_KEY_PREFIX=ChatPLUS_ VUE_APP_TITLE="Geek-AI 创作系统" -VUE_APP_VERSION=v4.0.9 +VUE_APP_VERSION=v4.1.0 diff --git a/web/public/images/ext/doc.png b/web/public/images/ext/doc.png index 9e2c3696..465c78f2 100644 Binary files a/web/public/images/ext/doc.png and b/web/public/images/ext/doc.png differ diff --git a/web/public/images/ext/ppt.png b/web/public/images/ext/ppt.png index 44019095..c1e1f331 100644 Binary files a/web/public/images/ext/ppt.png and b/web/public/images/ext/ppt.png differ diff --git a/web/public/images/ext/xls.png b/web/public/images/ext/xls.png index 1897bdc3..c7893c98 100644 Binary files a/web/public/images/ext/xls.png and b/web/public/images/ext/xls.png differ diff --git a/web/src/assets/css/chat-plus.styl b/web/src/assets/css/chat-plus.styl index 61522fe7..4e32cb3e 100644 --- a/web/src/assets/css/chat-plus.styl +++ b/web/src/assets/css/chat-plus.styl @@ -252,25 +252,35 @@ $borderColor = #4676d0; border: 2px solid #21AA93 border-radius 10px padding 10px + background-color #F4F4F4 - - .prompt-input::-webkit-scrollbar { - width: 0; - height: 0; - } - - .prompt-input { + .input-inner { + display flex + flex-flow column width 100% - line-height: 24px - border none - font-size 14px - background none - resize: none - white-space: pre-wrap; /* 保持文本换行 */ - word-wrap: break-word; /* 允许单词换行 */ - overflow-wrap: break-word; /* 允许长单词换行,适用于现代浏览器 */ + + .file-list { + padding-bottom 10px + } + .prompt-input::-webkit-scrollbar { + width: 0; + height: 0; + } + + .prompt-input { + width 100% + line-height: 24px + border none + font-size 14px + background none + resize: none + white-space: pre-wrap; /* 保持文本换行 */ + word-wrap: break-word; /* 允许单词换行 */ + overflow-wrap: break-word; /* 允许长单词换行,适用于现代浏览器 */ + } } + .send-btn { width 32px margin-left 10px diff --git a/web/src/components/ChatPrompt.vue b/web/src/components/ChatPrompt.vue index fcd924e2..eda29117 100644 --- a/web/src/components/ChatPrompt.vue +++ b/web/src/components/ChatPrompt.vue @@ -6,6 +6,25 @@
+
+
+
+ +
+
+
+ +
+
+
{{file.name}}
+
+ {{GetFileType(file.ext)}} + {{FormatFileSize(file.size)}} +
+
+
+
+
{{ createdAt }} @@ -17,50 +36,87 @@
- @@ -92,10 +148,58 @@ export default defineComponent({ .chat-item { width 100% - position: relative; padding: 0 5px 0 0; overflow: hidden; + .file-list-box { + display flex + flex-flow column + .image { + display flex + flex-flow row + margin-right 10px + position relative + + .el-image { + border 1px solid #e3e3e3 + border-radius 10px + margin-bottom 10px + } + } + .item { + display flex + flex-flow row + border-radius 10px + background-color #ffffff + border 1px solid #e3e3e3 + padding 6px + margin-bottom 10px + + .icon { + .el-image { + width 40px + height 40px + } + } + .body { + margin-left 8px + font-size 14px + .title { + font-weight bold + line-height 24px + color #0D0D0D + } + .info { + color #B4B4B4 + + span { + margin-right 10px + } + } + } + } + } + .content { word-break break-word; padding: 6px 10px; @@ -149,4 +253,4 @@ export default defineComponent({ } - \ No newline at end of file + diff --git a/web/src/components/FileList.vue b/web/src/components/FileList.vue new file mode 100644 index 00000000..950788dd --- /dev/null +++ b/web/src/components/FileList.vue @@ -0,0 +1,114 @@ + + + + + \ No newline at end of file diff --git a/web/src/components/FileSelect.vue b/web/src/components/FileSelect.vue index 97fc847f..5690f700 100644 --- a/web/src/components/FileSelect.vue +++ b/web/src/components/FileSelect.vue @@ -1,5 +1,5 @@