feat: 默认脚本编辑弹窗+后端读写default脚本接口
This commit is contained in:
@@ -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 加载默认脚本文件
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user