From 61aeaa7b2c91a47cf3edaf2f180acdf7220e1755 Mon Sep 17 00:00:00 2001 From: Dooy Date: Wed, 20 Dec 2023 17:04:28 +0800 Subject: [PATCH] 2.13.1 --- changlog.md | 4 ++-- src/api/mjapi.ts | 22 ++++++++++++++++++++++ src/locales/en-US.ts | 3 ++- src/locales/ko-KR.ts | 3 ++- src/locales/ru-RU.ts | 3 ++- src/locales/zh-CN.ts | 3 ++- src/locales/zh-TW.ts | 3 ++- src/views/mj/aiGptInput.vue | 12 ++++++++---- 8 files changed, 42 insertions(+), 11 deletions(-) diff --git a/changlog.md b/changlog.md index 0310be26bb..254d5b9123 100644 --- a/changlog.md +++ b/changlog.md @@ -2,8 +2,8 @@ ## 2.13.1 - 🐞 修复: gpts 加载排序 -- 😄 新建: google、百度统计 -- 😄 新建: 文件支持拖拽上传 #39 +- 😄 新增: google、百度统计 +- 😄 新增: 文件支持拖拽上传、粘贴截图上传 #39 ## 2.12.11 diff --git a/src/api/mjapi.ts b/src/api/mjapi.ts index d3c7e951fe..450ac9bce1 100644 --- a/src/api/mjapi.ts +++ b/src/api/mjapi.ts @@ -310,3 +310,25 @@ export const loadGallery = async ()=>{ if( d.length>0 ) localSaveAny({ctime: Date.now(), d}, localKey); return d as any[] ; } + + +export function getFileFromClipboard(event:any ){ + let rz=[]; + if ( event.clipboardData || event.originalEvent ) { + let clipboardData = (event.clipboardData || event.originalEvent.clipboardData); + if (clipboardData.items) { + let items = clipboardData.items; + // mlog('getFileFromClipboard', items ); + for (let i = 0; i < items.length; i++) { + if (items[i].type.indexOf("image") !== -1 || items[i].kind === 'file') { + //rz.push( await fileToBase64( items[i].getAsFile()) ); + //mlog('fff', items[i] ); + rz.push( items[i].getAsFile()) + } + } + + } + } + //console.log('passs>>' ,rz ); + return rz; +} diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 72259a37c5..56565c12a1 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -30,7 +30,8 @@ export default { }, chat: { newChatButton: 'New Chat', - placeholder: 'Ask me anything...(Shift + Enter = line break, "/" to trigger prompts)', + //placeholder: 'Ask me anything...(Shift + Enter = line break, "/" to trigger prompts)', + placeholder: 'Ask me anything, or paste screenshots or drag the file .(Shift + Enter = line break, "/" to trigger prompts)', placeholderMobile: 'Ask me anything...', copy: 'Copy', copied: 'Copied', diff --git a/src/locales/ko-KR.ts b/src/locales/ko-KR.ts index 7faaf1d244..329cfd7fe9 100644 --- a/src/locales/ko-KR.ts +++ b/src/locales/ko-KR.ts @@ -30,7 +30,8 @@ export default { }, chat: { newChatButton: '새로운 채팅', - placeholder: '무엇이든 물어보세요...(Shift + Enter = 줄바꿈, "/"를 눌러서 힌트를 보세요)', + //placeholder: '무엇이든 물어보세요...(Shift + Enter = 줄바꿈, "/"를 눌러서 힌트를 보세요)', + placeholder: '할 말을 입력하거나 스크린샷을 붙여넣거나 파일을 드래그 앤 드롭할 수 있습니다.', placeholderMobile: '무엇이든 물어보세요...', copy: '복사', copied: '복사됨', diff --git a/src/locales/ru-RU.ts b/src/locales/ru-RU.ts index b5bc53d9a0..41cec6ed2f 100644 --- a/src/locales/ru-RU.ts +++ b/src/locales/ru-RU.ts @@ -30,7 +30,8 @@ export default { }, chat: { newChatButton: 'Новый чат', - placeholder: 'Спросите меня о чем-нибудь ... (Shift + Enter = перенос строки, "/" для вызова подсказок)', + //placeholder: 'Спросите меня о чем-нибудь ... (Shift + Enter = перенос строки, "/" для вызова подсказок)', + placeholder: 'Вы можете ввести что-то сказать, или вы можете вставить скриншоты или перетащить файлы.', placeholderMobile: 'Спросите меня о чем-нибудь ...', copy: 'Копировать', copied: 'Скопировано', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 2e4769bfd2..74f043ec14 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -30,7 +30,8 @@ export default { }, chat: { newChatButton: '新建聊天', - placeholder: '来说点什么吧...(Shift + Enter = 换行,"/" 触发提示词)', + //placeholder: '来说点什么吧...(Shift + Enter = 换行,"/" 触发提示词)', + placeholder: '可输入说点什么,也可贴截图或拖拽文件(Shift + Enter = 换行,"/" 触发提示词)', placeholderMobile: '来说点什么...', copy: '复制', copied: '复制成功', diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts index ddc35afda4..5f1b27c190 100644 --- a/src/locales/zh-TW.ts +++ b/src/locales/zh-TW.ts @@ -30,7 +30,8 @@ export default { }, chat: { newChatButton: '新增對話', - placeholder: '來說點什麼...(Shift + Enter = 換行,"/" 觸發提示詞)', + //placeholder: '來說點什麼...(Shift + Enter = 換行,"/" 觸發提示詞)', + placeholder: '可輸入說點什麼,也可貼截圖或拖拽檔案(Shift + Enter = 換行,"/" 觸發提示詞)', placeholderMobile: '來說點什麼...', copy: '複製', copied: '複製成功', diff --git a/src/views/mj/aiGptInput.vue b/src/views/mj/aiGptInput.vue index b1e32f425a..94cd3eb58a 100644 --- a/src/views/mj/aiGptInput.vue +++ b/src/views/mj/aiGptInput.vue @@ -4,7 +4,7 @@ import { useBasicLayout } from '@/hooks/useBasicLayout' import { t } from '@/locales' import { NInput ,NButton,useMessage,NImage,NTooltip, NAutoComplete } from 'naive-ui' import { SvgIcon } from '@/components/common'; -import { canVisionModel, GptUploader, mlog, upImg } from '@/api'; +import { canVisionModel, GptUploader, mlog, upImg,getFileFromClipboard } from '@/api'; import { gptConfigStore, homeStore } from '@/store'; import { AutoCompleteOptions } from 'naive-ui/es/auto-complete/src/interface'; import { RenderLabel } from 'naive-ui/es/_internal/select-menu/src/interface'; @@ -18,7 +18,7 @@ const { isMobile } = useBasicLayout() const placeholder = computed(() => { if (isMobile.value) return t('chat.placeholderMobile') - return t('chat.placeholder') + return t('chat.placeholder');//可输入说点什么,也可贴截图或拖拽文件 }) const handleSubmit = ( ) => { @@ -136,9 +136,13 @@ const drop = (e: DragEvent) => { upFile(files[0]); //mlog('drop', files); } +const paste= (e: ClipboardEvent)=>{ + let rz = getFileFromClipboard(e); + if(rz.length>0 ) upFile(rz[0]); +}