添加文案处理的功能

This commit is contained in:
2024-07-13 15:44:13 +08:00
parent 669e57824d
commit c8a46d59fb
80 changed files with 7383 additions and 2613 deletions
+36 -46
View File
@@ -1,8 +1,7 @@
import { messageDark, useMessage } from "naive-ui";
import { defineStore } from "pinia";
import { errorMessage, successMessage } from "../main/generalTools";
import { BookTaskStatus } from "../define/enum/bookEnum";
import { messageDark, useMessage } from 'naive-ui'
import { defineStore } from 'pinia'
import { errorMessage, successMessage } from '../main/generalTools'
import { BookTaskStatus } from '../define/enum/bookEnum'
// 系统相关设置
export const useReverseManageStore = defineStore('reverseManage', {
@@ -18,6 +17,7 @@ export const useReverseManageStore = defineStore('reverseManage', {
srtPath: null,
audioPath: null,
imageFolder: null,
subtitlePosition: null
}, // 当前选中的小说
bookTaskData: [], // 当前显示的所有小说任务数据
@@ -34,27 +34,23 @@ export const useReverseManageStore = defineStore('reverseManage', {
styleList: null,
prefix: null,
status: BookTaskStatus.WAIT,
errorMsg: null,
}, // 当前选中的小说任务
errorMsg: null
} // 当前选中的小说任务
}),
getters: {
// 获取小说数据
GetBookData(state) {
return (bookId = null) => {
// 要是返回的数据为空,返回全部数据
if (bookId == null) return state.bookData;
if (bookId == null) return state.bookData
return state.bookData.find((item) => item.id === bookId)
};
},
}
}
},
actions: {
/**
* 获取小说的数据
* @param {*} condition
* @param {*} condition
*/
async GetBookDataFromDB(condition) {
try {
@@ -64,7 +60,7 @@ export const useReverseManageStore = defineStore('reverseManage', {
throw new Error(res.message)
}
if (res.data.res_book.length <= 0) {
throw new Error("没有找到对应的小说数据,请先添加小说");
throw new Error('没有找到对应的小说数据,请先添加小说')
}
this.SetBookData(res.data.res_book)
this.selectBook = res.data.res_book[0]
@@ -78,12 +74,12 @@ export const useReverseManageStore = defineStore('reverseManage', {
async GetBookTaskDataFromDB(condition) {
try {
debugger
let res = await window.book.GetBookTaskData(condition);
let res = await window.book.GetBookTaskData(condition)
if (res.code == 0) {
throw new Error(res.message)
}
if (res.data.bookTasks.length > 0) {
this.bookTaskData = res.data.bookTasks;
this.bookTaskData = res.data.bookTasks
this.selectBookTask = res.data.bookTasks[0]
} else {
throw new Error('没有找到对应的子批次数据,请先创建')
@@ -96,34 +92,30 @@ export const useReverseManageStore = defineStore('reverseManage', {
/**
* 修改小说数据
* @param value
* @param value
*/
SetBookData(value) {
try {
// 判断传入的数据不能为空,为空报错
if (!value) {
throw new Error('value不能为空');
throw new Error('value不能为空')
}
// 如果是函数,则执行函数,如果是BookModel对象,修改对应的行的数据,如果是数组,则直接赋值
if (typeof value === 'function') {
this.bookData = value();
}
else if (typeof value === 'object' && Array.isArray(value)) {
this.bookData = [];
this.bookData = value;
}
else if (typeof value === 'object') {
const index = this.bookData.findIndex((item) => item.id === value.id);
this.bookData = value()
} else if (typeof value === 'object' && Array.isArray(value)) {
this.bookData = []
this.bookData = value
} else if (typeof value === 'object') {
const index = this.bookData.findIndex((item) => item.id === value.id)
if (index !== -1) {
this.bookData[index] = value;
this.bookData[index] = value
} else {
throw new Error('未找到对应的数据');
throw new Error('未找到对应的数据')
}
} else {
throw new Error('value的类型不正确')
}
else {
throw new Error('value的类型不正确');
}
} catch (error) {
throw new Error(error.message)
}
@@ -131,22 +123,22 @@ export const useReverseManageStore = defineStore('reverseManage', {
// 设置选中的小说
SetSelectBook(value) {
this.selectBook = value;
this.selectBook = value
},
/**
* 设置小说类型
* 判断pinia中的小说类型数组的数据是不是存在,默认存在不修改,要出传入参数为true,会强制修改
* @param {*} value
* @param {*} value
*/
async SetBookType(value = false) {
try {
if (this.bookType.length <= 0 || value) {
let _bookType = await book.GetBookType();
let _bookType = await book.GetBookType()
if (_bookType.code == 0) {
throw new Error(_bookType.message);
throw new Error(_bookType.message)
}
this.bookType = _bookType.data;
this.bookType = _bookType.data
}
return successMessage(true)
} catch (error) {
@@ -156,11 +148,11 @@ export const useReverseManageStore = defineStore('reverseManage', {
/**
* 更新选中的小说数据
* @param {*} obj
* @param {*} obj
*/
async UpdateSelectBook(obj) {
// 直接修改,使用object.assign合并对象中的数据
this.selectBook = Object.assign(this.selectBook, obj);
this.selectBook = Object.assign(this.selectBook, obj)
},
/**
@@ -172,7 +164,7 @@ export const useReverseManageStore = defineStore('reverseManage', {
let save_res = null
if (book == null) {
// 保存this.selectBook
save_res = await window.book.AddOrModifyBook({ ...this.selectBook });
save_res = await window.book.AddOrModifyBook({ ...this.selectBook })
} else {
// 保存传入的数据
save_res = await window.book.AddOrModifyBook({ ...book })
@@ -191,11 +183,9 @@ export const useReverseManageStore = defineStore('reverseManage', {
this.selectBook = save_res.data
}
return successMessage(save_res.data)
} catch (error) {
return errorMessage(error.message);
return errorMessage(error.message)
}
}
}
});
})
+18 -15
View File
@@ -1,26 +1,31 @@
import { defineStore } from "pinia";
import { defineStore } from 'pinia'
// 系统相关设置
export const useSoftwareStore = defineStore('software', {
state: () => ({
spin: {
spinning: false,
tip: '加载中...'
},
softWare: {
theme: "light", // 系统主题,亮或是暗
theme: 'light', // 系统主题,亮或是暗
reverse_display_show: false, // 一键反推界面显示(简单的表格模式还是表格任务模式)
reverse_show_book_striped: false, // 是否显示斑马纹(反推界面)
reverse_data_table_size: "small", // 反推界面表格大小
reverse_data_table_size: 'small' // 反推界面表格大小
},
componentSize: [] // 组件尺寸(通用的选项)
componentSize: [], // 组件尺寸(通用的选项)
SoftColor: null // 按钮颜色
}),
getters: {
// 获取一键反推界面显示数据
GetReverseDispalayShow(state) {
return state.softWare.reverse_display_show;
},
return state.softWare.reverse_display_show
}
},
actions: {
// 设置一键反推界面显示数据
SetReverseDispalayShow(value) {
this.softWare.reverse_display_show = value;
this.softWare.reverse_display_show = value
},
// 设置反推界面时候小说信息显示斑马纹
@@ -30,29 +35,27 @@ export const useSoftwareStore = defineStore('software', {
// 修改软件主题
SetSoftware(value) {
this.softWare = Object.assign(this.softWare, value);
this.softWare = Object.assign(this.softWare, value)
},
// 获取组件尺寸(判断当前是不是存在,不存在的话到主线程拿)
async GetComponentSize() {
debugger
if (this.componentSize.length == 0) {
let res = await window.setting.GetComponentSize();
this.componentSize = res.data;
let res = await window.setting.GetComponentSize()
this.componentSize = res.data
}
return this.componentSize;
return this.componentSize
},
//#region 保存到数据库的操作
// 将当前的software数据保存到数据库中
async SaveSoftware() {
// 保存数据
return await window.setting.SaveSoftWareSetting(JSON.parse(JSON.stringify(this.softWare)));
return await window.setting.SaveSoftWareSetting(JSON.parse(JSON.stringify(this.softWare)))
}
//#endregion
}
});
})