From 12e1da5681e6437f5fc3840cbafa0d555d98b2e2 Mon Sep 17 00:00:00 2001 From: lq1405 <2769838458@qq.com> Date: Tue, 8 Jul 2025 15:55:45 +0800 Subject: [PATCH] =?UTF-8?q?V=203.4.1=20(2025.07.08)=201.=20=E9=80=82?= =?UTF-8?q?=E9=85=8D=20MJ=20V7=20=E7=89=88=E6=9C=AC=E7=9A=84=20oref=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=202.=20=E6=81=A2=E5=A4=8D=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E5=8D=95=E5=B8=A7=E4=B8=AD=E6=96=87=E7=89=88=E6=8E=A8=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=203.=20=E5=87=BA=E5=9B=BE=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=AC=E5=9C=B0=E5=9B=BE=E7=89=87=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD=204.=20=E6=96=B0=E5=A2=9E=20=E6=8E=A8=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=20Laitool=E6=8F=90=E7=A4=BA=E8=AF=8D?= =?UTF-8?q?=E4=B8=93=E5=AE=B6-=E5=85=A8=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- resources/scripts/db/book.realm.lock | Bin 1416 -> 1416 bytes resources/scripts/db/software.realm.lock | Bin 1416 -> 1416 bytes src/define/data/softawareData.ts | 16 +- src/define/gptDefine.js | 235 +++++++++++++++--- src/main/Service/MJ/mj.ts | 13 +- src/renderer/src/common/image.ts | 56 +++++ .../Book/MJReverse/MonitorStatus.vue | 19 +- 8 files changed, 279 insertions(+), 62 deletions(-) create mode 100644 src/renderer/src/common/image.ts diff --git a/package.json b/package.json index d56b6b1..ce59fc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "laitool", - "version": "3.4.0", + "version": "3.4.1", "description": "An AI tool for image processing, video processing, and other functions.", "main": "./out/main/index.js", "author": "laitool.cn", diff --git a/resources/scripts/db/book.realm.lock b/resources/scripts/db/book.realm.lock index bb9e84c309a54551785eefa053528d9bef3ee4d4..7e8318dfbd672b9c30d6d37a98e5eb8aa477ae88 100644 GIT binary patch literal 1416 zcmZQ%(1|Ho}f fFpW+i+y_x-V2^M+y4q3xXb6mkz-R~zg%AJ$C3*-g diff --git a/resources/scripts/db/software.realm.lock b/resources/scripts/db/software.realm.lock index fe9b9e53be9339ee9043bbf47d9ae7d3514869f4..221955b647e751eefe938e435338edd61ee39bf5 100644 GIT binary patch literal 1416 zcmZQ%vIA9sFgBn76a?7^!XS_cw-@4;9m%W^ g2{aPnK8U&lSrBzFbI_EJaz{g8Gz3ONV9,每一次输出都要严格遵守,一步一步思考,按顺序执行 ,使用默认 ,下面是小说文本:`, + prompt_example: [ + { + user_content: '上研究生后。发现导师竟然是曾经网恋的前男友。', + assistant_content: + '一位女士走进一间宽敞、光线充足的研究生实验室,她的目光定格在前方工作台前一位正在辛勤工作的男士身上--他是她的新导师;他身着深色衬衫和熨烫整齐的长裤,身材高大,散发着专业精神和魅力; 温暖的环境光柔和地照亮了他们过去网恋时熟悉的轮廓,皱起的眉头和专注的目光透露出学者坚定不移的奉献精神;熙熙攘攘的研究生和精密的设备融为一体,构成了一幅现代学术画卷,她的内心涌动着甜蜜的怀旧和尴尬的现实这两种复杂的情绪' + }, + { + user_content: '我欲哭无泪', + assistant_content: + '一位女士坐在昏暗的房间角落,双手紧握,眼神空洞,脸上流露出无法言说的悲伤;她的周围是散乱的家具和昏黄的灯光,营造出一种压抑和孤寂的氛围;她的身体微微前倾,仿佛承受着巨大的心理压力,却无法找到宣泄的出口;整个场景透露出一种深深的无奈和心碎,她的表情和姿态都在无声地诉说着“我欲哭无泪”的绝望。' + }, + { + user_content: '被窝里他搂着我的腰亲我,再丢掉我,就把你锁起来。', + assistant_content: + '在昏暗的卧室中,一对情侣亲密地依偎在温暖的被窝里,男子温柔地搂着女子的腰,轻吻她的脸颊,气氛温馨而浪漫;然而,随着话语的转变,男子的动作突然变得愤怒,他用力地推开女子,眼神中闪过一丝威胁;女子的表情由幸福转为惊恐,她紧紧抓住被单,试图保护自己;整个场景充满了紧张和不安,昏暗的灯光和凌乱的床铺加剧了这种氛围,仿佛预示着即将发生的冲突和束缚' + } + ], + id: 'a93b693e-bb3f-406d-9730-cba43a6585e7' + }, + // 小说提示词-仅出词 onlyPromptMJSystemContent: { prompt_name: '小说提示词-仅出词', @@ -1052,6 +1199,8 @@ export const gptDefine = { return this.replace(this.laitoolStoryboardMasterGeneralSystemContent, replacements) case 'laitoolTextToCartoon': return this.replace(this.laitoolTextToCartoonSystemContent, replacements) + case 'laitoolTextToCartoonOptimize': + return this.replace(this.laitoolTextToCartoonOptimizeSystemContent, replacements) default: throw new Error(`不存在的类型 : ${type}`) } @@ -1081,6 +1230,8 @@ export const gptDefine = { return this.replace(this.laitoolStoryboardMasterGeneralUserContent, replacements) case 'laitoolTextToCartoon': return this.replace(this.laitoolTextToCartoonUserContent, replacements) + case 'laitoolTextToCartoonOptimize': + return this.replace(this.laitoolTextToCartoonOptimizeUserContent, replacements) default: throw new Error(`不存在的类型 : ${type}`) } @@ -1138,7 +1289,11 @@ export const gptDefine = { }, { value: 'laitoolTextToCartoon', - label: 'Laitool文本转漫画提示词大师' + label: 'Laitool提示词专家-全能版' + }, + { + value: 'laitoolTextToCartoonOptimize', + label: 'Laitool提示词专家-全能优化版' }, { value: 'superSinglePromptChinese', diff --git a/src/main/Service/MJ/mj.ts b/src/main/Service/MJ/mj.ts index 6c3121f..deb6ed5 100644 --- a/src/main/Service/MJ/mj.ts +++ b/src/main/Service/MJ/mj.ts @@ -319,7 +319,7 @@ export class MJOpt { async GetCharacterPresetStringByIds(ids: string[]): Promise<{ characterString: string, characterUrl: string }> { let characterString = '' let characterUrl = '' - let crefCw = undefined + let crefCw = 50; for (let i = 0; i < ids.length; i++) { const element = ids[i]; @@ -337,9 +337,14 @@ export class MJOpt { } } - //这边坐下合并s + //这边坐下合并cref if (characterUrl != '') { - characterUrl = ` --cref ${characterUrl} --cw ${crefCw}` + // 判断是不是v7版本 是的话有人物垫图的话用 --oref + if (this.mjSimpleSetting.imageModel == 'a26fc136-4558-4426-b827-fa7d0c189fc9') { + characterUrl = ` --oref ${characterUrl} --ow ${crefCw}` + } else { + characterUrl = ` --cref ${characterUrl} --cw ${crefCw}` + } } return { characterString, characterUrl } } @@ -491,7 +496,7 @@ export class MJOpt { } } //#endregion - + //#region MJ生成图片相关 /** * 单个生成图片,将任务添加到队列中 diff --git a/src/renderer/src/common/image.ts b/src/renderer/src/common/image.ts new file mode 100644 index 0000000..e9b75e0 --- /dev/null +++ b/src/renderer/src/common/image.ts @@ -0,0 +1,56 @@ +import { isEmpty } from "lodash" + +// 通过加载图片的方式检查文件是否存在 +export function checkImageExists(imagePath: string): Promise { + return new Promise((resolve) => { + if (!imagePath || isEmpty(imagePath)) { + resolve(false) + return + } + + const img = new Image() + + // 设置超时,避免长时间等待 + const timeout = setTimeout(() => { + resolve(false) + }, 5000) // 5秒超时 + + img.onload = () => { + clearTimeout(timeout) + resolve(true) + } + + img.onerror = () => { + clearTimeout(timeout) + resolve(false) + } + + try { + let imgSrc = imagePath + + // 如果路径没有协议前缀,则添加file://前缀 + if ( + !imgSrc.startsWith('file://') && + !imgSrc.startsWith('http://') && + !imgSrc.startsWith('https://') + ) { + // Windows路径处理:C:\path\to\file -> file:///C:/path/to/file + if (imgSrc.match(/^[A-Za-z]:\\/)) { + imgSrc = 'file:///' + imgSrc.replace(/\\/g, '/') + } else { + // Unix-like路径处理 + imgSrc = 'file://' + imgSrc + } + } + + // 添加时间戳避免缓存 + imgSrc += `?t=${Date.now()}` + + img.src = imgSrc + } catch (error) { + clearTimeout(timeout) + console.error('设置图片源时出错:', error) + resolve(false) + } + }) +} \ No newline at end of file diff --git a/src/renderer/src/components/Book/MJReverse/MonitorStatus.vue b/src/renderer/src/components/Book/MJReverse/MonitorStatus.vue index cc202fe..f11c003 100644 --- a/src/renderer/src/components/Book/MJReverse/MonitorStatus.vue +++ b/src/renderer/src/components/Book/MJReverse/MonitorStatus.vue @@ -72,6 +72,7 @@ import { NProgress, useMessage } from 'naive-ui' import { useReverseManageStore } from '../../../../../stores/reverseManage' import { useSoftwareStore } from '../../../../../stores/software' import { isEmpty } from 'lodash' +import { checkImageExists } from '@/renderer/src/common/image' let gptPromptPercentage = ref(0) let promptPercentage = ref(0) @@ -85,7 +86,7 @@ let message = useMessage() let test = ref('error-class') // 计算所有的数据的百分比 -function ComputePercentage() { +async function ComputePercentage() { if ( reverseManageStore && reverseManageStore.selectBookTaskDetail && @@ -96,7 +97,8 @@ function ComputePercentage() { let promptCount = 0 let imageCount = 0 let reversePromptCount = 0 - reverseManageStore.selectBookTaskDetail.forEach((item) => { + + for (const item of reverseManageStore.selectBookTaskDetail) { if (!isEmpty(item.gptPrompt)) { gptPromptCount++ } @@ -104,15 +106,16 @@ function ComputePercentage() { promptCount++ } - // 计算图片的百分比。这个条件比较复杂 - if (item.outImagePath) { + // 现在 await 会正确等待 + let existImage = await checkImageExists(item.outImagePath) + if (item.outImagePath && existImage) { imageCount++ } if (item.reversePrompt && item.reversePrompt.length > 0) { reversePromptCount++ } - }) + } // 计算推理提示词的百分比 gptPromptPercentage.value = Math.floor((gptPromptCount / total) * 100) @@ -131,9 +134,9 @@ onMounted(() => { ComputePercentage() // 这边开始定时执行计算 - setInterval(() => { - ComputePercentage() - }, 5000) + setInterval(async () => { + await ComputePercentage() + }, 10000) }) function ErrorPosition(type) {