From 6f185570d60eaea7922c7d086d202dcf51b39c69 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 20 Nov 2022 20:05:02 +0800 Subject: [PATCH] =?UTF-8?q?pushDeer=E6=94=AF=E6=8C=81=E8=87=AA=E6=9E=B6?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/data/notify.ts | 1 + back/services/notify.ts | 4 ++-- sample/notify.js | 4 +++- sample/notify.py | 4 ++++ shell/update.sh | 1 + src/pages/setting/index.tsx | 13 +++++++++---- src/utils/config.ts | 4 ++++ 7 files changed, 24 insertions(+), 7 deletions(-) diff --git a/back/data/notify.ts b/back/data/notify.ts index 8ece8525..37e9d046 100644 --- a/back/data/notify.ts +++ b/back/data/notify.ts @@ -41,6 +41,7 @@ export class ServerChanNotification extends NotificationBaseInfo { export class PushDeerNotification extends NotificationBaseInfo { public pushDeerKey = ''; + public pushDeerUrl = ''; } export class ChatNotification extends NotificationBaseInfo { diff --git a/back/services/notify.ts b/back/services/notify.ts index 727e5a5a..8cbe5fd1 100644 --- a/back/services/notify.ts +++ b/back/services/notify.ts @@ -123,8 +123,8 @@ export default class NotificationService { } private async pushDeer() { - const { pushDeerKey } = this.params; - const url = `https://api2.pushdeer.com/message/push`; + const { pushDeerKey, pushDeerUrl } = this.params; + const url = pushDeerUrl || `https://api2.pushdeer.com/message/push`; const res: any = await got .post(url, { ...this.gotOption, diff --git a/sample/notify.js b/sample/notify.js index 1817941d..8eb4c7ef 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -38,6 +38,7 @@ let SCKEY = ''; //此处填你申请的PushDeer KEY. //(环境变量名 DEER_KEY) let PUSHDEER_KEY = ''; +let PUSHDEER_URL = ''; // =======================================Synology Chat通知设置区域=========================================== //此处填你申请的CHAT_URL与CHAT_TOKEN @@ -151,6 +152,7 @@ if (process.env.PUSH_KEY) { if (process.env.DEER_KEY) { PUSHDEER_KEY = process.env.DEER_KEY; + PUSHDEER_URL = process.env.DEER_URL; } if (process.env.CHAT_URL) { @@ -413,7 +415,7 @@ function PushDeerNotify(text, desp) { // PushDeer 建议对消息内容进行 urlencode desp = encodeURI(desp); const options = { - url: `https://api2.pushdeer.com/message/push`, + url: PUSHDEER_URL || `https://api2.pushdeer.com/message/push`, body: `pushkey=${PUSHDEER_KEY}&text=${text}&desp=${desp}&type=markdown`, headers: { 'Content-Type': 'application/x-www-form-urlencoded', diff --git a/sample/notify.py b/sample/notify.py index a12e985b..8392af54 100644 --- a/sample/notify.py +++ b/sample/notify.py @@ -61,6 +61,7 @@ push_config = { 'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版 'DEER_KEY': '', # PushDeer 的 PUSHDEER_KEY + 'DEER_URL': '', # PushDeer 的 PUSHDEER_URL 'CHAT_URL': '', # synology chat url 'CHAT_TOKEN': '', # synology chat token @@ -280,6 +281,9 @@ def pushdeer(title: str, content: str) -> None: print("PushDeer 服务启动") data = {"text": title, "desp": content, "type": "markdown", "pushkey": push_config.get("DEER_KEY")} url = 'https://api2.pushdeer.com/message/push' + if push_config.get("DEER_URL"): + url = push_config.get("DEER_URL") + response = requests.post(url, data=data).json() if len(response.get("content").get("result")) > 0: diff --git a/shell/update.sh b/shell/update.sh index eba0ec04..857cac02 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -252,6 +252,7 @@ update_qinglong() { if [ "$githubStatus" == "" ]; then mirror="gitee" fi + echo -e "\n使用 ${mirror} 源更新...\n" export isFirstStartServer=false local all_branch=$(git branch -a) diff --git a/src/pages/setting/index.tsx b/src/pages/setting/index.tsx index a5d7d2b7..15931f7f 100644 --- a/src/pages/setting/index.tsx +++ b/src/pages/setting/index.tsx @@ -31,7 +31,7 @@ import CheckUpdate from './checkUpdate'; import About from './about'; import { useOutletContext } from '@umijs/max'; import { SharedContext } from '@/layouts'; -import './index.less' +import './index.less'; const { Text } = Typography; const optionsWithDisabled = [ @@ -80,10 +80,15 @@ const Setting = () => { dataIndex: 'scopes', key: 'scopes', align: 'center' as const, + width: '40%', render: (text: string, record: any) => { - return record.scopes.map((scope: any) => { - return {(config.scopesMap as any)[scope]}; - }); + return ( +
+ {record.scopes.map((scope: any) => { + return {(config.scopesMap as any)[scope]}; + })} +
+ ); }, }, { diff --git a/src/utils/config.ts b/src/utils/config.ts index 98107adf..2c1f5938 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -137,6 +137,10 @@ export default { tip: 'PushDeer的Key,https://github.com/easychen/pushdeer', required: true, }, + { + label: 'pushDeerUrl', + tip: 'PushDeer的自架API endpoint,默认是 https://api2.pushdeer.com/message/push', + }, ], bark: [ {