diff --git a/common/globalFunction.js b/common/globalFunction.js index 093d7d7..3874daa 100644 --- a/common/globalFunction.js +++ b/common/globalFunction.js @@ -433,6 +433,12 @@ function parseQueryParams(url = window.location.href) { return params; } +function formatFileSize(bytes) { + if (bytes < 1024) return bytes + ' B' + else if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(2) + ' KB' + else if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(2) + ' MB' + else return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB' +} export const $api = { msg, prePage, @@ -442,7 +448,8 @@ export const $api = { streamRequest, chatRequest, insertSortData, - uploadFile + uploadFile, + formatFileSize } export default { diff --git a/pages/chat/components/ai-paging.vue b/pages/chat/components/ai-paging.vue index a523336..525fc6d 100644 --- a/pages/chat/components/ai-paging.vue +++ b/pages/chat/components/ai-paging.vue @@ -122,9 +122,18 @@ - - - + + + 拍照上传 + + + + 相册上传 + + + + 文件上传 + @@ -132,20 +141,26 @@ - + - - {{ file.name }} + + + {{ file.name }} + {{ file.size }} + + + + @@ -169,6 +184,7 @@ const { messages, isTyping, textInput, chatSessionID } = storeToRefs(useChatGrou import CollapseTransition from '@/components/CollapseTransition/CollapseTransition.vue'; import FadeView from '@/components/FadeView/FadeView.vue'; import AudioWave from './AudioWave.vue'; +import FileIcon from './fileIcon.vue'; import { useAudioRecorder } from '@/hook/useRealtimeRecorder.js'; const { isRecording, recognizedText, startRecording, stopRecording, cancelRecording } = useAudioRecorder( @@ -245,14 +261,16 @@ const sendMessageGuess = (item) => { const delfile = (file) => { uni.showModal({ content: '确认删除文件?', - success() { - filesList.value = filesList.value.filter((item) => item.url !== file.url); - if (!filesList.value.length) { - if (textInput.value === state.uploadFileTips) { - textInput.value = ''; + success(res) { + if (res.confirm) { + filesList.value = filesList.value.filter((item) => item.url !== file.url); + if (!filesList.value.length) { + if (textInput.value === state.uploadFileTips) { + textInput.value = ''; + } } + $api.msg('附件删除成功'); } - $api.msg('附件删除成功'); }, }); }; @@ -289,12 +307,16 @@ function getGuess() { }); } -function isImage(fileNmae) { - return new RegExp('image').test(fileNmae); +function isImage(type) { + return new RegExp('image').test(type); } -function isFile(fileNmae) { - return new RegExp('custom-doc').test(fileNmae); +function isFile(type) { + const allowedTypes = config.allowedFileTypes || []; + if (!allowedTypes.includes(type)) { + return false; + } + return true; } function jumpUrl(file) { @@ -347,6 +369,7 @@ function getUploadFile(type = 'camera') { const tempFilePaths = res.tempFilePaths; const file = res.tempFiles[0]; const allowedTypes = config.allowedFileTypes || []; + const size = $api.formatFileSize(file.size); if (!allowedTypes.includes(file.type)) { return $api.msg('仅支持 txt md html word pdf ppt csv excel 格式类型'); } @@ -355,8 +378,9 @@ function getUploadFile(type = 'camera') { resData = JSON.parse(resData); filesList.value.push({ url: resData.msg, - type: 'custom-doc', + type: file.type, name: file.name, + size: size, }); textInput.value = state.uploadFileTips; }); @@ -605,7 +629,7 @@ image-margin-top = 40rpx padding: 20rpx; } .input-area { - padding: 32rpx; + padding: 32rpx 28rpx 24rpx 28rpx; position: relative; background: #FFFFFF; box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(11,44,112,0.06); @@ -697,13 +721,28 @@ image-margin-top = 40rpx width: 100% grid-template-columns: repeat(3, 1fr) grid-gap: 20rpx - padding: 20rpx 0 0 0; - .file-img - height: 179rpx - width: 100% + padding: 32rpx 0 0 0; + .file-card + display: flex + flex-direction: column + align-items: center + padding: 24rpx 0 + background: #F5F5F5; + border-radius: 20rpx 20rpx 20rpx 20rpx; + text + font-size: 24rpx + font-weight: 500 + color: #000000 + padding-top: 8rpx + .card-img + height: 56rpx + width: 56rpx + .file-card:active + background: #e8e8e8 + .area-uploadfiles position: absolute - top: -100rpx + top: -180rpx width: calc(100% - 40rpx) background: #FFFFFF left: 0 @@ -715,18 +754,21 @@ image-margin-top = 40rpx height: 100% display: flex flex-wrap: nowrap - .file-uploadsend + .file-doc display: flex - flex-wrap: nowrap - justify-content: center - align-items: center + flex-direction: column + align-items: flex-start + justify-content: space-between + padding: 16rpx 20rpx 18rpx 20rpx + height: calc(100% - 40rpx) + .file-uploadsend margin: 10rpx 18rpx 0 10rpx; height: 100% border-radius: 30rpx font-size: 24rpx position: relative - width: 218rpx; - height: 80rpx; + width: 360rpx; + height: 160rpx; border-radius: 12rpx 12rpx 12rpx 12rpx; border: 2rpx solid #E2E2E2; .file-del @@ -751,13 +793,27 @@ image-margin-top = 40rpx text-overflow: ellipsis white-space: nowrap color: #333333 + font-size: 24rpx flex: 1 font-weight: 500 max-width: 100% + .filename-size + overflow: hidden + text-overflow: ellipsis + white-space: nowrap + color: #7B7B7B; + flex: 1 + max-width: 100% .file-icon height: 40rpx width: 40rpx - margin: 0 18rpx 0 18rpx + .file-iconImg + height: 100% + width: 100% + border-radius: 15rpx + .file-border + width: 160rpx; + border: 0 @keyframes ai-circle { 0% { diff --git a/pages/chat/components/fileIcon.vue b/pages/chat/components/fileIcon.vue new file mode 100644 index 0000000..81ddb13 --- /dev/null +++ b/pages/chat/components/fileIcon.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/static/.DS_Store b/static/.DS_Store index 818eaf4..d54921d 100644 Binary files a/static/.DS_Store and b/static/.DS_Store differ diff --git a/static/file/csv.png b/static/file/csv.png new file mode 100644 index 0000000..9108986 Binary files /dev/null and b/static/file/csv.png differ diff --git a/static/file/doc.png b/static/file/doc.png new file mode 100644 index 0000000..a9eec6f Binary files /dev/null and b/static/file/doc.png differ diff --git a/static/file/excel.png b/static/file/excel.png new file mode 100644 index 0000000..658a505 Binary files /dev/null and b/static/file/excel.png differ diff --git a/static/file/html.png b/static/file/html.png new file mode 100644 index 0000000..c730402 Binary files /dev/null and b/static/file/html.png differ diff --git a/static/file/md.png b/static/file/md.png new file mode 100644 index 0000000..f789311 Binary files /dev/null and b/static/file/md.png differ diff --git a/static/file/other.png b/static/file/other.png new file mode 100644 index 0000000..b8b66bd Binary files /dev/null and b/static/file/other.png differ diff --git a/static/file/pdf.png b/static/file/pdf.png new file mode 100644 index 0000000..7a9c70b Binary files /dev/null and b/static/file/pdf.png differ diff --git a/static/file/ppt.png b/static/file/ppt.png new file mode 100644 index 0000000..a343e06 Binary files /dev/null and b/static/file/ppt.png differ diff --git a/static/file/txt.png b/static/file/txt.png new file mode 100644 index 0000000..68f2c2e Binary files /dev/null and b/static/file/txt.png differ diff --git a/static/icon/.DS_Store b/static/icon/.DS_Store index 25de3ad..a3e2b80 100644 Binary files a/static/icon/.DS_Store and b/static/icon/.DS_Store differ diff --git a/static/icon/Comment-one.png b/static/icon/Comment-one.png index eea9d94..6125995 100644 Binary files a/static/icon/Comment-one.png and b/static/icon/Comment-one.png differ diff --git a/static/icon/Group1.png b/static/icon/Group1.png index 7db1b75..e20a906 100755 Binary files a/static/icon/Group1.png and b/static/icon/Group1.png differ diff --git a/static/icon/Hamburger-button.png b/static/icon/Hamburger-button.png index 696525f..ceddaff 100644 Binary files a/static/icon/Hamburger-button.png and b/static/icon/Hamburger-button.png differ diff --git a/static/icon/Location.png b/static/icon/Location.png index 31f2f3c..f61c857 100644 Binary files a/static/icon/Location.png and b/static/icon/Location.png differ diff --git a/static/icon/Vector2.png b/static/icon/Vector2.png index 3c11647..b79667f 100644 Binary files a/static/icon/Vector2.png and b/static/icon/Vector2.png differ diff --git a/static/icon/addGroup.png b/static/icon/addGroup.png index 72bbec6..232649b 100644 Binary files a/static/icon/addGroup.png and b/static/icon/addGroup.png differ diff --git a/static/icon/addGroup1.png b/static/icon/addGroup1.png index 271f1e5..803138f 100644 Binary files a/static/icon/addGroup1.png and b/static/icon/addGroup1.png differ diff --git a/static/icon/backAI.png b/static/icon/backAI.png index 16b958a..11ed51f 100644 Binary files a/static/icon/backAI.png and b/static/icon/backAI.png differ diff --git a/static/icon/boy.png b/static/icon/boy.png index 0628209..9ccb778 100644 Binary files a/static/icon/boy.png and b/static/icon/boy.png differ diff --git a/static/icon/carmreupload.png b/static/icon/carmreupload.png deleted file mode 100644 index ee77a12..0000000 Binary files a/static/icon/carmreupload.png and /dev/null differ diff --git a/static/icon/doc.png b/static/icon/doc.png deleted file mode 100644 index 040e4fd..0000000 Binary files a/static/icon/doc.png and /dev/null differ diff --git a/static/icon/file1.png b/static/icon/file1.png new file mode 100644 index 0000000..c44243d Binary files /dev/null and b/static/icon/file1.png differ diff --git a/static/icon/file2.png b/static/icon/file2.png new file mode 100644 index 0000000..0776598 Binary files /dev/null and b/static/icon/file2.png differ diff --git a/static/icon/file3.png b/static/icon/file3.png new file mode 100644 index 0000000..071100b Binary files /dev/null and b/static/icon/file3.png differ diff --git a/static/icon/fileupload.png b/static/icon/fileupload.png deleted file mode 100644 index 779826f..0000000 Binary files a/static/icon/fileupload.png and /dev/null differ diff --git a/static/icon/filter.png b/static/icon/filter.png index 945b6c2..706cb34 100644 Binary files a/static/icon/filter.png and b/static/icon/filter.png differ diff --git a/static/icon/flame.png b/static/icon/flame.png index c1c1c0c..5f3b10d 100644 Binary files a/static/icon/flame.png and b/static/icon/flame.png differ diff --git a/static/icon/girl.png b/static/icon/girl.png index 1b7ce26..7164286 100644 Binary files a/static/icon/girl.png and b/static/icon/girl.png differ diff --git a/static/icon/imgupload.png b/static/icon/imgupload.png deleted file mode 100644 index 66ae9cb..0000000 Binary files a/static/icon/imgupload.png and /dev/null differ diff --git a/static/icon/peopled.png b/static/icon/peopled.png index c806ad6..0d057a9 100644 Binary files a/static/icon/peopled.png and b/static/icon/peopled.png differ diff --git a/static/icon/point.png b/static/icon/point.png index 70f1f51..af0833a 100644 Binary files a/static/icon/point.png and b/static/icon/point.png differ diff --git a/static/icon/point2.png b/static/icon/point2.png index 40afccd..0cdd0be 100644 Binary files a/static/icon/point2.png and b/static/icon/point2.png differ diff --git a/static/icon/send2x.png b/static/icon/send2x.png index 031442b..cc89d57 100644 Binary files a/static/icon/send2x.png and b/static/icon/send2x.png differ diff --git a/static/icon/send2xx.png b/static/icon/send2xx.png index d93bc72..221d628 100644 Binary files a/static/icon/send2xx.png and b/static/icon/send2xx.png differ diff --git a/static/icon/send3.png b/static/icon/send3.png index 826cfe6..d4c7758 100644 Binary files a/static/icon/send3.png and b/static/icon/send3.png differ diff --git a/static/icon/send4.png b/static/icon/send4.png index a0f8843..0a4d35c 100644 Binary files a/static/icon/send4.png and b/static/icon/send4.png differ diff --git a/static/icon/tips2.png b/static/icon/tips2.png index 3bc712d..884ec9a 100644 Binary files a/static/icon/tips2.png and b/static/icon/tips2.png differ diff --git a/static/icon/woman.png b/static/icon/woman.png index e0d5318..fb2813b 100644 Binary files a/static/icon/woman.png and b/static/icon/woman.png differ diff --git a/static/tabbar/.DS_Store b/static/tabbar/.DS_Store index 45de7c8..d350365 100644 Binary files a/static/tabbar/.DS_Store and b/static/tabbar/.DS_Store differ