LaiTool V3.0.1-preview.2
This commit is contained in:
@@ -10,6 +10,7 @@ import { isEmpty, isNumber } from 'lodash'
|
||||
const { v4: uuidv4 } = require('uuid')
|
||||
import { version } from '../../../../../package.json'
|
||||
import { GeneralResponse } from '../../../../model/generalResponse'
|
||||
import { MJCategroy } from '../../../enum/bookEnum'
|
||||
|
||||
export class MJSettingService extends BaseSoftWareService {
|
||||
static instance: MJSettingService | null = null
|
||||
@@ -31,6 +32,58 @@ export class MJSettingService extends BaseSoftWareService {
|
||||
return MJSettingService.instance
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
InitData() {
|
||||
// 添加默认数据,然后重新获取
|
||||
this.transaction(() => {
|
||||
// 初始化MJ设置的数据
|
||||
this.realm.create('MjSetting', {
|
||||
id: uuidv4(),
|
||||
type: MJCategroy.API_MJ,
|
||||
selectRobot: 'niji',
|
||||
imageScale: '3e2772f2-041c-49c6-ba13-d0ed120310b8',
|
||||
imageSuffix: ' --niji 6 --ar 1:1',
|
||||
taskCount: 5,
|
||||
spaceTime: 5,
|
||||
createTime: new Date(),
|
||||
updateTime: new Date(),
|
||||
version: version,
|
||||
requestModel: MJCategroy.API_MJ,
|
||||
imageModel: "99377cad-c103-4cee-a958-86a104879328"
|
||||
})
|
||||
let apiSetting = this.realm.objects('APIMj');
|
||||
if (apiSetting.length <= 0) {
|
||||
this.realm.create('APIMj', {
|
||||
id: uuidv4(),
|
||||
mjApiUrl: 'b44c6f24-59e4-4a71-b2c7-3df0c4e35e65',
|
||||
mjSpeed: 'relaxed',
|
||||
apiKey: "自己的APIKey",
|
||||
createTime: new Date(),
|
||||
updateTime: new Date(),
|
||||
version: version
|
||||
})
|
||||
}
|
||||
let browserSetting = this.realm.objects('BrowserMJ');
|
||||
if (browserSetting.length <= 0) {
|
||||
this.realm.create('BrowserMJ', {
|
||||
id: uuidv4(),
|
||||
serviceId: "自己的服务ID",
|
||||
channelId: '自己的频道ID',
|
||||
mjBotId: '自己的MJ机器人ID',
|
||||
nijBotId: '自己的NIJI机器人ID',
|
||||
token: '自己的Token',
|
||||
userAgent: "自己的UserAgent",
|
||||
userAgentCustom: false,
|
||||
createTime: new Date(),
|
||||
updateTime: new Date(),
|
||||
version: version
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//#region 览器模式的MJ设置
|
||||
|
||||
/**
|
||||
@@ -525,7 +578,9 @@ export class MJSettingService extends BaseSoftWareService {
|
||||
// 获取MJ的基础配置信息
|
||||
let mjSettings = this.GetMjSetting(null)
|
||||
if (mjSettings.data.length <= 0) {
|
||||
throw new Error('没有找到MJ的配置信息,请先添加')
|
||||
this.InitData();
|
||||
mjSettings = this.GetMjSetting(null)
|
||||
|
||||
}
|
||||
// 获取API的配置信息
|
||||
let apiSettings = this.GetAPIMjSetting(null)
|
||||
|
||||
Reference in New Issue
Block a user