Compare commits

..

21 Commits

Author SHA1 Message Date
whyour bdc45c538c 更新版本 v2.17.13 2024-12-21 22:48:58 +08:00
FanchangWang 955c7377d7 新增 wxPusher 推送通道。wxPusher 官方文档: https://wxpusher.zjiecode.com/docs/ (#2594)
* 增加 wxPusher 推送方式

* 补全 wxPusher 推送方式代码

* fix js 方法多进行了一次 JSON 格式化
2024-12-13 14:13:34 +08:00
陈大人 c71abd8c86 完善pushplus通知方式的代码逻辑 (#2454)
* 1. pushplus通知方式返回结果优化
2. pushplus通知方式适配更多参数

* 细节bug修改

* 删除没用的空格

---------

Co-authored-by: 陈思远 <chensiyuan@yiban.com.cn>
Co-authored-by: 陈大人 <chensiyuan@pushplus.plus>
2024-12-13 14:12:16 +08:00
whyour ab27a4c908 更新 node 依赖 2024-12-12 00:26:11 +08:00
whyour 026640a757 修复任务列表下次运行时间展示 2024-12-03 22:35:34 +08:00
whyour a1501705c1 更新 readme 2024-11-18 23:19:15 +08:00
whyour b321530dcf 修复本地部署设置 dataPath 后,备份目录可能错误 2024-11-18 22:59:07 +08:00
xiaobingtech 02c6ad8004 mobile增加识别鸿蒙系统 (#2571)
由于鸿蒙系统的User-Agent如下
Mozilla/5.0 (Phone; OpenHarmony5.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile
导致目前登录显示desktop
2024-11-18 22:40:14 +08:00
Hugh Gao fff572869e chore: Update docker-compose.yml (#2553) 2024-11-08 22:52:19 +08:00
whyour b733937691 更新版本 v2.17.12 2024-10-26 14:59:36 +08:00
whyour 0d9eba4b6e 定时任务外漏标签改为 10 个 2024-10-26 14:49:02 +08:00
whyour 20c6a1e8bf 移除任务执行前后的脚本参数 2024-10-26 14:12:58 +08:00
qiaoyun680 56bc2f0b1d 改进ntfy通知,将中文标题进行编码后发送 (#2541)
* 1.改进ntfy通知,将中文标题进行编码后发送,可以直接展示中文标题;2.改进notify.py和notify.js中ntfy的推送;
---------

Co-authored-by: qiaoyun680 <qiaoyun680>
2024-10-23 16:38:51 +08:00
Easy ecc55883f0 优化Server酱Key相关的逻辑 (#2538)
* 优化sendkey的兼容

* 对title和desp encode
2024-10-22 21:49:07 +08:00
qiaoyun680 185fd2ff91 增加 ntfy 通知 (#2537)
Co-authored-by: qiaoyun680 <qiaoyun680>
2024-10-22 21:47:38 +08:00
whyour 3822c37fa0 修复登录日志保存 2024-10-19 00:18:24 +08:00
whyour 4244502949 增加 log 图标样式 2024-10-13 21:24:17 +08:00
Easy 71dd82f74e 适配Server酱APP分支(Server酱³),移除已废弃的旧版api入口 (#2524) 2024-10-10 22:09:00 +08:00
whyour 6ea8d361fd 修复 mac 时间格式化 2024-09-29 22:47:57 +08:00
whyour 3f71f9acdb 修复任务命令带有 -m 参数时,日志目录生成异常 2024-09-29 22:27:52 +08:00
whyour 418695c4aa 定时任务支持复制 2024-09-24 23:33:04 +08:00
39 changed files with 7046 additions and 6294 deletions
+2 -9
View File
@@ -43,19 +43,12 @@ export default defineConfig({
}),
);
}) as any,
externals: {
react: 'window.React',
'react-dom': 'window.ReactDOM',
},
headScripts: [
`./api/env.js`,
'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js',
'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js',
],
headScripts: [`./api/env.js`],
copy: [
{
from: 'node_modules/monaco-editor/min/vs',
to: 'static/dist/monaco-editor/min/vs',
},
],
npmClient: 'pnpm',
});
+1 -1
View File
@@ -126,7 +126,7 @@ curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
npm install -g node-pre-gyp pnpm@8.3.1
npm install -g @whyour/qinglong
qinglong
# Add the environment variables QL_DIR and QL_DATA_DIR when prompted
# Add the environment variables QL_DIR and QL_DATA_DIR when prompted, QL_DATA_DIR must end with /data.
export QL_DIR=""
export QL_DATA_DIR=""
# Run again
+2 -2
View File
@@ -88,7 +88,7 @@ docker run -dit \
```bash
# curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
mkdir qinglong
mkdir qinglong && cd $_
wget https://raw.githubusercontent.com/whyour/qinglong/master/docker/docker-compose.yml
# 启动
@@ -128,7 +128,7 @@ curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
npm install -g node-pre-gyp pnpm@8.3.1
npm install -g @whyour/qinglong
qinglong
# 根据提示增加环境变量 QL_DIR 和 QL_DATA_DIR
# 根据提示增加环境变量 QL_DIR 和 QL_DATA_DIRQL_DATA_DIR 必须以 /data 结尾
export QL_DIR=""
export QL_DATA_DIR=""
# 再次执行
+13 -6
View File
@@ -145,12 +145,14 @@ export function getPlatform(userAgent: string): 'mobile' | 'desktop' {
system = 'android'; // android系统
} else if (testUa(/ios|iphone|ipad|ipod|iwatch/g)) {
system = 'ios'; // ios系统
} else if (testUa(/openharmony/g)) {
system = 'openharmony'; // openharmony系统
}
let platform = 'desktop';
if (system === 'windows' || system === 'macos' || system === 'linux') {
platform = 'desktop';
} else if (system === 'android' || system === 'ios' || testUa(/mobile/g)) {
} else if (system === 'android' || system === 'ios' || system === 'openharmony' || testUa(/mobile/g)) {
platform = 'mobile';
}
@@ -469,13 +471,18 @@ export async function getUniqPath(
command: string,
id: string,
): Promise<string> {
let suffix = '';
if (/^\d+$/.test(id)) {
id = `_${id}`;
} else {
id = '';
suffix = `_${id}`;
}
let items = command.split(/ +/);
const maxTimeCommandIndex = items.findIndex((x) => x === '-m');
if (maxTimeCommandIndex !== -1) {
items = items.slice(maxTimeCommandIndex + 2);
}
const items = command.split(/ +/);
let str = items[0];
if (items[0] === TASK_COMMAND) {
str = items[1];
@@ -499,7 +506,7 @@ export async function getUniqPath(
str = `${tempStr}_${str.slice(slashIndex + 1)}`;
}
return `${str}${id}`;
return `${str}${suffix}`;
}
export function safeJSONParse(value?: string) {
+22 -2
View File
@@ -20,6 +20,8 @@ export enum NotificationMode {
'feishu' = 'feishu',
'webhook' = 'webhook',
'chronocat' = 'Chronocat',
'ntfy' = 'ntfy',
'wxPusherBot' = 'wxPusherBot',
}
abstract class NotificationBaseInfo {
@@ -99,6 +101,11 @@ export class IGotNotification extends NotificationBaseInfo {
export class PushPlusNotification extends NotificationBaseInfo {
public pushPlusToken = '';
public pushPlusUser = '';
public pushPlusTemplate = '';
public pushplusChannel = '';
public pushplusWebhook = '';
public pushplusCallbackUrl = '';
public pushplusTo = '';
}
export class WePlusBotNotification extends NotificationBaseInfo {
@@ -139,6 +146,18 @@ export class LarkNotification extends NotificationBaseInfo {
public larkKey = '';
}
export class NtfyNotification extends NotificationBaseInfo {
public ntfyUrl = '';
public ntfyTopic = '';
public ntfyPriority = '';
}
export class WxPusherBotNotification extends NotificationBaseInfo {
public wxPusherBotAppToken = '';
public wxPusherBotTopicIds = '';
public wxPusherBotUids = '';
}
export interface NotificationInfo
extends GoCqHttpBotNotification,
GotifyNotification,
@@ -158,5 +177,6 @@ export interface NotificationInfo
PushMeNotification,
WebhookNotification,
ChronocatNotification,
LarkNotification {}
LarkNotification,
NtfyNotification,
WxPusherBotNotification {}
+3 -3
View File
@@ -3,7 +3,7 @@ import bodyParser from 'body-parser';
import cors from 'cors';
import routes from '../api';
import config from '../config';
import jwt, { UnauthorizedError } from 'express-jwt';
import { UnauthorizedError, expressjwt } from 'express-jwt';
import fs from 'fs/promises';
import { getPlatform, getToken, safeJSONParse } from '../config/util';
import Container from 'typedi';
@@ -29,7 +29,7 @@ export default ({ app }: { app: Application }) => {
target: `http://0.0.0.0:${config.publicPort}/api`,
changeOrigin: true,
pathRewrite: { '/api/public': '' },
logProvider: () => Logger,
logger: Logger,
}),
);
@@ -37,7 +37,7 @@ export default ({ app }: { app: Application }) => {
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(
jwt({
expressjwt({
secret: config.secret,
algorithms: ['HS384'],
}).unless({
+4 -4
View File
@@ -4,10 +4,10 @@ import config from '../config';
import path from 'path';
const levelMap: Record<string, string> = {
info: '🔵',
warn: '🟡',
error: '🔴',
debug: '🔶'
info: '\ue6f5',
warn: '\ue880',
error: '\ue602',
debug: '\ue67f'
}
const customFormat = winston.format.combine(
+2 -2
View File
@@ -2,7 +2,7 @@ import bodyParser from 'body-parser';
import { errors } from 'celebrate';
import cors from 'cors';
import { Application, NextFunction, Request, Response } from 'express';
import jwt from 'express-jwt';
import { expressjwt } from 'express-jwt';
import Container from 'typedi';
import config from '../config';
import SystemService from '../services/system';
@@ -16,7 +16,7 @@ export default ({ app }: { app: Application }) => {
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(
jwt({
expressjwt({
secret: config.secret,
algorithms: ['HS384'],
}),
-1
View File
@@ -17,7 +17,6 @@ server.bindAsync(
if (err) {
throw err;
}
server.start();
Logger.debug(`✌️ 定时服务启动成功!`);
console.debug(`✌️ 定时服务启动成功!`);
process.send?.('ready');
+97 -15
View File
@@ -35,6 +35,8 @@ export default class NotificationService {
['webhook', this.webhook],
['lark', this.lark],
['chronocat', this.chronocat],
['ntfy', this.ntfy],
['wxPusherBot', this.wxPusherBot],
]);
private title = '';
@@ -151,14 +153,16 @@ export default class NotificationService {
private async serverChan() {
const { serverChanKey } = this.params;
const url = serverChanKey.startsWith('SCT')
? `https://sctapi.ftqq.com/${serverChanKey}.send`
: `https://sc.ftqq.com/${serverChanKey}.send`;
const matchResult = serverChanKey.match(/^sctp(\d+)t/i);
const url = matchResult && matchResult[1]
? `https://${matchResult[1]}.push.ft07.com/send/${serverChanKey}.send`
: `https://sctapi.ftqq.com/${serverChanKey}.send`;
try {
const res: any = await got
.post(url, {
...this.gotOption,
body: `title=${this.title}&desp=${this.content}`,
body: `title=${encodeURIComponent(this.title)}&desp=${encodeURIComponent(this.content)}`,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
})
.json();
@@ -516,22 +520,29 @@ export default class NotificationService {
} catch (error: any) {
throw new Error(error.response ? error.response.body : error);
}
}
}
private async pushPlus() {
const { pushPlusToken, pushPlusUser } = this.params;
const { pushPlusToken, pushPlusUser, pushplusWebhook, pushPlusTemplate, pushplusChannel, pushplusCallbackUrl, pushplusTo} = this.params;
const url = `https://www.pushplus.plus/send`;
try {
let body = {
...this.gotOption,
json: {
token: `${pushPlusToken}`,
title: `${this.title}`,
content: `${this.content.replace(/[\n\r]/g, '<br>')}`,
topic: `${pushPlusUser || ''}`,
template: `${pushPlusTemplate || 'html'}`,
channel: `${pushplusChannel || 'wechat'}`,
webhook: `${pushplusWebhook || ''}`,
callbackUrl: `${pushplusCallbackUrl || ''}`,
to: `${pushplusTo || ''}`
},
}
const res: any = await got
.post(url, {
...this.gotOption,
json: {
token: `${pushPlusToken}`,
title: `${this.title}`,
content: `${this.content.replace(/[\n\r]/g, '<br>')}`,
topic: `${pushPlusUser || ''}`,
},
})
.post(url, body)
.json();
if (res.code === 200) {
@@ -661,6 +672,77 @@ export default class NotificationService {
}
}
private async ntfy() {
const { ntfyUrl, ntfyTopic, ntfyPriority } = this.params;
// 编码函数
const encodeRfc2047 = (text: string, charset: string = 'UTF-8'): string => {
const encodedText = Buffer.from(text).toString('base64');
return `=?${charset}?B?${encodedText}?=`;
};
try {
const encodedTitle = encodeRfc2047(this.title);
const res: any = await got
.post(`${ntfyUrl || 'https://ntfy.sh'}/${ntfyTopic}`, {
...this.gotOption,
body: `${this.content}`,
headers: { 'Title': encodedTitle, 'Priority': `${ntfyPriority || '3'}` },
});
if (res.statusCode === 200) {
return true;
} else {
throw new Error(JSON.stringify(res));
}
} catch (error: any) {
throw new Error(error.response ? error.response.body : error);
}
}
private async wxPusherBot() {
const { wxPusherBotAppToken, wxPusherBotTopicIds, wxPusherBotUids } = this.params;
// 处理 topicIds,将分号分隔的字符串转为数组
const topicIds = wxPusherBotTopicIds ? wxPusherBotTopicIds.split(';')
.map(id => id.trim())
.filter(id => id)
.map(id => parseInt(id)) : [];
// 处理 uids,将分号分隔的字符串转为数组
const uids = wxPusherBotUids ? wxPusherBotUids.split(';')
.map(uid => uid.trim())
.filter(uid => uid) : [];
// topic_ids 和 uids 至少要有一个
if (!topicIds.length && !uids.length) {
throw new Error('wxPusher 服务的 TopicIds 和 Uids 至少配置一个才行');
}
const url = `https://wxpusher.zjiecode.com/api/send/message`;
try {
const res: any = await got
.post(url, {
...this.gotOption,
json: {
appToken: wxPusherBotAppToken,
content: `<h1>${this.title}</h1><br/><div style='white-space: pre-wrap;'>${this.content}</div>`,
summary: this.title,
contentType: 2,
topicIds: topicIds,
uids: uids,
verifyPayType: 0
},
})
.json();
if (res.code === 1000) {
return true;
} else {
throw new Error(JSON.stringify(res));
}
} catch (error: any) {
throw new Error(error.response ? error.response.body : error);
}
}
private async chronocat() {
const { chronocatURL, chronocatQQ, chronocatToken } = this.params;
try {
+1 -1
View File
@@ -214,7 +214,7 @@ export default class ScheduleService {
const job = new LongIntervalJob(
{ runImmediately: false, ...schedule },
task,
_id,
{ id: _id },
);
this.intervalSchedule.addIntervalJob(job);
+2 -2
View File
@@ -402,7 +402,7 @@ export default class SystemService {
public async exportData(res: Response) {
try {
await promiseExec(
`cd ${config.rootPath} && tar -zcvf ${config.dataTgzFile} data/`,
`cd ${config.dataPath} && cd ../ && tar -zcvf ${config.dataTgzFile} data/`,
);
res.download(config.dataTgzFile);
} catch (error: any) {
@@ -414,7 +414,7 @@ export default class SystemService {
try {
await promiseExec(`rm -rf ${path.join(config.tmpPath, 'data')}`);
const res = await promiseExec(
`cd ${config.tmpPath} && tar -zxvf data.tgz`,
`cd ${config.tmpPath} && tar -zxvf ${config.dataTgzFile}`,
);
return { code: 200, data: res };
} catch (error: any) {
+1 -1
View File
@@ -217,7 +217,7 @@ export default class UserService {
(a, b) => b.info!.timestamp! - a.info!.timestamp!,
);
if (result.length > 100) {
const ids = result.slice(0, result.length - 100).map((x) => x.id!);
const ids = result.slice(100).map((x) => x.id!);
await SystemModel.destroy({
where: { id: ids },
});
-13
View File
@@ -1,13 +0,0 @@
import { CommandModule } from 'yargs';
export const updateCommand: CommandModule = {
command: 'update',
describe: 'Update and restart qinglong',
builder: (yargs) => {
return yargs.option('repositority', {
type: 'string',
alias: 'r',
describe: `Specify the release warehouse address of the package`,
});
},
handler: async (argv) => {},
};
-13
View File
@@ -1,13 +0,0 @@
import * as yargs from 'yargs';
import { green, red } from 'chalk';
import { updateCommand } from './commands/update';
yargs
.usage('Usage: ql [command] <options>')
.command(updateCommand)
.fail((err) => {
console.error(`${red(err)}`);
})
.alias('h', 'help')
.showHelp()
.recommendCommands().argv;
+3 -8
View File
@@ -1,15 +1,10 @@
version: '2'
services:
web:
# alpine 基础镜像版本
image: whyour/qinglong:latest
# debian-slim 基础镜像版本
# image: whyour/qinglong:debian
image: whyour/qinglong:latest # 基于 Debian 的版本:whyour/qinglong:debian
volumes:
- ./data:/ql/data
ports:
- "0.0.0.0:5700:5700"
- "5700:5700"
environment:
# 部署路径非必须,以斜杠开头和结尾,比如 /test/
QlBaseUrl: '/'
QlBaseUrl: '/' # 部署路径非必须,以斜杠开头和结尾,比如 /test/
restart: unless-stopped
+38 -39
View File
@@ -57,59 +57,59 @@
}
},
"dependencies": {
"@grpc/grpc-js": "^1.8.13",
"@grpc/grpc-js": "^1.12.3",
"@otplib/preset-default": "^12.0.1",
"@sentry/node": "^8.26.0",
"body-parser": "^1.19.2",
"celebrate": "^15.0.1",
"chokidar": "^3.5.3",
"@sentry/node": "^8.42.0",
"body-parser": "^1.20.3",
"celebrate": "^15.0.3",
"chokidar": "^4.0.1",
"cors": "^2.8.5",
"cron-parser": "^4.2.1",
"cross-spawn": "^7.0.3",
"dayjs": "^1.11.2",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"express-jwt": "^6.1.1",
"express-rate-limit": "^7.0.0",
"express-urlrewrite": "^1.4.0",
"cron-parser": "^4.9.0",
"cross-spawn": "^7.0.6",
"dayjs": "^1.11.13",
"dotenv": "^16.4.6",
"express": "^4.21.1",
"express-jwt": "^8.4.1",
"express-rate-limit": "^7.4.1",
"express-urlrewrite": "^2.0.3",
"form-data": "^4.0.0",
"got": "^11.8.2",
"hpagent": "^1.2.0",
"http-proxy-middleware": "^2.0.6",
"http-proxy-middleware": "^3.0.3",
"iconv-lite": "^0.6.3",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^8.5.1",
"jsonwebtoken": "^9.0.2",
"lodash": "^4.17.21",
"multer": "1.4.5-lts.1",
"nedb": "^1.8.0",
"node-schedule": "^2.1.0",
"nodemailer": "^6.7.2",
"nodemailer": "^6.9.16",
"p-queue-cjs": "7.3.4",
"protobufjs": "^7.3.0",
"protobufjs": "^7.4.0",
"pstree.remy": "^1.1.8",
"reflect-metadata": "^0.1.13",
"sequelize": "^6.25.5",
"serve-handler": "^6.1.3",
"reflect-metadata": "^0.2.2",
"sequelize": "^6.37.5",
"serve-handler": "^6.1.6",
"sockjs": "^0.3.24",
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
"toad-scheduler": "^1.6.0",
"toad-scheduler": "^3.0.1",
"typedi": "^0.10.0",
"uuid": "^8.3.2",
"winston": "^3.6.0",
"winston-daily-rotate-file": "^4.7.1",
"yargs": "^17.3.1",
"tough-cookie": "^4.0.0",
"uuid": "^11.0.3",
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0",
"request-ip": "3.3.0",
"ip2region": "2.3.0"
},
"devDependencies": {
"moment": "2.30.1",
"@ant-design/icons": "^4.7.0",
"@ant-design/icons": "^5.0.1",
"@ant-design/pro-layout": "6.38.22",
"@codemirror/view": "^6.34.1",
"@codemirror/state": "^6.4.1",
"@monaco-editor/react": "4.2.1",
"@react-hook/resize-observer": "^1.2.6",
"@react-hook/resize-observer": "^2.0.2",
"react-router-dom": "6.26.1",
"@sentry/react": "^8.26.0",
"@sentry/react": "^8.42.0",
"@types/body-parser": "^1.19.2",
"@types/cors": "^2.8.12",
"@types/cross-spawn": "^6.0.2",
@@ -135,16 +135,16 @@
"@types/request-ip": "0.0.41",
"@uiw/codemirror-extensions-langs": "^4.21.9",
"@uiw/react-codemirror": "^4.21.9",
"@umijs/max": "^4.0.72",
"@umijs/max": "^4.3.36",
"@umijs/ssr-darkreader": "^4.9.45",
"ahooks": "^3.7.8",
"ansi-to-react": "^6.1.6",
"antd": "^4.24.8",
"antd-img-crop": "^4.2.3",
"antd-img-crop": "^4.23.0",
"axios": "^1.4.0",
"compression-webpack-plugin": "9.2.0",
"concurrently": "^7.0.0",
"react-hotkeys-hook": "^4.4.1",
"react-hotkeys-hook": "^4.6.1",
"file-saver": "2.0.2",
"lint-staged": "^13.0.3",
"monaco-editor": "0.33.0",
@@ -155,14 +155,14 @@
"qrcode.react": "^1.0.1",
"query-string": "^7.1.1",
"rc-tween-one": "^3.0.6",
"rc-virtual-list": "3.5.3",
"react": "18.2.0",
"rc-virtual-list": "3.15.0",
"react": "18.3.1",
"react-copy-to-clipboard": "^5.1.0",
"react-diff-viewer": "^3.1.1",
"react-dnd": "^14.0.2",
"react-dnd-html5-backend": "^14.0.0",
"react-dom": "18.2.0",
"react-intl-universal": "^2.6.21",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "18.3.1",
"react-intl-universal": "^2.12.0",
"react-split-pane": "^0.1.92",
"sockjs-client": "^1.6.0",
"ts-node": "^10.9.2",
@@ -171,7 +171,6 @@
"typescript": "5.2.2",
"vh-check": "^2.0.5",
"virtualizedtableforantd4": "1.3.0",
"webpack": "^5.70.0",
"yorkie": "^2.0.0"
}
}
+5220 -6119
View File
File diff suppressed because it is too large Load Diff
+30 -1
View File
@@ -117,6 +117,16 @@ export PUSH_PLUS_TOKEN=""
## 下方填写您的一对多推送的 "群组编码" ,(一对多推送下面->您的群组(如无则新建)->群组编码)
## 1. 需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送
export PUSH_PLUS_USER=""
## 发送模板,支持html,txt,json,markdown,cloudMonitor,jenkins,route,pay
export PUSH_PLUS_TEMPLATE="html"
## 发送渠道,支持wechat,webhook,cp,mail,sms
export PUSH_PLUS_CHANNEL="wechat"
## webhook编码,可在pushplus公众号上扩展配置出更多渠道
export PUSH_PLUS_WEBHOOK=""
## 发送结果回调地址,会把推送最终结果通知到这个地址上
export PUSH_PLUS_CALLBACKURL=""
## 好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id
export PUSH_PLUS_TO=""
## 9. 微加机器人
## 官方网站:http://www.weplusbot.com
@@ -211,7 +221,26 @@ export FSKEY=""
export QMSG_KEY=""
export QMSG_TYPE=""
## 20. 自定义通知
## 20.Ntfy
## 官方文档: https://docs.ntfy.sh
## ntfy_url 填写ntfy地址,如https://ntfy.sh
## ntfy_topic 填写ntfy的消息应用topic
## ntfy_priority 填写推送消息优先级,默认为3
export NTFY_URL=""
export NTFY_TOPIC=""
export NTFY_PRIORITY="3"
## 21. wxPusher
## 官方文档: https://wxpusher.zjiecode.com/docs/
## 管理后台: https://wxpusher.zjiecode.com/admin/
## wxPusher 的 appToken
export WXPUSHER_APP_TOKEN=""
## wxPusher 的 topicIds,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
export WXPUSHER_TOPIC_IDS=""
## wxPusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
export WXPUSHER_UIDS=""
## 22. 自定义通知
## 自定义通知 接收回调的URL
export WEBHOOK_URL=""
## WEBHOOK_BODY 和 WEBHOOK_HEADERS 多个参数时,直接换行或者使用 $'\n' 连接多行字符串,比如 export dd="line 1"$'\n'"line 2"
+143 -12
View File
@@ -40,9 +40,15 @@ const push_config = {
CHAT_URL: '', // synology chat url
CHAT_TOKEN: '', // synology chat token
// 官方文档:http://www.pushplus.plus/
PUSH_PLUS_TOKEN: '', // push+ 微信推送的用户令牌
PUSH_PLUS_USER: '', // push+ 微信推送的群组编码
// 官方文档:https://www.pushplus.plus/
PUSH_PLUS_TOKEN: '', // pushplus 推送的用户令牌
PUSH_PLUS_USER: '', // pushplus 推送的群组编码
PUSH_PLUS_TEMPLATE: 'html', // pushplus 发送模板,支持html,txt,json,markdown,cloudMonitor,jenkins,route,pay
PUSH_PLUS_CHANNEL: 'wechat', // pushplus 发送渠道,支持wechat,webhook,cp,mail,sms
PUSH_PLUS_WEBHOOK: '', // pushplus webhook编码,可在pushplus公众号上扩展配置出更多渠道
PUSH_PLUS_CALLBACKURL: '', // pushplus 发送结果回调地址,会把推送最终结果通知到这个地址上
PUSH_PLUS_TO: '', // pushplus 好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id
// 微加机器人,官方网站:https://www.weplusbot.com/
WE_PLUS_BOT_TOKEN: '', // 微加机器人的用户令牌
@@ -95,6 +101,16 @@ const push_config = {
WEBHOOK_HEADERS: '', // 自定义通知 请求头
WEBHOOK_METHOD: '', // 自定义通知 请求方法
WEBHOOK_CONTENT_TYPE: '', // 自定义通知 content-type
NTFY_URL: '', // ntfy地址,如https://ntfy.sh,默认为https://ntfy.sh
NTFY_TOPIC: '', // ntfy的消息应用topic
NTFY_PRIORITY: '3', // 推送消息优先级,默认为3
// 官方文档: https://wxpusher.zjiecode.com/docs/
// 管理后台: https://wxpusher.zjiecode.com/admin/
WXPUSHER_APP_TOKEN: '', // wxpusher 的 appToken
WXPUSHER_TOPIC_IDS: '', // wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
WXPUSHER_UIDS: '', // wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
};
for (const key in push_config) {
@@ -224,11 +240,13 @@ function serverNotify(text, desp) {
if (PUSH_KEY) {
// 微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换
desp = desp.replace(/[\n\r]/g, '\n\n');
const matchResult = PUSH_KEY.match(/^sctp(\d+)t/i);
const options = {
url: PUSH_KEY.includes('SCT')
? `https://sctapi.ftqq.com/${PUSH_KEY}.send`
: `https://sc.ftqq.com/${PUSH_KEY}.send`,
body: `text=${text}&desp=${desp}`,
url: matchResult && matchResult[1]
? `https://${matchResult[1]}.push.ft07.com/send/${PUSH_KEY}.send`
: `https://sctapi.ftqq.com/${PUSH_KEY}.send`,
body: `text=${encodeURIComponent(text)}&desp=${encodeURIComponent(desp)}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
@@ -759,7 +777,7 @@ function iGotNotify(text, desp, params = {}) {
function pushPlusNotify(text, desp) {
return new Promise((resolve) => {
const { PUSH_PLUS_TOKEN, PUSH_PLUS_USER } = push_config;
const { PUSH_PLUS_TOKEN, PUSH_PLUS_USER, PUSH_PLUS_TEMPLATE, PUSH_PLUS_CHANNEL, PUSH_PLUS_WEBHOOK, PUSH_PLUS_CALLBACKURL, PUSH_PLUS_TO } = push_config;
if (PUSH_PLUS_TOKEN) {
desp = desp.replace(/[\n\r]/g, '<br>'); // 默认为html, 不支持plaintext
const body = {
@@ -767,6 +785,11 @@ function pushPlusNotify(text, desp) {
title: `${text}`,
content: `${desp}`,
topic: `${PUSH_PLUS_USER}`,
template: `${PUSH_PLUS_TEMPLATE}`,
channel: `${PUSH_PLUS_CHANNEL}`,
webhook: `${PUSH_PLUS_WEBHOOK}`,
callbackUrl: `${PUSH_PLUS_CALLBACKURL}`,
to: `${PUSH_PLUS_TO}`
};
const options = {
url: `https://www.pushplus.plus/send`,
@@ -780,7 +803,7 @@ function pushPlusNotify(text, desp) {
try {
if (err) {
console.log(
`Push+ 发送${
`pushplus 发送${
PUSH_PLUS_USER ? '一对多' : '一对一'
}通知消息失败😞\n`,
err,
@@ -788,13 +811,13 @@ function pushPlusNotify(text, desp) {
} else {
if (data.code === 200) {
console.log(
`Push+ 发送${
`pushplus 发送${
PUSH_PLUS_USER ? '一对多' : '一对一'
}通知消息完成🎉\n`,
}通知请求成功🎉,可根据流水号查询推送结果:${data.data}\n注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果`,
);
} else {
console.log(
`Push+ 发送${
`pushplus 发送${
PUSH_PLUS_USER ? '一对多' : '一对一'
}通知消息异常 ${data.msg}\n`,
);
@@ -1188,6 +1211,112 @@ function webhookNotify(text, desp) {
});
}
function ntfyNotify(text, desp) {
function encodeRFC2047(text) {
const encodedBase64 = Buffer.from(text).toString('base64');
return `=?utf-8?B?${encodedBase64}?=`;
}
return new Promise((resolve) => {
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY } = push_config;
if (NTFY_TOPIC) {
const options = {
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
body: `${desp}`,
headers: {
'Title': `${encodeRFC2047(text)}`,
'Priority': NTFY_PRIORITY || '3'
},
timeout,
};
$.post(options, (err, resp, data) => {
try {
if (err) {
console.log('Ntfy 通知调用API失败😞\n', err);
} else {
if (data.id) {
console.log('Ntfy 发送通知消息成功🎉\n');
} else {
console.log(`Ntfy 发送通知消息异常 ${JSON.stringify(data)}`);
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve(data);
}
});
} else {
resolve();
}
});
}
function wxPusherNotify(text, desp) {
return new Promise((resolve) => {
const { WXPUSHER_APP_TOKEN, WXPUSHER_TOPIC_IDS, WXPUSHER_UIDS } = push_config;
if (WXPUSHER_APP_TOKEN) {
// 处理topic_ids,将分号分隔的字符串转为数组
const topicIds = WXPUSHER_TOPIC_IDS ? WXPUSHER_TOPIC_IDS.split(';')
.map(id => id.trim())
.filter(id => id)
.map(id => parseInt(id)) : [];
// 处理uids,将分号分隔的字符串转为数组
const uids = WXPUSHER_UIDS ? WXPUSHER_UIDS.split(';')
.map(uid => uid.trim())
.filter(uid => uid) : [];
// topic_ids uids 至少有一个
if (!topicIds.length && !uids.length) {
console.log("wxpusher 服务的 WXPUSHER_TOPIC_IDS 和 WXPUSHER_UIDS 至少设置一个!!\n取消推送");
return resolve();
}
const body = {
appToken: WXPUSHER_APP_TOKEN,
content: `<h1>${text}</h1><br/><div style='white-space: pre-wrap;'>${desp}</div>`,
summary: text,
contentType: 2,
topicIds: topicIds,
uids: uids,
verifyPayType: 0
};
const options = {
url: 'https://wxpusher.zjiecode.com/api/send/message',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json'
},
timeout
};
$.post(options, (err, resp, data) => {
try {
if (err) {
console.log('wxpusher发送通知消息失败!\n', err);
} else {
if (data.code === 1000) {
console.log('wxpusher发送通知消息完成!');
} else {
console.log(`wxpusher发送通知消息异常:${data.msg}`);
}
}
} catch (e) {
$.logErr(e, resp);
} finally {
resolve(data);
}
});
} else {
console.log('wxpusher 服务的 WXPUSHER_APP_TOKEN 未设置!!\n取消推送');
resolve();
}
});
}
function parseString(input, valueFormatFn) {
const regex = /(\w+):\s*((?:(?!\n\w+:).)*)/g;
const matches = {};
@@ -1316,6 +1445,8 @@ async function sendNotify(text, desp, params = {}) {
chronocatNotify(text, desp), // Chronocat
webhookNotify(text, desp), // 自定义通知
qmsgNotify(text, desp), // 自定义通知
ntfyNotify(text, desp), // Ntfy
wxPusherNotify(text, desp), // wxpusher
]);
}
+128 -12
View File
@@ -72,8 +72,13 @@ push_config = {
'CHAT_URL': '', # synology chat url
'CHAT_TOKEN': '', # synology chat token
'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌
'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码
'PUSH_PLUS_TOKEN': '', # pushplus 推送的用户令牌
'PUSH_PLUS_USER': '', # pushplus 推送的群组编码
'PUSH_PLUS_TEMPLATE': 'html', # pushplus 发送模板,支持html,txt,json,markdown,cloudMonitor,jenkins,route,pay
'PUSH_PLUS_CHANNEL': 'wechat', # pushplus 发送渠道,支持wechat,webhook,cp,mail,sms
'PUSH_PLUS_WEBHOOK': '', # pushplus webhook编码,可在pushplus公众号上扩展配置出更多渠道
'PUSH_PLUS_CALLBACKURL': '', # pushplus 发送结果回调地址,会把推送最终结果通知到这个地址上
'PUSH_PLUS_TO': '', # pushplus 好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id
'WE_PLUS_BOT_TOKEN': '', # 微加机器人的用户令牌
'WE_PLUS_BOT_RECEIVER': '', # 微加机器人的消息接收者
@@ -116,7 +121,15 @@ push_config = {
'WEBHOOK_BODY': '', # 自定义通知 请求体
'WEBHOOK_HEADERS': '', # 自定义通知 请求头
'WEBHOOK_METHOD': '', # 自定义通知 请求方法
'WEBHOOK_CONTENT_TYPE': '' # 自定义通知 content-type
'WEBHOOK_CONTENT_TYPE': '', # 自定义通知 content-type
'NTFY_URL': '', # ntfy地址,如https://ntfy.sh
'NTFY_TOPIC': '', # ntfy的消息应用topic
'NTFY_PRIORITY':'3', # 推送消息优先级,默认为3
'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
'WXPUSHER_UIDS': '', # wxpusher 的 用户ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
}
# fmt: on
@@ -298,10 +311,14 @@ def serverJ(title: str, content: str) -> None:
print("serverJ 服务启动")
data = {"text": title, "desp": content.replace("\n", "\n\n")}
if push_config.get("PUSH_KEY").find("SCT") != -1:
url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
match = re.match(r'sctp(\d+)t', push_config.get("PUSH_KEY"))
if match:
num = match.group(1)
url = f'https://{num}.push.ft07.com/send/{push_config.get("PUSH_KEY")}.send'
else:
url = f'https://sc.ftqq.com/{push_config.get("PUSH_KEY")}.send'
url = f'https://sctapi.ftqq.com/{push_config.get("PUSH_KEY")}.send'
response = requests.post(url, data=data).json()
if response.get("errno") == 0 or response.get("code") == 0:
@@ -356,26 +373,35 @@ def chat(title: str, content: str) -> None:
def pushplus_bot(title: str, content: str) -> None:
"""
通过 push+ 推送消息。
通过 pushplus 推送消息。
"""
if not push_config.get("PUSH_PLUS_TOKEN"):
print("PUSHPLUS 服务的 PUSH_PLUS_TOKEN 未设置!!\n取消推送")
return
print("PUSHPLUS 服务启动")
url = "http://www.pushplus.plus/send"
url = "https://www.pushplus.plus/send"
data = {
"token": push_config.get("PUSH_PLUS_TOKEN"),
"title": title,
"content": content,
"topic": push_config.get("PUSH_PLUS_USER"),
"template": push_config.get("PUSH_PLUS_TEMPLATE"),
"channel": push_config.get("PUSH_PLUS_CHANNEL"),
"webhook": push_config.get("PUSH_PLUS_WEBHOOK"),
"callbackUrl": push_config.get("PUSH_PLUS_CALLBACKURL"),
"to": push_config.get("PUSH_PLUS_TO")
}
body = json.dumps(data).encode(encoding="utf-8")
headers = {"Content-Type": "application/json"}
response = requests.post(url=url, data=body, headers=headers).json()
if response["code"] == 200:
print("PUSHPLUS 推送成功!")
code = response["code"]
if code == 200:
print("PUSHPLUS 推送请求成功,可根据流水号查询推送结果:"+ response["data"])
print("注意:请求成功并不代表推送成功,如未收到消息,请到pushplus官网使用流水号查询推送最终结果")
elif code == 900 or code == 903 or code == 905 or code == 999 :
print(response["msg"])
else:
url_old = "http://pushplus.hxtrip.com/send"
@@ -777,6 +803,93 @@ def chronocat(title: str, content: str) -> None:
print(f"QQ群消息:{ids}推送失败!")
def ntfy(title: str, content: str) -> None:
"""
通过 Ntfy 推送消息
"""
def encode_rfc2047(text: str) -> str:
"""将文本编码为符合 RFC 2047 标准的格式"""
encoded_bytes = base64.b64encode(text.encode('utf-8'))
encoded_str = encoded_bytes.decode('utf-8')
return f'=?utf-8?B?{encoded_str}?='
if not push_config.get("NTFY_TOPIC"):
print("ntfy 服务的 NTFY_TOPIC 未设置!!\n取消推送")
return
print("ntfy 服务启动")
priority = '3'
if not push_config.get("NTFY_PRIORITY"):
print("ntfy 服务的NTFY_PRIORITY 未设置!!默认设置为3")
else:
priority = push_config.get("NTFY_PRIORITY")
# 使用 RFC 2047 编码 title
encoded_title = encode_rfc2047(title)
data = content.encode(encoding='utf-8')
headers = {
"Title": encoded_title, # 使用编码后的 title
"Priority": priority
}
url = push_config.get("NTFY_URL") + "/" + push_config.get("NTFY_TOPIC")
response = requests.post(url, data=data, headers=headers)
if response.status_code == 200: # 使用 response.status_code 进行检查
print("Ntfy 推送成功!")
else:
print("Ntfy 推送失败!错误信息:", response.text)
def wxpusher_bot(title: str, content: str) -> None:
"""
通过 wxpusher 推送消息。
支持的环境变量:
- WXPUSHER_APP_TOKEN: appToken
- WXPUSHER_TOPIC_IDS: 主题ID, 多个用英文分号;分隔
- WXPUSHER_UIDS: 用户ID, 多个用英文分号;分隔
"""
if not push_config.get("WXPUSHER_APP_TOKEN"):
print("wxpusher 服务的 WXPUSHER_APP_TOKEN 未设置!!\n取消推送")
return
url = "https://wxpusher.zjiecode.com/api/send/message"
# 处理topic_ids和uids,将分号分隔的字符串转为数组
topic_ids = []
if push_config.get("WXPUSHER_TOPIC_IDS"):
topic_ids = [int(id.strip()) for id in push_config.get("WXPUSHER_TOPIC_IDS").split(";") if id.strip()]
uids = []
if push_config.get("WXPUSHER_UIDS"):
uids = [uid.strip() for uid in push_config.get("WXPUSHER_UIDS").split(";") if uid.strip()]
# topic_ids uids 至少有一个
if not topic_ids and not uids:
print("wxpusher 服务的 WXPUSHER_TOPIC_IDS 和 WXPUSHER_UIDS 至少设置一个!!\n取消推送")
return
print("wxpusher 服务启动")
data = {
"appToken": push_config.get("WXPUSHER_APP_TOKEN"),
"content": f"<h1>{title}</h1><br/><div style='white-space: pre-wrap;'>{content}</div>",
"summary": title,
"contentType": 2,
"topicIds": topic_ids,
"uids": uids,
"verifyPayType": 0
}
headers = {"Content-Type": "application/json"}
response = requests.post(url=url, json=data, headers=headers).json()
if response.get("code") == 1000:
print("wxpusher 推送成功!")
else:
print(f"wxpusher 推送失败!错误信息:{response.get('msg')}")
def parse_headers(headers):
if not headers:
return {}
@@ -937,7 +1050,10 @@ def add_notify_function():
notify_function.append(chronocat)
if push_config.get("WEBHOOK_URL") and push_config.get("WEBHOOK_METHOD"):
notify_function.append(custom_notify)
if push_config.get("NTFY_TOPIC"):
notify_function.append(ntfy)
if push_config.get("WXPUSHER_APP_TOKEN") and (push_config.get("WXPUSHER_TOPIC_IDS") or push_config.get("WXPUSHER_UIDS")):
notify_function.append(wxpusher_bot)
if not notify_function:
print(f"无推送渠道,请检查通知变量是否正确")
return notify_function
@@ -979,4 +1095,4 @@ def main():
if __name__ == "__main__":
main()
main()
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -125,7 +125,8 @@ run_concurrent() {
fi
handle_env_split
single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%3N")
time=$(date "+$mtime_format")
single_log_time=$(format_log_time "$mtime_format" "$time")
cd $dir_scripts
local relative_path="${file_param%/*}"
+3 -3
View File
@@ -29,7 +29,7 @@ function run() {
file_task_before_js,
dir_scripts,
task_before,
PREV_NODE_OPTIONS
PREV_NODE_OPTIONS,
} = process.env;
try {
@@ -62,10 +62,10 @@ function run() {
}
} catch (error) {
if (!error.message.includes('spawnSync /bin/sh E2BIG')) {
console.log(` run task before error: `, error);
console.log(`\ue926 run task before error: `, error);
} else {
console.log(
` The environment variable is too large. It is recommended to use task_before.js instead of task_before.sh\n`,
`\ue926 The environment variable is too large. It is recommended to use task_before.js instead of task_before.sh\n`,
);
}
if (task_before) {
+2 -2
View File
@@ -72,10 +72,10 @@ def run():
except OSError as error:
error_message = str(error)
if "Argument list too long" not in error_message:
print(f" run task before error: {error}")
print(f"\ue926 run task before error: {error}")
else:
print(
" The environment variable is too large. It is recommended to use task_before.py instead of task_before.sh\n"
"\ue926 The environment variable is too large. It is recommended to use task_before.py instead of task_before.sh\n"
)
if task_before:
print("执行前置命令结束")
+3 -3
View File
@@ -340,7 +340,7 @@ format_log_time() {
local time="$2"
if [[ $is_macos -eq 1 ]]; then
echo $(date -j -f "$format" "$time" "+%Y-%m-%d-%H-%M-%S-%3N")
echo $(python3 -c 'from datetime import datetime; print(datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")[:-3])')
else
echo $(date -d "$time" "+%Y-%m-%d-%H-%M-%S-%3N")
fi
@@ -453,7 +453,7 @@ run_task_before() {
if [[ ${task_before:=} ]]; then
echo -e "执行前置命令\n"
eval "${task_before%;}" "$@"
eval "${task_before%;}"
echo -e "\n执行前置命令结束\n"
fi
}
@@ -463,7 +463,7 @@ run_task_after() {
if [[ ${task_after:=} ]]; then
echo -e "\n执行后置命令\n"
eval "${task_after%;}" "$@"
eval "${task_after%;}"
echo -e "\n执行后置命令结束"
fi
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+16
View File
@@ -8,6 +8,13 @@
url('../assets/fonts/SourceCodePro-Regular.ttf') format('truetype');
}
@font-face {
font-family: Log;
src: url('../assets/fonts/log.woff2') format('woff2'),
url('../assets/fonts/log.woff') format('woff'),
url('../assets/fonts/log.ttf') format('truetype');
}
body {
// 禁止手机页面下拉刷新
overflow: hidden;
@@ -52,6 +59,11 @@ body {
width: 100%;
padding: 24px;
overflow-y: auto;
code,
span {
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo,
Courier, monospace, Log;
}
}
}
@@ -63,6 +75,10 @@ body {
}
}
.ͼ1 .cm-scroller {
font-family: monospace, Log;
}
.monaco-editor:not(.rename-box) {
height: calc(100vh - 128px) !important;
height: calc(100vh - var(--vh-offset, 0px) - 128px) !important;
+10
View File
@@ -379,6 +379,11 @@
"iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX": "iGot information push key, e.g., https://push.hellyw.com/XXXXXXXX",
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "After WeChat scan login, one-to-one or one-to-many push using the provided token (your Token). If PUSH_PLUS_USER is not provided, it defaults to one-to-one push. See reference at https://www.pushplus.plus/",
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "The 'group code' for one-to-many push (one-to-many push -> your group (if none, create one) -> group code). If you are the creator of the group, you need to click 'View QR code' to scan and bind, otherwise, you won't receive group messages.",
"发送模板": "send template, can use type: 'html,txt,json,markdown,cloudMonitor,jenkins,route,pay'",
"发送渠道": "send channel, can use type: 'wechat,webhook,cp,mail,sms'",
"webhook编码": "webhook code",
"发送结果回调地址": "send result callback url",
"好友令牌": "friend token",
"用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/": "Token, which can be obtained after scanning and logging in, is available under 'My Account' -> 'Settings' -> 'Tokens'. Please refer to the instructions for detailed steps: https://www.weplusbot.com/",
"消息接收人": "message recipient",
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "Version, you can specify 'pro' for the Professional version and 'personal' for the Personal version. If left blank, it will default to the Professional version.",
@@ -388,6 +393,11 @@
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "The SMTP login password may also be a special passphrase, depending on the specific email service provider's instructions",
"PushMe的Keyhttps://push.i-i.me/": "PushMe key, https://push.i-i.me/",
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "The self built PushMeServer message interface address, for example: http://127.0.0.1:3010 If left blank, use the official message interface",
"ntfy的url地址,例如 https://ntfy.sh'": "The URL address of ntfy, for example, https://ntfy.sh.",
"ntfy的消息应用topic": "The topic for ntfy's messaging application.",
"wxPusherBot的appToken": "wxPusherBot's appToken, obtain according to docs https://wxpusher.zjiecode.com/docs/",
"wxPusherBot的topicIds": "wxPusherBot's topicIds, at least one of topicIds or uids must be configured",
"wxPusherBot的uids": "wxPusherBot's uids, at least one of topicIds or uids must be configured",
"请求方法": "Request Method",
"请求头Content-Type": "Request Header Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title$content可选,对应api内容的位置": "Request URL should start with http or https. URL or body must contain $title, $content is optional and corresponds to the API content position.",
+11 -1
View File
@@ -377,8 +377,13 @@
"好友": "好友",
"要发送的用户昵称或群名,如果目标是群,需要填群名,如果目标是好友,需要填好友昵称": "要发送的用户昵称或群名,如果目标是群,需要填群名,如果目标是好友,需要填好友昵称",
"iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX": "iGot的信息推送key,例如:https://push.hellyw.com/XXXXXXXX",
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "微信扫码登录后一对一推送或一对多推送下面的token(的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/",
"微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/": "微信扫码登录后一对一推送或一对多推送下面的token(的Token),不提供PUSH_PLUS_USER则默认为一对一推送,参考 https://www.pushplus.plus/",
"一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)": "一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)",
"发送模板": "发送模板,支持html,txt,json,markdown,cloudMonitor,jenkins,route,pay",
"发送渠道": "发送渠道,支持wechat,webhook,cp,mail,sms",
"webhook编码": "webhook编码,可在pushplus公众号上扩展配置出更多渠道",
"发送结果回调地址": "发送结果回调地址,会把推送最终结果通知到这个地址上",
"好友令牌": "好友令牌,微信公众号渠道填写好友令牌,企业微信渠道填写企业微信用户id",
"用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/": "用户令牌,扫描登录后 我的—>设置->令牌 中获取,参考 https://www.weplusbot.com/",
"消息接收人": "消息接收人",
"调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版": "调用版本;专业版填写pro,个人版填写personal,为空默认使用专业版",
@@ -388,6 +393,11 @@
"SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定": "SMTP 登录密码,也可能为特殊口令,视具体邮件服务商说明而定",
"PushMe的Keyhttps://push.i-i.me/": "PushMe的Keyhttps://push.i-i.me/",
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口",
"ntfy的url地址,例如 https://ntfy.sh": "ntfy的url地址,例如 https://ntfy.sh",
"ntfy的消息应用topic": "ntfy的消息应用topic",
"wxPusherBot的appToken": "wxPusherBot的appToken, 按照文档获取 https://wxpusher.zjiecode.com/docs/",
"wxPusherBot的topicIds": "wxPusherBot的topicIds, topicIds 和 uids 至少配置一个才行",
"wxPusherBot的uids": "wxPusherBot的uids, topicIds 和 uids 至少配置一个才行",
"请求方法": "请求方法",
"请求头Content-Type": "请求头Content-Type",
"请求链接以http或者https开头。url或者body中必须包含$title$content可选,对应api内容的位置": "请求链接以http或者https开头。url或者body中必须包含$title$content可选,对应api内容的位置",
+10 -4
View File
@@ -36,6 +36,7 @@ import {
PlusOutlined,
UnorderedListOutlined,
CheckOutlined,
CopyOutlined,
} from '@ant-design/icons';
import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout';
@@ -57,10 +58,11 @@ import { useVT } from 'virtualizedtableforantd4';
import { ICrontab, OperationName, OperationPath, CrontabStatus } from './type';
import Name from '@/components/name';
import dayjs from 'dayjs';
import { noop } from 'lodash';
import { noop, omit } from 'lodash';
const { Text, Paragraph, Link } = Typography;
const { Search } = Input;
const SHOW_TAB_COUNT = 10;
const Crontab = () => {
const { headerStyle, isPhone, theme } = useOutletContext<SharedContext>();
@@ -620,6 +622,7 @@ const Crontab = () => {
icon:
record.isDisabled === 1 ? <CheckCircleOutlined /> : <StopOutlined />,
},
{ label: intl.get('复制'), key: 'copy', icon: <CopyOutlined /> },
{ label: intl.get('删除'), key: 'delete', icon: <DeleteOutlined /> },
{
label: record.isPinned === 1 ? intl.get('取消置顶') : intl.get('置顶'),
@@ -655,6 +658,9 @@ const Crontab = () => {
case 'edit':
editCron(record, index);
break;
case 'copy':
editCron(omit(record, 'id'), index);
break;
case 'enableOrDisable':
enabledOrDisabledCron(record, index);
break;
@@ -800,7 +806,7 @@ const Crontab = () => {
useEffect(() => {
if (viewConf && enabledCronViews && enabledCronViews.length > 0) {
const view = enabledCronViews.slice(4).find((x) => x.id === viewConf.id);
const view = enabledCronViews.slice(SHOW_TAB_COUNT).find((x) => x.id === viewConf.id);
setMoreMenuActive(!!view);
}
}, [viewConf, enabledCronViews]);
@@ -830,7 +836,7 @@ const Crontab = () => {
viewAction(key);
},
items: [
...[...enabledCronViews].slice(4).map((x) => ({
...[...enabledCronViews].slice(SHOW_TAB_COUNT).map((x) => ({
label: (
<Space style={{ display: 'flex', justifyContent: 'space-between' }}>
<span>{x.name}</span>
@@ -950,7 +956,7 @@ const Crontab = () => {
}
onTabClick={tabClick}
items={[
...[...enabledCronViews].slice(0, 4).map((x) => ({
...[...enabledCronViews].slice(0, SHOW_TAB_COUNT).map((x) => ({
key: x.id,
label: x.name,
})),
+4 -4
View File
@@ -21,9 +21,9 @@ const CronModal = ({
const handleOk = async (values: any) => {
setLoading(true);
const method = cron ? 'put' : 'post';
const method = cron?.id ? 'put' : 'post';
const payload = { ...values };
if (cron) {
if (cron?.id) {
payload.id = cron.id;
}
try {
@@ -34,7 +34,7 @@ const CronModal = ({
if (code === 200) {
message.success(
cron ? intl.get('更新任务成功') : intl.get('创建任务成功'),
cron?.id ? intl.get('更新任务成功') : intl.get('创建任务成功'),
);
handleCancel(data);
}
@@ -50,7 +50,7 @@ const CronModal = ({
return (
<Modal
title={cron ? intl.get('编辑任务') : intl.get('创建任务')}
title={cron?.id ? intl.get('编辑任务') : intl.get('创建任务')}
open={visible}
forceRender
centered
+16 -1
View File
@@ -1,3 +1,4 @@
import intl from 'react-intl-universal';
import React, { useRef, useState } from 'react';
import CodeMirror from '@uiw/react-codemirror';
import { Button, DatePicker, Empty, message, Spin } from 'antd';
@@ -9,6 +10,13 @@ import { request } from '@/utils/http';
import config from '@/utils/config';
import { useRequest } from 'ahooks';
import moment from 'moment';
import {
systemLogDebugHighlightPlugin,
systemLogErrorHighlightPlugin,
systemLogInfoHighlightPlugin,
systemLogTheme,
systemLogWarnHighlightPlugin,
} from '@/utils/codemirror/systemLog';
const { RangePicker } = DatePicker;
@@ -83,7 +91,7 @@ const SystemLog = ({ height, theme }: any) => {
deleteLog();
}}
>
{intl.get('清空日志')}
</Button>
</div>
{systemLogData ? (
@@ -94,6 +102,13 @@ const SystemLog = ({ height, theme }: any) => {
onCreateEditor={(view) => {
editorRef.current = view;
}}
extensions={[
systemLogDebugHighlightPlugin,
systemLogErrorHighlightPlugin,
systemLogInfoHighlightPlugin,
systemLogWarnHighlightPlugin,
systemLogTheme,
]}
readOnly={true}
theme={theme.includes('dark') ? 'dark' : 'light'}
/>
+174
View File
@@ -0,0 +1,174 @@
import {
Decoration,
EditorView,
ViewPlugin,
ViewUpdate,
} from '@codemirror/view';
import { RangeSet, RangeSetBuilder } from '@codemirror/state';
const infoWord = /\[\ue6f5info\]/g;
const debugWord = /\[\ue67fdebug\]/g;
const warnWord = /\[\ue880warn\]/g;
const errorWord = /\[\ue602error\]/g;
const customWordClassMap = {
info: 'system-log-info',
warn: 'system-warn-info',
error: 'system-error-info',
debug: 'system-debug-info',
};
export const systemLogInfoHighlightPlugin = ViewPlugin.fromClass(
class {
decorations: RangeSet<Decoration>;
constructor(view: EditorView) {
this.decorations = this.getDecorations(view);
}
update(update: ViewUpdate) {
if (update.docChanged) {
this.decorations = this.getDecorations(update.view);
}
}
getDecorations(view: EditorView) {
const builder = new RangeSetBuilder<Decoration>();
const doc = view.state.doc.toString();
let match;
while ((match = infoWord.exec(doc)) !== null) {
const deco = Decoration.mark({
class: customWordClassMap.info,
});
builder.add(match.index, match.index + match[0].length, deco);
}
return builder.finish();
}
},
{
decorations: (v) => v.decorations,
},
);
export const systemLogWarnHighlightPlugin = ViewPlugin.fromClass(
class {
decorations: RangeSet<Decoration>;
constructor(view: EditorView) {
this.decorations = this.getDecorations(view);
}
update(update: ViewUpdate) {
if (update.docChanged) {
this.decorations = this.getDecorations(update.view);
}
}
getDecorations(view: EditorView) {
const builder = new RangeSetBuilder<Decoration>();
const doc = view.state.doc.toString();
let match;
while ((match = warnWord.exec(doc)) !== null) {
const deco = Decoration.mark({
class: customWordClassMap.warn,
});
builder.add(match.index, match.index + match[0].length, deco);
}
return builder.finish();
}
},
{
decorations: (v) => v.decorations,
},
);
export const systemLogDebugHighlightPlugin = ViewPlugin.fromClass(
class {
decorations: RangeSet<Decoration>;
constructor(view: EditorView) {
this.decorations = this.getDecorations(view);
}
update(update: ViewUpdate) {
if (update.docChanged) {
this.decorations = this.getDecorations(update.view);
}
}
getDecorations(view: EditorView) {
const builder = new RangeSetBuilder<Decoration>();
const doc = view.state.doc.toString();
let match;
while ((match = debugWord.exec(doc)) !== null) {
const deco = Decoration.mark({
class: customWordClassMap.debug,
});
builder.add(match.index, match.index + match[0].length, deco);
}
return builder.finish();
}
},
{
decorations: (v) => v.decorations,
},
);
export const systemLogErrorHighlightPlugin = ViewPlugin.fromClass(
class {
decorations: RangeSet<Decoration>;
constructor(view: EditorView) {
this.decorations = this.getDecorations(view);
}
update(update: ViewUpdate) {
if (update.docChanged) {
this.decorations = this.getDecorations(update.view);
}
}
getDecorations(view: EditorView) {
const builder = new RangeSetBuilder<Decoration>();
const doc = view.state.doc.toString();
let match;
while ((match = errorWord.exec(doc)) !== null) {
const deco = Decoration.mark({
class: customWordClassMap.error,
});
builder.add(match.index, match.index + match[0].length, deco);
}
return builder.finish();
}
},
{
decorations: (v) => v.decorations,
},
);
export const systemLogTheme = EditorView.baseTheme({
'.system-log-info': {
color: '#2196F3',
},
'.system-warn-info': {
color: '#FFB827',
},
'.system-error-info': {
color: '#FA5151',
},
'.system-debug-info': {
color: '#009A29',
},
});
+62
View File
@@ -84,6 +84,7 @@ export default {
},
notificationModes: [
{ value: 'gotify', label: 'Gotify' },
{ value: 'ntfy', label: 'Ntfy' },
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
{ value: 'serverChan', label: intl.get('Server酱') },
{ value: 'pushDeer', label: 'PushDeer' },
@@ -96,6 +97,7 @@ export default {
{ value: 'iGot', label: 'IGot' },
{ value: 'pushPlus', label: 'PushPlus' },
{ value: 'wePlusBot', label: intl.get('微加机器人') },
{ value: 'wxPusherBot', label: 'wxPusher' },
{ value: 'chat', label: intl.get('群晖chat') },
{ value: 'email', label: intl.get('邮箱') },
{ value: 'lark', label: intl.get('飞书机器人') },
@@ -118,6 +120,19 @@ export default {
},
{ label: 'gotifyPriority', tip: intl.get('推送消息的优先级') },
],
ntfy: [
{
label: 'ntfyUrl',
tip: intl.get('ntfy的url地址,例如 https://ntfy.sh'),
required: true,
},
{
label: 'ntfyTopic',
tip: intl.get('ntfy的消息应用topic'),
required: true,
},
{ label: 'ntfyPriority', tip: intl.get('推送消息的优先级') },
],
chat: [
{
label: 'chatUrl',
@@ -312,6 +327,36 @@ export default {
'一对多推送的“群组编码”(一对多推送下面->您的群组(如无则创建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送)',
),
},
{
label: 'pushplusTemplate',
tip: intl.get(
'发送模板',
),
},
{
label: 'pushplusChannel',
tip: intl.get(
'发送渠道',
),
},
{
label: 'pushplusWebhook',
tip: intl.get(
'webhook编码',
),
},
{
label: 'pushplusCallbackUrl',
tip: intl.get(
'发送结果回调地址',
),
},
{
label: 'pushplusTo',
tip: intl.get(
'好友令牌',
),
},
],
wePlusBot: [
{
@@ -334,6 +379,23 @@ export default {
),
},
],
wxPusherBot: [
{
label: 'wxPusherBotAppToken',
tip: intl.get('wxPusherBot的appToken'),
required: true,
},
{
label: 'wxPusherBotTopicIds',
tip: intl.get('wxPusherBot的topicIds'),
required: false,
},
{
label: 'wxPusherBotUids',
tip: intl.get('wxPusherBot的uids'),
required: false,
},
],
lark: [
{
label: 'larkKey',
+3 -2
View File
@@ -1,6 +1,7 @@
import intl from 'react-intl-universal';
import { LANG_MAP, LOG_END_SYMBOL } from './const';
import cron_parser from 'cron-parser';
import { ICrontab } from '@/pages/crontab/type';
export default function browserType() {
// 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
@@ -343,12 +344,12 @@ export function parseCrontab(schedule: string): Date | null {
export function getCrontabsNextDate(
schedule: string,
extra_schedules: string[],
extra_schedules: ICrontab['extra_schedules'],
): Date | null {
let date = parseCrontab(schedule);
if (extra_schedules?.length) {
extra_schedules.forEach((x) => {
const _date = parseCrontab(x);
const _date = parseCrontab(x.schedule);
if (_date && (!date || _date < date)) {
date = _date;
}
+8 -7
View File
@@ -1,8 +1,9 @@
version: 2.17.11
changeLogLink: https://t.me/jiao_long/422
publishTime: 2024-09-13 23:00
version: 2.17.13
changeLogLink: https://t.me/jiao_long/423
publishTime: 2024-12-21 23:30
changeLog: |
1. 修复无法获取设置的环境变量 PYTHONPATH 和 NODE_OPTIONS
2. 修复定时任务视图过多时,无法看到视图管理
3. 修复自定义通知 json 解析
4. 修复可能产生目录遍历攻击 API
1. 新增 wxPusher 通知
2. 完善 pushplus 通知
3. 修复任务列表下次运行时间展示
4. 修复本地部署设置 dataPath 后,备份目录可能错误
5. h5 登录增加识别鸿蒙系统