LaiTool V3.1.1.

This commit is contained in:
2024-09-12 14:13:09 +08:00
parent 5dc75f018a
commit 918d06e990
123 changed files with 8028 additions and 756 deletions
@@ -15,6 +15,7 @@ export class BookBackTaskList extends Realm.Object<BookBackTaskList> {
updateTime: Date
startTime: number
endTime: number
messageName?: string
static schema: ObjectSchema = {
name: 'BookBackTaskList',
@@ -31,7 +32,8 @@ export class BookBackTaskList extends Realm.Object<BookBackTaskList> {
createTime: 'date',
updateTime: 'date',
startTime: 'int',
endTime: 'int'
endTime: 'int',
messageName: 'string?'
},
primaryKey: 'id'
}
@@ -141,6 +141,7 @@ export class BookTaskDetailModel extends Realm.Object<BookTaskDetailModel> {
timeLimit: string | null // 事件实现(0 -- 3000
subValue: string | null // 包含的字幕数据
characterTags: string[] | null // 角色标签
sceneTags: string[] | null // 场景标签
gptPrompt: string | null // GPT提示词
mjMessage: MJMessage | null // MJ消息
outImagePath: string | null // 输出图片地址
@@ -174,6 +175,7 @@ export class BookTaskDetailModel extends Realm.Object<BookTaskDetailModel> {
subValue: 'string?',
reversePrompt: { type: 'list', objectType: 'ReversePrompt' },
characterTags: { type: 'list', objectType: 'string' },
sceneTags: 'string[]',
gptPrompt: 'string?',
mjMessage: 'MJMessage?',
outImagePath: 'string?',
+36
View File
@@ -0,0 +1,36 @@
import Realm, { ObjectSchema } from 'realm'
export class PresetModel extends Realm.Object<PresetModel> {
id: string
label: string
type: string
showImage?: string
prompt: string
chinesePrompt?: string
imageUrl?: string
srefSw?: number
crefCw?: number
lora?: string
loraWeight?: number
isShow: boolean
children?: string
static schema: ObjectSchema = {
name: 'PresetModel',
properties: {
id: 'string',
label: 'string',
type: 'string',
showImage: 'string?',
imageUrl: 'string?',
prompt: 'string',
chinesePrompt: 'string?',
srefSw: 'int?',
crefCw: 'int?',
lora: 'string?',
loraWeight: 'int?',
isShow: 'bool',
children: 'string?'
},
primaryKey: 'id'
}
}
@@ -140,7 +140,8 @@ export class BookBackTaskListService extends BaseRealmService {
taskType: BookBackTaskType,
executeType = TaskExecuteType.AUTO,
bookTaskId = null,
bookTaskDetailId = null
bookTaskDetailId = null,
responseMessageName: string = null
): GeneralResponse.SuccessItem | GeneralResponse.ErrorItem {
try {
// 通过bookid获取book信息
@@ -181,6 +182,7 @@ export class BookBackTaskListService extends BaseRealmService {
status: BookBackTaskStatus.WAIT,
createTime: new Date(),
updateTime: new Date(),
messageName: responseMessageName,
startTime: 0,
endTime: 0
} as TaskModal.Task
+15 -1
View File
@@ -162,6 +162,20 @@ const migration = (oldRealm: Realm, newRealm: Realm) => {
newBookTask[i].watermarkPosition = '[]'
}
}
if (oldRealm.schemaVersion < 23) {
const oldBookTask = oldRealm.objects('BookTaskDetail')
const newBookTask = newRealm.objects('BookTaskDetail')
for (let i = 0; i < oldBookTask.length; i++) {
newBookTask[i].subImagePath = '[]'
}
}
if (oldRealm.schemaVersion < 24) {
const oldBookTask = oldRealm.objects('BookBackTaskList')
const newBookTask = newRealm.objects('BookBackTaskList')
for (let i = 0; i < oldBookTask.length; i++) {
newBookTask[i].messageName = ''
}
}
}
export class BaseRealmService extends BaseService {
@@ -203,7 +217,7 @@ export class BaseRealmService extends BaseService {
BookTaskDetailModel
],
path: this.dbpath,
schemaVersion: 22,
schemaVersion: 24,
migration: migration
}
this.realm = await Realm.open(config)
@@ -195,6 +195,9 @@ export class BookService extends BaseRealmService {
await CheckFolderExistsOrCreate(bookTaskImageFolder) // 创建默认的任务文件夹
// 修改数据
book.oldVideoPath = path.relative(define.project_path, oldVideoPath)
if (book.type == BookType.ORIGINAL) {
book.oldVideoPath = null
}
let imageCategory = BookImageCategory.MJ
if (book.type == BookType.SD_REVERSE) {
@@ -1,6 +1,6 @@
import Realm from 'realm'
import path from 'path'
import { define } from '../../../define.js'
import { define } from '../../../define'
import { BookTaskModel } from '../../model/Book/bookTask.js'
import { successMessage } from '../../../../main/Public/generalTools'
import { BaseRealmService } from './bookBasic'
@@ -72,6 +72,7 @@ export class BookTaskDetailService extends BaseRealmService {
return JoinPath(define.project_path, subImage)
}),
characterTags: item.characterTags ? item.characterTags.map((tag) => tag) : null,
sceneTags: item.sceneTags ? item.sceneTags.map((tag) => tag) : null,
subValue: isEmpty(item.subValue) ? null : JSON.parse(item.subValue),
reversePrompt: item.reversePrompt.map((reversePrompt) => {
return {
@@ -116,7 +117,7 @@ export class BookTaskDetailService extends BaseRealmService {
* 添加一条小说任务对应的详细数据
* @param BookTaskDetail
*/
public AddBookTaskDetail(bookTaskDetail) {
public AddBookTaskDetail(bookTaskDetail: Book.SelectBookTaskDetail) {
try {
// 判断是不是又小说ID
if (isEmpty(bookTaskDetail.bookId) || isEmpty(bookTaskDetail.bookTaskId)) {
@@ -191,7 +192,6 @@ export class BookTaskDetailService extends BaseRealmService {
*/
UpdateBookTaskDetailMjMessage(bookTaskDetailId: string, mjMessage: Book.MJMessage): void {
try {
console.log('UpdateBookTaskDetailMjMessage', bookTaskDetailId, mjMessage)
this.transaction(() => {
let mjMessageRes = this.realm.objectForPrimaryKey('MJMessage', bookTaskDetailId)
let bookTaskDetail = this.realm.objectForPrimaryKey('BookTaskDetail', bookTaskDetailId)
@@ -1,6 +1,6 @@
import Realm from 'realm'
import path from 'path'
import { define } from '../../../define.js'
import { define } from '../../../define'
import { BookTaskModel } from '../../model/Book/bookTask.js'
import { BookBackTaskStatus, BookImageCategory, BookTaskStatus } from '../../../enum/bookEnum.js'
import { successMessage } from '../../../../main/Public/generalTools'
@@ -0,0 +1,26 @@
import Realm, { UpdateMode } from 'realm'
import path from 'path'
import { errorMessage, successMessage } from '../../../../main/Public/generalTools'
import { BaseSoftWareService } from './softwareBasic.js'
import { isEmpty } from 'lodash'
const { v4: uuidv4 } = require('uuid')
export class ImageStyleService extends BaseSoftWareService {
static instance: ImageStyleService | null = null
realm: Realm
private constructor() {
super()
}
/**
* 获取当前实例对象,为空则创建一个新的
* @returns
*/
public static async getInstance() {
if (ImageStyleService.instance === null) {
ImageStyleService.instance = new ImageStyleService()
await super.getInstance()
}
return ImageStyleService.instance
}
}
@@ -1,7 +1,7 @@
import Realm, { UpdateMode } from 'realm'
import path from 'path'
import { BaseService } from '../baseService'
import { define } from '../../../define.js'
import { define } from '../../../define'
import { SoftwareModel } from '../../model/SoftWare/software'
import { ComponentSize, SoftwareThemeType } from '../../../enum/softwareEnum.js'
import { errorMessage, successMessage } from '../../../../main/Public/generalTools'
@@ -12,6 +12,7 @@ import {
RemoteMJModel
} from '../../model/SoftWare/mjSetting'
import { MJImageType, MJRobotType } from '../../../enum/mjEnum'
import { PresetModel } from '../../model/SoftWare/preset'
const { v4: uuidv4 } = require('uuid')
let dbPath = path.resolve(define.db_path, 'software.realm')
@@ -155,6 +156,9 @@ const migration = (oldRealm: Realm, newRealm: Realm) => {
}
})
}
if (oldRealm.schemaVersion < 22) {
}
}
export class BaseSoftWareService extends BaseService {
@@ -190,10 +194,11 @@ export class BaseSoftWareService extends BaseService {
BrowserMJModel,
RemoteMJModel,
APIMjModel,
MjSettingModel
MjSettingModel,
PresetModel
],
path: dbPath,
schemaVersion: 21, // 当前版本号
schemaVersion: 23, // 当前版本号
migration: migration
}
// 判断当前全局是不是又当前这个
@@ -25,15 +25,25 @@ export class SoftwareService extends BaseSoftWareService {
}
// 修改数据库中行中的某个属性数据
UpdateSoftware(software: SoftwareSettingModel.SoftwareSetting): GeneralResponse.SuccessItem {
try {
UpdateSoftware(software: SoftwareSettingModel.SoftwareSetting) {
if (software.id) {
this.realm.write(() => {
this.realm.create('Software', software, UpdateMode.Modified)
})
// 返回成功信息
return successMessage(null, '修改软件配置信息成功', 'SoftwareService_UpdateSoftware')
} catch (error) {
throw error
} else {
// 没有ID,就修改指定属性
let softwareData = this.realm.objects('Software')
if (softwareData.length <= 0) {
throw new Error('数据库中没有软件配置信息')
}
let _software = softwareData[0]
this.realm.write(() => {
for (let key in software) {
if (software[key] != undefined) {
_software[key] = software[key]
}
}
})
}
}