diff --git a/.env.prod b/.env.prod index 2d32c4a..6b8620b 100644 --- a/.env.prod +++ b/.env.prod @@ -1,9 +1,7 @@ # Glob API URL VITE_GLOB_API_URL=/api -VITE_APP_API_BASE_URL=http://114.218.158.24:9020 -http://114.218.158.24:9020 -https://erpapi.fontree.cn +VITE_APP_API_BASE_URL=https://erpapi.fontree.cn # Whether long replies are supported, which may result in higher API fees VITE_GLOB_OPEN_LONG_REPLY=true diff --git a/package.json b/package.json index e96cdff..afd5d7a 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "2.11.1", "private": false, "description": "ChatGPT Web", - "author": "ChenZhaoYu ", + "author": "xingyuyang", "keywords": [ "chatgpt-web", "chatgpt", @@ -12,9 +12,9 @@ ], "scripts": { "dev": "vite", - "build": "run-p build-only", + "build": "vite build", "preview": "vite preview", - "build-only": "vite build --mode prod", + "build-prod": "vite build --mode prod", "type-check": "vue-tsc --noEmit", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/src/api/api.js b/src/api/api.js index af3cc46..29fa149 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -30,6 +30,7 @@ export const postRequest = (url,data) => { } export const uploadImg = (data) => { return request({ + loading:false, headers: { 'Content-Type': 'multipart/form-data' }, diff --git a/src/utils/request/request.js b/src/utils/request/request.js index 8bae72f..bffd3a8 100644 --- a/src/utils/request/request.js +++ b/src/utils/request/request.js @@ -8,18 +8,20 @@ const request = axios.create({ }); let loading request.interceptors.request.use((config)=>{ -loading=ElLoading.service({ - lock: true, - text: '加载中', - background: 'rgba(0, 0, 0, 0.7)', - }) + if (config.loading!==false){ + loading=ElLoading.service({ + lock: true, + text: '加载中', + background: 'rgba(0, 0, 0, 0.7)', + }) + } config.headers.Authorization =Local.get('token') return config; }); request.interceptors.response.use((res)=>{ - loading.close() + loading?.close() return res.data; },()=>{ - loading.close() + loading?.close() }); export default request; diff --git a/src/views/chat/components/Message/Text.vue b/src/views/chat/components/Message/Text.vue index ff1b83e..ead8e4f 100644 --- a/src/views/chat/components/Message/Text.vue +++ b/src/views/chat/components/Message/Text.vue @@ -116,11 +116,16 @@ onUnmounted(() => {
- + + + + + +
diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index bf4c4c0..360c80a 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -4,7 +4,6 @@ import {Local} from "@/utils/storage/storage"; import dayjs from "dayjs"; import {computed, onMounted, onUnmounted, ref, watch} from 'vue' import {useRoute} from 'vue-router' -import {NAutoComplete, NButton, NInput, useDialog, useMessage, NBackTop,NIcon} from 'naive-ui' import {AreaChartOutlined, PlusOutlined} from '@ant-design/icons-vue'; import html2canvas from 'html2canvas' import {Message} from './components' @@ -99,21 +98,19 @@ const API_URL = `${import.meta.env.VITE_APP_API_BASE_URL}/chat/completion`; const createParams = () => { const messages = dataSources.value.map((x) => { return { - content: (() => { - if (gptMode.value === 'gpt-4-vision-preview') { - return [{ - type: "text", - text: x.text - }, ...x.fileList.map((y) => { - return { - type: "image_url", - image_url: y - } - })] - } else { - return x.text - } - })(), + content: (() => { + if (gptMode.value === 'gpt-4-vision-preview') { + return [{ + type: "text", + text: x.text + }, ...(Array.isArray(x.fileList) && x.fileList.length > 0 ? x.fileList.map(y => ({ + type: "image_url", + image_url: y + })) : [])] + } else { + return x.text + } + })(), role: x.inversion ? 'user' : 'assistant' } }); @@ -388,17 +385,13 @@ const handleCancel = () => { previewTitle.value = ''; }; const handlePreview = async (file) => { - if (!file.url && !file.preview) { - file.preview = (await getBase64(file.originFileObj)) - } - previewImage.value = file.url || file.preview; - previewVisible.value = true; - previewTitle.value = file.name || file.url.substring(file.url.lastIndexOf('/') + 1); + previewImage.value = (await getBase64(file.file)); + previewVisible.value = true; }; const value = ref('gpt-3.5-turbo'); const visible = ref(false) const removeImg = (data) => { - fileList.value.splice(fileList.value.findIndex(x => x.url === data.url), 1) + fileList.value.splice(fileList.value.findIndex(x => x.id === data.file.id), 1) } watch(gptMode, () => { currentListUuid.value = '' @@ -409,11 +402,11 @@ const fileList1 = ref([]) const isFile = ref(false) const upItemImage1 = async (file) => { const data = { - file: file.file, + file: file.file.file, } const res = await uploadFormData(data) if (res.code === 0) { - file.onSuccess() + file.onFinish() dataSources.value = [...dataSources.value, ...res.data.paragraph.flatMap(n => [n, '']).map((x) => { return { dateTime: dayjs().format('YYYY/MM/DD HH:mm:ss'), @@ -433,14 +426,17 @@ watch(dataSources,()=>{ scrollToBottom('auto') }) const customRequest = async (file) => { + console.log(file,'file') const res = await uploadImg({ - file: file.file, + file: file.file.file, source: 'approval' }) if (res.code === 0) { - file.onSuccess() - fileList.value.push({ - url: res.data.ori_url + file.onFinish() + fileList.value.push({ + id:file.file.id, + url: res.data.ori_url, + status: 'finished', }) } } @@ -515,31 +511,48 @@ const customRequest = async (file) => { + + +