mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-04-01 06:09:50 +08:00
feat(config): 添加密钥验证功能
- 在配置中新增 key 字段用于存储密钥 - 实现 checkKey 函数用于验证密钥正确性 - 添加密钥错误时的异常处理机制 - 将 checkKey 函数导出供外部使用 - 添加初始化秘境配置的相关注释文档
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user