feat: 默认脚本编辑弹窗+后端读写default脚本接口

This commit is contained in:
mediabot-pt
2026-07-05 12:41:37 +08:00
parent 79dfd60348
commit 692b1bd863
4 changed files with 109 additions and 2 deletions

View File

@@ -43,6 +43,23 @@ public class GroovyScriptEngine {
return null; // placeholder, 由 AdapterController 实现具体逻辑
}
/**
* 保存站点类型默认脚本到 classpath
*/
public static void saveDefaultScript(String siteType, String script) {
if (siteType == null || script == null) return;
String key = siteType.toLowerCase();
DEFAULT_SCRIPTS.put(key, script);
try {
var path = java.nio.file.Paths.get(
GroovyScriptEngine.class.getClassLoader().getResource("scripts/default-" + key + ".groovy").toURI());
java.nio.file.Files.writeString(path, script, java.nio.charset.StandardCharsets.UTF_8);
log.info("Default script saved: default-{}.groovy", key);
} catch (Exception e) {
log.error("Failed to save default script: {}", key, e);
}
}
/**
* 从 classpath 加载默认脚本文件
*/