2025-04-02 19:52:57 +08:00
|
|
|
|
import { isEmpty } from "lodash";
|
|
|
|
|
|
import { errorMessage, successMessage } from "./Public/generalTools";
|
|
|
|
|
|
import { SoftWareServiceBasic } from "./Service/ServiceBasic/softwareServiceBasic";
|
2025-08-09 18:46:07 +08:00
|
|
|
|
import { OptionKeyName, OptionType } from "@/define/enum/option";
|
|
|
|
|
|
import { OptionServices } from "./Service/Options/optionServices";
|
2025-04-02 19:52:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 初始化远程MJ的设置类型
|
|
|
|
|
|
* @description 远程MJ的设置类型有两种:remote和local,remote表示远程代理模式,local表示本地模式
|
|
|
|
|
|
*/
|
|
|
|
|
|
export async function InitRemoteMjSettingType() {
|
|
|
|
|
|
try {
|
|
|
|
|
|
let softWareServiceBasic = new SoftWareServiceBasic()
|
|
|
|
|
|
softWareServiceBasic.transaction((realm: any) => {
|
|
|
|
|
|
let remoteMjs = realm.objects('RemoteMJ');
|
|
|
|
|
|
for (let remoteMj of remoteMjs) {
|
|
|
|
|
|
if (remoteMj.type == null || isEmpty(remoteMj.type)) {
|
|
|
|
|
|
remoteMj.type = "remote" // 默认都是remote的;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
successMessage("", "初始化远程MJ的设置类型成功", "InitRemoteMjSettingType")
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
errorMessage("初始化远程MJ的设置类型失败," + error.toString(), "InitRemoteMjSettingType")
|
|
|
|
|
|
}
|
2025-08-09 18:46:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 初始化数据函数
|
|
|
|
|
|
* @description 用于初始化应用程序所需的选项数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
export async function InitData() {
|
|
|
|
|
|
// 初始化 Options 数据
|
|
|
|
|
|
// 循环 initObject 进行添加,在添加之前需要判断数据是不是存在,存在的话不进行处理,直接跳过,只有当不存在的时候在添加
|
|
|
|
|
|
let optionService = new OptionServices();
|
|
|
|
|
|
// 遍历初始化对象数组
|
|
|
|
|
|
for (let i = 0; i < initObject.length; i++) {
|
|
|
|
|
|
const item = initObject[i];
|
|
|
|
|
|
// 通过键名获取选项数据
|
|
|
|
|
|
let res = await optionService.GetOptionByKey(item.key);
|
|
|
|
|
|
if (res.code == 1 && res.data == null) {
|
|
|
|
|
|
// 不存在,进行添加
|
|
|
|
|
|
await optionService.ModifyOptionByKey(item.key, item.value, item.type);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 存在,跳过
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const initObject = [
|
|
|
|
|
|
{
|
|
|
|
|
|
table: "Options",
|
|
|
|
|
|
key: OptionKeyName.ImageToVideo_ShowRightPanel,
|
|
|
|
|
|
value: "true",
|
|
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
table: "Options",
|
|
|
|
|
|
key: OptionKeyName.ImageToVideo_ShowPagination,
|
|
|
|
|
|
value: "true",
|
|
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|