From bb443c857ae1acfe648855a8613f2425c6c8e0d2 Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 30 Aug 2025 17:24:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E7=9F=A5=E6=94=AF=E6=8C=81=20?= =?UTF-8?q?shoutrrr(=E9=9C=80=E8=87=AA=E8=A1=8C=E5=AE=89=E8=A3=85=E6=88=96?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=89=93=E5=8C=85=E5=A5=BD=E7=9A=84=20Docker?= =?UTF-8?q?=20=E9=95=9C=E5=83=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/vendor/open-api.js | 75 ++++++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/backend/package.json b/backend/package.json index 0f2e3c90..de23f6bd 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.20.15", + "version": "2.20.16", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/vendor/open-api.js b/backend/src/vendor/open-api.js index 56619709..747dda0c 100644 --- a/backend/src/vendor/open-api.js +++ b/backend/src/vendor/open-api.js @@ -278,28 +278,61 @@ export class OpenAPI { let push = eval('process.env.SUB_STORE_PUSH_SERVICE'); if (push) { - const url = push - .replace( - '[推送标题]', - encodeURIComponent(title || 'Sub-Store'), - ) - .replace( - '[推送内容]', - encodeURIComponent( - [subtitle, content_].map((i) => i).join('\n'), - ), - ); - const $http = HTTP(); - $http - .get({ url }) - .then((resp) => { - console.log( - `[Push Service] URL: ${url}\nRES: ${resp.statusCode} ${resp.body}`, + if (/^https?:\/\//.test(push)) { + // 处理 HTTP/HTTPS URL + const url = push + .replace( + '[推送标题]', + encodeURIComponent(title || 'Sub-Store'), + ) + .replace( + '[推送内容]', + encodeURIComponent( + [subtitle, content_].map((i) => i).join('\n'), + ), ); - }) - .catch((e) => { - console.log(`[Push Service] URL: ${url}\nERROR: ${e}`); - }); + const $http = HTTP(); + $http + .get({ url }) + .then((resp) => { + console.log( + `[Push Service] URL: ${url}\nRES: ${resp.statusCode} ${resp.body}`, + ); + }) + .catch((e) => { + console.log( + `[Push Service] URL: ${url}\nERROR: ${e}`, + ); + }); + } else { + const { execFile } = eval(`require("child_process")`); + execFile( + 'shoutrrr', + [ + 'send', + '--url', + push, + '--message', + `${title}\n${subtitle}\n${content_}`, + ], + (error, stdout, stderr) => { + if (error) { + console.log( + `[Push Service] URL: ${push}\nERROR: ${error}`, + ); + return; + } + if (stderr) { + console.log( + `[Push Service] URL: ${push}\nstderr: ${stderr}`, + ); + } + console.log( + `[Push Service] URL: ${push}\nstdout: ${stdout}`, + ); + }, + ); + } } } if (isGUIforCores) {