s
This commit is contained in:
parent
820f95a15e
commit
3f99879fce
@ -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
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
"version": "2.11.1",
|
||||
"private": false,
|
||||
"description": "ChatGPT Web",
|
||||
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>",
|
||||
"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",
|
||||
|
@ -30,6 +30,7 @@ export const postRequest = (url,data) => {
|
||||
}
|
||||
export const uploadImg = (data) => {
|
||||
return request({
|
||||
loading:false,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
|
@ -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;
|
||||
|
@ -116,11 +116,16 @@ onUnmounted(() => {
|
||||
<div v-else class="whitespace-pre-wrap" >
|
||||
<div v-text="text"></div>
|
||||
<div v-if="fileList?.length>0">
|
||||
<a-image
|
||||
v-for="item in fileList"
|
||||
:width="200"
|
||||
:src="item"
|
||||
/>
|
||||
<n-image-group>
|
||||
<n-space>
|
||||
<n-image
|
||||
v-for="item in fileList"
|
||||
width="150"
|
||||
:src="item"
|
||||
/>
|
||||
</n-space>
|
||||
</n-image-group>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -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) => {
|
||||
<footer :class="footerClass">
|
||||
<div class="w-full max-w-screen-xl m-auto">
|
||||
<div class="flex items-center justify-center space-x-2" style="flex-wrap: initial">
|
||||
<a-popover :open="visible1" trigger="click">
|
||||
<template #content>
|
||||
<div class="clearfix">
|
||||
<a-upload
|
||||
:max-count="1"
|
||||
v-model:file-list="fileList1"
|
||||
name="file"
|
||||
:customRequest="upItemImage1"
|
||||
>
|
||||
<a-button>
|
||||
<upload-outlined></upload-outlined>
|
||||
上传文件
|
||||
</a-button>
|
||||
</a-upload>
|
||||
</div>
|
||||
</template>
|
||||
<HoverButton @click="visible1=!visible1">
|
||||
<NPopover trigger="click" :show="visible1">
|
||||
<template #trigger>
|
||||
<HoverButton @click="visible1=!visible1">
|
||||
<span class="text-xl text-[#4f555e] dark:text-white"
|
||||
style="display: flex;justify-content: center;align-items: center"
|
||||
>
|
||||
style="display: flex;justify-content: center;align-items: center"
|
||||
>
|
||||
<SvgIcon icon="ri:upload-2-line"/>
|
||||
</span>
|
||||
</HoverButton>
|
||||
</a-popover>
|
||||
<a-popover v-if="gptMode==='gpt-4-vision-preview'" :open="visible" trigger="click">
|
||||
</HoverButton>
|
||||
</template>
|
||||
<div class="clearfix">
|
||||
<NUpload
|
||||
:max-count="1"
|
||||
:default-file-list="fileList1"
|
||||
name="file"
|
||||
:customRequest="upItemImage1"
|
||||
>
|
||||
<NButton >上传文件</NButton>
|
||||
</NUpload>
|
||||
</div>
|
||||
|
||||
</NPopover>
|
||||
<NPopover v-if="gptMode==='gpt-4-vision-preview'" :show="visible" trigger="click">
|
||||
<template #trigger>
|
||||
<HoverButton @click="visible=!visible">
|
||||
<span class="text-xl text-[#4f555e] dark:text-white"
|
||||
style="display: flex;justify-content: center;align-items: center"
|
||||
>
|
||||
<AreaChartOutlined/>
|
||||
</span>
|
||||
</HoverButton>
|
||||
</template>
|
||||
<NUpload
|
||||
:file-list-style="{display:'flex'}"
|
||||
:custom-request="customRequest"
|
||||
:default-file-list="fileList"
|
||||
list-type="image-card"
|
||||
:on-preview="handlePreview"
|
||||
:on-remove="removeImg"
|
||||
/>
|
||||
</NPopover>
|
||||
<!-- <a-popover v-if="gptMode==='gpt-4-vision-preview'" :open="visible" trigger="click">
|
||||
<template #content>
|
||||
<div class="clearfix">
|
||||
<a-upload
|
||||
@ -566,7 +579,7 @@ const customRequest = async (file) => {
|
||||
<AreaChartOutlined/>
|
||||
</span>
|
||||
</HoverButton>
|
||||
</a-popover>
|
||||
</a-popover>-->
|
||||
<!-- <HoverButton v-if="!isMobile" @click="handleClear">
|
||||
<span class="text-xl text-[#4f555e] dark:text-white">
|
||||
<SvgIcon icon="ri:delete-bin-line" />
|
||||
@ -601,6 +614,7 @@ const customRequest = async (file) => {
|
||||
@blur="handleBlur"
|
||||
@keypress="handleEnter"
|
||||
/> -->
|
||||
|
||||
<NInput
|
||||
style="width:75%"
|
||||
ref="inputRef"
|
||||
@ -626,6 +640,13 @@ const customRequest = async (file) => {
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<NModal
|
||||
v-model:show="previewVisible"
|
||||
preset="card"
|
||||
style="width: 600px"
|
||||
>
|
||||
<img :src="previewImage" style="width: 100%">
|
||||
</NModal>
|
||||
</div>
|
||||
</template>
|
||||
<style scoped>
|
||||
|
@ -3,6 +3,9 @@ import type { PluginOption } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { VitePWA } from 'vite-plugin-pwa'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
|
||||
function setupPlugins(env: ImportMetaEnv): PluginOption[] {
|
||||
return [
|
||||
vue(),
|
||||
@ -29,7 +32,24 @@ export default defineConfig((env) => {
|
||||
'@': path.resolve(process.cwd(), 'src'),
|
||||
},
|
||||
},
|
||||
plugins: [setupPlugins(viteEnv)],
|
||||
plugins: [setupPlugins(viteEnv),
|
||||
AutoImport({
|
||||
imports: [
|
||||
'vue',
|
||||
{
|
||||
'naive-ui': [
|
||||
'useDialog',
|
||||
'useMessage',
|
||||
'useNotification',
|
||||
'useLoadingBar'
|
||||
]
|
||||
}
|
||||
]
|
||||
}),
|
||||
Components({
|
||||
resolvers: [NaiveUiResolver()]
|
||||
})
|
||||
],
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 1002,
|
||||
|
Loading…
Reference in New Issue
Block a user