feat: 支持在配置文件中自定义下载的源脚本的基础信息

This commit is contained in:
helloplhm-qwq 2023-12-24 15:56:00 +08:00
parent da0737ecfd
commit 37f1b5bbb0
No known key found for this signature in database
GPG Key ID: B7542212855B2C26
2 changed files with 18 additions and 1 deletions

View File

@ -66,7 +66,14 @@ default = {
"log_file": True,
"_log_file-desc": "是否开启日志文件",
"allow_download_script": True,
'_allow_download_script-desc': '是否允许直接从服务端下载脚本,开启后可以直接访问/script下载脚本',
'_allow_download_script-desc': '是否允许直接从服务端下载脚本,开启后可以直接访问 /script?key=你的请求key 下载脚本',
"download_config": {
"desc": "源脚本的相关配置",
"name": "修改为你的源脚本名称",
"intro": "修改为你的源脚本描述",
"author": "修改为你的源脚本作者",
"version": "修改为你的源版本"
}
},
"security": {
"rate_limit": {

View File

@ -55,6 +55,16 @@ async def generate_script_response(request):
newScriptLines.append(f'const API_URL = "{request.scheme}://{request.host}"')
elif (line.startswith('const API_KEY')):
newScriptLines.append(f'const API_KEY = "{config.read_config("security.key.value")}"')
elif (line.startswith("/*")):
newScriptLines.append(" /*")
elif (line.startswith("* @name")):
newScriptLines.append(" * @name " + config.read_config("common.download_config.name"))
elif (line.startswith("* @description")):
newScriptLines.append(" * @description " + config.read_config("common.download_config.intro"))
elif (line.startswith("* @author")):
newScriptLines.append((" * @author helloplhm-qwq & Folltoshe & " + config.read_config("common.download_config.author")) if config.read_config("common.download_config.author") else " * @author helloplhm-qwq & Folltoshe")
elif (line.startswith("* @version")):
newScriptLines.append(" * @name " + config.read_config("common.download_config.version"))
else:
newScriptLines.append(line)