feat:UI及部分后端
This commit is contained in:
38
backend/src/utils/config.ts
Normal file
38
backend/src/utils/config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import fs from "fs";
|
||||
interface IConfig {
|
||||
mirror: {
|
||||
bmclapi: boolean;
|
||||
mcimirror: boolean;
|
||||
};
|
||||
filter: {
|
||||
hashes: boolean;
|
||||
dexpub: boolean;
|
||||
mixins: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export class Config {
|
||||
private readonly default_config: IConfig = {
|
||||
mirror: {
|
||||
bmclapi: true,
|
||||
mcimirror: true,
|
||||
},
|
||||
filter: {
|
||||
hashes: true,
|
||||
dexpub: false,
|
||||
mixins: true,
|
||||
},
|
||||
};
|
||||
config(): IConfig {
|
||||
if (!fs.existsSync("./config.json")) {
|
||||
fs.writeFileSync("./config.json", JSON.stringify(this.default_config));
|
||||
return this.default_config;
|
||||
}
|
||||
return JSON.parse(fs.readFileSync("./config.json", "utf-8"));
|
||||
}
|
||||
static write_config(config: IConfig) {
|
||||
fs.writeFileSync("./config.json", JSON.stringify(config));
|
||||
}
|
||||
}
|
||||
|
||||
export default new Config().config();
|
||||
14
backend/src/utils/utils.ts
Normal file
14
backend/src/utils/utils.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import config from "./config.js";
|
||||
|
||||
export class Utils{
|
||||
public modrinth_url: string;
|
||||
public curseforge_url: string;
|
||||
constructor(){
|
||||
this.modrinth_url = "https://api.modrinth.com"
|
||||
this.curseforge_url = "https://api.curseforge.com"
|
||||
if(config.mirror.mcimirror){
|
||||
this.modrinth_url = "https://mod.mcimirror.top/modrinth"
|
||||
this.curseforge_url = "https://mod.mcimirror.top/curseforge"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user