From a5853369c1ebede1e7b5d911b8551460a66ad6df Mon Sep 17 00:00:00 2001 From: Dooy Date: Fri, 15 Dec 2023 17:13:54 +0800 Subject: [PATCH] 2.12.9 --- README.md | 12 ++++ api/session.js | 1 + changlog.md | 5 ++ package.json | 2 +- service/src/index.ts | 3 +- src/api/mjapi.ts | 29 ++++++++ src/store/homeStore.ts | 1 + src/views/chat/components/Message/index.vue | 16 +++-- src/views/chat/index.vue | 6 +- src/views/mj/aiGallery.vue | 2 +- src/views/mj/aiGalleryItem.vue | 76 +++++++++++++++++++-- src/views/mj/aiGpt.vue | 2 + src/views/mj/aiGptInput.vue | 6 +- 13 files changed, 142 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 589169d822..f26c9df297 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,18 @@ [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/Dooy/chatgpt-web-midjourney-proxy&env=OPENAI_API_BASE_URL&env=OPENAI_API_KEY&env=MJ_SERVER&env=MJ_API_SECRET&project-name=chatgpt-web-midjourney-proxy&repository-name=chatgpt-web-midjourney-proxy) +## env 环境变量 + +| 环境变量 | 说明 | 默认值 |docker等部署| vercel 部署| +| --- | --- | --- | --- | --- | +| OPENAI_API_BASE_URL | OpenAI API 接口地址 | https://api.openai.com | ✅ | ✅| +| OPENAI_API_KEY | OpenAI API 密钥 | sk-xxxxx | ✅ | ✅| +| OPENAI_API_MODEL | 默认模型 | gpt-3.5-turbo | ✅ | ✅| +| MJ_SERVER | mj proxy 接口地址 | https://api.openai.com | ✅ | ✅| +| MJ_API_SECRET | mj proxy | 空 | ✅ | ✅| +| AUTH_SECRET_KEY | 验证密码 | 无 | ✅ | ✅| +| API_UPLOADER | 支持上传 | 关闭 | ✅ | x| +| HIDE_SERVER | 前端ui隐藏服务端| | ✅ | x| ## docker 部署 **假设**: diff --git a/api/session.js b/api/session.js index 28f77cfafc..a8acb10917 100644 --- a/api/session.js +++ b/api/session.js @@ -11,6 +11,7 @@ module.exports = (req, res) => { "auth": process.env.AUTH_SECRET_KEY?true:false , "model": "ChatGPTAPI", "amodel": process.env.OPENAI_API_MODEL?? "gpt-3.5-turbo" + ,isApiGallery: process.env.MJ_API_GALLERY ? true : false } } res.writeHead(200).end( diff --git a/changlog.md b/changlog.md index 0bd49118c6..8b9d75f0b3 100644 --- a/changlog.md +++ b/changlog.md @@ -1,5 +1,10 @@ # 功能升级日志 +## 2.12.9 +- 🐞 修复:按住回车不放,会一直触发提交刷新页面 #24 +- 🔨 优化:我的画廊 支持来之服务端的数据(适合自建服务器) +- 🔨 优化:midjourney 新增 `原始链接` 按钮 + ## 2.12.8 - 😄 新增:我的画廊 - 🐞 修复:重试按钮、停止按钮功能 #15 diff --git a/package.json b/package.json index c05dc48dc8..2bb891d61a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chatgpt-web-midjourney-proxy", - "version": "2.12.8", + "version": "2.12.9", "private": false, "description": "ChatGPT Web Midjourney Proxy", "author": "Dooy ", diff --git a/service/src/index.ts b/service/src/index.ts index 3d23ba5136..d08e66159b 100644 --- a/service/src/index.ts +++ b/service/src/index.ts @@ -73,7 +73,8 @@ router.post('/session', async (req, res) => { const isUpload= isNotEmptyString( process.env.API_UPLOADER ) const isHideServer= isNotEmptyString( process.env.HIDE_SERVER ); const amodel= process.env.OPENAI_API_MODEL?? "gpt-3.5-turbo" ; - res.send({ status: 'Success', message: '', data: {isHideServer,isUpload, auth: hasAuth, model: currentModel(),amodel } }) + const isApiGallery= isNotEmptyString( process.env.MJ_API_GALLERY ); + res.send({ status: 'Success', message: '', data: {isHideServer,isUpload, auth: hasAuth, model: currentModel(),amodel,isApiGallery } }) } catch (error) { res.send({ status: 'Fail', message: error.message, data: null }) diff --git a/src/api/mjapi.ts b/src/api/mjapi.ts index 8c3b2bd864..d3c7e951fe 100644 --- a/src/api/mjapi.ts +++ b/src/api/mjapi.ts @@ -3,6 +3,8 @@ import { gptConfigStore, gptServerStore, homeStore } from "@/store"; import { copyToClip } from "@/utils/copy"; +import { isNumber } from "@/utils/is"; +import { localGet, localSaveAny } from "./mjsave"; //import { useMessage } from "naive-ui"; export interface gptsType{ gid:string @@ -281,3 +283,30 @@ export const canVisionModel= (model:string)=>{ if(model.indexOf('gpt-4-gizmo')>-1 )return true; return false; } + +function isStringOnlyDigits(input: string): boolean { + // 使用正则表达式检查字符串是否只包含数字 + const regex = /^[0-9]+$/; + return regex.test(input); +} +export const loadGallery = async ()=>{ + let localKey= 'mj-list-condition'; + const d2:any = await localGet(localKey); + //mlog('d2',d2 , (Date.now()- d2.ctime)); + if(d2 && (Date.now()- d2.ctime)<300*1000 ){ + + return d2.d as any[]; + } + let d = await mjFetch(`/mj/gallery`); + //mlog('tsList', d.data.list ); + if( !d.data.list || d.data.list.length ==0 ) return []; + const list =d.data.list as any[]; + const ids = list.filter(v=> isStringOnlyDigits(v.reqid)).map(v=> +v.reqid ) ; + mlog('ids', ids ); + if(ids.length==0) return []; + ///mj/task/list-by-condition + d= await mjFetch('/mj/task/list-by-condition',{ids } ); + + if( d.length>0 ) localSaveAny({ctime: Date.now(), d}, localKey); + return d as any[] ; +} diff --git a/src/store/homeStore.ts b/src/store/homeStore.ts index a33a3867e9..477dfa28bf 100644 --- a/src/store/homeStore.ts +++ b/src/store/homeStore.ts @@ -6,6 +6,7 @@ export const homeStore = reactive({ actData:{} //动作类别 ,local:'' //当前所处的版本 ,session:{} as any + ,isLoader:false } diff --git a/src/views/chat/components/Message/index.vue b/src/views/chat/components/Message/index.vue index ae0052911e..b7030434d5 100644 --- a/src/views/chat/components/Message/index.vue +++ b/src/views/chat/components/Message/index.vue @@ -149,15 +149,19 @@ function handleRegenerate2() {
-

+

{{ dateTime }} {{ chat.model }} - -

- Seed:{{ chat.opt?.seed }} - Seed -
+

{ }) onUnmounted(() => { - if (loading.value) - controller.abort() + + if (loading.value) controller.abort() + homeStore.setMyData({isLoader:false}); }) const local= computed(()=>homeStore.myData.local ); @@ -483,6 +484,7 @@ watch(()=>homeStore.myData.act,(n)=>{ }); const st =ref({inputme:true}); +watch( ()=>loading.value ,(n)=> homeStore.setMyData({isLoader:n }))