opt: config

This commit is contained in:
idranme 2024-08-07 21:39:26 +08:00
parent 5005d83ce0
commit 50ab62f103
No known key found for this signature in database
GPG Key ID: 926F7B5B668E495F

View File

@ -1,4 +1,3 @@
/// <reference path="../global.d.ts" />
import { CheckVersion } from '../common/types'
import { SettingButton, SettingItem, SettingList, SettingSwitch, SettingSelect } from './components'
// @ts-ignore
@ -26,22 +25,24 @@ function initSideBar() {
})
}
function isEmpty(value: unknown) {
return value === undefined || value === null || value === ''
}
async function onSettingWindowCreated(view: Element) {
window.llonebot.log('setting window created')
initSideBar()
const isEmpty = (value: any) => value === undefined || value === null || value === ''
let config = await window.llonebot.getConfig()
let ob11Config = { ...config.ob11 }
const setConfig = (key: string, value: any) => {
const configKey = key.split('.')
if (key.indexOf('ob11') === 0) {
if (configKey.length === 2) ob11Config[configKey[1]] = value
else ob11Config[key] = value
} else {
if (configKey.length === 2) config[configKey[0]][configKey[1]] = value
else config[key] = value
if (!['heartInterval', 'token', 'ffmpeg'].includes(key)) {
window.llonebot.setConfig(false, config)
}
@ -167,14 +168,14 @@ async function onSettingWindowCreated(view: Element) {
),
),
SettingItem(
'ffmpeg 路径发送语音、视频需要同时保证ffprobe和ffmpeg在一起',
` <a href="javascript:LiteLoader.api.openExternal(\'https://llonebot.github.io/zh-CN/guide/ffmpeg\');">下载地址</a> <span id="config-ffmpeg-path-text">, 路径:${
'FFmpeg 路径,发送语音、视频需要',
`<a href="javascript:LiteLoader.api.openExternal(\'https://llonebot.github.io/zh-CN/guide/ffmpeg\');">可点此下载</a>, 路径: <span id="config-ffmpeg-path-text">${
!isEmpty(config.ffmpeg) ? config.ffmpeg : '未指定'
}</span>`,
SettingButton('选择ffmpeg', 'config-ffmpeg-select'),
}</span>, FFprobe FFmpeg `,
SettingButton('选择 FFmpeg', 'config-ffmpeg-select'),
),
SettingItem(
'音乐卡片签名地址',
'音乐卡片签名 URL 地址',
null,
`<div class="q-input" style="width:210px;"><input class="q-input__inner" data-config-key="musicSignUrl" type="text" value="${config.musicSignUrl}" placeholder="未设置" /></div>`,
'config-musicSignUrl',