Phoenix 7 months ago
parent 820f95a15e
commit 3f99879fce

@ -1,9 +1,7 @@
# Glob API URL # Glob API URL
VITE_GLOB_API_URL=/api VITE_GLOB_API_URL=/api
VITE_APP_API_BASE_URL=http://114.218.158.24:9020 VITE_APP_API_BASE_URL=https://erpapi.fontree.cn
http://114.218.158.24:9020
https://erpapi.fontree.cn
# Whether long replies are supported, which may result in higher API fees # Whether long replies are supported, which may result in higher API fees
VITE_GLOB_OPEN_LONG_REPLY=true VITE_GLOB_OPEN_LONG_REPLY=true

@ -3,7 +3,7 @@
"version": "2.11.1", "version": "2.11.1",
"private": false, "private": false,
"description": "ChatGPT Web", "description": "ChatGPT Web",
"author": "ChenZhaoYu <chenzhaoyu1994@gmail.com>", "author": "xingyuyang",
"keywords": [ "keywords": [
"chatgpt-web", "chatgpt-web",
"chatgpt", "chatgpt",
@ -12,9 +12,9 @@
], ],
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "run-p build-only", "build": "vite build",
"preview": "vite preview", "preview": "vite preview",
"build-only": "vite build --mode prod", "build-prod": "vite build --mode prod",
"type-check": "vue-tsc --noEmit", "type-check": "vue-tsc --noEmit",
"lint": "eslint .", "lint": "eslint .",
"lint:fix": "eslint . --fix", "lint:fix": "eslint . --fix",

