Skip to content

Commit

Permalink
2.11.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Dooy committed Nov 28, 2023
1 parent c30f5ba commit db68272
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 10 deletions.
10 changes: 10 additions & 0 deletions changlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 功能升级日志

## 2.11.8
- 🐞 修复:midjourney 辅助提示“性格” 出现的bug
- 😄 新增:最新版本检查
- 😄 新增:midjourney 获取seed

## 2.11.7
- 😀 新增:midjourney 换脸
- 😀 新增:midjourney 混图
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatgpt-web-midjourney-proxy",
"version": "2.11.7",
"version": "2.11.8",
"private": false,
"description": "ChatGPT Web Midjourney Proxy",
"author": "Dooy <[email protected]>",
Expand Down
51 changes: 51 additions & 0 deletions src/api/mjapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//import { useChat } from '@/views/chat/hooks/useChat'

import { homeStore } from "@/store";
import { copyToClip } from "@/utils/copy";
//import { useMessage } from "naive-ui";

//const { addChat, updateChat, updateChatSome, getChatByUuidAndIndex } = useChat()
export function upImg(file:any ):Promise<any>
Expand Down Expand Up @@ -75,6 +77,7 @@ export const mlog = (msg: string, ...args: unknown[]) => {
}

const getUrl=(url:string)=>{
if(url.indexOf('http')==0) return url;
return `/mjapi${url}`;
}

Expand All @@ -95,6 +98,7 @@ export const mjFetch=(url:string,data?:any)=>{

}


