LaiTool V3.0.1-preview.7
This commit is contained in:
@@ -135,13 +135,13 @@ export class BookBackTaskListService extends BaseRealmService {
|
||||
* 新增一个小说相关的后台任务队列
|
||||
* @param bookBackTask 要添加的小说数据
|
||||
*/
|
||||
async AddBookBackTask(
|
||||
AddBookBackTask(
|
||||
bookId: string,
|
||||
taskType: BookBackTaskType,
|
||||
executeType = TaskExecuteType.AUTO,
|
||||
bookTaskId = null,
|
||||
bookTaskDetailId = null
|
||||
) {
|
||||
): GeneralResponse.SuccessItem | GeneralResponse.ErrorItem {
|
||||
try {
|
||||
// 通过bookid获取book信息
|
||||
let book = this.realm.objectForPrimaryKey('Book', bookId)
|
||||
|
||||
@@ -11,6 +11,7 @@ import { isEmpty } from 'lodash'
|
||||
import { FfmpegOptions } from '../../../../main/Service/ffmpegOptions.js'
|
||||
import { version } from '../../../../../package.json'
|
||||
import { Book } from '../../../../model/book.js'
|
||||
import { GeneralResponse } from '../../../../model/generalResponse.js'
|
||||
|
||||
export class BookService extends BaseRealmService {
|
||||
static instance: BookService | null = null
|
||||
@@ -37,7 +38,7 @@ export class BookService extends BaseRealmService {
|
||||
* 获取小说信息,没有找到返回null
|
||||
* @param bookId
|
||||
*/
|
||||
GetBookDataById(bookId): Book.SelectBook | null {
|
||||
GetBookDataById(bookId: string): Book.SelectBook | null {
|
||||
try {
|
||||
if (isEmpty(bookId)) {
|
||||
throw new Error('获取小说信息失败,缺少小说ID')
|
||||
@@ -275,7 +276,7 @@ export class BookService extends BaseRealmService {
|
||||
* @param bookId 小说的ID
|
||||
* @param bookData 要修改的小说数据
|
||||
*/
|
||||
async UpdateBookData(bookId: string, bookData: Book.SelectBook) {
|
||||
UpdateBookData(bookId: string, bookData: Book.SelectBook): Book.SelectBook {
|
||||
try {
|
||||
if (bookId == null) {
|
||||
throw new Error('修改小说数据失败,缺少小说ID')
|
||||
@@ -303,8 +304,27 @@ export class BookService extends BaseRealmService {
|
||||
if (bookRes == null) {
|
||||
throw new Error('获取修改后的小说数据失败,小说ID对应的数据不存在')
|
||||
}
|
||||
// return successMessage(bookRes, '修改小说数据成功', 'ReverseBook_UpdateBookData')
|
||||
return bookRes;
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
return successMessage(bookRes, '修改小说数据成功', 'ReverseBook_UpdateBookData')
|
||||
/**
|
||||
* 删除指定的小说任务
|
||||
* @param bookId 需要删除的小说的ID
|
||||
*/
|
||||
DeleteBookData(bookId: string): void {
|
||||
try {
|
||||
this.transaction(() => {
|
||||
let book = this.realm.objectForPrimaryKey('Book', bookId);
|
||||
if (book == null) {
|
||||
throw new Error('未找到对应的小说')
|
||||
}
|
||||
// 删除对应的小说
|
||||
this.realm.delete(book)
|
||||
})
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
return JoinPath(define.project_path, subImage)
|
||||
}),
|
||||
characterTags: item.characterTags ? item.characterTags.map((tag) => tag) : null,
|
||||
subValue: item.subValue,
|
||||
subValue: isEmpty(item.subValue) ? null : JSON.parse(item.subValue),
|
||||
reversePrompt: item.reversePrompt.map((reversePrompt) => {
|
||||
return {
|
||||
...reversePrompt
|
||||
@@ -101,7 +101,6 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
if (bookTaskDetailId == null) {
|
||||
throw new Error('获取小说任务详细信息失败,缺少ID')
|
||||
}
|
||||
|
||||
let bookTaskDetails = this.GetBookTaskData({ id: bookTaskDetailId })
|
||||
if (bookTaskDetails.data.length <= 0) {
|
||||
return null;
|
||||
@@ -165,7 +164,7 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
* @param bookTaskDetailId
|
||||
* @param updateData
|
||||
*/
|
||||
UpdateBookTaskDetail(bookTaskDetailId: string, updateData: Book.SelectBookTaskDetail) {
|
||||
UpdateBookTaskDetail(bookTaskDetailId: string, updateData: Book.SelectBookTaskDetail): Book.SelectBookTaskDetail {
|
||||
try {
|
||||
this.transaction(() => {
|
||||
let bookTaskDetail = this.realm.objectForPrimaryKey('BookTaskDetail', bookTaskDetailId)
|
||||
@@ -178,18 +177,21 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
}
|
||||
bookTaskDetail.updateTime = new Date()
|
||||
})
|
||||
return successMessage(
|
||||
null,
|
||||
'修改小说任务详细信息成功',
|
||||
'BookTaskDetailService_UpdateBookTaskDetail'
|
||||
)
|
||||
let res = this.GetBookTaskDetailDataById(bookTaskDetailId)
|
||||
return res;
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定ID的反推提示词数据
|
||||
* @param bookTaskDetailId
|
||||
* @param mjMessage
|
||||
*/
|
||||
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)
|
||||
@@ -276,12 +278,20 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
* @param bookTaskDetailId 小说分镜的ID
|
||||
*/
|
||||
DeleteBookTaskDetailReversePromptById(bookTaskDetailId: string): void {
|
||||
let bookTaskDetail = this.realm.objectForPrimaryKey('BookTaskDetail', bookTaskDetailId);
|
||||
if (bookTaskDetail == null) {
|
||||
throw new Error('删除小说任务详细信息的反推提示词失败,未找到对应的分镜信息')
|
||||
}
|
||||
this.transaction(() => {
|
||||
this.realm.delete(bookTaskDetail.reversePrompt)
|
||||
let bookTaskDetails = this.realm.objects<BookTaskDetailModel>('BookTaskDetail').filtered('id = $0', bookTaskDetailId);
|
||||
if (bookTaskDetails.length <= 0) {
|
||||
throw new Error('删除小说任务详细信息的反推提示词失败,未找到对应的分镜信息')
|
||||
}
|
||||
let bookTaskDetail = bookTaskDetails[0];
|
||||
|
||||
bookTaskDetail.gptPrompt = undefined;
|
||||
// 删除所有的反推提示词
|
||||
if (bookTaskDetail.reversePrompt) {
|
||||
bookTaskDetail.reversePrompt.forEach(item => {
|
||||
this.realm.delete(item)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ export class BookTaskService extends BaseRealmService {
|
||||
* @param bookTaskId 小说批次任务Id
|
||||
* @param status 目标状态
|
||||
*/
|
||||
UpdateBookTaskStatus(bookTaskId: string, status: BookTaskStatus, errorMsg: string | null = null) {
|
||||
UpdateBookTaskStatus(bookTaskId: string, status: BookTaskStatus, errorMsg: string | null = null): GeneralResponse.SuccessItem {
|
||||
try {
|
||||
this.transaction(() => {
|
||||
// 修改对应小说批次任务的状态
|
||||
|
||||
@@ -147,6 +147,14 @@ const migration = (oldRealm: Realm, newRealm: Realm) => {
|
||||
}
|
||||
})
|
||||
}
|
||||
if (oldRealm.schemaVersion < 20) {
|
||||
newRealm.write(() => {
|
||||
const newSoftwares = newRealm.objects('Software')
|
||||
for (let software of newSoftwares) {
|
||||
software.subtitleSetting = null // 字幕的默认设置
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class BaseSoftWareService extends BaseService {
|
||||
@@ -185,7 +193,7 @@ export class BaseSoftWareService extends BaseService {
|
||||
MjSettingModel
|
||||
],
|
||||
path: dbPath,
|
||||
schemaVersion: 19, // 当前版本号
|
||||
schemaVersion: 21, // 当前版本号
|
||||
migration: migration
|
||||
}
|
||||
// 判断当前全局是不是又当前这个
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Realm, { UpdateMode } from 'realm'
|
||||
import { successMessage } from '../../../../main/Public/generalTools'
|
||||
import { BaseSoftWareService } from './softwareBasic.js'
|
||||
import { GeneralResponse } from '../../../../model/generalResponse'
|
||||
const { v4: uuidv4 } = require('uuid')
|
||||
|
||||
export class SoftwareService extends BaseSoftWareService {
|
||||
@@ -24,7 +25,7 @@ export class SoftwareService extends BaseSoftWareService {
|
||||
}
|
||||
|
||||
// 修改数据库中行中的某个属性数据
|
||||
UpdateSoftware(software) {
|
||||
UpdateSoftware(software: SoftwareSettingModel.SoftwareSetting): GeneralResponse.SuccessItem {
|
||||
try {
|
||||
this.realm.write(() => {
|
||||
this.realm.create('Software', software, UpdateMode.Modified)
|
||||
@@ -41,7 +42,7 @@ export class SoftwareService extends BaseSoftWareService {
|
||||
* @param software 软件配置信息
|
||||
* @returns
|
||||
*/
|
||||
AddSfotware(software) {
|
||||
AddSfotware(software: SoftwareSettingModel.SoftwareSetting): GeneralResponse.SuccessItem {
|
||||
try {
|
||||
software.id = uuidv4()
|
||||
this.realm.write(() => {
|
||||
@@ -56,7 +57,7 @@ export class SoftwareService extends BaseSoftWareService {
|
||||
/**
|
||||
* 或软件基础配置信息
|
||||
*/
|
||||
GetSoftwareData() {
|
||||
GetSoftwareData(): GeneralResponse.SuccessItem {
|
||||
try {
|
||||
let softwares = this.realm.objects('Software')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user