feat: 新增自定义配置合并到 Surge 输出
管理面板新增「自定义」面板,可按 Surge 格式书写 [Proxy]/[Rule]/ [General] 等配置片段,生成时合并进最终输出:[Proxy] 行追加到节点 之后,[Rule] 行注入到规则最顶部(优先级最高),其他段注入对应段 顶部且同名 key 覆盖模板取值(如 doh-server)。仅管理员链接生效, 游客链接不包含自定义内容。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,22 @@ router.post('/surge-token', (_req, res) => {
|
||||
res.json({ token });
|
||||
});
|
||||
|
||||
// GET /api/config/custom - get custom config snippet
|
||||
router.get('/custom', (_req, res) => {
|
||||
const row = db.prepare("SELECT value FROM config WHERE key = 'custom_config'").get() as any;
|
||||
res.json({ content: row?.value || '' });
|
||||
});
|
||||
|
||||
// PUT /api/config/custom - save custom config snippet
|
||||
router.put('/custom', (req, res) => {
|
||||
const { content } = req.body;
|
||||
if (typeof content !== 'string') {
|
||||
return res.status(400).json({ error: 'content must be a string' });
|
||||
}
|
||||
db.prepare("INSERT OR REPLACE INTO config (key, value) VALUES ('custom_config', ?)").run(content);
|
||||
res.json({ ok: true });
|
||||
});
|
||||
|
||||
// GET /api/config/preview - preview generated config
|
||||
router.get('/preview', (req, res) => {
|
||||
const host = req.headers.host || 'localhost:3456';
|
||||
|
||||
Reference in New Issue
Block a user