mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
refactor: optimize save config
This commit is contained in:
parent
d9377e4684
commit
1d69764952
@ -1,4 +1,5 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import fsPromise from "fs/promises";
|
||||||
import {Config, OB11Config} from './types';
|
import {Config, OB11Config} from './types';
|
||||||
|
|
||||||
import {mergeNewProperties} from "./utils/helper";
|
import {mergeNewProperties} from "./utils/helper";
|
||||||
@ -76,7 +77,7 @@ export class ConfigUtil {
|
|||||||
|
|
||||||
setConfig(config: Config) {
|
setConfig(config: Config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2), "utf-8")
|
fsPromise.writeFile(this.configPath, JSON.stringify(config, null, 2), "utf-8").then()
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkOldConfig(currentConfig: Config | OB11Config,
|
private checkOldConfig(currentConfig: Config | OB11Config,
|
||||||
|
@ -146,7 +146,7 @@ export class OB11Constructor {
|
|||||||
if (url.includes("&rkey=")) {
|
if (url.includes("&rkey=")) {
|
||||||
// 正则提取rkey
|
// 正则提取rkey
|
||||||
const rkey = url.match(/&rkey=([^&]+)/)[1]
|
const rkey = url.match(/&rkey=([^&]+)/)[1]
|
||||||
log("图片url已有rkey", rkey)
|
// log("图片url已有rkey", rkey)
|
||||||
if (rkey != currentRKey){
|
if (rkey != currentRKey){
|
||||||
config.imageRKey = rkey
|
config.imageRKey = rkey
|
||||||
getConfigUtil().setConfig(config)
|
getConfigUtil().setConfig(config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user