mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-11 19:05:20 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dd8d9df91 | ||
|
|
2dbee94e85 | ||
|
|
9001797037 | ||
|
|
5e7104d5a3 | ||
|
|
7c33b22d63 | ||
|
|
b7cb1e379c | ||
|
|
274a6ce52e | ||
|
|
8079e4e7b8 | ||
|
|
920efb8fab | ||
|
|
92aeb2b9da | ||
|
|
ced76cf343 | ||
|
|
3750d6ecd5 | ||
|
|
7444f30384 | ||
|
|
b0fd5ba47f | ||
|
|
cc098bc2e5 | ||
|
|
1cfcf8d194 | ||
|
|
d1e9f741d0 | ||
|
|
0cde9d07ee | ||
|
|
a266425348 | ||
|
|
6dbe02e321 | ||
|
|
39979879c9 | ||
|
|
ba3f604a5c | ||
|
|
9572582401 | ||
|
|
2bcef0ba75 | ||
|
|
31cd7c4007 | ||
|
|
1c4c1799b0 | ||
|
|
2d558df15e | ||
|
|
7b769da4e2 |
-92
@@ -1,92 +0,0 @@
|
|||||||
# 安装说明
|
|
||||||
|
|
||||||
## 前置要求
|
|
||||||
```bash
|
|
||||||
1.已安装docker-ce
|
|
||||||
2.选装docker-compose
|
|
||||||
```
|
|
||||||
## 安装方式1
|
|
||||||
```bash
|
|
||||||
1. 新建一个文件夹,用于存放相关数据
|
|
||||||
2. 下载本仓库中的`docker-compose.yml`至本地,或是复制文件内容后在本地自行建立并粘贴内容
|
|
||||||
3. 使用docker-compose启动
|
|
||||||
4. 浏览器输入ip:5700即可进入面板
|
|
||||||
|
|
||||||
# 新建数据文件夹
|
|
||||||
mkdir qinglong
|
|
||||||
cd qinglong
|
|
||||||
# 下载docker-compose.yml文件
|
|
||||||
wget https://raw.githubusercontent.com/whyour/qinglong/develop/docker-compose.yml
|
|
||||||
# 启动
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
|
|
||||||
## 安装方式2
|
|
||||||
```bash
|
|
||||||
# 复制下列命令在ssh执行(先安装docker)
|
|
||||||
# 注:$PWD请修改为实际你想安装的路径
|
|
||||||
docker run -dit \
|
|
||||||
-v $PWD/ql/config:/ql/config \
|
|
||||||
-v $PWD/ql/log:/ql/log \
|
|
||||||
-v $PWD/ql/db:/ql/db \
|
|
||||||
-v $PWD/ql/repo:/ql/repo \
|
|
||||||
-v $PWD/ql/raw:/ql/raw \
|
|
||||||
-v $PWD/ql/scripts:/ql/scripts \
|
|
||||||
-v $PWD/ql/jbot:/ql/jbot \
|
|
||||||
-p 5700:5700 \
|
|
||||||
--name qinglong \
|
|
||||||
--hostname qinglong \
|
|
||||||
--restart unless-stopped \
|
|
||||||
whyour/qinglong:latest
|
|
||||||
```
|
|
||||||
## 登录
|
|
||||||
```bash
|
|
||||||
|
|
||||||
打开浏览器访问宿主机ip的5700端口即可
|
|
||||||
例如http://192.168.100.123:5700即ip:5700
|
|
||||||
|
|
||||||
首次登录
|
|
||||||
账号:admin 密码:admin
|
|
||||||
会生成`auth.json`
|
|
||||||
|
|
||||||
在ssh输入
|
|
||||||
1.docker exec -it qinglong bash
|
|
||||||
2.cat /ql/config/auth.json
|
|
||||||
|
|
||||||
cat查看之后返回的结果类似如下字段
|
|
||||||
|
|
||||||
{"username":"admin","password":"Xb-ZYP526wmg4_h6q1WqIO"}
|
|
||||||
# admin即为登录名;Xb-ZYP526wmg4_h6q1WqIO为登录密码
|
|
||||||
```
|
|
||||||
|
|
||||||
输入此处记录的`username`及`password`,即可成功登录qinglong面板,登录后即可正常使用
|
|
||||||
|
|
||||||
## 拉取脚本
|
|
||||||
```bash
|
|
||||||
示例
|
|
||||||
ql repo https://github.com/xxx.git #拉取仓库
|
|
||||||
ql raw https://raw.githubusercontent.com/xxx #拉取单个脚本
|
|
||||||
```
|
|
||||||
## 备份
|
|
||||||
|
|
||||||
所有数据都将保存在`docker-compose.yml`所在的同级目录的`data`文件夹中,如需要备份,请直接备份`docker-compose.yml`及`data`文件夹即可
|
|
||||||
|
|
||||||
```bash
|
|
||||||
root@debian:/opt/qinglong# ls -lah
|
|
||||||
总用量 8.0K
|
|
||||||
drwxr-xr-x 3 root root 4.0K 8月 30 01:29 .
|
|
||||||
drwxr-xr-x 4 root root 4.0K 8月 30 00:51 ..
|
|
||||||
drwxr-xr-x 8 root root 4.0K 8月 30 01:30 data
|
|
||||||
-rw-r--r-- 1 root root 386 8月 30 01:29 docker-compose.yml
|
|
||||||
```
|
|
||||||
## 更新
|
|
||||||
|
|
||||||
在面板执行"更新面板"任务即可
|
|
||||||
|
|
||||||
或者
|
|
||||||
```bash
|
|
||||||
cd qinglong
|
|
||||||
docker-compose down
|
|
||||||
docker pull whyour/qinglong:latest
|
|
||||||
docker-compose up -d
|
|
||||||
```
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/whyour/qinglong">
|
<a href="https://github.com/whyour/qinglong">
|
||||||
<img width="150" src="/public/images/qinglong.png">
|
<img width="150" src="https://z3.ax1x.com/2021/11/18/I7MpAe.png">
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -8,12 +8,10 @@
|
|||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
A timed task management panel that supports typescript, javaScript, python3, and shell.(支持python3、javaScript、shell、typescript 的定时任务管理面板)
|
支持python3、javaScript、shell、typescript 的定时任务管理面板(A timed task management panel that supports typescript, javaScript, python3, and shell.)
|
||||||
|
|
||||||
[![docker version][docker-version-image]][docker-version-url] [![docker pulls][docker-pulls-image]][docker-pulls-url] [![docker stars][docker-stars-image]][docker-stars-url] [![docker image size][docker-image-size-image]][docker-image-size-url] [![donate][donate-image]][donate-url]
|
[![docker version][docker-version-image]][docker-version-url] [![docker pulls][docker-pulls-image]][docker-pulls-url] [![docker stars][docker-stars-image]][docker-stars-url] [![docker image size][docker-image-size-image]][docker-image-size-url]
|
||||||
|
|
||||||
[donate-image]: https://img.shields.io/badge/donate-wechat-green?style=flat
|
|
||||||
[donate-url]: https://qinglong.whyour.cn/nice.png
|
|
||||||
[docker-pulls-image]: https://img.shields.io/docker/pulls/whyour/qinglong?style=flat
|
[docker-pulls-image]: https://img.shields.io/docker/pulls/whyour/qinglong?style=flat
|
||||||
[docker-pulls-url]: https://hub.docker.com/r/whyour/qinglong
|
[docker-pulls-url]: https://hub.docker.com/r/whyour/qinglong
|
||||||
[docker-version-image]: https://img.shields.io/docker/v/whyour/qinglong?style=flat
|
[docker-version-image]: https://img.shields.io/docker/v/whyour/qinglong?style=flat
|
||||||
@@ -24,31 +22,151 @@ A timed task management panel that supports typescript, javaScript, python3, and
|
|||||||
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p align="center">
|
[](https://whyour.cn)
|
||||||
<img width="49%" src="/public/images/login.png">
|
|
||||||
<img width="49%" src="/public/images/home.png">
|
简体中文 | [English](./README-en.md)
|
||||||
</p>
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
- 支持多种脚本语言(python3、javaScript、shell、typescript)
|
||||||
|
- 支持在线管理脚本、环境变量、配置文件
|
||||||
|
- 支持在线查看任务日志
|
||||||
|
- 支持秒级任务设置
|
||||||
|
- 支持系统级通知
|
||||||
|
- 支持暗黑模式
|
||||||
|
- 支持手机端操作
|
||||||
|
|
||||||
|
## 部署
|
||||||
|
|
||||||
|
### 本机部署
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 待完善
|
||||||
|
```
|
||||||
|
|
||||||
|
### docker 部署
|
||||||
|
|
||||||
|
1. docker 安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo curl -sSL get.docker.com | sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 启动容器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -dit \
|
||||||
|
-v $PWD/ql/config:/ql/config \
|
||||||
|
-v $PWD/ql/log:/ql/log \
|
||||||
|
-v $PWD/ql/db:/ql/db \
|
||||||
|
-v $PWD/ql/repo:/ql/repo \
|
||||||
|
-v $PWD/ql/raw:/ql/raw \
|
||||||
|
-v $PWD/ql/scripts:/ql/scripts \
|
||||||
|
-p 5700:5700 \
|
||||||
|
--name qinglong \
|
||||||
|
--hostname qinglong \
|
||||||
|
--restart unless-stopped \
|
||||||
|
whyour/qinglong:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### docker-compose 部署
|
||||||
|
|
||||||
|
1. docker-compose 安装
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 启动容器
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir qinglong
|
||||||
|
wget https://raw.githubusercontent.com/whyour/qinglong/master/docker-compose.yml
|
||||||
|
|
||||||
|
# 启动
|
||||||
|
docker-compose up -d
|
||||||
|
# 停止
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
## 使用
|
||||||
|
|
||||||
|
1. 内置命令
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 更新并重启青龙
|
||||||
|
ql update
|
||||||
|
# 运行自定义脚本extra.sh
|
||||||
|
ql extra
|
||||||
|
# 添加单个脚本文件
|
||||||
|
ql raw <file_url>
|
||||||
|
# 添加单个仓库的指定脚本
|
||||||
|
ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch>
|
||||||
|
# 删除旧日志
|
||||||
|
ql rmlog <days>
|
||||||
|
# 启动tg-bot
|
||||||
|
ql bot
|
||||||
|
# 检测青龙环境并修复
|
||||||
|
ql check
|
||||||
|
# 重置登录错误次数
|
||||||
|
ql resetlet
|
||||||
|
# 禁用两步登录
|
||||||
|
ql resettfa
|
||||||
|
|
||||||
|
# 依次执行,如果设置了随机延迟,将随机延迟一定秒数
|
||||||
|
task <file_path>
|
||||||
|
# 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
|
||||||
|
task <file_path> now
|
||||||
|
# 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
|
||||||
|
task <file_path> conc <env_name> <account_number>(可选的)
|
||||||
|
# 指定账号执行,无论是否设置了随机延迟,均立即运行
|
||||||
|
task <file_path> desi <env_name> <account_number>
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 参数说明
|
||||||
|
|
||||||
|
* file_url: 脚本地址
|
||||||
|
* repo_url: 仓库地址
|
||||||
|
* whitelist: 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串
|
||||||
|
* blacklist: 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串
|
||||||
|
* dependence: 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响
|
||||||
|
* branch: 拉取仓库的分支
|
||||||
|
* days: 需要保留的日志的天数
|
||||||
|
* file_path: 任务执行时的文件路径
|
||||||
|
* env_name: 任务执行时需要并发或者指定时的环境变量名称
|
||||||
|
* account_number: 任务执行时指定某个环境变量需要执行的账号序号
|
||||||
|
|
||||||
|
## 链接
|
||||||
|
|
||||||
|
- [nevinee](https://gitee.com/evine)
|
||||||
|
- [crontab-ui](https://github.com/alseambusher/crontab-ui)
|
||||||
|
- [Ant Design](https://ant.design)
|
||||||
|
- [Ant Design Pro](https://pro.ant.design/)
|
||||||
|
- [Umijs3.0](https://umijs.org)
|
||||||
|
- [darkreader](https://github.com/darkreader/darkreader)
|
||||||
|
- [admin-server](https://github.com/sunpu007/admin-server)
|
||||||
|
|
||||||
|
## 开发
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git clone git@github.com:whyour/qinglong.git
|
||||||
|
$ cd qinglong
|
||||||
|
$ cp .env.example .env
|
||||||
|
$ yarn install
|
||||||
|
$ yarn start-back
|
||||||
|
$ yarn start
|
||||||
|
```
|
||||||
|
|
||||||
|
打开你的浏览器,访问 http://127.0.0.1:5601
|
||||||
|
|
||||||
|
## 交流
|
||||||
|
|
||||||
|
[telegram频道](https://t.me/jiao_long)
|
||||||
|
|
||||||
|
## 名称来源
|
||||||
|
|
||||||
青龙,又名苍龙,在中国传统文化中是四象之一、[天之四灵](https://zh.wikipedia.org/wiki/%E5%A4%A9%E4%B9%8B%E5%9B%9B%E7%81%B5)之一,根据五行学说,它是代表东方的灵兽,为青色的龙,五行属木,代表的季节是春季,八卦主震。苍龙与应龙一样,都是身具羽翼。《张果星宗》称“又有辅翼,方为真龙”。
|
青龙,又名苍龙,在中国传统文化中是四象之一、[天之四灵](https://zh.wikipedia.org/wiki/%E5%A4%A9%E4%B9%8B%E5%9B%9B%E7%81%B5)之一,根据五行学说,它是代表东方的灵兽,为青色的龙,五行属木,代表的季节是春季,八卦主震。苍龙与应龙一样,都是身具羽翼。《张果星宗》称“又有辅翼,方为真龙”。
|
||||||
|
|
||||||
《后汉书·律历志下》记载:日周于天,一寒一暑,四时备成,万物毕改,摄提迁次,青龙移辰,谓之岁。
|
《后汉书·律历志下》记载:日周于天,一寒一暑,四时备成,万物毕改,摄提迁次,青龙移辰,谓之岁。
|
||||||
|
|
||||||
在中国[二十八宿](https://zh.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%85%AB%E5%AE%BF)中,青龙是东方七宿(角、亢、氐、房、心、尾、箕)的总称。 在早期星宿信仰中,祂是最尊贵的天神。 但被道教信仰吸纳入其神系后,神格大跌,道教将其称为“孟章”,在不同的道经中有“帝君”、“圣将”、“神将”和“捕鬼将”等称呼,与白虎监兵神君一起,是道教的护卫天神。
|
在中国[二十八宿](https://zh.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%85%AB%E5%AE%BF)中,青龙是东方七宿(角、亢、氐、房、心、尾、箕)的总称。 在早期星宿信仰中,祂是最尊贵的天神。 但被道教信仰吸纳入其神系后,神格大跌,道教将其称为“孟章”,在不同的道经中有“帝君”、“圣将”、“神将”和“捕鬼将”等称呼,与白虎监兵神君一起,是道教的护卫天神。
|
||||||
|
|
||||||
## 如何安装
|
|
||||||
|
|
||||||
请查看[INSTALL.md](INSTALL.md)
|
|
||||||
|
|
||||||
## 多谢
|
|
||||||
|
|
||||||
* [nevinee](https://gitee.com/evine)
|
|
||||||
|
|
||||||
* [crontab-ui](https://github.com/alseambusher/crontab-ui)
|
|
||||||
|
|
||||||
* [Ant Design](https://ant.design)
|
|
||||||
|
|
||||||
* [Ant Design Pro](https://pro.ant.design/)
|
|
||||||
|
|
||||||
* [Umijs3.0](https://umijs.org)
|
|
||||||
|
|
||||||
* [darkreader](https://github.com/darkreader/darkreader)
|
|
||||||
|
|||||||
+35
-3
@@ -10,6 +10,7 @@ import config from '../config';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { celebrate, Joi } from 'celebrate';
|
import { celebrate, Joi } from 'celebrate';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import ScriptService from '../services/script';
|
||||||
const route = Router();
|
const route = Router();
|
||||||
|
|
||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
@@ -43,7 +44,7 @@ export default (app: Router) => {
|
|||||||
children.push({
|
children.push({
|
||||||
title: childFile,
|
title: childFile,
|
||||||
value: childFile,
|
value: childFile,
|
||||||
key: childFile,
|
key: `${fileOrDir}-${childFile}`,
|
||||||
mtime: statObj.mtimeMs,
|
mtime: statObj.mtimeMs,
|
||||||
parent: fileOrDir,
|
parent: fileOrDir,
|
||||||
});
|
});
|
||||||
@@ -120,6 +121,9 @@ export default (app: Router) => {
|
|||||||
if (!path.endsWith('/')) {
|
if (!path.endsWith('/')) {
|
||||||
path += '/';
|
path += '/';
|
||||||
}
|
}
|
||||||
|
if (!path.startsWith('/')) {
|
||||||
|
path = `${config.scriptPath}${path}`;
|
||||||
|
}
|
||||||
if (config.writePathList.every((x) => !path.startsWith(x))) {
|
if (config.writePathList.every((x) => !path.startsWith(x))) {
|
||||||
return res.send({
|
return res.send({
|
||||||
code: 430,
|
code: 430,
|
||||||
@@ -184,15 +188,17 @@ export default (app: Router) => {
|
|||||||
celebrate({
|
celebrate({
|
||||||
body: Joi.object({
|
body: Joi.object({
|
||||||
filename: Joi.string().required(),
|
filename: Joi.string().required(),
|
||||||
|
path: Joi.string().allow(''),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
try {
|
try {
|
||||||
let { filename } = req.body as {
|
let { filename, path } = req.body as {
|
||||||
filename: string;
|
filename: string;
|
||||||
|
path: string;
|
||||||
};
|
};
|
||||||
const filePath = `${config.scriptPath}${filename}`;
|
const filePath = `${config.scriptPath}${path}/${filename}`;
|
||||||
fs.unlinkSync(filePath);
|
fs.unlinkSync(filePath);
|
||||||
res.send({ code: 200 });
|
res.send({ code: 200 });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -232,4 +238,30 @@ export default (app: Router) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
route.put(
|
||||||
|
'/scripts/run',
|
||||||
|
celebrate({
|
||||||
|
body: Joi.object({
|
||||||
|
filename: Joi.string().required(),
|
||||||
|
path: Joi.string().optional().allow(''),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
const logger: Logger = Container.get('logger');
|
||||||
|
try {
|
||||||
|
let { filename, path } = req.body as {
|
||||||
|
filename: string;
|
||||||
|
path: string;
|
||||||
|
};
|
||||||
|
const filePath = `${path}/${filename}`;
|
||||||
|
const scriptService = Container.get(ScriptService);
|
||||||
|
const result = await scriptService.runScript(filePath);
|
||||||
|
res.send(result);
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('🔥 error: %o', e);
|
||||||
|
return next(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import Logger from './loaders/logger';
|
|||||||
async function startServer() {
|
async function startServer() {
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
await require('./loaders/initFile').default();
|
||||||
|
|
||||||
await require('./loaders/sentry').default({ expressApp: app });
|
await require('./loaders/sentry').default({ expressApp: app });
|
||||||
|
|
||||||
await require('./loaders/db').default();
|
await require('./loaders/db').default();
|
||||||
|
|||||||
@@ -32,16 +32,10 @@ const authDbFile = path.join(rootPath, 'db/auth.db');
|
|||||||
const dependenceDbFile = path.join(rootPath, 'db/dependence.db');
|
const dependenceDbFile = path.join(rootPath, 'db/dependence.db');
|
||||||
const versionFile = path.join(rootPath, 'src/version.ts');
|
const versionFile = path.join(rootPath, 'src/version.ts');
|
||||||
|
|
||||||
const configFound = dotenv.config({ path: confFile });
|
|
||||||
|
|
||||||
if (envFound.error) {
|
if (envFound.error) {
|
||||||
throw new Error("⚠️ Couldn't find .env file ⚠️");
|
throw new Error("⚠️ Couldn't find .env file ⚠️");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configFound.error) {
|
|
||||||
throw new Error("⚠️ Couldn't find config.sh file ⚠️");
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
port: parseInt(process.env.PORT as string, 10),
|
port: parseInt(process.env.PORT as string, 10),
|
||||||
cronPort: parseInt(process.env.CRON_PORT as string, 10),
|
cronPort: parseInt(process.env.CRON_PORT as string, 10),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export enum NotificationMode {
|
export enum NotificationMode {
|
||||||
|
'gotify' = 'gotify',
|
||||||
'goCqHttpBot' = 'goCqHttpBot',
|
'goCqHttpBot' = 'goCqHttpBot',
|
||||||
'serverChan' = 'serverChan',
|
'serverChan' = 'serverChan',
|
||||||
'bark' = 'bark',
|
'bark' = 'bark',
|
||||||
@@ -15,6 +16,12 @@ abstract class NotificationBaseInfo {
|
|||||||
public type!: NotificationMode;
|
public type!: NotificationMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GotifyNotification extends NotificationBaseInfo {
|
||||||
|
public gotifyUrl = '';
|
||||||
|
public gotifyToken = '';
|
||||||
|
public gotifyPriority = 0;
|
||||||
|
}
|
||||||
|
|
||||||
export class GoCqHttpBotNotification extends NotificationBaseInfo {
|
export class GoCqHttpBotNotification extends NotificationBaseInfo {
|
||||||
public goCqHttpBotUrl = '';
|
public goCqHttpBotUrl = '';
|
||||||
public goCqHttpBotToken = '';
|
public goCqHttpBotToken = '';
|
||||||
@@ -70,6 +77,7 @@ export class EmailNotification extends NotificationBaseInfo {
|
|||||||
|
|
||||||
export interface NotificationInfo
|
export interface NotificationInfo
|
||||||
extends GoCqHttpBotNotification,
|
extends GoCqHttpBotNotification,
|
||||||
|
GotifyNotification,
|
||||||
ServerChanNotification,
|
ServerChanNotification,
|
||||||
BarkNotification,
|
BarkNotification,
|
||||||
TelegramBotNotification,
|
TelegramBotNotification,
|
||||||
|
|||||||
+2
-1
@@ -13,4 +13,5 @@ export class SockMessage {
|
|||||||
export type SockMessageType =
|
export type SockMessageType =
|
||||||
| 'ping'
|
| 'ping'
|
||||||
| 'installDependence'
|
| 'installDependence'
|
||||||
| 'updateSystemVersion';
|
| 'updateSystemVersion'
|
||||||
|
| 'manuallyRunScript';
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import dotenv from 'dotenv';
|
||||||
|
import Logger from './logger';
|
||||||
|
import { fileExist } from '../config/util';
|
||||||
|
|
||||||
|
const rootPath = process.cwd();
|
||||||
|
const confFile = path.join(rootPath, 'config/config.sh');
|
||||||
|
const sampleConfigFile = path.join(rootPath, 'sample/config.sample.sh');
|
||||||
|
const sampleAuthFile = path.join(rootPath, 'sample/auth.sample.json');
|
||||||
|
const authConfigFile = path.join(rootPath, 'config/auth.json');
|
||||||
|
const configPath = path.join(rootPath, 'config/');
|
||||||
|
const scriptPath = path.join(rootPath, 'scripts/');
|
||||||
|
const logPath = path.join(rootPath, 'log/');
|
||||||
|
|
||||||
|
export default async () => {
|
||||||
|
const authFileExist = await fileExist(authConfigFile);
|
||||||
|
const confFileExist = await fileExist(confFile);
|
||||||
|
const scriptDirExist = await fileExist(scriptPath);
|
||||||
|
const logDirExist = await fileExist(logPath);
|
||||||
|
const configDirExist = await fileExist(configPath);
|
||||||
|
|
||||||
|
if (!configDirExist) {
|
||||||
|
fs.mkdirSync(configPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!authFileExist) {
|
||||||
|
fs.writeFileSync(authConfigFile, fs.readFileSync(sampleAuthFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confFileExist) {
|
||||||
|
fs.writeFileSync(confFile, fs.readFileSync(sampleConfigFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!scriptDirExist) {
|
||||||
|
fs.mkdirSync(scriptPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!logDirExist) {
|
||||||
|
fs.mkdirSync(logPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
dotenv.config({ path: confFile });
|
||||||
|
|
||||||
|
Logger.info('✌️ Init file down');
|
||||||
|
};
|
||||||
+5
-2
@@ -44,8 +44,11 @@ const run = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
app
|
app
|
||||||
.listen(config.cronPort, () => {
|
.listen(config.cronPort, async () => {
|
||||||
run();
|
await require('./loaders/sentry').default({ expressApp: app });
|
||||||
|
await require('./loaders/db').default();
|
||||||
|
|
||||||
|
await run();
|
||||||
Logger.info(`
|
Logger.info(`
|
||||||
################################################
|
################################################
|
||||||
🛡️ Schedule listening on port: ${config.cronPort} 🛡️
|
🛡️ Schedule listening on port: ${config.cronPort} 🛡️
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ export default class NotificationService {
|
|||||||
private userService!: UserService;
|
private userService!: UserService;
|
||||||
|
|
||||||
private modeMap = new Map([
|
private modeMap = new Map([
|
||||||
|
['gotify', this.gotify],
|
||||||
['goCqHttpBot', this.goCqHttpBot],
|
['goCqHttpBot', this.goCqHttpBot],
|
||||||
['serverChan', this.serverChan],
|
['serverChan', this.serverChan],
|
||||||
['bark', this.bark],
|
['bark', this.bark],
|
||||||
@@ -67,6 +68,25 @@ export default class NotificationService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async gotify() {
|
||||||
|
const { gotifyUrl, gotifyToken, gotifyPriority } = this.params;
|
||||||
|
const res: any = await got
|
||||||
|
.post(`${gotifyUrl}/message?token=${gotifyToken}`, {
|
||||||
|
timeout: this.timeout,
|
||||||
|
retry: 0,
|
||||||
|
body: `title=${encodeURIComponent(
|
||||||
|
this.title,
|
||||||
|
)}&message=${encodeURIComponent(
|
||||||
|
this.content,
|
||||||
|
)}&priority=${gotifyPriority}`,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.json();
|
||||||
|
return typeof res.id === 'number';
|
||||||
|
}
|
||||||
|
|
||||||
private async goCqHttpBot() {
|
private async goCqHttpBot() {
|
||||||
const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params;
|
const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params;
|
||||||
const res: any = await got
|
const res: any = await got
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { Service, Inject } from 'typedi';
|
||||||
|
import winston from 'winston';
|
||||||
|
import { spawn } from 'child_process';
|
||||||
|
import SockService from './sock';
|
||||||
|
|
||||||
|
@Service()
|
||||||
|
export default class ScriptService {
|
||||||
|
constructor(
|
||||||
|
@Inject('logger') private logger: winston.Logger,
|
||||||
|
private sockService: SockService,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public async runScript(path: string) {
|
||||||
|
const cp = spawn(`task -l ${path} now`, { shell: '/bin/bash' });
|
||||||
|
|
||||||
|
this.sockService.sendMessage({
|
||||||
|
type: 'manuallyRunScript',
|
||||||
|
message: `开始执行脚本`,
|
||||||
|
});
|
||||||
|
cp.stdout.on('data', (data) => {
|
||||||
|
this.sockService.sendMessage({
|
||||||
|
type: 'manuallyRunScript',
|
||||||
|
message: data.toString(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
cp.stderr.on('data', (data) => {
|
||||||
|
this.sockService.sendMessage({
|
||||||
|
type: 'manuallyRunScript',
|
||||||
|
message: data.toString(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
cp.on('error', (err) => {
|
||||||
|
this.sockService.sendMessage({
|
||||||
|
type: 'manuallyRunScript',
|
||||||
|
message: JSON.stringify(err),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return { code: 200 };
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-4
@@ -8,9 +8,7 @@ services:
|
|||||||
- ./data/db:/ql/db
|
- ./data/db:/ql/db
|
||||||
- ./data/scripts:/ql/scripts
|
- ./data/scripts:/ql/scripts
|
||||||
- ./data/repo:/ql/repo
|
- ./data/repo:/ql/repo
|
||||||
|
- ./data/raw:/ql/raw
|
||||||
ports:
|
ports:
|
||||||
- "0.0.0.0:5700:5700"
|
- "0.0.0.0:5700:5700"
|
||||||
environment:
|
restart: unless-stopped
|
||||||
- ENABLE_HANGUP=true
|
|
||||||
- ENABLE_WEB_PANEL=true
|
|
||||||
restart: always
|
|
||||||
|
|||||||
+1
-3
@@ -1,4 +1,4 @@
|
|||||||
FROM node:lts-alpine
|
FROM node:lts-alpine3.12
|
||||||
ARG QL_MAINTAINER="whyour"
|
ARG QL_MAINTAINER="whyour"
|
||||||
LABEL maintainer="${QL_MAINTAINER}"
|
LABEL maintainer="${QL_MAINTAINER}"
|
||||||
ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
|
ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
|
||||||
@@ -8,8 +8,6 @@ ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
|||||||
SHELL=/bin/bash \
|
SHELL=/bin/bash \
|
||||||
PS1="\u@\h:\w \$ " \
|
PS1="\u@\h:\w \$ " \
|
||||||
QL_DIR=/ql \
|
QL_DIR=/ql \
|
||||||
QL_MAINTAINER=${QL_MAINTAINER} \
|
|
||||||
QL_URL=${QL_URL} \
|
|
||||||
QL_BRANCH=${QL_BRANCH}
|
QL_BRANCH=${QL_BRANCH}
|
||||||
WORKDIR ${QL_DIR}
|
WORKDIR ${QL_DIR}
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 178 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 172 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 115 KiB |
@@ -112,4 +112,12 @@ export GOBOT_URL=""
|
|||||||
export GOBOT_TOKEN=""
|
export GOBOT_TOKEN=""
|
||||||
export GOBOT_QQ=""
|
export GOBOT_QQ=""
|
||||||
|
|
||||||
|
## 10. gotify
|
||||||
|
## gotify_url 填写gotify地址,如https://push.example.de:8080
|
||||||
|
## gotify_token 填写gotify的消息应用token
|
||||||
|
## gotify_priority 填写推送消息优先级,默认为0
|
||||||
|
export GOTIFY_URL="";
|
||||||
|
export GOTIFY_TOKEN="";
|
||||||
|
export GOTIFY_PRIORITY=0;
|
||||||
|
|
||||||
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
||||||
|
|||||||
@@ -13,6 +13,13 @@
|
|||||||
const querystring = require('querystring');
|
const querystring = require('querystring');
|
||||||
const $ = new Env();
|
const $ = new Env();
|
||||||
const timeout = 15000; //超时时间(单位毫秒)
|
const timeout = 15000; //超时时间(单位毫秒)
|
||||||
|
// =======================================gotify通知设置区域==============================================
|
||||||
|
//gotify_url 填写gotify地址,如https://push.example.de:8080
|
||||||
|
//gotify_token 填写gotify的消息应用token
|
||||||
|
//gotify_priority 填写推送消息优先级,默认为0
|
||||||
|
let GOTIFY_URL = '';
|
||||||
|
let GOTIFY_TOKEN = '';
|
||||||
|
let GOTIFY_PRIORITY = 0;
|
||||||
// =======================================go-cqhttp通知设置区域===========================================
|
// =======================================go-cqhttp通知设置区域===========================================
|
||||||
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
|
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
|
||||||
//gobot_token 填写在go-cqhttp文件设置的访问密钥
|
//gobot_token 填写在go-cqhttp文件设置的访问密钥
|
||||||
@@ -84,6 +91,16 @@ let PUSH_PLUS_TOKEN = '';
|
|||||||
let PUSH_PLUS_USER = '';
|
let PUSH_PLUS_USER = '';
|
||||||
|
|
||||||
//==========================云端环境变量的判断与接收=========================
|
//==========================云端环境变量的判断与接收=========================
|
||||||
|
if (process.env.GOTIFY_URL) {
|
||||||
|
GOTIFY_URL = process.env.GOTIFY_URL;
|
||||||
|
}
|
||||||
|
if (process.env.GOTIFY_TOKEN) {
|
||||||
|
GOTIFY_TOKEN = process.env.GOTIFY_TOKEN;
|
||||||
|
}
|
||||||
|
if (process.env.GOTIFY_PRIORITY) {
|
||||||
|
GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
if (process.env.GOBOT_URL) {
|
if (process.env.GOBOT_URL) {
|
||||||
GOBOT_URL = process.env.GOBOT_URL;
|
GOBOT_URL = process.env.GOBOT_URL;
|
||||||
}
|
}
|
||||||
@@ -200,9 +217,45 @@ async function sendNotify(
|
|||||||
qywxamNotify(text, desp), //企业微信应用消息推送
|
qywxamNotify(text, desp), //企业微信应用消息推送
|
||||||
iGotNotify(text, desp, params), //iGot
|
iGotNotify(text, desp, params), //iGot
|
||||||
gobotNotify(text, desp),//go-cqhttp
|
gobotNotify(text, desp),//go-cqhttp
|
||||||
|
gotifyNotify(text, desp),//gotify
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gotifyNotify(text, desp) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
if (GOTIFY_URL && GOTIFY_TOKEN) {
|
||||||
|
const options = {
|
||||||
|
url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`,
|
||||||
|
body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(desp)}&priority=${GOTIFY_PRIORITY}`,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$.post(options, (err, resp, data) => {
|
||||||
|
try {
|
||||||
|
if (err) {
|
||||||
|
console.log('gotify发送通知调用API失败!!\n');
|
||||||
|
console.log(err);
|
||||||
|
} else {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
if (data.id) {
|
||||||
|
console.log('gotify发送通知消息成功🎉\n');
|
||||||
|
} else {
|
||||||
|
console.log(`${data.message}\n`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
$.logErr(e, resp);
|
||||||
|
} finally {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function gobotNotify(text, desp, time = 2100) {
|
function gobotNotify(text, desp, time = 2100) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
if (GOBOT_URL) {
|
if (GOBOT_URL) {
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ push_config = {
|
|||||||
# /send_group_msg 时填入 group_id=QQ群
|
# /send_group_msg 时填入 group_id=QQ群
|
||||||
'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
|
'GOBOT_TOKEN': '', # go-cqhttp 的 access_token
|
||||||
|
|
||||||
|
'GOTIFY_URL': '', # gotify地址,如https://push.example.de:8080
|
||||||
|
'GOTIFY_TOKEN': '', # gotify的消息应用token
|
||||||
|
'GOTIFY_PRIORITY': 0, # 推送消息优先级,默认为0
|
||||||
|
|
||||||
'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
|
'IGOT_PUSH_KEY': '', # iGot 聚合推送的 IGOT_PUSH_KEY
|
||||||
|
|
||||||
'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
|
'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
|
||||||
@@ -194,6 +198,25 @@ def go_cqhttp(title: str, content: str) -> None:
|
|||||||
print("go-cqhttp 推送失败!")
|
print("go-cqhttp 推送失败!")
|
||||||
|
|
||||||
|
|
||||||
|
def gotify(title:str,content:str) -> None:
|
||||||
|
"""
|
||||||
|
使用 gotify 推送消息。
|
||||||
|
"""
|
||||||
|
if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"):
|
||||||
|
print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送")
|
||||||
|
return
|
||||||
|
print("gotify 服务启动")
|
||||||
|
|
||||||
|
url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}'
|
||||||
|
data = {"title": title,"message": content,"priority": push_config.get("GOTIFY_PRIORITY")}
|
||||||
|
response = requests.post(url,data=data).json()
|
||||||
|
|
||||||
|
if response.get("id"):
|
||||||
|
print("gotify 推送成功!")
|
||||||
|
else:
|
||||||
|
print("gotify 推送失败!")
|
||||||
|
|
||||||
|
|
||||||
def iGot(title: str, content: str) -> None:
|
def iGot(title: str, content: str) -> None:
|
||||||
"""
|
"""
|
||||||
使用 iGot 推送消息。
|
使用 iGot 推送消息。
|
||||||
@@ -473,6 +496,8 @@ if push_config.get("FSKEY"):
|
|||||||
notify_function.append(feishu_bot)
|
notify_function.append(feishu_bot)
|
||||||
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
|
if push_config.get("GOBOT_URL") and push_config.get("GOBOT_QQ"):
|
||||||
notify_function.append(go_cqhttp)
|
notify_function.append(go_cqhttp)
|
||||||
|
if push_config.get("GOTIFY_URL") and push_config.get("GOTIFY_TOKEN"):
|
||||||
|
notify_function.append(gotify)
|
||||||
if push_config.get("IGOT_PUSH_KEY"):
|
if push_config.get("IGOT_PUSH_KEY"):
|
||||||
notify_function.append(iGot)
|
notify_function.append(iGot)
|
||||||
if push_config.get("PUSH_KEY"):
|
if push_config.get("PUSH_KEY"):
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ cp -f "$repo_path/jbot/requirements.txt" "$dir_root"
|
|||||||
cd $dir_root
|
cd $dir_root
|
||||||
cat requirements.txt | while read LREAD
|
cat requirements.txt | while read LREAD
|
||||||
do
|
do
|
||||||
if test ! -z "$(pip3 show "${LREAD%%=*}" 1>/dev/null)"; then
|
if [[ ! $(pip3 show "${LREAD%%=*}" 2>/dev/null) ]]; then
|
||||||
pip3 --default-timeout=100 install ${LREAD}
|
pip3 --default-timeout=100 install ${LREAD}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
+2
-8
@@ -39,17 +39,11 @@ copy_dep() {
|
|||||||
reload_pm2() {
|
reload_pm2() {
|
||||||
pm2 l &>/dev/null
|
pm2 l &>/dev/null
|
||||||
|
|
||||||
if test -z "$(pm2 info panel 1>/dev/null)"; then
|
pm2 delete panel --source-map-support --time &>/dev/null
|
||||||
pm2 reload panel --source-map-support --time &>/dev/null
|
|
||||||
else
|
|
||||||
pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null
|
pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null
|
||||||
fi
|
|
||||||
|
|
||||||
if test -z "$(pm2 info schedule 1>/dev/null)"; then
|
pm2 delete schedule --source-map-support --time &>/dev/null
|
||||||
pm2 reload schedule --source-map-support --time &>/dev/null
|
|
||||||
else
|
|
||||||
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pm2_log() {
|
pm2_log() {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ dir_repo=$dir_root/repo
|
|||||||
dir_raw=$dir_root/raw
|
dir_raw=$dir_root/raw
|
||||||
dir_log=$dir_root/log
|
dir_log=$dir_root/log
|
||||||
dir_db=$dir_root/db
|
dir_db=$dir_root/db
|
||||||
|
dir_dep=$dir_root/deps
|
||||||
dir_list_tmp=$dir_log/.tmp
|
dir_list_tmp=$dir_log/.tmp
|
||||||
dir_code=$dir_log/code
|
dir_code=$dir_log/code
|
||||||
dir_update_log=$dir_log/update
|
dir_update_log=$dir_log/update
|
||||||
@@ -154,6 +155,7 @@ fix_config() {
|
|||||||
make_dir $dir_repo
|
make_dir $dir_repo
|
||||||
make_dir $dir_raw
|
make_dir $dir_raw
|
||||||
make_dir $dir_update_log
|
make_dir $dir_update_log
|
||||||
|
make_dir $dir_dep
|
||||||
|
|
||||||
if [[ ! -s $file_config_user ]]; then
|
if [[ ! -s $file_config_user ]]; then
|
||||||
echo -e "复制一份 $file_config_sample 为 $file_config_user,随后请按注释编辑你的配置文件:$file_config_user\n"
|
echo -e "复制一份 $file_config_sample 为 $file_config_user,随后请按注释编辑你的配置文件:$file_config_user\n"
|
||||||
|
|||||||
+3
-3
@@ -106,7 +106,7 @@ run_normal() {
|
|||||||
|
|
||||||
cd $dir_scripts
|
cd $dir_scripts
|
||||||
local relative_path="${first_param%/*}"
|
local relative_path="${first_param%/*}"
|
||||||
if [[ ! -z ${relative_path} ]]; then
|
if [[ ! -z ${relative_path} ]] && [[ ${first_param} =~ "/" ]]; then
|
||||||
cd ${relative_path}
|
cd ${relative_path}
|
||||||
first_param=${first_param/$relative_path\//}
|
first_param=${first_param/$relative_path\//}
|
||||||
fi
|
fi
|
||||||
@@ -174,7 +174,7 @@ run_concurrent() {
|
|||||||
|
|
||||||
cd $dir_scripts
|
cd $dir_scripts
|
||||||
local relative_path="${first_param%/*}"
|
local relative_path="${first_param%/*}"
|
||||||
if [[ ! -z ${relative_path} ]]; then
|
if [[ ! -z ${relative_path} ]] && [[ ${first_param} =~ "/" ]]; then
|
||||||
cd ${relative_path}
|
cd ${relative_path}
|
||||||
first_param=${first_param/$relative_path\//}
|
first_param=${first_param/$relative_path\//}
|
||||||
fi
|
fi
|
||||||
@@ -248,7 +248,7 @@ run_designated() {
|
|||||||
|
|
||||||
cd $dir_scripts
|
cd $dir_scripts
|
||||||
local relative_path="${file_param%/*}"
|
local relative_path="${file_param%/*}"
|
||||||
if [[ ! -z ${relative_path} ]]; then
|
if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then
|
||||||
cd ${relative_path}
|
cd ${relative_path}
|
||||||
file_param=${file_param/$relative_path\//}
|
file_param=${file_param/$relative_path\//}
|
||||||
fi
|
fi
|
||||||
|
|||||||
+11
-17
@@ -318,17 +318,11 @@ patch_version() {
|
|||||||
reload_pm2() {
|
reload_pm2() {
|
||||||
pm2 l &>/dev/null
|
pm2 l &>/dev/null
|
||||||
|
|
||||||
if [[ $(pm2 info panel 2>/dev/null) ]]; then
|
pm2 delete panel --source-map-support --time &>/dev/null
|
||||||
pm2 reload panel --source-map-support --time &>/dev/null
|
|
||||||
else
|
|
||||||
pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null
|
pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $(pm2 info schedule 2>/dev/null) ]]; then
|
pm2 delete schedule --source-map-support --time &>/dev/null
|
||||||
pm2 reload schedule --source-map-support --time &>/dev/null
|
|
||||||
else
|
|
||||||
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## 对比脚本
|
## 对比脚本
|
||||||
@@ -391,16 +385,11 @@ gen_list_repo() {
|
|||||||
if [[ $blackword ]]; then
|
if [[ $blackword ]]; then
|
||||||
files=$(echo "$files" | egrep -v $blackword)
|
files=$(echo "$files" | egrep -v $blackword)
|
||||||
fi
|
fi
|
||||||
if [[ $dependence ]]; then
|
|
||||||
cd ${dir_scripts}
|
|
||||||
depInScripts=$(eval $cmd | sed 's/^..//' | egrep -v $uniq_path | egrep $dependence)
|
|
||||||
for dep in ${depInScripts}; do
|
|
||||||
file_path=$(dirname $dep)
|
|
||||||
[[ ! $file_path =~ "/" ]] && file_path=""
|
|
||||||
make_dir "${dir_scripts}/${uniq_path}/${file_path#*/}"
|
|
||||||
cp -f $dep "${dir_scripts}/${uniq_path}/${file_path#*/}"
|
|
||||||
done
|
|
||||||
|
|
||||||
|
cp -f $file_notify_js "${dir_scripts}/${uniq_path}"
|
||||||
|
cp -f $file_notify_py "${dir_scripts}/${uniq_path}"
|
||||||
|
|
||||||
|
if [[ $dependence ]]; then
|
||||||
cd ${repo_path}
|
cd ${repo_path}
|
||||||
results=$(eval $cmd | sed 's/^..//' | egrep $dependence)
|
results=$(eval $cmd | sed 's/^..//' | egrep $dependence)
|
||||||
for _file in ${results}; do
|
for _file in ${results}; do
|
||||||
@@ -409,6 +398,11 @@ gen_list_repo() {
|
|||||||
cp -f $_file "${dir_scripts}/${uniq_path}/${file_path}"
|
cp -f $_file "${dir_scripts}/${uniq_path}/${file_path}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -d $dir_dep ]]; then
|
||||||
|
cp -rf $dir_dep/* "${dir_scripts}/${uniq_path}" &>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
for file in ${files}; do
|
for file in ${files}; do
|
||||||
filename=$(basename $file)
|
filename=$(basename $file)
|
||||||
cp -f $file "$dir_scripts/${uniq_path}/${filename}"
|
cp -f $file "$dir_scripts/${uniq_path}/${filename}"
|
||||||
|
|||||||
@@ -79,6 +79,6 @@ export default {
|
|||||||
fixSiderbar: true,
|
fixSiderbar: true,
|
||||||
contentWidth: 'Fixed',
|
contentWidth: 'Fixed',
|
||||||
splitMenus: false,
|
splitMenus: false,
|
||||||
logo: '/images/qinglong.png',
|
logo: 'https://z3.ax1x.com/2021/11/18/I7MpAe.png',
|
||||||
siderWidth: 180,
|
siderWidth: 180,
|
||||||
} as any;
|
} as any;
|
||||||
|
|||||||
@@ -235,6 +235,7 @@
|
|||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
transition: background-color 5000s ease-in-out 0s;
|
transition: background-color 5000s ease-in-out 0s;
|
||||||
-webkit-text-fill-color: @text-color;
|
-webkit-text-fill-color: @text-color;
|
||||||
|
caret-color: #e8e6f3 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
::placeholder {
|
::placeholder {
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
.ant-table-pagination.ant-pagination {
|
.ant-table-pagination.ant-pagination {
|
||||||
margin-bottom: 0 !important;
|
margin-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
td:nth-child(2) {
|
||||||
|
span {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import CronLogModal from './logModal';
|
|||||||
import cron_parser from 'cron-parser';
|
import cron_parser from 'cron-parser';
|
||||||
import { diffTime } from '@/utils/date';
|
import { diffTime } from '@/utils/date';
|
||||||
import { getTableScroll } from '@/utils/index';
|
import { getTableScroll } from '@/utils/index';
|
||||||
|
import { history } from 'umi';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
@@ -76,7 +77,11 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
|||||||
width: 150,
|
width: 150,
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
render: (text: string, record: any) => (
|
render: (text: string, record: any) => (
|
||||||
<span>
|
<span
|
||||||
|
onClick={() => {
|
||||||
|
goToScriptManager(record);
|
||||||
|
}}
|
||||||
|
>
|
||||||
{record.name || record._id}{' '}
|
{record.name || record._id}{' '}
|
||||||
{record.isPinned ? (
|
{record.isPinned ? (
|
||||||
<span>
|
<span>
|
||||||
@@ -329,6 +334,20 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
|||||||
const [pageSize, setPageSize] = useState(20);
|
const [pageSize, setPageSize] = useState(20);
|
||||||
const [tableScrollHeight, setTableScrollHeight] = useState<number>();
|
const [tableScrollHeight, setTableScrollHeight] = useState<number>();
|
||||||
|
|
||||||
|
const goToScriptManager = (record: any) => {
|
||||||
|
const cmd = record.command.split(' ');
|
||||||
|
if (cmd[0] === 'task') {
|
||||||
|
let [p, s] = cmd[1].split('/');
|
||||||
|
if (!s) {
|
||||||
|
s = p;
|
||||||
|
p = '';
|
||||||
|
}
|
||||||
|
history.push(`/script?p=${p}&s=${s}`);
|
||||||
|
} else if (cmd[1] === 'repo') {
|
||||||
|
location.href = cmd[2];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getCrons = () => {
|
const getCrons = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
request
|
request
|
||||||
@@ -847,6 +866,7 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
|||||||
defaultPageSize: 20,
|
defaultPageSize: 20,
|
||||||
showTotal: (total: number, range: number[]) =>
|
showTotal: (total: number, range: number[]) =>
|
||||||
`第 ${range[0]}-${range[1]} 条/总共 ${total} 条`,
|
`第 ${range[0]}-${range[1]} 条/总共 ${total} 条`,
|
||||||
|
pageSizeOptions: [10, 20, 50, 100, 200, 500, 1000],
|
||||||
}}
|
}}
|
||||||
dataSource={value}
|
dataSource={value}
|
||||||
rowKey="_id"
|
rowKey="_id"
|
||||||
|
|||||||
Vendored
+14
-6
@@ -118,13 +118,17 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
dataIndex: 'value',
|
dataIndex: 'value',
|
||||||
key: 'value',
|
key: 'value',
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
width: '44%',
|
width: '35%',
|
||||||
ellipsis: {
|
ellipsis: {
|
||||||
showTitle: false,
|
showTitle: false,
|
||||||
},
|
},
|
||||||
render: (text: string, record: any) => {
|
render: (text: string, record: any) => {
|
||||||
return (
|
return (
|
||||||
<Tooltip placement="topLeft" title={text}>
|
<Tooltip
|
||||||
|
placement="topLeft"
|
||||||
|
title={text}
|
||||||
|
trigger={['hover', 'click']}
|
||||||
|
>
|
||||||
<span>{text}</span>
|
<span>{text}</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
@@ -141,7 +145,7 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
dataIndex: 'timestamp',
|
dataIndex: 'timestamp',
|
||||||
key: 'timestamp',
|
key: 'timestamp',
|
||||||
align: 'center' as const,
|
align: 'center' as const,
|
||||||
width: 164,
|
width: 165,
|
||||||
ellipsis: {
|
ellipsis: {
|
||||||
showTitle: false,
|
showTitle: false,
|
||||||
},
|
},
|
||||||
@@ -151,9 +155,13 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
.toLocaleString(language, {
|
.toLocaleString(language, {
|
||||||
hour12: false,
|
hour12: false,
|
||||||
})
|
})
|
||||||
.replace(' 24:', ' 00:')
|
.replace(' 24:', ' 00:');
|
||||||
return (
|
return (
|
||||||
<Tooltip placement="topLeft" title={date}>
|
<Tooltip
|
||||||
|
placement="topLeft"
|
||||||
|
title={date}
|
||||||
|
trigger={['hover', 'click']}
|
||||||
|
>
|
||||||
<span>{date}</span>
|
<span>{date}</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
@@ -528,7 +536,7 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
dataSource={value}
|
dataSource={value}
|
||||||
rowKey="_id"
|
rowKey="_id"
|
||||||
size="middle"
|
size="middle"
|
||||||
scroll={{ x: 768, y: tableScrollHeight }}
|
scroll={{ x: 1000, y: tableScrollHeight }}
|
||||||
components={components}
|
components={components}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onRow={(record: any, index: number) => {
|
onRow={(record: any, index: number) => {
|
||||||
|
|||||||
@@ -225,7 +225,11 @@ const Initialization = () => {
|
|||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.top}>
|
<div className={styles.top}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<img alt="logo" className={styles.logo} src="/images/qinglong.png" />
|
<img
|
||||||
|
alt="logo"
|
||||||
|
className={styles.logo}
|
||||||
|
src="https://z3.ax1x.com/2021/11/18/I7MpAe.png"
|
||||||
|
/>
|
||||||
<span className={styles.title}>初始化配置</span>
|
<span className={styles.title}>初始化配置</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ function getFilterData(keyword: string, data: any) {
|
|||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
if (item.title.toLocaleLowerCase().includes(keyword)) {
|
if (item.title.toLocaleLowerCase().includes(keyword)) {
|
||||||
tree.push(item);
|
tree.push(item);
|
||||||
expandedKeys.push(...item.children.map((x: any) => x.key));
|
|
||||||
} else {
|
} else {
|
||||||
const children: any[] = [];
|
const children: any[] = [];
|
||||||
(item.children || []).forEach((subItem: any) => {
|
(item.children || []).forEach((subItem: any) => {
|
||||||
@@ -29,7 +28,7 @@ function getFilterData(keyword: string, data: any) {
|
|||||||
...item,
|
...item,
|
||||||
children,
|
children,
|
||||||
});
|
});
|
||||||
expandedKeys.push(...children.map((x) => x.key));
|
expandedKeys.push(item.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -47,6 +46,7 @@ const Log = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [height, setHeight] = useState<number>();
|
const [height, setHeight] = useState<number>();
|
||||||
const treeDom = useRef<any>();
|
const treeDom = useRef<any>();
|
||||||
|
const [expandedKeys, setExpandedKeys] = useState<string[]>([]);
|
||||||
|
|
||||||
const getLogs = () => {
|
const getLogs = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -100,8 +100,12 @@ const Log = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
const onSearch = useCallback(
|
const onSearch = useCallback(
|
||||||
(e) => {
|
(e) => {
|
||||||
const keyword = e.target.value;
|
const keyword = e.target.value;
|
||||||
const { tree } = getFilterData(keyword.toLocaleLowerCase(), data);
|
const { tree, expandedKeys } = getFilterData(
|
||||||
|
keyword.toLocaleLowerCase(),
|
||||||
|
data,
|
||||||
|
);
|
||||||
setFilterData(tree);
|
setFilterData(tree);
|
||||||
|
setExpandedKeys(expandedKeys);
|
||||||
},
|
},
|
||||||
[data, setFilterData],
|
[data, setFilterData],
|
||||||
);
|
);
|
||||||
@@ -127,7 +131,6 @@ const Log = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
treeData={data}
|
treeData={data}
|
||||||
placeholder="请选择日志文件"
|
placeholder="请选择日志文件"
|
||||||
showSearch
|
showSearch
|
||||||
key="value"
|
|
||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
/>,
|
/>,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -124,7 +124,11 @@ const Login = () => {
|
|||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.top}>
|
<div className={styles.top}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<img alt="logo" className={styles.logo} src="/images/qinglong.png" />
|
<img
|
||||||
|
alt="logo"
|
||||||
|
className={styles.logo}
|
||||||
|
src="https://z3.ax1x.com/2021/11/18/I7MpAe.png"
|
||||||
|
/>
|
||||||
<span className={styles.title}>
|
<span className={styles.title}>
|
||||||
{twoFactor ? '两步验证' : config.siteName}
|
{twoFactor ? '两步验证' : config.siteName}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -28,16 +28,19 @@ const EditModal = ({
|
|||||||
content,
|
content,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
visible,
|
||||||
|
socketMessage,
|
||||||
}: {
|
}: {
|
||||||
treeData?: any;
|
treeData?: any;
|
||||||
currentFile?: string;
|
currentFile?: string;
|
||||||
content?: string;
|
content?: string;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
|
socketMessage: any;
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
const [language, setLanguage] = useState<string>('javascript');
|
const [language, setLanguage] = useState<string>('javascript');
|
||||||
const [fileName, setFileName] = useState<string>('');
|
const [fileName, setFileName] = useState<string>('');
|
||||||
|
const [selectedKey, setSelectedKey] = useState<string>('');
|
||||||
const [saveModalVisible, setSaveModalVisible] = useState<boolean>(false);
|
const [saveModalVisible, setSaveModalVisible] = useState<boolean>(false);
|
||||||
const [settingModalVisible, setSettingModalVisible] =
|
const [settingModalVisible, setSettingModalVisible] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
@@ -50,10 +53,14 @@ const EditModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSelect = (value: any, node: any) => {
|
const onSelect = (value: any, node: any) => {
|
||||||
|
if (node.value === fileName || !value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const newMode = LangMap[value.slice(-3)] || '';
|
const newMode = LangMap[value.slice(-3)] || '';
|
||||||
setFileName(value);
|
setFileName(value);
|
||||||
setLanguage(newMode);
|
setLanguage(newMode);
|
||||||
getDetail(node);
|
getDetail(node);
|
||||||
|
setSelectedKey(node.key);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDetail = (node: any) => {
|
const getDetail = (node: any) => {
|
||||||
@@ -62,12 +69,39 @@ const EditModal = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const run = () => {};
|
const run = () => {
|
||||||
|
request
|
||||||
|
.put(`${config.apiPrefix}scripts/run`, {
|
||||||
|
data: {
|
||||||
|
filename: fileName,
|
||||||
|
path: '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((data) => {});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!socketMessage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { type, message: _message, references } = socketMessage;
|
||||||
|
|
||||||
|
if (type !== 'manuallyRunScript') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log) {
|
||||||
|
_message = `\n${_message}`;
|
||||||
|
}
|
||||||
|
setLog(`${log}${_message}`);
|
||||||
|
}, [socketMessage]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentFile) {
|
if (currentFile) {
|
||||||
setFileName(currentFile);
|
setFileName(currentFile);
|
||||||
setValue(content as string);
|
setValue(content as string);
|
||||||
|
setSelectedKey(currentFile);
|
||||||
}
|
}
|
||||||
}, [currentFile, content]);
|
}, [currentFile, content]);
|
||||||
|
|
||||||
@@ -79,12 +113,11 @@ const EditModal = ({
|
|||||||
<span style={{ marginRight: 8 }}>{fileName}</span>
|
<span style={{ marginRight: 8 }}>{fileName}</span>
|
||||||
<TreeSelect
|
<TreeSelect
|
||||||
style={{ marginRight: 8, width: 120 }}
|
style={{ marginRight: 8, width: 120 }}
|
||||||
value={currentFile}
|
value={selectedKey}
|
||||||
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
||||||
treeData={treeData}
|
treeData={treeData}
|
||||||
placeholder="请选择脚本文件"
|
placeholder="请选择脚本文件"
|
||||||
showSearch
|
showSearch
|
||||||
key="value"
|
|
||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -1,28 +1,42 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Modal, message, Input, Form } from 'antd';
|
import { Modal, message, Input, Form, Select } from 'antd';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
|
|
||||||
|
const { Option } = Select;
|
||||||
|
|
||||||
const EditScriptNameModal = ({
|
const EditScriptNameModal = ({
|
||||||
handleCancel,
|
handleCancel,
|
||||||
|
treeData,
|
||||||
visible,
|
visible,
|
||||||
}: {
|
}: {
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
handleCancel: (file?: { filename: string }) => void;
|
treeData: any[];
|
||||||
|
handleCancel: (file?: {
|
||||||
|
filename: string;
|
||||||
|
path: string;
|
||||||
|
key: string;
|
||||||
|
}) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [dirs, setDirs] = useState<any[]>([]);
|
||||||
|
|
||||||
const handleOk = async (values: any) => {
|
const handleOk = async (values: any) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
values.path = values.path || '';
|
||||||
request
|
request
|
||||||
.post(`${config.apiPrefix}scripts`, {
|
.post(`${config.apiPrefix}scripts`, {
|
||||||
data: { filename: values.filename, content: '' },
|
data: { filename: values.filename, path: values.path, content: '' },
|
||||||
})
|
})
|
||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
message.success('保存文件成功');
|
message.success('保存文件成功');
|
||||||
handleCancel({ filename: values.filename });
|
handleCancel({
|
||||||
|
filename: values.filename,
|
||||||
|
path: values.path,
|
||||||
|
key: `${values.path}-${values.filename}`,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
message.error(data);
|
message.error(data);
|
||||||
}
|
}
|
||||||
@@ -33,6 +47,8 @@ const EditScriptNameModal = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
const originDirs = treeData.filter((x) => x.disabled);
|
||||||
|
setDirs([{ key: '' }, ...originDirs]);
|
||||||
}, [visible]);
|
}, [visible]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -56,10 +72,22 @@ const EditScriptNameModal = ({
|
|||||||
<Form form={form} layout="vertical" name="edit_name_modal">
|
<Form form={form} layout="vertical" name="edit_name_modal">
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="filename"
|
name="filename"
|
||||||
|
label="文件名"
|
||||||
rules={[{ required: true, message: '请输入文件名' }]}
|
rules={[{ required: true, message: '请输入文件名' }]}
|
||||||
>
|
>
|
||||||
<Input placeholder="请输入文件名" />
|
<Input placeholder="请输入文件名" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label="父目录"
|
||||||
|
name="path"
|
||||||
|
initialValue={dirs && dirs.length > 0 ? dirs[0].key : ''}
|
||||||
|
>
|
||||||
|
<Select placeholder="请选择父目录">
|
||||||
|
{dirs.map((x) => (
|
||||||
|
<Option value={x.key}>{x.key || '根'}</Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
+114
-19
@@ -31,20 +31,37 @@ import {
|
|||||||
UserOutlined,
|
UserOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import EditScriptNameModal from './editNameModal';
|
import EditScriptNameModal from './editNameModal';
|
||||||
|
import debounce from 'lodash/debounce';
|
||||||
|
import { history } from 'umi';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
function getFilterData(keyword: string, data: any) {
|
function getFilterData(keyword: string, data: any) {
|
||||||
|
const expandedKeys: string[] = [];
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
const tree: any = [];
|
const tree: any = [];
|
||||||
data.forEach((item: any) => {
|
data.forEach((item: any) => {
|
||||||
if (item.title.toLocaleLowerCase().includes(keyword)) {
|
if (item.title.toLocaleLowerCase().includes(keyword)) {
|
||||||
tree.push(item);
|
tree.push(item);
|
||||||
|
} else {
|
||||||
|
const children: any[] = [];
|
||||||
|
(item.children || []).forEach((subItem: any) => {
|
||||||
|
if (subItem.title.toLocaleLowerCase().includes(keyword)) {
|
||||||
|
children.push(subItem);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { tree };
|
if (children.length > 0) {
|
||||||
|
tree.push({
|
||||||
|
...item,
|
||||||
|
children,
|
||||||
|
});
|
||||||
|
expandedKeys.push(item.key);
|
||||||
}
|
}
|
||||||
return { tree: data };
|
}
|
||||||
|
});
|
||||||
|
return { tree, expandedKeys };
|
||||||
|
}
|
||||||
|
return { tree: data, expandedKeys };
|
||||||
}
|
}
|
||||||
|
|
||||||
const LangMap: any = {
|
const LangMap: any = {
|
||||||
@@ -54,7 +71,7 @@ const LangMap: any = {
|
|||||||
'.ts': 'typescript',
|
'.ts': 'typescript',
|
||||||
};
|
};
|
||||||
|
|
||||||
const Script = ({ headerStyle, isPhone, theme }: any) => {
|
const Script = ({ headerStyle, isPhone, theme, socketMessage }: any) => {
|
||||||
const [title, setTitle] = useState('请选择脚本文件');
|
const [title, setTitle] = useState('请选择脚本文件');
|
||||||
const [value, setValue] = useState('请选择脚本文件');
|
const [value, setValue] = useState('请选择脚本文件');
|
||||||
const [select, setSelect] = useState<any>();
|
const [select, setSelect] = useState<any>();
|
||||||
@@ -70,6 +87,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
const editorRef = useRef<any>(null);
|
const editorRef = useRef<any>(null);
|
||||||
const [isAddFileModalVisible, setIsAddFileModalVisible] = useState(false);
|
const [isAddFileModalVisible, setIsAddFileModalVisible] = useState(false);
|
||||||
const [currentNode, setCurrentNode] = useState<any>();
|
const [currentNode, setCurrentNode] = useState<any>();
|
||||||
|
const [expandedKeys, setExpandedKeys] = useState<string[]>([]);
|
||||||
|
|
||||||
const getScripts = () => {
|
const getScripts = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -78,6 +96,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
setData(data.data);
|
setData(data.data);
|
||||||
setFilterData(data.data);
|
setFilterData(data.data);
|
||||||
|
initGetScript();
|
||||||
})
|
})
|
||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
};
|
};
|
||||||
@@ -90,6 +109,22 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const initGetScript = () => {
|
||||||
|
const { p, s } = history.location.query as any;
|
||||||
|
if (s) {
|
||||||
|
const obj = {
|
||||||
|
node: {
|
||||||
|
title: s,
|
||||||
|
value: s,
|
||||||
|
key: p ? `${p}-${s}` : s,
|
||||||
|
parent: p,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
setExpandedKeys([p]);
|
||||||
|
onTreeSelect([`${p}-${s}`], obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onSelect = (value: any, node: any) => {
|
const onSelect = (value: any, node: any) => {
|
||||||
if (node.key === select || !value) {
|
if (node.key === select || !value) {
|
||||||
return;
|
return;
|
||||||
@@ -97,12 +132,16 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
setValue('加载中...');
|
setValue('加载中...');
|
||||||
const newMode = value ? LangMap[value.slice(-3)] : '';
|
const newMode = value ? LangMap[value.slice(-3)] : '';
|
||||||
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
|
setMode(isPhone && newMode === 'typescript' ? 'javascript' : newMode);
|
||||||
setSelect(value);
|
setSelect(node.key);
|
||||||
setTitle(node.parent || node.value);
|
setTitle(node.parent || node.value);
|
||||||
setCurrentNode(node);
|
setCurrentNode(node);
|
||||||
getDetail(node);
|
getDetail(node);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onExpand = (expKeys: any) => {
|
||||||
|
setExpandedKeys(expKeys);
|
||||||
|
};
|
||||||
|
|
||||||
const onTreeSelect = useCallback(
|
const onTreeSelect = useCallback(
|
||||||
(keys: Key[], e: any) => {
|
(keys: Key[], e: any) => {
|
||||||
const content = editorRef.current
|
const content = editorRef.current
|
||||||
@@ -131,13 +170,24 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
const onSearch = useCallback(
|
const onSearch = useCallback(
|
||||||
(e) => {
|
(e) => {
|
||||||
const keyword = e.target.value;
|
const keyword = e.target.value;
|
||||||
setSearchValue(keyword);
|
debounceSearch(keyword);
|
||||||
const { tree } = getFilterData(keyword.toLocaleLowerCase(), data);
|
|
||||||
setFilterData(tree);
|
|
||||||
},
|
},
|
||||||
[data, setFilterData],
|
[data, setFilterData],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const debounceSearch = useCallback(
|
||||||
|
debounce((keyword) => {
|
||||||
|
setSearchValue(keyword);
|
||||||
|
const { tree, expandedKeys } = getFilterData(
|
||||||
|
keyword.toLocaleLowerCase(),
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
setExpandedKeys(expandedKeys);
|
||||||
|
setFilterData(tree);
|
||||||
|
}, 300),
|
||||||
|
[data, setFilterData],
|
||||||
|
);
|
||||||
|
|
||||||
const editFile = () => {
|
const editFile = () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setIsEditing(true);
|
setIsEditing(true);
|
||||||
@@ -147,7 +197,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
const cancelEdit = () => {
|
const cancelEdit = () => {
|
||||||
setIsEditing(false);
|
setIsEditing(false);
|
||||||
setValue('加载中...');
|
setValue('加载中...');
|
||||||
getDetail({ value: select });
|
getDetail(currentNode);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveFile = () => {
|
const saveFile = () => {
|
||||||
@@ -157,7 +207,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
<>
|
<>
|
||||||
确认保存文件
|
确认保存文件
|
||||||
<Text style={{ wordBreak: 'break-all' }} type="warning">
|
<Text style={{ wordBreak: 'break-all' }} type="warning">
|
||||||
{select}
|
{currentNode.value}
|
||||||
</Text>{' '}
|
</Text>{' '}
|
||||||
,保存后不可恢复
|
,保存后不可恢复
|
||||||
</>
|
</>
|
||||||
@@ -170,7 +220,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}scripts`, {
|
.put(`${config.apiPrefix}scripts`, {
|
||||||
data: {
|
data: {
|
||||||
filename: select,
|
filename: currentNode.value,
|
||||||
path: currentNode.parent || '',
|
path: currentNode.parent || '',
|
||||||
content,
|
content,
|
||||||
},
|
},
|
||||||
@@ -210,15 +260,30 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
request
|
request
|
||||||
.delete(`${config.apiPrefix}scripts`, {
|
.delete(`${config.apiPrefix}scripts`, {
|
||||||
data: {
|
data: {
|
||||||
filename: select,
|
filename: currentNode.value,
|
||||||
|
path: currentNode.parent || '',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((_data: any) => {
|
.then((_data: any) => {
|
||||||
if (_data.code === 200) {
|
if (_data.code === 200) {
|
||||||
message.success(`删除成功`);
|
message.success(`删除成功`);
|
||||||
let newData = [...data];
|
let newData = [...data];
|
||||||
const index = newData.findIndex((x) => x.value === select);
|
if (currentNode.parent) {
|
||||||
|
const parentNodeIndex = newData.findIndex(
|
||||||
|
(x) => x.key === currentNode.parent,
|
||||||
|
);
|
||||||
|
const parentNode = newData[parentNodeIndex];
|
||||||
|
const index = parentNode.children.findIndex(
|
||||||
|
(y) => y.key === currentNode.key,
|
||||||
|
);
|
||||||
|
parentNode.children.splice(index, 1);
|
||||||
|
newData.splice(parentNodeIndex, 1, { ...parentNode });
|
||||||
|
} else {
|
||||||
|
const index = newData.findIndex(
|
||||||
|
(x) => x.key === currentNode.key,
|
||||||
|
);
|
||||||
newData.splice(index, 1);
|
newData.splice(index, 1);
|
||||||
|
}
|
||||||
setData(newData);
|
setData(newData);
|
||||||
} else {
|
} else {
|
||||||
message.error(_data);
|
message.error(_data);
|
||||||
@@ -236,12 +301,27 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addFileModalClose = (
|
const addFileModalClose = (
|
||||||
{ filename }: { filename: string } = { filename: '' },
|
{ filename, path, key }: { filename: string; path: string; key: string } = {
|
||||||
|
filename: '',
|
||||||
|
path: '',
|
||||||
|
key: '',
|
||||||
|
},
|
||||||
) => {
|
) => {
|
||||||
if (filename) {
|
if (filename) {
|
||||||
const newData = [...data];
|
const newData = [...data];
|
||||||
const _file = { title: filename, key: filename, value: filename };
|
const _file = { title: filename, key, value: filename, parent: path };
|
||||||
|
if (path) {
|
||||||
|
const parentNodeIndex = newData.findIndex((x) => x.key === path);
|
||||||
|
const parentNode = newData[parentNodeIndex];
|
||||||
|
if (parentNode.children && parentNode.children.length > 0) {
|
||||||
|
parentNode.children.unshift(_file);
|
||||||
|
} else {
|
||||||
|
parentNode.children = [_file];
|
||||||
|
}
|
||||||
|
newData.splice(parentNodeIndex, 1, { ...parentNode });
|
||||||
|
} else {
|
||||||
newData.unshift(_file);
|
newData.unshift(_file);
|
||||||
|
}
|
||||||
setData(newData);
|
setData(newData);
|
||||||
onSelect(_file.value, _file);
|
onSelect(_file.value, _file);
|
||||||
setIsEditing(true);
|
setIsEditing(true);
|
||||||
@@ -253,7 +333,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
request
|
request
|
||||||
.post(`${config.apiPrefix}scripts/download`, {
|
.post(`${config.apiPrefix}scripts/download`, {
|
||||||
data: {
|
data: {
|
||||||
filename: select,
|
filename: currentNode.value,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((_data: any) => {
|
.then((_data: any) => {
|
||||||
@@ -261,7 +341,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download = select;
|
a.download = currentNode.value;
|
||||||
document.documentElement.appendChild(a);
|
document.documentElement.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.documentElement.removeChild(a);
|
document.documentElement.removeChild(a);
|
||||||
@@ -299,10 +379,20 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
<Menu.Item key="add" icon={<PlusOutlined />} onClick={addFile}>
|
<Menu.Item key="add" icon={<PlusOutlined />} onClick={addFile}>
|
||||||
添加
|
添加
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="edit" icon={<EditOutlined />} onClick={editFile}>
|
<Menu.Item
|
||||||
|
key="edit"
|
||||||
|
icon={<EditOutlined />}
|
||||||
|
onClick={editFile}
|
||||||
|
disabled={!select}
|
||||||
|
>
|
||||||
编辑
|
编辑
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item key="delete" icon={<DeleteOutlined />} onClick={deleteFile}>
|
<Menu.Item
|
||||||
|
key="delete"
|
||||||
|
icon={<DeleteOutlined />}
|
||||||
|
onClick={deleteFile}
|
||||||
|
disabled={!select}
|
||||||
|
>
|
||||||
删除
|
删除
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
@@ -323,7 +413,6 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
treeData={data}
|
treeData={data}
|
||||||
placeholder="请选择脚本文件"
|
placeholder="请选择脚本文件"
|
||||||
showSearch
|
showSearch
|
||||||
key="value"
|
|
||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
/>,
|
/>,
|
||||||
<Dropdown overlay={menu} trigger={['click']}>
|
<Dropdown overlay={menu} trigger={['click']}>
|
||||||
@@ -349,6 +438,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
</Tooltip>,
|
</Tooltip>,
|
||||||
<Tooltip title="编辑">
|
<Tooltip title="编辑">
|
||||||
<Button
|
<Button
|
||||||
|
disabled={!select}
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={editFile}
|
onClick={editFile}
|
||||||
icon={<EditOutlined />}
|
icon={<EditOutlined />}
|
||||||
@@ -357,6 +447,7 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
<Tooltip title="删除">
|
<Tooltip title="删除">
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
disabled={!select}
|
||||||
onClick={deleteFile}
|
onClick={deleteFile}
|
||||||
icon={<DeleteOutlined />}
|
icon={<DeleteOutlined />}
|
||||||
/>
|
/>
|
||||||
@@ -390,6 +481,8 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
showIcon={true}
|
showIcon={true}
|
||||||
height={height}
|
height={height}
|
||||||
selectedKeys={[select]}
|
selectedKeys={[select]}
|
||||||
|
expandedKeys={expandedKeys}
|
||||||
|
onExpand={onExpand}
|
||||||
showLine={{ showLeafIcon: true }}
|
showLine={{ showLeafIcon: true }}
|
||||||
onSelect={onTreeSelect}
|
onSelect={onTreeSelect}
|
||||||
></Tree>
|
></Tree>
|
||||||
@@ -434,12 +527,14 @@ const Script = ({ headerStyle, isPhone, theme }: any) => {
|
|||||||
treeData={data}
|
treeData={data}
|
||||||
currentFile={select}
|
currentFile={select}
|
||||||
content={value}
|
content={value}
|
||||||
|
socketMessage={socketMessage}
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setIsLogModalVisible(false);
|
setIsLogModalVisible(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<EditScriptNameModal
|
<EditScriptNameModal
|
||||||
visible={isAddFileModalVisible}
|
visible={isAddFileModalVisible}
|
||||||
|
treeData={data}
|
||||||
handleCancel={addFileModalClose}
|
handleCancel={addFileModalClose}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export default {
|
|||||||
logs: '任务日志',
|
logs: '任务日志',
|
||||||
},
|
},
|
||||||
notificationModes: [
|
notificationModes: [
|
||||||
|
{ value: 'gotify', label: 'Gotify' },
|
||||||
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
||||||
{ value: 'serverChan', label: 'Server酱' },
|
{ value: 'serverChan', label: 'Server酱' },
|
||||||
{ value: 'bark', label: 'Bark' },
|
{ value: 'bark', label: 'Bark' },
|
||||||
@@ -77,6 +78,15 @@ export default {
|
|||||||
{ value: 'closed', label: '已关闭' },
|
{ value: 'closed', label: '已关闭' },
|
||||||
],
|
],
|
||||||
notificationModeMap: {
|
notificationModeMap: {
|
||||||
|
gotify: [
|
||||||
|
{
|
||||||
|
label: 'gotifyUrl',
|
||||||
|
tip: 'gotify的url地址,例如 https://push.example.de:8080',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
{ label: 'gotifyToken', tip: 'gotify的消息应用token码', required: true },
|
||||||
|
{ label: 'gotifyPriority', tip: '推送消息的优先级' },
|
||||||
|
],
|
||||||
goCqHttpBot: [
|
goCqHttpBot: [
|
||||||
{
|
{
|
||||||
label: 'goCqHttpBotUrl',
|
label: 'goCqHttpBotUrl',
|
||||||
|
|||||||
+9
-8
@@ -1,9 +1,10 @@
|
|||||||
export const version = '2.10.6';
|
export const version = '2.10.9';
|
||||||
export const changeLogLink = 'https://t.me/jiao_long/225';
|
export const changeLogLink = 'https://t.me/jiao_long/228';
|
||||||
export const changeLog = `2.10.6 版本说明
|
export const changeLog = `2.10.9 版本说明
|
||||||
1. 增加各版本自动打包workflow,感谢 https://github.com/fzls PR
|
1. 任务管理支持任务名跳转脚本管理页,感谢 https://github.com/kilo5hz PR
|
||||||
2. 环境变量添加更新时间,感谢 https://github.com/miniers PR
|
2. 系统通知支持gotify,感谢 https://github.com/kilo5hz PR
|
||||||
3. 修复脚本管理结构
|
3. 定时任务列表pageSize增加200/500/1000,感谢 https://github.com/fzls PR
|
||||||
4. 修复定时匹配规则
|
4. 修复deps目录依赖文件拷贝
|
||||||
5. 修复检查更新
|
5. 修改alpine基础镜像版本,解决arm32位系统无法启动容器,感谢 https://github.com/lx200916
|
||||||
|
6. 修复调试功能
|
||||||
`;
|
`;
|
||||||
|
|||||||
Reference in New Issue
Block a user