mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-29 02:27:26 +00:00
3a2c672aed
* `#刻晴排行` 命令会触发排行更新,防止部分排行错位 * `#喵喵设置` 部分配置项及功能改进 * 其余一些已知问题修正及改进
53 lines
1.1 KiB
JavaScript
53 lines
1.1 KiB
JavaScript
import fs from 'fs'
|
|
import lodash from 'lodash'
|
|
import cfgData from './cfg-lib/cfg-data.js'
|
|
|
|
const _path = process.cwd()
|
|
const _cfgPath = `${_path}/plugins/miao-plugin/components/`
|
|
let cfg = {}
|
|
|
|
try {
|
|
if (fs.existsSync(_cfgPath + 'cfg.json')) {
|
|
cfg = await cfgData.loadOldData()
|
|
cfgData.saveCfg(cfg)
|
|
fs.unlinkSync(_cfgPath + 'cfg.json')
|
|
} else {
|
|
cfg = await cfgData.getCfg()
|
|
cfgData.saveCfg(cfg)
|
|
}
|
|
cfg = await cfgData.getCfg()
|
|
} catch (e) {
|
|
// do nth
|
|
}
|
|
|
|
let Cfg = {
|
|
get (rote) {
|
|
return lodash.get(cfg, rote)
|
|
},
|
|
set (rote, val) {
|
|
cfg[rote] = val
|
|
cfgData.saveCfg(cfg)
|
|
},
|
|
del (rote) {
|
|
lodash.set(cfg, rote, undefined)
|
|
fs.writeFileSync(_cfgPath + 'cfg.json', JSON.stringify(cfg, null, '\t'))
|
|
},
|
|
getCfg () {
|
|
return cfg
|
|
},
|
|
getCfgSchema () {
|
|
return cfgData.getCfgSchema()
|
|
},
|
|
getCfgSchemaMap () {
|
|
return cfgData.getCfgSchemaMap()
|
|
},
|
|
scale (pct = 1) {
|
|
let scale = Cfg.get('renderScale', 100)
|
|
scale = Math.min(2, Math.max(0.5, scale / 100))
|
|
pct = pct * scale
|
|
return `style=transform:scale(${pct})`
|
|
}
|
|
}
|
|
|
|
export default Cfg
|