@ -30,6 +30,7 @@ export const postRequest = (url,data) => {
} }
export const uploadImg = (data) => { export const uploadImg = (data) => {
return request({ return request({
loading:false,
headers: { headers: {
'Content-Type': 'multipart/form-data' 'Content-Type': 'multipart/form-data'
}, },

@ -8,18 +8,20 @@ const request = axios.create({
}); });
let loading let loading
request.interceptors.request.use((config)=>{ request.interceptors.request.use((config)=>{
loading=ElLoading.service({ if (config.loading!==false){
lock: true, loading=ElLoading.service({
text: '加载中', lock: true,
background: 'rgba(0, 0, 0, 0.7)', text: '加载中',
}) background: 'rgba(0, 0, 0, 0.7)',
})
}
config.headers.Authorization =Local.get('token') config.headers.Authorization =Local.get('token')
return config; return config;
}); });
request.interceptors.response.use((res)=>{ request.interceptors.response.use((res)=>{
loading.close() loading?.close()
return res.data; return res.data;
},()=>{ },()=>{
loading.close() loading?.close()
}); });
export default request; export default request;

@ -116,11 +116,16 @@ onUnmounted(() => {
<div v-else class="whitespace-pre-wrap" > <div v-else class="whitespace-pre-wrap" >
<div v-text="text"></div> <div v-text="text"></div>
<div v-if="fileList?.length>0"> <div v-if="fileList?.length>0">
<a-image <n-image-group>
v-for="item in fileList" <n-space>
:width="200" <n-image
:src="item" v-for="item in fileList"
/> width="150"
:src="item"
/>
</n-space>
</n-image-group>
</div> </div>
</div> </div>

@ -4,7 +4,6 @@ import {Local} from "@/utils/storage/storage";
import dayjs from "dayjs"; import dayjs from "dayjs";
import {computed, onMounted, onUnmounted, ref, watch} from 'vue' import {computed, onMounted, onUnmounted, ref, watch} from 'vue'
import {useRoute} from 'vue-router' 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 {AreaChartOutlined, PlusOutlined} from '@ant-design/icons-vue';
import html2canvas from 'html2canvas' import html2canvas from 'html2canvas'
import {Message} from './components' import {Message} from './components'
@ -99,21 +98,19 @@ const API_URL = `${import.meta.env.VITE_APP_API_BASE_URL}/chat/completion`;
const createParams = () => { const createParams = () => {
const messages = dataSources.value.map((x) => { const messages = dataSources.value.map((x) => {
return { return {
content: (() => { content: (() => {
if (gptMode.value === 'gpt-4-vision-preview') { if (gptMode.value === 'gpt-4-vision-preview') {
return [{ return [{
type: "text", type: "text",
text: x.text text: x.text
}, ...x.fileList.map((y) => { }, ...(Array.isArray(x.fileList) && x.fileList.length > 0 ? x.fileList.map(y => ({
return { type: "image_url",
type: "image_url", image_url: y
image_url: y })) : [])]
} } else {
})] return x.text
} else { }
return x.text })(),
}
})(),
role: x.inversion ? 'user' : 'assistant' role: x.inversion ? 'user' : 'assistant'
} }
}); });
@ -388,17 +385,13 @@ const handleCancel = () => {
previewTitle.value = ''; previewTitle.value = '';
}; };
const handlePreview = async (file) => { const handlePreview = async (file) => {
if (!file.url && !file.preview) { previewImage.value = (await getBase64(file.file));
file.preview = (await getBase64(file.originFileObj)) previewVisible.value = true;
}
previewImage.value = file.url || file.preview;
previewVisible.value = true;
previewTitle.value = file.name || file.url.substring(file.url.lastIndexOf('/') + 1);
}; };
const value = ref('gpt-3.5-turbo'); const value = ref('gpt-3.5-turbo');
const visible = ref(false) const visible = ref(false)
const removeImg = (data) => { 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, () => { watch(gptMode, () => {
currentListUuid.value = '' currentListUuid.value = ''
@ -409,11 +402,11 @@ const fileList1 = ref([])
const isFile = ref(false) const isFile = ref(false)
const upItemImage1 = async (file) => { const upItemImage1 = async (file) => {
const data = { const data = {
file: file.file, file: file.file.file,
} }
const res = await uploadFormData(data) const res = await uploadFormData(data)
if (res.code === 0) { if (res.code === 0) {
file.onSuccess() file.onFinish()
dataSources.value = [...dataSources.value, ...res.data.paragraph.flatMap(n => [n, '']).map((x) => { dataSources.value = [...dataSources.value, ...res.data.paragraph.flatMap(n => [n, '']).map((x) => {
return { return {
dateTime: dayjs().format('YYYY/MM/DD HH:mm:ss'), dateTime: dayjs().format('YYYY/MM/DD HH:mm:ss'),
@ -433,14 +426,17 @@ watch(dataSources,()=>{
scrollToBottom('auto') scrollToBottom('auto')
}) })
const customRequest = async (file) => { const customRequest = async (file) => {
console.log(file,'file')
const res = await uploadImg({ const res = await uploadImg({
file: file.file, file: file.file.file,
source: 'approval' source: 'approval'
}) })
if (res.code === 0) { if (res.code === 0) {
file.onSuccess() file.onFinish()
fileList.value.push({ fileList.value.push({
url: res.data.ori_url id:file.file.id,
url: res.data.ori_url,
status: 'finished',
}) })
} }
} }
@ -515,31 +511,48 @@ const customRequest = async (file) => {
<footer :class="footerClass"> <footer :class="footerClass">
<div class="w-full max-w-screen-xl m-auto"> <div class="w-full max-w-screen-xl m-auto">
<div class="flex items-center justify-center space-x-2" style="flex-wrap: initial"> <div class="flex items-center justify-center space-x-2" style="flex-wrap: initial">
<a-popover :open="visible1" trigger="click"> <NPopover trigger="click" :show="visible1">
<template #content> <template #trigger>
<div class="clearfix"> <HoverButton @click="visible1=!visible1">
<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">
<span class="text-xl text-[#4f555e] dark:text-white" <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"/> <SvgIcon icon="ri:upload-2-line"/>
</span> </span>
</HoverButton> </HoverButton>
</a-popover> </template>
<a-popover v-if="gptMode==='gpt-4-vision-preview'" :open="visible" trigger="click"> <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> <template #content>
<div class="clearfix"> <div class="clearfix">
<a-upload <a-upload
@ -566,7 +579,7 @@ const customRequest = async (file) => {
<AreaChartOutlined/> <AreaChartOutlined/>
</span> </span>
</HoverButton> </HoverButton>
</a-popover> </a-popover>-->
<!-- <HoverButton v-if="!isMobile" @click="handleClear"> <!-- <HoverButton v-if="!isMobile" @click="handleClear">
<span class="text-xl text-[#4f555e] dark:text-white"> <span class="text-xl text-[#4f555e] dark:text-white">
<SvgIcon icon="ri:delete-bin-line" /> <SvgIcon icon="ri:delete-bin-line" />
@ -601,6 +614,7 @@ const customRequest = async (file) => {
@blur="handleBlur" @blur="handleBlur"
@keypress="handleEnter" @keypress="handleEnter"
/> --> /> -->
<NInput <NInput
style="width:75%" style="width:75%"
ref="inputRef" ref="inputRef"
@ -626,6 +640,13 @@ const customRequest = async (file) => {
</div> </div>
</div> </div>
</footer> </footer>
<NModal
v-model:show="previewVisible"
preset="card"
style="width: 600px"
>
<img :src="previewImage" style="width: 100%">
</NModal>
</div> </div>
</template> </template>
<style scoped> <style scoped>

@ -3,6 +3,9 @@ import type { PluginOption } from 'vite'
import { defineConfig, loadEnv } from 'vite' import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa' 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[] { function setupPlugins(env: ImportMetaEnv): PluginOption[] {
return [ return [
vue(), vue(),
@ -29,7 +32,24 @@ export default defineConfig((env) => {
'@': path.resolve(process.cwd(), 'src'), '@': path.resolve(process.cwd(), 'src'),
}, },
}, },
plugins: [setupPlugins(viteEnv)], plugins: [setupPlugins(viteEnv),
AutoImport({
imports: [
'vue',
{
'naive-ui': [
'useDialog',
'useMessage',
'useNotification',
'useLoadingBar'
]
}
]
}),
Components({
resolvers: [NaiveUiResolver()]
})
],
server: { server: {
host: '0.0.0.0', host: '0.0.0.0',
port: 1002, port: 1002,

Loading…
Cancel
Save