export const flechTask= ( chat:Chat.Chat)=>{
let cnt=0;
const check= async ()=>{
Expand Down Expand Up @@ -182,3 +186,50 @@ const backOpt= (d:any, chat:Chat.Chat )=>{
}
}

export const mjSeed= async ( mjid:string )=>{
const ts= await mjFetch(`/mj/task/${mjid}/image-seed`);
return ts;
}



export const getSeed = async (cchat:Chat.Chat,message:any )=>{
// const message = useMessage();
// let cchat = props.chat;
if(!cchat.mjID ) return ;
let seed=0 ;
if(cchat.opt?.seed) seed =cchat.opt?.seed;
else{
try{
message.info('获取中...');
const res:any = await mjSeed( cchat.mjID);
seed= res.result;
if(seed>0 ) {

if ( cchat.opt ){
cchat.opt.seed = seed;

homeStore.setMyData({act:'updateChat', actData:cchat });
}
message.success('获取成功');
}

} catch(e){
message.error('获取失败')
}
}
mlog('getSeed',seed);
if(seed>0 ) {
await copyToClip(`${seed}`);
message.success('复制seed成功');
}

}

export const getLastVersion= async ()=>{
const url='https://api.github.com/repos/Dooy/chatgpt-web-midjourney-proxy/tags?per_page=1';
const a= await mjFetch(url);
mlog('lastVersion', a );
return a;

}
34 changes: 30 additions & 4 deletions src/components/common/Setting/About.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { computed, onMounted, ref } from 'vue'
import { NSpin } from 'naive-ui'
import pkg from '../../../../package.json'
import { fetchChatConfig } from '@/api'
import { fetchChatConfig ,getLastVersion} from '@/api'
import { useAuthStore } from '@/store'
interface ConfigState {
Expand All @@ -19,6 +19,7 @@ const authStore = useAuthStore()
const loading = ref(false)
const config = ref<ConfigState>()
const st = ref({lastVersion:''})
const isChatGPTAPI = computed<boolean>(() => !!authStore.isChatGPTAPI)
Expand All @@ -32,17 +33,42 @@ async function fetchConfig() {
loading.value = false
}
}
onMounted(() => {
fetchConfig()
const getLastFrom= ()=>{
const str = localStorage.getItem('lastVersion');
if(!str) return '';
const obj = JSON.parse(str);
if( Date.now()- obj.t>1000*60*60 ){
return '';
}
return obj.v;
}
onMounted( () => {
fetchConfig();
let t = getLastFrom();
if(t){
st.value.lastVersion = t ;
}else {
getLastVersion().then(res=>{
if( res[0] && res[0].name ){
st.value.lastVersion = res[0].name;
localStorage.setItem('lastVersion',JSON.stringify( {v: res[0].name,t: Date.now() } ))
}
});
}
})
const isShow = computed(()=>{
return st.value.lastVersion && st.value.lastVersion != `v${pkg.version}`
});
</script>

<template>
<NSpin :show="loading">
<div class="p-4 space-y-4">
<h2 class="text-xl font-bold">
Version - {{ pkg.version }}
<a class="text-red-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank" v-if=" isShow "> (发现更新版本 {{ st.lastVersion }})</a>
<a class="text-gray-500" href="https://github.com/Dooy/chatgpt-web-midjourney-proxy" target="_blank" v-else-if="st.lastVersion"> (已是最新版本)</a>
</h2>
<div class="p-2 space-y-2 rounded-md bg-neutral-100 dark:bg-neutral-700">
<p>
Expand Down
8 changes: 7 additions & 1 deletion src/typings/chat.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ declare namespace Chat {
requestOptions: { prompt: string; options?: ConversationRequest | null }
model?:string //模型
mjID?:string //MJ的ID
opt?:{progress?:string, imageUrl?:string, status?:string, images?:string[],promptEn?:string,buttons?:any[],action?:string} //
opt?:{
progress?:string,seed?:number, imageUrl?:string
, status?:string, images?:string[]
,promptEn?:string,buttons?:any[]
,action?:string
} //
uuid?:number
index?:number

//progress?:string
}

Expand Down
40 changes: 36 additions & 4 deletions src/views/chat/components/Message/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { t } from '@/locales'
import { useBasicLayout } from '@/hooks/useBasicLayout'
import { copyToClip } from '@/utils/copy'
import { homeStore } from '@/store'
import { mlog } from '@/api'
import { getSeed } from '@/api'
interface Props {
dateTime?: string
Expand Down Expand Up @@ -84,9 +84,9 @@ function handleRegenerate() {
emit('regenerate')
}
async function handleCopy() {
async function handleCopy(txt?:string) {
try {
await copyToClip(props.text || '')
await copyToClip( txt|| props.text || '')
message.success('复制成功')
}
catch {
Expand All @@ -97,7 +97,35 @@ async function handleCopy() {
const sendReload = () => {
homeStore.setMyData({act:'mjReload', actData:{mjID:props.chat.mjID} })
}
// const getSeed = async ()=>{
// let cchat = props.chat;
// if(!cchat.mjID ) return ;
// let seed=0 ;
// if(props.chat.opt?.seed) seed = props.chat.opt?.seed;
// else{
// try{
// message.info('获取中...');
// const res:any = await mjSeed( cchat.mjID);
// seed= res.result;
// if(seed>0 ) {
// if ( cchat.opt ){
// cchat.opt.seed = seed;
// homeStore.setMyData({act:'updateChat', actData:cchat });
// }
// message.success('获取成功');
// }
// } catch(e){
// message.error('获取失败')
// }
// }
// mlog('getSeed',seed);
// if(seed>0 ) await handleCopy(`${seed}`);
// }
</script>

<template>
Expand All @@ -117,6 +145,10 @@ const sendReload = () => {
<span>{{ dateTime }}</span>
<!-- <span>{{ chat.opt?.progress }}</span> -->
<SvgIcon icon="ri:restart-line" @click="sendReload" class="cursor-pointer text-neutral-300 hover:text-neutral-800 dark:hover:text-neutral-300 " v-if="chat.opt?.status=='SUCCESS'"></SvgIcon>
<div v-if="chat.opt?.status=='SUCCESS'" @click="getSeed(chat, message )" class="cursor-pointer">
<span v-if="chat.opt?.seed">Seed:{{ chat.opt?.seed }}</span>
<span v-else>Seed</span>
</div>
</p>
<div
Expand Down
1 change: 1 addition & 0 deletions src/views/mj/aiDrawInputItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function createPrompt(rz:string){
for(let v of farr){
if( ! f.value[v.k] || f.value[v.k]==null || f.value[v.k]=='' ) continue;
if(v.k=='quality') rz +=` --q ${f.value.quality}`;
else if(v.k=='styles') rz +=` ${f.value.styles}`;
else if(v.k=='version') {
st.value.bot= '';
if(['MID_JOURNEY','NIJI_JOURNEY'].indexOf(f.value.version)>-1 ){
Expand Down

0 comments on commit db68272

Please sign in to comment.