2024-08-03 12:46:12 +08:00
|
|
|
|
import { ipcMain } from 'electron'
|
|
|
|
|
|
import { DEFINE_STRING } from '../../define/define_string'
|
|
|
|
|
|
import { MjSimple } from '../discord/mjSimple'
|
|
|
|
|
|
import { TagCustomize } from '../Original/TagCustomize'
|
2024-05-15 12:57:15 +08:00
|
|
|
|
import { MJOriginalImageGenerate } from '../Original/MJOriginalImageGenerate'
|
2024-08-03 12:46:12 +08:00
|
|
|
|
import { PublicMethod } from '../Public/publicMethod'
|
|
|
|
|
|
import { DiscordSimple } from '../discord/discordSimple'
|
|
|
|
|
|
import { Tools } from '../tools'
|
2024-05-15 12:57:15 +08:00
|
|
|
|
import path from 'path'
|
2024-08-03 12:46:12 +08:00
|
|
|
|
import { MJOpt } from '../Service/MJ/mj'
|
2024-05-15 12:57:15 +08:00
|
|
|
|
|
|
|
|
|
|
let mjSimple = new MjSimple(global)
|
|
|
|
|
|
let discordSimple = new DiscordSimple(null)
|
2024-08-03 12:46:12 +08:00
|
|
|
|
let tagCustomize = new TagCustomize(global)
|
|
|
|
|
|
let mJOriginalImageGenerate = new MJOriginalImageGenerate(global)
|
|
|
|
|
|
let publicMethod = new PublicMethod(global)
|
|
|
|
|
|
let mjOpt = new MJOpt()
|
2024-05-15 12:57:15 +08:00
|
|
|
|
|
|
|
|
|
|
function MjIpc() {
|
2024-08-03 12:46:12 +08:00
|
|
|
|
// 监听保存mj的文案配置信息
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.SAVE_WORD_SRT,
|
|
|
|
|
|
async (event, value) => await mjSimple.SvaeMJWordSrt(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 监听获取MJ的文件配置信息
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_MJ_CONFIG_SRT_INFORMATION,
|
|
|
|
|
|
async (event, value) => await mjSimple.GetMJConfigSrtInformation(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 监听获取标签数据
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_TAG_DATA_BY_TYPE_AND_PROPERTY,
|
|
|
|
|
|
async (event, value) => await tagCustomize.GetTagDataByTypeAndProperty(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 保存指定的标签数据
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.SAVE_TAG_PROPERTY_DATA,
|
|
|
|
|
|
async (event, value) => await tagCustomize.SaveTagPropertyData(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 删除指定的标签数据
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.DELETE_TAG_PROPERTY_DATA,
|
|
|
|
|
|
async (event, value) => await tagCustomize.DeleteTagPropertyData(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// MJ 原创生图
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.ORIGINAL_MJ_IMAGE_GENERATE,
|
|
|
|
|
|
async (event, value) => await mJOriginalImageGenerate.OriginalMJImageGenerate(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 获取discord的频道机器人
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_CHANNEL_ROBOTS,
|
|
|
|
|
|
async (event, value) => await mjSimple.GetChannelRobots(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 获取MJ生图的方式
|
|
|
|
|
|
// GetMJGenerateCategory: async (callback) => callback(await ipcRenderer.invoke(DEFINE_STRING.MJ.GET_MJ_GENERATE_CATEGORY)),
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_MJ_GENERATE_CATEGORY,
|
|
|
|
|
|
async (event) => await mjSimple.GetMJGenerateCategory()
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// MJ生成的图片分割
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.IMAGE_SPLIT,
|
|
|
|
|
|
async (event, value) => await mJOriginalImageGenerate.ImageSplit(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 添加MJ敏感词
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.ADD_MJ_BAD_PROMPT,
|
|
|
|
|
|
async (event, value) => await mjSimple.AddMJBadPrompt(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 添加MJ敏感词检查
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.MJ_BAD_PROMPT_CHECK,
|
|
|
|
|
|
async (event, value) => await mjSimple.MJBadPromptCheck(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 获取已经生图完成的数据,并获取图片
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_GENERATED_MJ_IMAGE_AND_SPLIT,
|
|
|
|
|
|
async (event, value) => await mJOriginalImageGenerate.GetGeneratedMJImageAndSplit(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 给图片链接,下载指定的图片并分割保存
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.DOWNLOAD_IMAGE_URL_AND_SPLIT,
|
|
|
|
|
|
async (event, value) => await mJOriginalImageGenerate.DownloadImageUrlAndSplit(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 获取MJ图片的所有的分割尺寸
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_MJ_IMAGE_SCALE,
|
|
|
|
|
|
async (event) => await mjSimple.GetMJImageScale()
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有的MJ生图模型
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.GET_MJ_IMAGE_ROBOT_MODEL,
|
|
|
|
|
|
async (event) => await mjSimple.GetMJImageRobotModel()
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// 自动匹配用户表标签
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.AUTO_MATCH_USER,
|
|
|
|
|
|
async (event, value) => await mJOriginalImageGenerate.AutoMatchUser(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 监听DISCORD界面创建消息,并修改数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
ipcMain.on(
|
|
|
|
|
|
DEFINE_STRING.DISCORD.CREATE_MESSAGE,
|
|
|
|
|
|
async (event, value) => await discordSimple.DiscordCreateMessage(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 监听DISCORD界面的更新消息,并修改数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
ipcMain.on(
|
|
|
|
|
|
DEFINE_STRING.DISCORD.UPDATE_MESSAGE,
|
|
|
|
|
|
async (event, value) => await discordSimple.DiscordUpdateMessage(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 监听DISCORD界面的删除消息,并修改数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
ipcMain.on(
|
|
|
|
|
|
DEFINE_STRING.DISCORD.DELETE_MESSAGE,
|
|
|
|
|
|
async (event, value) => await discordSimple.DiscordDeleteMessage(value)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// MJ出单张图
|
|
|
|
|
|
ipcMain.handle(
|
|
|
|
|
|
DEFINE_STRING.MJ.ADD_MJ_GENADD_MJ_GENERATE_IMAGE_TASK,
|
2024-09-12 14:13:09 +08:00
|
|
|
|
async (event, id, operateBookType, responseMessageName, coverData) =>
|
|
|
|
|
|
await mjOpt.AddMJGenerateImageTask(id, operateBookType, responseMessageName, coverData)
|
2024-08-03 12:46:12 +08:00
|
|
|
|
)
|
2024-05-15 12:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-03 12:46:12 +08:00
|
|
|
|
export { MjIpc }
|