feat(config): 添加密钥验证功能

- 在配置中新增 key 字段用于存储密钥
- 实现 checkKey 函数用于验证密钥正确性
- 添加密钥错误时的异常处理机制
- 将 checkKey 函数导出供外部使用
- 添加初始化秘境配置的相关注释文档
This commit is contained in:
yan
2026-02-08 14:13:51 +08:00
parent e2d976765e
commit 4d834403e4

View File

@@ -4,6 +4,7 @@ const config = {
config: ''
},
info: {
key: undefined,//密钥
manifest: {},
settings: undefined
},
@@ -115,7 +116,19 @@ async function getValueByMultiCheckboxName(name) {
log.debug("values={key}", JSON.stringify(values))
return values
}
/**
* 检查密钥是否正确
*/
async function checkKey(key="") {
if (config.info.key !== key.trim()) {
throw new Error("密钥错误");
}
}
/**
* 初始化秘境配置
* @returns {Promise<void>}
*/
async function initConfig() {
/* const domainList = [
{
@@ -401,6 +414,7 @@ async function initConfig() {
export {
config,
checkKey,
initSettings,
getMultiCheckboxMap,
getValueByMultiCheckboxName,