mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-10 11:24:33 +08:00
Compare commits
143 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa6d57d809 | |||
| 1060fc7476 | |||
| 56bc38e9e7 | |||
| 18be65d6fe | |||
| 3409085195 | |||
| 17e17ac077 | |||
| c655e1da38 | |||
| 0ea158724f | |||
| fb521498ff | |||
| 399550ccad | |||
| c7c30c86f2 | |||
| 5f6c0882d6 | |||
| 6e05a4f3a5 | |||
| ea8aa6a231 | |||
| ae2570c677 | |||
| c76d952d41 | |||
| cdf9fb24be | |||
| 2131e16781 | |||
| b0c8425639 | |||
| f0869567de | |||
| be2a19949b | |||
| 8627cccb58 | |||
| 4a8eaebf17 | |||
| e7edd0a5a4 | |||
| 9ccbea0a04 | |||
| ab715ef840 | |||
| 117822fe7c | |||
| da922678a1 | |||
| 133e9e0e1f | |||
| 7cc6081d15 | |||
| 5a24f62a62 | |||
| be597355a7 | |||
| 51afcb6c5b | |||
| 92ebb70eaa | |||
| ab19f30342 | |||
| fc9bc7bea2 | |||
| 793da29f22 | |||
| 5afe4da607 | |||
| a7a56c03ce | |||
| 7639b588d8 | |||
| 1d536cdd53 | |||
| 9f08245b6d | |||
| ff9bf20e57 | |||
| b201730100 | |||
| 6ca098f9e2 | |||
| e0eef05f5c | |||
| 6398e5ec70 | |||
| 6f93219c44 | |||
| 9b957ac019 | |||
| e0d1b127aa | |||
| 64072b3435 | |||
| f81f7720f0 | |||
| 69fab610e6 | |||
| d693e1f9ea | |||
| 2a9ca67355 | |||
| 3fb01860d4 | |||
| d92a46d09c | |||
| ec605bfba4 | |||
| d2f999a5e2 | |||
| 627f541f17 | |||
| c457dca555 | |||
| ff3ec7395e | |||
| fdaba146ca | |||
| 31a6d30c23 | |||
| fa3b185fd5 | |||
| 101d4fb497 | |||
| ccd308f5b0 | |||
| 999d9f8e01 | |||
| 313db0d74e | |||
| 634e9705a7 | |||
| c959cec738 | |||
| 95330e04a3 | |||
| a099d09af7 | |||
| a0d0197ad7 | |||
| d49e711a34 | |||
| e3b8cd75b9 | |||
| 7a240eaabb | |||
| 01564e96d3 | |||
| 03f4b5c219 | |||
| 99e1d44f7d | |||
| 8c55659c18 | |||
| 3ea980b2f8 | |||
| f5fc987b51 | |||
| 9cfa4af2b2 | |||
| 3efdf1fa87 | |||
| 25fc832605 | |||
| a7e404c5d5 | |||
| 90b27f0564 | |||
| 632440965d | |||
| aedfac446b | |||
| 3372b0025a | |||
| 0112b92e77 | |||
| 0caf53b147 | |||
| 4d1354d5f4 | |||
| fc4562eca2 | |||
| 5b048a5510 | |||
| d23049b2fe | |||
| caac5607b9 | |||
| fb2e69b12d | |||
| fc1838ff39 | |||
| 25689cf40f | |||
| c746a3d215 | |||
| 548d924fa0 | |||
| 18a6be3ecd | |||
| afef0cb72f | |||
| 1221b47eca | |||
| a356eeb5da | |||
| 25bb0972b9 | |||
| 0914075cf6 | |||
| 74b258e1b6 | |||
| 27eb0a21e4 | |||
| d77c6d50d8 | |||
| 6a64c18a7b | |||
| b97ff714ae | |||
| 1f23eea805 | |||
| cb0cb7df21 | |||
| f3e8628664 | |||
| 4758471f9f | |||
| c10bd5a549 | |||
| d53faf96eb | |||
| 2307b8ed1a | |||
| 711af8d4a5 | |||
| 458c9c456b | |||
| 29069df48c | |||
| 300e84ae2c | |||
| bf11768b92 | |||
| 91bd1d9263 | |||
| ac40f9ff12 | |||
| f930837220 | |||
| 1d5e3acc93 | |||
| 2aec1f9846 | |||
| b56a681b98 | |||
| 2713419b32 | |||
| 764a3492cc | |||
| 29fc471ac4 | |||
| 54a597aad3 | |||
| 778961d0b6 | |||
| 14b01ac761 | |||
| f87848c05b | |||
| 153e5a806d | |||
| ee1b8a906f | |||
| 734685d45a | |||
| e3b540c212 |
+7
-4
@@ -1,9 +1,12 @@
|
||||
MONGODB_URI='mongodb://'
|
||||
YIYAN_MONGODB_URI=''
|
||||
|
||||
PUBLIC_PORT=5400
|
||||
CRON_PORT=5500
|
||||
PORT=5600
|
||||
BACK_PORT=5600
|
||||
PORT=5700
|
||||
|
||||
LOG_LEVEL='debug'
|
||||
|
||||
SECRET='whyour'
|
||||
|
||||
QINIU_AK = ''
|
||||
QINIU_SK = ''
|
||||
QINIU_SCOPE = ''
|
||||
@@ -27,18 +27,19 @@ jobs:
|
||||
|
||||
- name: build front and back
|
||||
run: |
|
||||
yarn install
|
||||
yarn build
|
||||
yarn build-back
|
||||
npm i -g pnpm
|
||||
pnpm install
|
||||
pnpm build:front
|
||||
pnpm build:back
|
||||
|
||||
- name: copy to static repo
|
||||
env:
|
||||
GITHUB_REPO: github.com/${{ github.repository_owner }}/qinglong-static
|
||||
GITHUB_BRANCH: ${{ github.ref_name }}
|
||||
run: |
|
||||
mkdir -p static
|
||||
cd ./static
|
||||
cp -rf ../dist ./ && cp -rf ../build ./
|
||||
mkdir -p tmp
|
||||
cd ./tmp
|
||||
cp -rf ../static/* ./
|
||||
git init -b ${GITHUB_BRANCH} && git add .
|
||||
git config --local user.name 'github-actions[bot]'
|
||||
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
@@ -111,7 +112,7 @@ jobs:
|
||||
build-args: |
|
||||
MAINTAINER=${{ github.repository_owner }}
|
||||
QL_BRANCH=${{ github.ref_name }}
|
||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x
|
||||
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
|
||||
context: docker/
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
+3
-2
@@ -4,12 +4,13 @@
|
||||
/node_modules
|
||||
/npm-debug.log*
|
||||
/yarn-error.log
|
||||
/yarn.lock
|
||||
/pnpm-lock.yaml
|
||||
/package-lock.json
|
||||
|
||||
# production
|
||||
/dist
|
||||
/build
|
||||
/static
|
||||
/data
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
||||
@@ -4,15 +4,22 @@ const CompressionPlugin = require('compression-webpack-plugin');
|
||||
export default defineConfig({
|
||||
hash: true,
|
||||
layout: false,
|
||||
outputPath: 'static/dist',
|
||||
nodeModulesTransform: {
|
||||
type: 'none',
|
||||
},
|
||||
fastRefresh: {},
|
||||
esbuild: {},
|
||||
webpack5: {},
|
||||
dynamicImport: {
|
||||
loading: '@/components/pageLoading',
|
||||
},
|
||||
favicon: '/images/g5.ico',
|
||||
proxy: {
|
||||
'/api/public': {
|
||||
target: 'http://127.0.0.1:5400/',
|
||||
changeOrigin: true,
|
||||
},
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:5600/',
|
||||
changeOrigin: true,
|
||||
@@ -32,18 +39,9 @@ export default defineConfig({
|
||||
externals: {
|
||||
react: 'window.React',
|
||||
'react-dom': 'window.ReactDOM',
|
||||
darkreader: 'window.DarkReader',
|
||||
codemirror: 'window.CodeMirror',
|
||||
'sockjs-client': 'window.SockJS',
|
||||
},
|
||||
scripts: [
|
||||
'https://gw.alipayobjects.com/os/lib/react/16.13.1/umd/react.production.min.js',
|
||||
'https://gw.alipayobjects.com/os/lib/react-dom/16.13.1/umd/react-dom.production.min.js',
|
||||
'https://unpkg.zhimg.com/darkreader@4.9.40/darkreader.js',
|
||||
'https://unpkg.zhimg.com/codemirror@5/lib/codemirror.js',
|
||||
'https://unpkg.zhimg.com/codemirror@5/mode/shell/shell.js',
|
||||
'https://unpkg.zhimg.com/codemirror@5/mode/python/python.js',
|
||||
'https://unpkg.zhimg.com/codemirror@5/mode/javascript/javascript.js',
|
||||
'https://unpkg.zhimg.com/sockjs-client@1/dist/sockjs.min.js',
|
||||
],
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
||||
</div>
|
||||
|
||||
[](https://whyour.cn)
|
||||
[](https://whyour.cn)
|
||||
|
||||
简体中文 | [English](./README-en.md)
|
||||
|
||||
@@ -44,6 +44,27 @@
|
||||
# 待完善
|
||||
```
|
||||
|
||||
### podman 部署
|
||||
|
||||
1. podman 安装
|
||||
|
||||
```bash
|
||||
https://podman.io/getting-started/installation
|
||||
```
|
||||
|
||||
2. 启动容器
|
||||
|
||||
```bash
|
||||
podman run -dit \
|
||||
--network bridge \
|
||||
-v $PWD/ql:/ql/data \
|
||||
-p 5700:5700 \
|
||||
--name qinglong \
|
||||
--hostname qinglong \
|
||||
--restart unless-stopped \
|
||||
docker.io/whyour/qinglong:latest
|
||||
```
|
||||
|
||||
### docker 部署
|
||||
|
||||
1. docker 安装
|
||||
@@ -56,12 +77,7 @@ sudo curl -sSL get.docker.com | sh
|
||||
|
||||
```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 \
|
||||
-v $PWD/ql:/ql/data \
|
||||
-p 5700:5700 \
|
||||
--name qinglong \
|
||||
--hostname qinglong \
|
||||
@@ -81,7 +97,7 @@ sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-c
|
||||
|
||||
```bash
|
||||
mkdir qinglong
|
||||
wget https://raw.githubusercontent.com/whyour/qinglong/master/docker-compose.yml
|
||||
wget https://raw.githubusercontent.com/whyour/qinglong/master/docker/docker-compose.yml
|
||||
|
||||
# 启动
|
||||
docker-compose up -d
|
||||
@@ -152,12 +168,13 @@ task <file_path> desi <env_name> <account_number>
|
||||
$ git clone git@github.com:whyour/qinglong.git
|
||||
$ cd qinglong
|
||||
$ cp .env.example .env
|
||||
$ yarn install
|
||||
$ yarn start-back
|
||||
$ yarn start
|
||||
# 推荐使用 pnpm https://pnpm.io/zh/installation
|
||||
$ npm install -g pnpm
|
||||
$ pnpm install
|
||||
$ pnpm start
|
||||
```
|
||||
|
||||
打开你的浏览器,访问 http://127.0.0.1:5601
|
||||
打开你的浏览器,访问 http://127.0.0.1:5700
|
||||
|
||||
## 交流
|
||||
|
||||
|
||||
@@ -333,4 +333,24 @@ export default (app: Router) => {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
route.get(
|
||||
'/:id/logs',
|
||||
celebrate({
|
||||
params: Joi.object({
|
||||
id: Joi.number().required(),
|
||||
}),
|
||||
}),
|
||||
async (req: Request<{ id: number }>, res: Response, next: NextFunction) => {
|
||||
const logger: Logger = Container.get('logger');
|
||||
try {
|
||||
const cronService = Container.get(CronService);
|
||||
const data = await cronService.logs(req.params.id);
|
||||
return res.send({ code: 200, data });
|
||||
} catch (e) {
|
||||
logger.error('🔥 error: %o', e);
|
||||
return next(e);
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
+24
-3
@@ -5,8 +5,8 @@ import * as fs from 'fs';
|
||||
import config from '../config';
|
||||
import SystemService from '../services/system';
|
||||
import { celebrate, Joi } from 'celebrate';
|
||||
import { getFileContentByName } from '../config/util';
|
||||
import UserService from '../services/user';
|
||||
import { EnvModel } from '../data/env';
|
||||
const route = Router();
|
||||
|
||||
export default (app: Router) => {
|
||||
@@ -17,7 +17,7 @@ export default (app: Router) => {
|
||||
try {
|
||||
const userService = Container.get(UserService);
|
||||
const authInfo = await userService.getUserInfo();
|
||||
const envDbContent = getFileContentByName(config.envDbFile);
|
||||
const envCount = await EnvModel.count();
|
||||
const versionRegx = /.*export const version = \'(.*)\'\;/;
|
||||
|
||||
const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8');
|
||||
@@ -28,7 +28,7 @@ export default (app: Router) => {
|
||||
Object.keys(authInfo).length === 2 &&
|
||||
authInfo.username === 'admin' &&
|
||||
authInfo.password === 'admin' &&
|
||||
envDbContent.length === 0
|
||||
envCount === 0
|
||||
) {
|
||||
isInitialized = false;
|
||||
}
|
||||
@@ -111,4 +111,25 @@ export default (app: Router) => {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
route.put(
|
||||
'/notify',
|
||||
celebrate({
|
||||
body: Joi.object({
|
||||
title: Joi.string().required(),
|
||||
content: Joi.string().required(),
|
||||
}),
|
||||
}),
|
||||
async (req: Request, res: Response, next: NextFunction) => {
|
||||
const logger: Logger = Container.get('logger');
|
||||
try {
|
||||
const systemService = Container.get(SystemService);
|
||||
const result = await systemService.notify(req.body);
|
||||
res.send(result);
|
||||
} catch (e) {
|
||||
logger.error('🔥 error: %o', e);
|
||||
return next(e);
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
+20
-25
@@ -4,32 +4,30 @@ import { createRandomString } from './util';
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
const lastVersionFile =
|
||||
'https://raw.githubusercontent.com/whyour/qinglong/master/src/version.ts';
|
||||
const lastVersionFile = 'http://qn.whyour.cn/version.ts?v=2.12.1';
|
||||
|
||||
const envFound = dotenv.config();
|
||||
const rootPath = process.cwd();
|
||||
const envFile = path.join(rootPath, 'config/env.sh');
|
||||
const confFile = path.join(rootPath, 'config/config.sh');
|
||||
const sampleFile = path.join(rootPath, 'sample/config.sample.sh');
|
||||
const crontabFile = path.join(rootPath, 'config/crontab.list');
|
||||
const confBakDir = path.join(rootPath, 'config/bak/');
|
||||
const authConfigFile = path.join(rootPath, 'config/auth.json');
|
||||
const extraFile = path.join(rootPath, 'config/extra.sh');
|
||||
const configPath = path.join(rootPath, 'config/');
|
||||
const scriptPath = path.join(rootPath, 'scripts/');
|
||||
const bakPath = path.join(rootPath, 'bak/');
|
||||
const dataPath = path.join(rootPath, 'data/');
|
||||
const samplePath = path.join(rootPath, 'sample/');
|
||||
const logPath = path.join(rootPath, 'log/');
|
||||
const configPath = path.join(dataPath, 'config/');
|
||||
const scriptPath = path.join(dataPath, 'scripts/');
|
||||
const bakPath = path.join(dataPath, 'bak/');
|
||||
const logPath = path.join(dataPath, 'log/');
|
||||
const dbPath = path.join(dataPath, 'db/');
|
||||
|
||||
const envFile = path.join(configPath, 'env.sh');
|
||||
const confFile = path.join(configPath, 'config.sh');
|
||||
const crontabFile = path.join(configPath, 'crontab.list');
|
||||
const authConfigFile = path.join(configPath, 'auth.json');
|
||||
const extraFile = path.join(configPath, 'extra.sh');
|
||||
const confBakDir = path.join(dataPath, 'config/bak/');
|
||||
const sampleFile = path.join(samplePath, 'config.sample.sh');
|
||||
const sqliteFile = path.join(samplePath, 'database.sqlite');
|
||||
|
||||
const authError = '错误的用户名密码,请重试';
|
||||
const loginFaild = '请先登录!';
|
||||
const configString = 'config sample crontab shareCode diy';
|
||||
const dbPath = path.join(rootPath, 'db/');
|
||||
const cronDbFile = path.join(rootPath, 'db/crontab.db');
|
||||
const envDbFile = path.join(rootPath, 'db/env.db');
|
||||
const appDbFile = path.join(rootPath, 'db/app.db');
|
||||
const authDbFile = path.join(rootPath, 'db/auth.db');
|
||||
const dependenceDbFile = path.join(rootPath, 'db/dependence.db');
|
||||
const versionFile = path.join(rootPath, 'src/version.ts');
|
||||
|
||||
if (envFound.error) {
|
||||
@@ -37,8 +35,9 @@ if (envFound.error) {
|
||||
}
|
||||
|
||||
export default {
|
||||
port: parseInt(process.env.PORT as string, 10),
|
||||
port: parseInt(process.env.BACK_PORT as string, 10),
|
||||
cronPort: parseInt(process.env.CRON_PORT as string, 10),
|
||||
publicPort: parseInt(process.env.PUBLIC_PORT as string, 10),
|
||||
secret: process.env.SECRET || createRandomString(16, 32),
|
||||
logs: {
|
||||
level: process.env.LOG_LEVEL || 'silly',
|
||||
@@ -59,11 +58,6 @@ export default {
|
||||
confFile,
|
||||
envFile,
|
||||
dbPath,
|
||||
cronDbFile,
|
||||
envDbFile,
|
||||
appDbFile,
|
||||
authDbFile,
|
||||
dependenceDbFile,
|
||||
configPath,
|
||||
scriptPath,
|
||||
samplePath,
|
||||
@@ -86,4 +80,5 @@ export default {
|
||||
],
|
||||
versionFile,
|
||||
lastVersionFile,
|
||||
sqliteFile,
|
||||
};
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ export function createRandomString(min: number, max: number): string {
|
||||
newArr.push(arr.splice(Math.random() * arr.length, 1)[0]);
|
||||
}
|
||||
|
||||
function getOne(arr) {
|
||||
function getOne(arr: any[]) {
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
}
|
||||
|
||||
|
||||
+11
-5
@@ -4,7 +4,7 @@ import { DataTypes, Model, ModelDefined } from 'sequelize';
|
||||
export class Crontab {
|
||||
name?: string;
|
||||
command: string;
|
||||
schedule: string;
|
||||
schedule?: string;
|
||||
timestamp?: string;
|
||||
saved?: boolean;
|
||||
id?: number;
|
||||
@@ -49,12 +49,18 @@ export enum CrontabStatus {
|
||||
|
||||
interface CronInstance extends Model<Crontab, Crontab>, Crontab {}
|
||||
export const CrontabModel = sequelize.define<CronInstance>('Crontab', {
|
||||
name: DataTypes.STRING,
|
||||
command: {
|
||||
unique: 'command',
|
||||
name: {
|
||||
unique: 'compositeIndex',
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
command: {
|
||||
unique: 'compositeIndex',
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
schedule: {
|
||||
unique: 'compositeIndex',
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
schedule: DataTypes.STRING,
|
||||
timestamp: DataTypes.STRING,
|
||||
saved: DataTypes.BOOLEAN,
|
||||
status: DataTypes.NUMBER,
|
||||
|
||||
+2
-2
@@ -30,10 +30,10 @@ export const initEnvPosition = 9999999999;
|
||||
|
||||
interface EnvInstance extends Model<Env, Env>, Env {}
|
||||
export const EnvModel = sequelize.define<EnvInstance>('Env', {
|
||||
value: DataTypes.STRING,
|
||||
value: { type: DataTypes.STRING, unique: 'compositeIndex' },
|
||||
timestamp: DataTypes.STRING,
|
||||
status: DataTypes.NUMBER,
|
||||
position: DataTypes.NUMBER,
|
||||
name: DataTypes.STRING,
|
||||
name: { type: DataTypes.STRING, unique: 'compositeIndex' },
|
||||
remarks: DataTypes.STRING,
|
||||
});
|
||||
|
||||
@@ -5,4 +5,11 @@ export const sequelize = new Sequelize({
|
||||
dialect: 'sqlite',
|
||||
storage: `${config.dbPath}database.sqlite`,
|
||||
logging: false,
|
||||
pool: {
|
||||
max: 6,
|
||||
min: 0,
|
||||
idle: 30000,
|
||||
},
|
||||
});
|
||||
|
||||
export type ResponseType<T> = { code: number; data?: T; message?: string };
|
||||
|
||||
@@ -2,6 +2,7 @@ export enum NotificationMode {
|
||||
'gotify' = 'gotify',
|
||||
'goCqHttpBot' = 'goCqHttpBot',
|
||||
'serverChan' = 'serverChan',
|
||||
'pushDeer' = 'pushDeer',
|
||||
'bark' = 'bark',
|
||||
'telegramBot' = 'telegramBot',
|
||||
'dingtalkBot' = 'dingtalkBot',
|
||||
@@ -32,8 +33,13 @@ export class ServerChanNotification extends NotificationBaseInfo {
|
||||
public serverChanKey = '';
|
||||
}
|
||||
|
||||
export class PushDeerNotification extends NotificationBaseInfo {
|
||||
public pushDeerKey = '';
|
||||
}
|
||||
|
||||
export class BarkNotification extends NotificationBaseInfo {
|
||||
public barkPush = '';
|
||||
public barkIcon = 'http://qn.whyour.cn/logo.png';
|
||||
public barkSound = '';
|
||||
public barkGroup = 'qinglong';
|
||||
}
|
||||
@@ -79,6 +85,7 @@ export interface NotificationInfo
|
||||
extends GoCqHttpBotNotification,
|
||||
GotifyNotification,
|
||||
ServerChanNotification,
|
||||
PushDeerNotification,
|
||||
BarkNotification,
|
||||
TelegramBotNotification,
|
||||
DingtalkBotNotification,
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ export enum CrontabStatus {
|
||||
|
||||
interface AppInstance extends Model<App, App>, App {}
|
||||
export const AppModel = sequelize.define<AppInstance>('App', {
|
||||
name: DataTypes.STRING,
|
||||
name: { type: DataTypes.STRING, unique: 'name' },
|
||||
scopes: DataTypes.JSON,
|
||||
client_id: DataTypes.STRING,
|
||||
client_secret: DataTypes.STRING,
|
||||
|
||||
+33
-14
@@ -1,23 +1,42 @@
|
||||
import DataStore from 'nedb';
|
||||
import config from '../config';
|
||||
import Logger from './logger';
|
||||
import { fileExist } from '../config/util';
|
||||
import path from 'path';
|
||||
import DataStore from 'nedb';
|
||||
import { EnvModel } from '../data/env';
|
||||
import { CrontabModel } from '../data/cron';
|
||||
import { DependenceModel } from '../data/dependence';
|
||||
import { AppModel } from '../data/open';
|
||||
import { AuthModel } from '../data/auth';
|
||||
import { sequelize } from '../data';
|
||||
import { fileExist } from '../config/util';
|
||||
import config from '../config';
|
||||
|
||||
export default async () => {
|
||||
try {
|
||||
await sequelize.sync({ alter: true });
|
||||
await CrontabModel.sync();
|
||||
await DependenceModel.sync();
|
||||
await AppModel.sync();
|
||||
await AuthModel.sync();
|
||||
await EnvModel.sync();
|
||||
await sequelize.sync();
|
||||
|
||||
const crondbExist = await fileExist(config.cronDbFile);
|
||||
const dependenceDbExist = await fileExist(config.dependenceDbFile);
|
||||
const envDbExist = await fileExist(config.envDbFile);
|
||||
const appDbExist = await fileExist(config.appDbFile);
|
||||
const authDbExist = await fileExist(config.authDbFile);
|
||||
// try {
|
||||
// const queryInterface = sequelize.getQueryInterface();
|
||||
// await queryInterface.addIndex('Crontabs', ['command'], { unique: true });
|
||||
// await queryInterface.addIndex('Envs', ['name', 'value'], { unique: true });
|
||||
// await queryInterface.addIndex('Apps', ['name'], { unique: true });
|
||||
// } catch (error) { }
|
||||
|
||||
// 2.10-2.11 升级
|
||||
const cronDbFile = path.join(config.rootPath, 'db/crontab.db');
|
||||
const envDbFile = path.join(config.rootPath, 'db/env.db');
|
||||
const appDbFile = path.join(config.rootPath, 'db/app.db');
|
||||
const authDbFile = path.join(config.rootPath, 'db/auth.db');
|
||||
const dependenceDbFile = path.join(config.rootPath, 'db/dependence.db');
|
||||
const crondbExist = await fileExist(cronDbFile);
|
||||
const dependenceDbExist = await fileExist(dependenceDbFile);
|
||||
const envDbExist = await fileExist(envDbFile);
|
||||
const appDbExist = await fileExist(appDbFile);
|
||||
const authDbExist = await fileExist(authDbFile);
|
||||
|
||||
const cronCount = await CrontabModel.count();
|
||||
const dependenceCount = await DependenceModel.count();
|
||||
@@ -26,7 +45,7 @@ export default async () => {
|
||||
const authCount = await AuthModel.count();
|
||||
if (crondbExist && cronCount === 0) {
|
||||
const cronDb = new DataStore({
|
||||
filename: config.cronDbFile,
|
||||
filename: cronDbFile,
|
||||
autoload: true,
|
||||
});
|
||||
cronDb.persistence.compactDatafile();
|
||||
@@ -37,7 +56,7 @@ export default async () => {
|
||||
|
||||
if (dependenceDbExist && dependenceCount === 0) {
|
||||
const dependenceDb = new DataStore({
|
||||
filename: config.dependenceDbFile,
|
||||
filename: dependenceDbFile,
|
||||
autoload: true,
|
||||
});
|
||||
dependenceDb.persistence.compactDatafile();
|
||||
@@ -48,7 +67,7 @@ export default async () => {
|
||||
|
||||
if (envDbExist && envCount === 0) {
|
||||
const envDb = new DataStore({
|
||||
filename: config.envDbFile,
|
||||
filename: envDbFile,
|
||||
autoload: true,
|
||||
});
|
||||
envDb.persistence.compactDatafile();
|
||||
@@ -59,7 +78,7 @@ export default async () => {
|
||||
|
||||
if (appDbExist && appCount === 0) {
|
||||
const appDb = new DataStore({
|
||||
filename: config.appDbFile,
|
||||
filename: appDbFile,
|
||||
autoload: true,
|
||||
});
|
||||
appDb.persistence.compactDatafile();
|
||||
@@ -70,7 +89,7 @@ export default async () => {
|
||||
|
||||
if (authDbExist && authCount === 0) {
|
||||
const authDb = new DataStore({
|
||||
filename: config.authDbFile,
|
||||
filename: authDbFile,
|
||||
autoload: true,
|
||||
});
|
||||
authDb.persistence.compactDatafile();
|
||||
|
||||
+10
-8
@@ -5,13 +5,14 @@ import routes from '../api';
|
||||
import config from '../config';
|
||||
import jwt from 'express-jwt';
|
||||
import fs from 'fs';
|
||||
import { getFileContentByName, getPlatform, getToken } from '../config/util';
|
||||
import { getPlatform, getToken } from '../config/util';
|
||||
import Container from 'typedi';
|
||||
import OpenService from '../services/open';
|
||||
import rewrite from 'express-urlrewrite';
|
||||
import UserService from '../services/user';
|
||||
import handler from 'serve-handler';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import { EnvModel } from '../data/env';
|
||||
|
||||
export default ({ app }: { app: Application }) => {
|
||||
app.enable('trust proxy');
|
||||
@@ -22,7 +23,7 @@ export default ({ app }: { app: Application }) => {
|
||||
next();
|
||||
} else {
|
||||
return handler(req, res, {
|
||||
public: 'dist',
|
||||
public: 'static/dist',
|
||||
rewrites: [{ source: '**', destination: '/index.html' }],
|
||||
});
|
||||
}
|
||||
@@ -68,18 +69,19 @@ export default ({ app }: { app: Application }) => {
|
||||
}
|
||||
}
|
||||
|
||||
const originPath = `${req.baseUrl}${req.path === '/' ? '' : req.path}`;
|
||||
if (
|
||||
!headerToken &&
|
||||
req.path &&
|
||||
config.apiWhiteList.includes(req.path) &&
|
||||
req.path !== '/api/crons/status'
|
||||
originPath &&
|
||||
config.apiWhiteList.includes(originPath) &&
|
||||
originPath !== '/api/crons/status'
|
||||
) {
|
||||
return next();
|
||||
}
|
||||
const remoteAddress = req.socket.remoteAddress;
|
||||
if (
|
||||
remoteAddress === '::ffff:127.0.0.1' &&
|
||||
req.path === '/api/crons/status'
|
||||
originPath === '/api/crons/status'
|
||||
) {
|
||||
return next();
|
||||
}
|
||||
@@ -103,14 +105,14 @@ export default ({ app }: { app: Application }) => {
|
||||
}
|
||||
const userService = Container.get(UserService);
|
||||
const authInfo = await userService.getUserInfo();
|
||||
const envDbContent = getFileContentByName(config.envDbFile);
|
||||
const envCount = await EnvModel.count();
|
||||
|
||||
let isInitialized = true;
|
||||
if (
|
||||
Object.keys(authInfo).length === 2 &&
|
||||
authInfo.username === 'admin' &&
|
||||
authInfo.password === 'admin' &&
|
||||
envDbContent.length === 0
|
||||
envCount === 0
|
||||
) {
|
||||
isInitialized = false;
|
||||
}
|
||||
|
||||
@@ -7,11 +7,16 @@ import EnvService from '../services/env';
|
||||
import _ from 'lodash';
|
||||
import { DependenceModel } from '../data/dependence';
|
||||
import { Op } from 'sequelize';
|
||||
import SystemService from '../services/system';
|
||||
import ScheduleService from '../services/schedule';
|
||||
import config from '../config';
|
||||
|
||||
export default async () => {
|
||||
const cronService = Container.get(CronService);
|
||||
const envService = Container.get(EnvService);
|
||||
const dependenceService = Container.get(DependenceService);
|
||||
const systemService = Container.get(SystemService);
|
||||
const scheduleService = Container.get(ScheduleService);
|
||||
|
||||
// 初始化更新所有任务状态为空闲
|
||||
await CrontabModel.update(
|
||||
@@ -27,7 +32,9 @@ export default async () => {
|
||||
const group = groups[key];
|
||||
const depIds = group.map((x) => x.id);
|
||||
for (const dep of depIds) {
|
||||
await dependenceService.reInstall([dep]);
|
||||
if (dep) {
|
||||
await dependenceService.reInstall([dep]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +45,7 @@ export default async () => {
|
||||
where: {
|
||||
isDisabled: { [Op.ne]: 1 },
|
||||
command: {
|
||||
[Op.or]: [{ [Op.like]: `%ql repo%` }, { [Op.like]: `%$ql raw%` }],
|
||||
[Op.or]: [{ [Op.like]: `%ql repo%` }, { [Op.like]: `%ql raw%` }],
|
||||
},
|
||||
},
|
||||
}).then((docs) => {
|
||||
@@ -50,9 +57,82 @@ export default async () => {
|
||||
}
|
||||
});
|
||||
|
||||
// 更新2.11.3以前的脚本路径
|
||||
CrontabModel.findAll({
|
||||
where: {
|
||||
command: {
|
||||
[Op.or]: [
|
||||
{ [Op.like]: `%\/${config.rootPath}\/scripts\/%` },
|
||||
{ [Op.like]: `%\/${config.rootPath}\/config\/%` },
|
||||
{ [Op.like]: `%\/${config.rootPath}\/log\/%` },
|
||||
{ [Op.like]: `%\/${config.rootPath}\/db\/%` },
|
||||
],
|
||||
},
|
||||
},
|
||||
}).then(async (docs) => {
|
||||
for (let i = 0; i < docs.length; i++) {
|
||||
const doc = docs[i];
|
||||
if (doc) {
|
||||
if (doc.command.includes(`${config.rootPath}/scripts/`)) {
|
||||
await CrontabModel.update(
|
||||
{ command: doc.command.replace(`${config.rootPath}/scripts/`, '') },
|
||||
{ where: { id: doc.id } },
|
||||
);
|
||||
}
|
||||
if (doc.command.includes(`${config.rootPath}/log/`)) {
|
||||
await CrontabModel.update(
|
||||
{
|
||||
command: `${config.rootPath}/data/log/${doc.command.replace(
|
||||
`${config.rootPath}/log/`,
|
||||
'',
|
||||
)}`,
|
||||
},
|
||||
{ where: { id: doc.id } },
|
||||
);
|
||||
}
|
||||
if (doc.command.includes(`${config.rootPath}/config/`)) {
|
||||
await CrontabModel.update(
|
||||
{
|
||||
command: `${config.rootPath}/data/config/${doc.command.replace(
|
||||
`${config.rootPath}/config/`,
|
||||
'',
|
||||
)}`,
|
||||
},
|
||||
{ where: { id: doc.id } },
|
||||
);
|
||||
}
|
||||
if (doc.command.includes(`${config.rootPath}/db/`)) {
|
||||
await CrontabModel.update(
|
||||
{
|
||||
command: `${config.rootPath}/data/db/${doc.command.replace(
|
||||
`${config.rootPath}/db/`,
|
||||
'',
|
||||
)}`,
|
||||
},
|
||||
{ where: { id: doc.id } },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化保存一次ck和定时任务数据
|
||||
await cronService.autosave_crontab();
|
||||
await envService.set_envs();
|
||||
|
||||
// 运行删除日志任务
|
||||
const data = await systemService.getLogRemoveFrequency();
|
||||
if (data && data.info && data.info.frequency) {
|
||||
const cron = {
|
||||
id: data.id,
|
||||
name: '删除日志',
|
||||
command: `ql rmlog ${data.info.frequency}`,
|
||||
};
|
||||
await scheduleService.createIntervalTask(cron, {
|
||||
days: data.info.frequency,
|
||||
runImmediately: true,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function randomSchedule(from: number, to: number) {
|
||||
|
||||
@@ -5,13 +5,15 @@ 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/');
|
||||
const dataPath = path.join(rootPath, 'data/');
|
||||
const configPath = path.join(dataPath, 'config/');
|
||||
const scriptPath = path.join(dataPath, 'scripts/');
|
||||
const logPath = path.join(dataPath, 'log/');
|
||||
const samplePath = path.join(rootPath, 'sample/');
|
||||
const confFile = path.join(configPath, 'config.sh');
|
||||
const authConfigFile = path.join(configPath, 'auth.json');
|
||||
const sampleConfigFile = path.join(samplePath, 'config.sample.sh');
|
||||
const sampleAuthFile = path.join(samplePath, 'auth.sample.json');
|
||||
|
||||
export default async () => {
|
||||
const authFileExist = await fileExist(authConfigFile);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import express from 'express';
|
||||
import { exec } from 'child_process';
|
||||
import Logger from './loaders/logger';
|
||||
import config from './config';
|
||||
|
||||
const app = express();
|
||||
|
||||
app.get('/api/public/panel/log', (req, res) => {
|
||||
exec(
|
||||
'pm2 logs panel --lines 500 --nostream --timestamp',
|
||||
(err, stdout, stderr) => {
|
||||
if (err || stderr) {
|
||||
return res.send({ code: 400, data: err || stderr });
|
||||
}
|
||||
return res.send({ code: 200, data: stdout });
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
app
|
||||
.listen(config.publicPort, async () => {
|
||||
await require('./loaders/sentry').default({ expressApp: app });
|
||||
await require('./loaders/db').default();
|
||||
|
||||
Logger.info(`
|
||||
################################################
|
||||
🛡️ Public listening on port: ${config.publicPort} 🛡️
|
||||
################################################
|
||||
`);
|
||||
})
|
||||
.on('error', (err) => {
|
||||
Logger.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
+97
-33
@@ -5,10 +5,11 @@ import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
||||
import { exec, execSync, spawn } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import cron_parser from 'cron-parser';
|
||||
import { getFileContentByName, concurrentRun } from '../config/util';
|
||||
import { getFileContentByName, concurrentRun, fileExist } from '../config/util';
|
||||
import { promises, existsSync } from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { Op } from 'sequelize';
|
||||
import path from 'path';
|
||||
|
||||
@Service()
|
||||
export default class CronService {
|
||||
@@ -16,7 +17,7 @@ export default class CronService {
|
||||
|
||||
private isSixCron(cron: Crontab) {
|
||||
const { schedule } = cron;
|
||||
if (schedule.split(/ +/).length === 6) {
|
||||
if (schedule?.split(/ +/).length === 6) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -31,12 +32,6 @@ export default class CronService {
|
||||
}
|
||||
|
||||
public async insert(payload: Crontab): Promise<Crontab> {
|
||||
const cron = await CrontabModel.findOne({
|
||||
where: { command: payload.command },
|
||||
});
|
||||
if (cron) {
|
||||
return cron;
|
||||
}
|
||||
return await CrontabModel.create(payload, { returning: true });
|
||||
}
|
||||
|
||||
@@ -165,7 +160,7 @@ export default class CronService {
|
||||
try {
|
||||
const result = await CrontabModel.findAll({
|
||||
where: query,
|
||||
order: [['updatedAt', 'DESC']],
|
||||
order: [['createdAt', 'DESC']],
|
||||
});
|
||||
return result as any;
|
||||
} catch (error) {
|
||||
@@ -200,10 +195,12 @@ export default class CronService {
|
||||
}
|
||||
}
|
||||
const err = await this.killTask(doc.command);
|
||||
if (doc.log_path) {
|
||||
const absolutePath = path.resolve(config.logPath, `${doc.log_path}`);
|
||||
const logFileExist = doc.log_path && (await fileExist(absolutePath));
|
||||
if (logFileExist) {
|
||||
const str = err ? `\n${err}` : '';
|
||||
fs.appendFileSync(
|
||||
`${doc.log_path}`,
|
||||
`${absolutePath}`,
|
||||
`${str}\n## 执行结束... ${new Date()
|
||||
.toLocaleString('zh', { hour12: false })
|
||||
.replace(' 24:', ' 00:')} `,
|
||||
@@ -231,15 +228,18 @@ export default class CronService {
|
||||
const killLogs = [];
|
||||
if (pids && pids.length > 0) {
|
||||
// node 执行脚本时还会有10个子进程,但是ps -ef中不存在,所以截取前三个
|
||||
pids = pids.slice(0, 3);
|
||||
for (const id of pids) {
|
||||
const c = `kill -9 ${id.slice(1)}`;
|
||||
const { stdout, stderr } = await execAsync(c);
|
||||
if (stderr) {
|
||||
killLogs.push(stderr);
|
||||
}
|
||||
if (stdout) {
|
||||
killLogs.push(stdout);
|
||||
try {
|
||||
const { stdout, stderr } = await execAsync(c);
|
||||
if (stderr) {
|
||||
killLogs.push(stderr);
|
||||
}
|
||||
if (stdout) {
|
||||
killLogs.push(stdout);
|
||||
}
|
||||
} catch (error: any) {
|
||||
killLogs.push(error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,6 +258,8 @@ export default class CronService {
|
||||
}
|
||||
|
||||
let { id, command, log_path } = cron;
|
||||
const absolutePath = path.resolve(config.logPath, `${log_path}`);
|
||||
const logFileExist = log_path && (await fileExist(absolutePath));
|
||||
|
||||
this.logger.silly('Running job');
|
||||
this.logger.silly('ID: ' + id);
|
||||
@@ -278,13 +280,13 @@ export default class CronService {
|
||||
{ where: { id } },
|
||||
);
|
||||
cp.stderr.on('data', (data) => {
|
||||
if (log_path) {
|
||||
fs.appendFileSync(`${log_path}`, `${data}`);
|
||||
if (logFileExist) {
|
||||
fs.appendFileSync(`${absolutePath}`, `${data}`);
|
||||
}
|
||||
});
|
||||
cp.on('error', (err) => {
|
||||
if (log_path) {
|
||||
fs.appendFileSync(`${log_path}`, `${JSON.stringify(err)}`);
|
||||
if (logFileExist) {
|
||||
fs.appendFileSync(`${absolutePath}`, `${JSON.stringify(err)}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -325,8 +327,10 @@ export default class CronService {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (doc.log_path) {
|
||||
return getFileContentByName(`${doc.log_path}`);
|
||||
const absolutePath = path.resolve(config.logPath, `${doc.log_path}`);
|
||||
const logFileExist = doc.log_path && (await fileExist(absolutePath));
|
||||
if (logFileExist) {
|
||||
return getFileContentByName(`${absolutePath}`);
|
||||
}
|
||||
const [, commandStr, url] = doc.command.split(/ +/);
|
||||
let logPath = this.getKey(commandStr);
|
||||
@@ -349,14 +353,74 @@ export default class CronService {
|
||||
}
|
||||
}
|
||||
|
||||
private getKey(command: string) {
|
||||
public async logs(id: number) {
|
||||
const doc = await this.getDb({ id });
|
||||
if (!doc) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (doc.log_path) {
|
||||
const relativeDir = path.dirname(`${doc.log_path}`);
|
||||
const dir = path.resolve(config.logPath, relativeDir);
|
||||
if (existsSync(dir)) {
|
||||
let files = await promises.readdir(dir);
|
||||
return files
|
||||
.map((x) => ({
|
||||
filename: x,
|
||||
directory: relativeDir.replace(config.logPath, ''),
|
||||
time: fs.statSync(`${dir}/${x}`).mtime.getTime(),
|
||||
}))
|
||||
.sort((a, b) => b.time - a.time);
|
||||
}
|
||||
}
|
||||
|
||||
const [, commandStr, url] = doc.command.split(/ +/);
|
||||
let logPath = this.getKey(commandStr);
|
||||
const isQlCommand = doc.command.startsWith('ql ');
|
||||
const key =
|
||||
(url && ['repo', 'raw'].includes(commandStr) && this.getKey(url)) ||
|
||||
logPath;
|
||||
if (isQlCommand) {
|
||||
logPath = 'update';
|
||||
}
|
||||
let logDir = `${config.logPath}${logPath}`;
|
||||
if (existsSync(logDir)) {
|
||||
let files = await promises.readdir(logDir);
|
||||
if (isQlCommand) {
|
||||
files = files.filter((x) => x.includes(key));
|
||||
}
|
||||
return files
|
||||
.map((x) => ({
|
||||
filename: x,
|
||||
directory: logPath,
|
||||
time: fs.statSync(`${logDir}/${x}`).mtime.getTime(),
|
||||
}))
|
||||
.sort((a, b) => b.time - a.time);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private getKey(command: string): string {
|
||||
const start =
|
||||
command.lastIndexOf('/') !== -1 ? command.lastIndexOf('/') + 1 : 0;
|
||||
const end =
|
||||
command.lastIndexOf('.') !== -1
|
||||
? command.lastIndexOf('.')
|
||||
: command.length;
|
||||
return command.substring(start, end);
|
||||
|
||||
const tmpStr = command.substring(0, start - 1);
|
||||
let index = 0;
|
||||
if (tmpStr.lastIndexOf('/') !== -1 && tmpStr.startsWith('http')) {
|
||||
index = tmpStr.lastIndexOf('/');
|
||||
} else if (tmpStr.lastIndexOf(':') !== -1 && tmpStr.startsWith('git@')) {
|
||||
index = tmpStr.lastIndexOf(':');
|
||||
}
|
||||
if (index) {
|
||||
return `${tmpStr.substring(index + 1)}_${command.substring(start, end)}`;
|
||||
} else {
|
||||
return command.substring(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
private make_command(tab: Crontab) {
|
||||
@@ -369,7 +433,7 @@ export default class CronService {
|
||||
var crontab_string = '';
|
||||
tabs.forEach((tab) => {
|
||||
const _schedule = tab.schedule && tab.schedule.split(/ +/);
|
||||
if (tab.isDisabled === 1 || _schedule.length !== 5) {
|
||||
if (tab.isDisabled === 1 || _schedule!.length !== 5) {
|
||||
crontab_string += '# ';
|
||||
crontab_string += tab.schedule;
|
||||
crontab_string += ' ';
|
||||
@@ -395,22 +459,22 @@ export default class CronService {
|
||||
|
||||
public import_crontab() {
|
||||
exec('crontab -l', (error, stdout, stderr) => {
|
||||
var lines = stdout.split('\n');
|
||||
var namePrefix = new Date().getTime();
|
||||
const lines = stdout.split('\n');
|
||||
const namePrefix = new Date().getTime();
|
||||
|
||||
lines.reverse().forEach(async (line, index) => {
|
||||
line = line.replace(/\t+/g, ' ');
|
||||
var regex =
|
||||
const regex =
|
||||
/^((\@[a-zA-Z]+\s+)|(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+))/;
|
||||
var command = line.replace(regex, '').trim();
|
||||
var schedule = line.replace(command, '').trim();
|
||||
const command = line.replace(regex, '').trim();
|
||||
const schedule = line.replace(command, '').trim();
|
||||
|
||||
if (
|
||||
command &&
|
||||
schedule &&
|
||||
cron_parser.parseExpression(schedule).hasNext()
|
||||
) {
|
||||
var name = namePrefix + '_' + index;
|
||||
const name = namePrefix + '_' + index;
|
||||
|
||||
const _crontab = await CrontabModel.findOne({
|
||||
where: { command, schedule },
|
||||
|
||||
@@ -80,7 +80,7 @@ export default class DependenceService {
|
||||
const encodeText = encodeURIComponent(searchValue);
|
||||
const reg = {
|
||||
[Op.or]: [
|
||||
{ [Op.like]: `%${searchValue}&` },
|
||||
{ [Op.like]: `%${searchValue}%` },
|
||||
{ [Op.like]: `%${encodeText}%` },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -28,8 +28,12 @@ export default class EnvService {
|
||||
}
|
||||
|
||||
public async insert(payloads: Env[]): Promise<Env[]> {
|
||||
const docs = await EnvModel.bulkCreate(payloads);
|
||||
return docs;
|
||||
const result = [];
|
||||
for (const env of payloads) {
|
||||
const doc = await EnvModel.create(env, { returning: true });
|
||||
result.push(doc);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async update(payload: Env): Promise<Env> {
|
||||
@@ -45,6 +49,7 @@ export default class EnvService {
|
||||
|
||||
public async remove(ids: string[]) {
|
||||
await EnvModel.destroy({ where: { id: ids } });
|
||||
await this.set_envs();
|
||||
}
|
||||
|
||||
public async move(
|
||||
|
||||
+27
-10
@@ -16,6 +16,7 @@ export default class NotificationService {
|
||||
['gotify', this.gotify],
|
||||
['goCqHttpBot', this.goCqHttpBot],
|
||||
['serverChan', this.serverChan],
|
||||
['pushDeer', this.pushDeer],
|
||||
['bark', this.bark],
|
||||
['telegramBot', this.telegramBot],
|
||||
['dingtalkBot', this.dingtalkBot],
|
||||
@@ -90,14 +91,12 @@ export default class NotificationService {
|
||||
private async goCqHttpBot() {
|
||||
const { goCqHttpBotQq, goCqHttpBotToken, goCqHttpBotUrl } = this.params;
|
||||
const res: any = await got
|
||||
.post(
|
||||
`${goCqHttpBotUrl}?access_token=${goCqHttpBotToken}&${goCqHttpBotQq}`,
|
||||
{
|
||||
timeout: this.timeout,
|
||||
retry: 0,
|
||||
json: { message: `${this.title}\n${this.content}` },
|
||||
},
|
||||
)
|
||||
.post(`${goCqHttpBotUrl}?${goCqHttpBotQq}`, {
|
||||
timeout: this.timeout,
|
||||
retry: 0,
|
||||
json: { message: `${this.title}\n${this.content}` },
|
||||
headers: { Authorization: 'Bearer ' + goCqHttpBotToken },
|
||||
})
|
||||
.json();
|
||||
return res.retcode === 0;
|
||||
}
|
||||
@@ -118,8 +117,26 @@ export default class NotificationService {
|
||||
return res.errno === 0 || res.data.errno === 0;
|
||||
}
|
||||
|
||||
private async pushDeer() {
|
||||
const { pushDeerKey } = this.params;
|
||||
const url = `https://api2.pushdeer.com/message/push`;
|
||||
const res: any = await got
|
||||
.post(url, {
|
||||
timeout: this.timeout,
|
||||
retry: 0,
|
||||
body: `pushkey=${pushDeerKey}&text=${encodeURIComponent(
|
||||
this.title,
|
||||
)}&desp=${encodeURIComponent(this.content)}&type=markdown`,
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
})
|
||||
.json();
|
||||
return (
|
||||
res.content.result.length !== undefined && res.content.result.length > 0
|
||||
);
|
||||
}
|
||||
|
||||
private async bark() {
|
||||
let { barkPush, barkSound, barkGroup } = this.params;
|
||||
let { barkPush, barkIcon, barkSound, barkGroup } = this.params;
|
||||
if (!barkPush.startsWith('http') && !barkPush.startsWith('https')) {
|
||||
barkPush = `https://api.day.app/${barkPush}`;
|
||||
}
|
||||
@@ -127,7 +144,7 @@ export default class NotificationService {
|
||||
this.title,
|
||||
)}/${encodeURIComponent(
|
||||
this.content,
|
||||
)}?sound=${barkSound}&group=${barkGroup}`;
|
||||
)}?icon=${barkIcon}?sound=${barkSound}&group=${barkGroup}`;
|
||||
const res: any = await got
|
||||
.get(url, {
|
||||
timeout: this.timeout,
|
||||
|
||||
+18
-4
@@ -24,8 +24,8 @@ export default class OpenService {
|
||||
return { ...doc, tokens: [] };
|
||||
}
|
||||
|
||||
public async insert(payloads: App): Promise<App> {
|
||||
const doc = await AppModel.create(payloads, { returning: true });
|
||||
public async insert(payload: App): Promise<App> {
|
||||
const doc = await AppModel.create(payload, { returning: true });
|
||||
return doc.get({ plain: true }) as App;
|
||||
}
|
||||
|
||||
@@ -108,12 +108,26 @@ export default class OpenService {
|
||||
client_id: string;
|
||||
client_secret: string;
|
||||
}): Promise<any> {
|
||||
const token = uuidV4();
|
||||
let token = uuidV4();
|
||||
const expiration = Math.round(Date.now() / 1000) + 2592000; // 2592000 30天
|
||||
const doc = await AppModel.findOne({ where: { client_id, client_secret } });
|
||||
if (doc) {
|
||||
const timestamp = Math.round(Date.now() / 1000);
|
||||
const invalidTokens = (doc.tokens || []).filter(
|
||||
(x) => x.expiration >= timestamp,
|
||||
);
|
||||
let tokens = invalidTokens;
|
||||
if (invalidTokens.length > 5) {
|
||||
tokens = [
|
||||
...invalidTokens.slice(0, 4),
|
||||
{ ...invalidTokens[4], expiration },
|
||||
];
|
||||
token = invalidTokens[4].value;
|
||||
} else {
|
||||
tokens = [...invalidTokens, { value: token, expiration }];
|
||||
}
|
||||
await AppModel.update(
|
||||
{ tokens: [...(doc.tokens || []), { value: token, expiration }] },
|
||||
{ tokens },
|
||||
{ where: { client_id, client_secret } },
|
||||
);
|
||||
return {
|
||||
|
||||
+99
-21
@@ -3,27 +3,96 @@ import winston from 'winston';
|
||||
import nodeSchedule from 'node-schedule';
|
||||
import { Crontab } from '../data/cron';
|
||||
import { exec } from 'child_process';
|
||||
import {
|
||||
ToadScheduler,
|
||||
SimpleIntervalJob,
|
||||
Task,
|
||||
SimpleIntervalSchedule,
|
||||
} from 'toad-scheduler';
|
||||
|
||||
@Service()
|
||||
export default class ScheduleService {
|
||||
private scheduleStacks = new Map<number, nodeSchedule.Job>();
|
||||
private scheduleStacks = new Map<string, nodeSchedule.Job>();
|
||||
|
||||
private intervalSchedule = new ToadScheduler();
|
||||
|
||||
private maxBuffer = 200 * 1024 * 1024;
|
||||
|
||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||
|
||||
async generateSchedule({ id = 0, command, name, schedule }: Crontab) {
|
||||
async createCronTask({ id = 0, command, name, schedule = '' }: Crontab) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info(
|
||||
'[创建定时任务],任务ID: %s,cron: %s,任务名: %s,执行命令: %s',
|
||||
id,
|
||||
'[创建cron任务],任务ID: %s,cron: %s,任务名: %s,执行命令: %s',
|
||||
_id,
|
||||
schedule,
|
||||
name,
|
||||
command,
|
||||
);
|
||||
|
||||
this.scheduleStacks.set(
|
||||
id,
|
||||
_id,
|
||||
nodeSchedule.scheduleJob(id + '', schedule, async () => {
|
||||
try {
|
||||
exec(command, async (error, stdout, stderr) => {
|
||||
exec(
|
||||
command,
|
||||
{ maxBuffer: this.maxBuffer },
|
||||
async (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
await this.logger.info(
|
||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||
command,
|
||||
new Date().toLocaleString(),
|
||||
error,
|
||||
);
|
||||
}
|
||||
|
||||
if (stderr) {
|
||||
await this.logger.info(
|
||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||
command,
|
||||
new Date().toLocaleString(),
|
||||
stderr,
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
await this.logger.info(
|
||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||
command,
|
||||
new Date().toLocaleString(),
|
||||
error,
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
async cancelCronTask({ id = 0, name }: Crontab) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info('[取消定时任务],任务名:%s', name);
|
||||
this.scheduleStacks.has(_id) && this.scheduleStacks.get(_id)?.cancel();
|
||||
}
|
||||
|
||||
async createIntervalTask(
|
||||
{ id = 0, command, name = '' }: Crontab,
|
||||
schedule: SimpleIntervalSchedule,
|
||||
) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info(
|
||||
'[创建interval任务],任务ID: %s,任务名: %s,执行命令: %s',
|
||||
_id,
|
||||
name,
|
||||
command,
|
||||
);
|
||||
const task = new Task(name, async () => {
|
||||
try {
|
||||
exec(
|
||||
command,
|
||||
{ maxBuffer: this.maxBuffer },
|
||||
async (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
await this.logger.info(
|
||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||
@@ -41,22 +110,31 @@ export default class ScheduleService {
|
||||
stderr,
|
||||
);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
await this.logger.info(
|
||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||
command,
|
||||
new Date().toLocaleString(),
|
||||
error,
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
await this.logger.info(
|
||||
'执行任务%s失败,时间:%s, 错误信息:%j',
|
||||
command,
|
||||
new Date().toLocaleString(),
|
||||
error,
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
});
|
||||
|
||||
const job = new SimpleIntervalJob({ ...schedule }, task, _id);
|
||||
|
||||
this.intervalSchedule.addIntervalJob(job);
|
||||
}
|
||||
|
||||
async cancelSchedule({ id = 0, name }: Crontab) {
|
||||
this.logger.info('[取消定时任务],任务名:%s', name);
|
||||
this.scheduleStacks.has(id) && this.scheduleStacks.get(id)?.cancel();
|
||||
async cancelIntervalTask({ id = 0, name }: Crontab) {
|
||||
const _id = this.formatId(id);
|
||||
this.logger.info('[取消interval任务],任务ID: %s,任务名:%s', _id, name);
|
||||
this.intervalSchedule.removeById(_id);
|
||||
}
|
||||
|
||||
private formatId(id: number): string {
|
||||
return String(id);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-11
@@ -24,7 +24,7 @@ export default class SystemService {
|
||||
|
||||
public async getLogRemoveFrequency() {
|
||||
const doc = await this.getDb({ type: AuthDataType.removeLogFrequency });
|
||||
return (doc && doc.info) || {};
|
||||
return doc || {};
|
||||
}
|
||||
|
||||
private async updateAuthDb(payload: AuthInfo): Promise<any> {
|
||||
@@ -65,11 +65,13 @@ export default class SystemService {
|
||||
id: result.id,
|
||||
name: '删除日志',
|
||||
command: `ql rmlog ${frequency}`,
|
||||
schedule: `5 23 */${frequency} * *`,
|
||||
};
|
||||
await this.scheduleService.cancelSchedule(cron);
|
||||
await this.scheduleService.cancelIntervalTask(cron);
|
||||
if (frequency > 0) {
|
||||
await this.scheduleService.generateSchedule(cron);
|
||||
await this.scheduleService.createIntervalTask(cron, {
|
||||
days: frequency,
|
||||
runImmediately: true,
|
||||
});
|
||||
}
|
||||
return { code: 200, data: { ...cron } };
|
||||
}
|
||||
@@ -85,13 +87,10 @@ export default class SystemService {
|
||||
let lastVersion = '';
|
||||
let lastLog = '';
|
||||
try {
|
||||
const result = await Promise.race([
|
||||
got.get(config.lastVersionFile, { timeout: 1000, retry: 0 }),
|
||||
got.get(`https://ghproxy.com/${config.lastVersionFile}`, {
|
||||
timeout: 5000,
|
||||
retry: 0,
|
||||
}),
|
||||
]);
|
||||
const result = await got.get(config.lastVersionFile, {
|
||||
timeout: 6000,
|
||||
retry: 0,
|
||||
});
|
||||
const lastVersionFileContent = result.body;
|
||||
lastVersion = lastVersionFileContent.match(versionRegx)![1];
|
||||
lastLog = lastVersionFileContent.match(logRegx)
|
||||
@@ -164,4 +163,13 @@ export default class SystemService {
|
||||
|
||||
return { code: 200 };
|
||||
}
|
||||
|
||||
public async notify({ title, content }: { title: string; content: string }) {
|
||||
const isSuccess = await this.notificationService.notify(title, content);
|
||||
if (isSuccess) {
|
||||
return { code: 200, data: '通知发送成功' };
|
||||
} else {
|
||||
return { code: 400, data: '通知发送失败,请检查参数' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-116
@@ -307,14 +307,17 @@ export default class UserService {
|
||||
return (doc && doc.info) || {};
|
||||
}
|
||||
|
||||
public async getLogRemoveFrequency() {
|
||||
const doc = await this.getDb({ type: AuthDataType.removeLogFrequency });
|
||||
return (doc && doc.info) || {};
|
||||
}
|
||||
|
||||
private async updateAuthDb(payload: AuthInfo): Promise<any> {
|
||||
await AuthModel.upsert({ ...payload });
|
||||
const doc = await this.getDb({ type: payload.type });
|
||||
let doc = await AuthModel.findOne({ type: payload.type });
|
||||
if (doc) {
|
||||
const updateResult = await AuthModel.update(payload, {
|
||||
where: { id: doc.id },
|
||||
returning: true,
|
||||
});
|
||||
doc = updateResult[1][0];
|
||||
} else {
|
||||
doc = await AuthModel.create(payload, { returning: true });
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -340,113 +343,4 @@ export default class UserService {
|
||||
return { code: 400, data: '通知发送失败,请检查参数' };
|
||||
}
|
||||
}
|
||||
|
||||
public async updateLogRemoveFrequency(frequency: number) {
|
||||
const result = await this.updateAuthDb({
|
||||
type: AuthDataType.removeLogFrequency,
|
||||
info: { frequency },
|
||||
});
|
||||
const cron = {
|
||||
id: result.id,
|
||||
name: '删除日志',
|
||||
command: `ql rmlog ${frequency}`,
|
||||
schedule: `5 23 */${frequency} * *`,
|
||||
};
|
||||
await this.scheduleService.cancelSchedule(cron);
|
||||
if (frequency > 0) {
|
||||
await this.scheduleService.generateSchedule(cron);
|
||||
}
|
||||
return { code: 200, data: { ...cron } };
|
||||
}
|
||||
|
||||
public async checkUpdate() {
|
||||
try {
|
||||
const versionRegx = /.*export const version = \'(.*)\'\;/;
|
||||
const logRegx = /.*export const changeLog = \`((.*\n.*)+)\`;/;
|
||||
|
||||
const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8');
|
||||
const currentVersion = currentVersionFile.match(versionRegx)![1];
|
||||
|
||||
let lastVersion = '';
|
||||
let lastLog = '';
|
||||
try {
|
||||
const result = await Promise.race([
|
||||
got.get(config.lastVersionFile, { timeout: 1000, retry: 0 }),
|
||||
got.get(`https://ghproxy.com/${config.lastVersionFile}`, {
|
||||
timeout: 5000,
|
||||
retry: 0,
|
||||
}),
|
||||
]);
|
||||
const lastVersionFileContent = result.body;
|
||||
lastVersion = lastVersionFileContent.match(versionRegx)![1];
|
||||
lastLog = lastVersionFileContent.match(logRegx)
|
||||
? lastVersionFileContent.match(logRegx)![1]
|
||||
: '';
|
||||
} catch (error) {}
|
||||
|
||||
return {
|
||||
code: 200,
|
||||
data: {
|
||||
hasNewVersion: this.checkHasNewVersion(currentVersion, lastVersion),
|
||||
lastVersion,
|
||||
lastLog,
|
||||
},
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
code: 400,
|
||||
data: error.message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private checkHasNewVersion(curVersion: string, lastVersion: string) {
|
||||
const curArr = curVersion.split('.').map((x) => parseInt(x, 10));
|
||||
const lastArr = lastVersion.split('.').map((x) => parseInt(x, 10));
|
||||
if (curArr[0] < lastArr[0]) {
|
||||
return true;
|
||||
}
|
||||
if (curArr[0] === lastArr[0] && curArr[1] < lastArr[1]) {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
curArr[0] === lastArr[0] &&
|
||||
curArr[1] === lastArr[1] &&
|
||||
curArr[2] < lastArr[2]
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public async updateSystem() {
|
||||
const cp = spawn('ql -l update', { shell: '/bin/bash' });
|
||||
|
||||
this.sockService.sendMessage({
|
||||
type: 'updateSystemVersion',
|
||||
message: `开始更新系统`,
|
||||
});
|
||||
cp.stdout.on('data', (data) => {
|
||||
this.sockService.sendMessage({
|
||||
type: 'updateSystemVersion',
|
||||
message: data.toString(),
|
||||
});
|
||||
});
|
||||
|
||||
cp.stderr.on('data', (data) => {
|
||||
this.sockService.sendMessage({
|
||||
type: 'updateSystemVersion',
|
||||
message: data.toString(),
|
||||
});
|
||||
});
|
||||
|
||||
cp.on('error', (err) => {
|
||||
this.sockService.sendMessage({
|
||||
type: 'updateSystemVersion',
|
||||
message: JSON.stringify(err),
|
||||
});
|
||||
});
|
||||
|
||||
return { code: 200 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
version: '2'
|
||||
services:
|
||||
web:
|
||||
image: whyour/qinglong:latest
|
||||
volumes:
|
||||
- ./data/config:/ql/config
|
||||
- ./data/log:/ql/log
|
||||
- ./data/db:/ql/db
|
||||
- ./data/scripts:/ql/scripts
|
||||
- ./data/repo:/ql/repo
|
||||
- ./data/raw:/ql/raw
|
||||
ports:
|
||||
- "0.0.0.0:5700:5700"
|
||||
restart: unless-stopped
|
||||
+15
-11
@@ -1,17 +1,21 @@
|
||||
FROM node:lts-alpine3.12
|
||||
FROM node:alpine
|
||||
|
||||
ARG QL_MAINTAINER="whyour"
|
||||
LABEL maintainer="${QL_MAINTAINER}"
|
||||
ARG QL_URL=https://github.com/${QL_MAINTAINER}/qinglong.git
|
||||
ARG QL_BRANCH=master
|
||||
|
||||
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
LANG=zh_CN.UTF-8 \
|
||||
SHELL=/bin/bash \
|
||||
PS1="\u@\h:\w \$ " \
|
||||
QL_DIR=/ql \
|
||||
QL_BRANCH=${QL_BRANCH}
|
||||
|
||||
WORKDIR ${QL_DIR}
|
||||
|
||||
RUN set -x \
|
||||
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
|
||||
&& sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
||||
&& apk update -f \
|
||||
&& apk upgrade \
|
||||
&& apk --no-cache add -f bash \
|
||||
@@ -28,27 +32,27 @@ RUN set -x \
|
||||
jq \
|
||||
openssh \
|
||||
py3-pip \
|
||||
python2 \
|
||||
g++ \
|
||||
make \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone \
|
||||
&& touch ~/.bashrc \
|
||||
&& git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
|
||||
&& git config --global user.email "qinglong@@users.noreply.github.com" \
|
||||
&& git config --global user.name "qinglong" \
|
||||
&& npm install -g pnpm \
|
||||
&& pnpm install -g pm2 \
|
||||
&& pnpm install -g ts-node typescript tslib \
|
||||
&& git clone -b ${QL_BRANCH} ${QL_URL} ${QL_DIR} \
|
||||
&& cd ${QL_DIR} \
|
||||
&& cp -f .env.example .env \
|
||||
&& chmod 777 ${QL_DIR}/shell/*.sh \
|
||||
&& chmod 777 ${QL_DIR}/docker/*.sh \
|
||||
&& npm install -g pnpm \
|
||||
&& pnpm install -g pm2 \
|
||||
&& pnpm install -g ts-node typescript tslib \
|
||||
&& rm -rf /root/.npm \
|
||||
&& pnpm install --prod \
|
||||
&& rm -rf /root/.pnpm-store \
|
||||
&& rm -rf /root/.cache \
|
||||
&& rm -rf /root/.npm \
|
||||
&& git clone -b ${QL_BRANCH} https://github.com/${QL_MAINTAINER}/qinglong-static.git /static \
|
||||
&& cp -rf /static/* ${QL_DIR} \
|
||||
&& mkdir -p ${QL_DIR}/static \
|
||||
&& cp -rf /static/* ${QL_DIR}/static \
|
||||
&& rm -rf /static
|
||||
|
||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
version: '2'
|
||||
services:
|
||||
web:
|
||||
image: whyour/qinglong:latest
|
||||
volumes:
|
||||
- ./data:/ql/data
|
||||
ports:
|
||||
- "0.0.0.0:5700:5700"
|
||||
restart: unless-stopped
|
||||
@@ -20,24 +20,29 @@ echo -e "======================3. 启动nginx========================\n"
|
||||
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||
echo -e "nginx启动成功...\n"
|
||||
|
||||
echo -e "======================4. 启动控制面板========================\n"
|
||||
echo -e "======================4. 启动面板监控========================\n"
|
||||
pm2 delete public &>/dev/null
|
||||
pm2 start $dir_static/build/public.js -n public --source-map-support --time
|
||||
echo -e "监控服务启动成功...\n"
|
||||
|
||||
echo -e "======================5. 启动控制面板========================\n"
|
||||
pm2 delete panel &>/dev/null
|
||||
pm2 start $dir_root/build/app.js -n panel --source-map-support --time
|
||||
pm2 start $dir_static/build/app.js -n panel --source-map-support --time
|
||||
echo -e "控制面板启动成功...\n"
|
||||
|
||||
echo -e "======================5. 启动定时任务========================\n"
|
||||
echo -e "======================6. 启动定时任务========================\n"
|
||||
pm2 delete schedule &>/dev/null
|
||||
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time
|
||||
pm2 start $dir_static/build/schedule.js -n schedule --source-map-support --time
|
||||
echo -e "定时任务启动成功...\n"
|
||||
|
||||
if [[ $AutoStartBot == true ]]; then
|
||||
echo -e "======================6. 启动bot========================\n"
|
||||
echo -e "======================7. 启动bot========================\n"
|
||||
nohup ql bot >>$dir_log/start.log 2>&1 &
|
||||
echo -e "bot后台启动中...\n"
|
||||
fi
|
||||
|
||||
if [[ $EnableExtraShell == true ]]; then
|
||||
echo -e "======================7. 执行自定义脚本========================\n"
|
||||
echo -e "======================8. 执行自定义脚本========================\n"
|
||||
nohup ql extra >>$dir_log/start.log 2>&1 &
|
||||
echo -e "自定义脚本后台执行中...\n"
|
||||
fi
|
||||
|
||||
+12
-1
@@ -2,6 +2,10 @@ upstream api {
|
||||
server 0.0.0.0:5600;
|
||||
}
|
||||
|
||||
upstream public {
|
||||
server 0.0.0.0:5400;
|
||||
}
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default keep-alive;
|
||||
'websocket' upgrade;
|
||||
@@ -9,9 +13,16 @@ map $http_upgrade $connection_upgrade {
|
||||
|
||||
server {
|
||||
listen 5700;
|
||||
root /ql/dist;
|
||||
root /ql/static/dist;
|
||||
ssl_session_timeout 5m;
|
||||
|
||||
location /api/public {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_pass http://public;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
+64
-58
@@ -1,14 +1,17 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "umi dev",
|
||||
"build": "umi build",
|
||||
"build-back": "tsc -p tsconfig.back.json",
|
||||
"start-back": "nodemon",
|
||||
"panel": "npm run build-back && node build/app.js",
|
||||
"schedule": "npm run build-back && node build/schedule.js",
|
||||
"prepare": "umi generate tmp",
|
||||
"start": "concurrently -n w: npm:start:*",
|
||||
"start:front": "umi dev",
|
||||
"start:back": "nodemon",
|
||||
"start:public": "ts-node back/public.ts",
|
||||
"build:front": "umi build",
|
||||
"build:back": "tsc -p tsconfig.back.json",
|
||||
"panel": "npm run build:back && node static/build/app.js",
|
||||
"schedule": "npm run build:back && node static/build/schedule.js",
|
||||
"public": "npm run build:back && node static/build/public.js",
|
||||
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
||||
"prepare": "umi generate tmp",
|
||||
"test": "umi-test",
|
||||
"test:coverage": "umi-test --coverage"
|
||||
},
|
||||
@@ -25,16 +28,16 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@otplib/preset-default": "^12.0.1",
|
||||
"@sentry/node": "^6.16.1",
|
||||
"@sentry/tracing": "^6.16.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"celebrate": "^13.0.3",
|
||||
"chokidar": "^3.5.2",
|
||||
"@sentry/node": "^6.18.1",
|
||||
"@sentry/tracing": "^6.18.1",
|
||||
"body-parser": "^1.19.2",
|
||||
"celebrate": "^15.0.1",
|
||||
"chokidar": "^3.5.3",
|
||||
"cors": "^2.8.5",
|
||||
"cron-parser": "^3.5.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"express-jwt": "^6.0.0",
|
||||
"cron-parser": "^4.2.1",
|
||||
"dotenv": "^16.0.0",
|
||||
"express": "^4.17.3",
|
||||
"express-jwt": "^6.1.1",
|
||||
"express-urlrewrite": "^1.4.0",
|
||||
"got": "^11.8.2",
|
||||
"hpagent": "^0.1.2",
|
||||
@@ -42,53 +45,56 @@
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"lodash": "^4.17.21",
|
||||
"nedb": "^1.8.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-schedule": "^2.0.0",
|
||||
"nodemailer": "^6.7.0",
|
||||
"p-queue": "6.6.2",
|
||||
"node-fetch": "^3.2.1",
|
||||
"node-schedule": "^2.1.0",
|
||||
"nodemailer": "^6.7.2",
|
||||
"p-queue": "7.2.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"sequelize": "^7.0.0-alpha.3",
|
||||
"sequelize": "^6.17.0",
|
||||
"serve-handler": "^6.1.3",
|
||||
"sockjs": "^0.3.21",
|
||||
"sqlite3": "^5.0.2",
|
||||
"typedi": "^0.8.0",
|
||||
"sockjs": "^0.3.24",
|
||||
"sqlite3": "npm:@louislam/sqlite3@^6.0.1",
|
||||
"toad-scheduler": "^1.6.0",
|
||||
"typedi": "^0.10.0",
|
||||
"uuid": "^8.3.2",
|
||||
"winston": "^3.3.3",
|
||||
"yargs": "^17.2.1"
|
||||
"winston": "^3.6.0",
|
||||
"yargs": "^17.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ant-design/icons": "^4.6.2",
|
||||
"@ant-design/pro-layout": "^6.26.0",
|
||||
"@ant-design/icons": "^4.7.0",
|
||||
"@ant-design/pro-layout": "^6.33.1",
|
||||
"@monaco-editor/react": "^4.3.1",
|
||||
"@sentry/react": "^6.16.1",
|
||||
"@sentry/webpack-plugin": "^1.18.3",
|
||||
"@types/cors": "^2.8.10",
|
||||
"@types/express": "^4.17.8",
|
||||
"@types/express-jwt": "^6.0.1",
|
||||
"@types/jsonwebtoken": "^8.5.0",
|
||||
"@types/lodash": "^4.14.170",
|
||||
"@types/nedb": "^1.8.11",
|
||||
"@types/node": "^14.11.2",
|
||||
"@types/node-fetch": "^2.5.8",
|
||||
"@sentry/react": "^6.18.1",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/express-jwt": "^6.0.4",
|
||||
"@types/jsonwebtoken": "^8.5.8",
|
||||
"@types/lodash": "^4.14.179",
|
||||
"@types/nedb": "^1.8.12",
|
||||
"@types/node": "^17.0.21",
|
||||
"@types/node-fetch": "^2.6.1",
|
||||
"@types/node-schedule": "^1.3.2",
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/qrcode.react": "^1.0.1",
|
||||
"@types/react": "^17.0.0",
|
||||
"@types/react-dom": "^17.0.0",
|
||||
"@types/qrcode.react": "^1.0.2",
|
||||
"@types/react": "^17.0.39",
|
||||
"@types/react-dom": "^17.0.13",
|
||||
"@types/serve-handler": "^6.1.1",
|
||||
"@types/sockjs": "^0.3.33",
|
||||
"@types/sockjs-client": "^1.5.1",
|
||||
"@types/uuid": "^8.3.3",
|
||||
"@umijs/plugin-antd": "^0.11.0",
|
||||
"@umijs/test": "^3.3.9",
|
||||
"antd": "^4.17.0-alpha.6",
|
||||
"codemirror": "^5.62.2",
|
||||
"compression-webpack-plugin": "6.1.1",
|
||||
"darkreader": "^4.9.27",
|
||||
"lint-staged": "^10.0.7",
|
||||
"@mapbox/node-pre-gyp": "1.0.8",
|
||||
"nodemon": "^2.0.4",
|
||||
"prettier": "^2.2.0",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@umijs/plugin-antd": "^0.15.0",
|
||||
"@umijs/plugin-esbuild": "^1.4.1",
|
||||
"@umijs/test": "^3.5.21",
|
||||
"ansi-to-react": "^6.1.6",
|
||||
"antd": "^4.18.9",
|
||||
"codemirror": "^5.65.2",
|
||||
"compression-webpack-plugin": "9.2.0",
|
||||
"concurrently": "^7.0.0",
|
||||
"darkreader": "4.9.44",
|
||||
"lint-staged": "^12.3.4",
|
||||
"nodemon": "^2.0.15",
|
||||
"prettier": "^2.5.1",
|
||||
"qiniu": "^7.4.0",
|
||||
"qrcode.react": "^1.0.1",
|
||||
"react": "17.x",
|
||||
"react-codemirror2": "^7.2.1",
|
||||
@@ -97,13 +103,13 @@
|
||||
"react-dnd-html5-backend": "^14.0.0",
|
||||
"react-dom": "17.x",
|
||||
"react-split-pane": "^0.1.92",
|
||||
"sockjs-client": "^1.5.2",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.1.2",
|
||||
"umi": "^3.5.0",
|
||||
"umi-request": "^1.3.5",
|
||||
"sockjs-client": "^1.6.0",
|
||||
"ts-node": "^10.6.0",
|
||||
"typescript": "^4.6.2",
|
||||
"umi": "^3.5.21",
|
||||
"umi-request": "^1.4.0",
|
||||
"vh-check": "^2.0.5",
|
||||
"webpack": "^5.28.0",
|
||||
"webpack": "^5.70.0",
|
||||
"yorkie": "^2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ export PUSH_KEY=""
|
||||
## 2. BARK
|
||||
## 下方填写app提供的设备码,例如:https://api.day.app/123 那么此处的设备码就是123
|
||||
export BARK_PUSH=""
|
||||
## 下方填写推送图标设置,自定义推送图标(需iOS15或以上)
|
||||
export BARK_ICON="http://qn.whyour.cn/logo.png"
|
||||
## 下方填写推送声音设置,例如choo,具体值请在bark-推送铃声-查看所有铃声
|
||||
export BARK_SOUND=""
|
||||
## 下方填写推送消息分组,默认为"QingLong"
|
||||
@@ -123,4 +125,8 @@ export GOTIFY_URL=""
|
||||
export GOTIFY_TOKEN=""
|
||||
export GOTIFY_PRIORITY=0
|
||||
|
||||
## 11. PushDeer
|
||||
## deer_key 填写PushDeer的key
|
||||
export DEER_KEY=""
|
||||
|
||||
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
||||
|
||||
+82
-14
@@ -25,18 +25,25 @@ let GOTIFY_PRIORITY = 0;
|
||||
//gobot_token 填写在go-cqhttp文件设置的访问密钥
|
||||
//gobot_qq 填写推送到个人QQ或者QQ群号
|
||||
//go-cqhttp相关API https://docs.go-cqhttp.org/api
|
||||
let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg
|
||||
let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg
|
||||
let GOBOT_TOKEN = ''; //访问密钥
|
||||
let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群
|
||||
let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群
|
||||
|
||||
// =======================================微信server酱通知设置区域===========================================
|
||||
//此处填你申请的SCKEY.
|
||||
//(环境变量名 PUSH_KEY)
|
||||
let SCKEY = '';
|
||||
|
||||
// =======================================PushDeer通知设置区域===========================================
|
||||
//此处填你申请的PushDeer KEY.
|
||||
//(环境变量名 DEER_KEY)
|
||||
let PUSHDEER_KEY = '';
|
||||
|
||||
// =======================================Bark App通知设置区域===========================================
|
||||
//此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX)
|
||||
let BARK_PUSH = '';
|
||||
//BARK app推送图标,自定义推送图标(需iOS15或以上)
|
||||
let BARK_ICON = 'http://qn.whyour.cn/logo.png';
|
||||
//BARK app推送铃声,铃声列表去APP查看复制填写
|
||||
let BARK_SOUND = '';
|
||||
//BARK app推送消息的分组, 默认为"QingLong"
|
||||
@@ -115,6 +122,10 @@ if (process.env.PUSH_KEY) {
|
||||
SCKEY = process.env.PUSH_KEY;
|
||||
}
|
||||
|
||||
if (process.env.DEER_KEY) {
|
||||
PUSHDEER_KEY = process.env.DEER_KEY;
|
||||
}
|
||||
|
||||
if (process.env.QQ_SKEY) {
|
||||
QQ_SKEY = process.env.QQ_SKEY;
|
||||
}
|
||||
@@ -133,6 +144,9 @@ if (process.env.BARK_PUSH) {
|
||||
} else {
|
||||
BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}`;
|
||||
}
|
||||
if (process.env.BARK_ICON) {
|
||||
BARK_ICON = process.env.BARK_ICON;
|
||||
}
|
||||
if (process.env.BARK_SOUND) {
|
||||
BARK_SOUND = process.env.BARK_SOUND;
|
||||
}
|
||||
@@ -216,8 +230,8 @@ async function sendNotify(
|
||||
qywxBotNotify(text, desp), //企业微信机器人
|
||||
qywxamNotify(text, desp), //企业微信应用消息推送
|
||||
iGotNotify(text, desp, params), //iGot
|
||||
gobotNotify(text, desp),//go-cqhttp
|
||||
gotifyNotify(text, desp),//gotify
|
||||
gobotNotify(text, desp), //go-cqhttp
|
||||
gotifyNotify(text, desp), //gotify
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -226,10 +240,12 @@ function gotifyNotify(text, desp) {
|
||||
if (GOTIFY_URL && GOTIFY_TOKEN) {
|
||||
const options = {
|
||||
url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`,
|
||||
body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(desp)}&priority=${GOTIFY_PRIORITY}`,
|
||||
body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(
|
||||
desp,
|
||||
)}&priority=${GOTIFY_PRIORITY}`,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
},
|
||||
};
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
@@ -261,7 +277,7 @@ function gobotNotify(text, desp, time = 2100) {
|
||||
if (GOBOT_URL) {
|
||||
const options = {
|
||||
url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`,
|
||||
json: {message:`${text}\n${desp}`},
|
||||
json: { message: `${text}\n${desp}` },
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -346,6 +362,52 @@ function serverNotify(text, desp, time = 2100) {
|
||||
});
|
||||
}
|
||||
|
||||
function PushDeerNotify(text, desp, time = 2100) {
|
||||
return new Promise((resolve) => {
|
||||
if (PUSHDEER_KEY) {
|
||||
// PushDeer 建议对消息内容进行 urlencode
|
||||
desp = encodeURI(desp);
|
||||
const options = {
|
||||
url: `https://api2.pushdeer.com/message/push`,
|
||||
body: `pushkey=${PUSHDEER_KEY}&text=${text}&desp=${desp}&type=markdown`,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
timeout,
|
||||
};
|
||||
setTimeout(() => {
|
||||
$.post(options, (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log('发送通知调用API失败!!\n');
|
||||
console.log(err);
|
||||
} else {
|
||||
data = JSON.parse(data);
|
||||
// 通过返回的result的长度来判断是否成功
|
||||
if (
|
||||
data.content.result.length !== undefined &&
|
||||
data.content.result.length > 0
|
||||
) {
|
||||
console.log('PushDeer发送通知消息成功🎉\n');
|
||||
} else {
|
||||
console.log(
|
||||
`PushDeer发送通知消息异常\n${JSON.stringify(data)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp);
|
||||
} finally {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
}, time);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function CoolPush(text, desp) {
|
||||
return new Promise((resolve) => {
|
||||
if (QQ_SKEY) {
|
||||
@@ -429,7 +491,9 @@ function BarkNotify(text, desp, params = {}) {
|
||||
const options = {
|
||||
url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(
|
||||
desp,
|
||||
)}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(params)}`,
|
||||
)}?icon=${BARK_ICON}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(
|
||||
params,
|
||||
)}`,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
@@ -465,9 +529,13 @@ function tgBotNotify(text, desp) {
|
||||
if (TG_BOT_TOKEN && TG_USER_ID) {
|
||||
const options = {
|
||||
url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`,
|
||||
body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`,
|
||||
json: {
|
||||
chat_id: `${TG_USER_ID}`,
|
||||
text: `${text}\n\n${desp}`,
|
||||
disable_web_page_preview: true,
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
timeout,
|
||||
};
|
||||
@@ -726,8 +794,8 @@ function qywxamNotify(text, desp) {
|
||||
if (err) {
|
||||
console.log(
|
||||
'成员ID:' +
|
||||
ChangeUserId(desp) +
|
||||
'企业微信应用消息发送通知消息失败!!\n',
|
||||
ChangeUserId(desp) +
|
||||
'企业微信应用消息发送通知消息失败!!\n',
|
||||
);
|
||||
console.log(err);
|
||||
} else {
|
||||
@@ -735,8 +803,8 @@ function qywxamNotify(text, desp) {
|
||||
if (data.errcode === 0) {
|
||||
console.log(
|
||||
'成员ID:' +
|
||||
ChangeUserId(desp) +
|
||||
'企业微信应用消息发送通知消息成功🎉。\n',
|
||||
ChangeUserId(desp) +
|
||||
'企业微信应用消息发送通知消息成功🎉。\n',
|
||||
);
|
||||
} else {
|
||||
console.log(`${data.errmsg}\n`);
|
||||
|
||||
@@ -35,6 +35,7 @@ push_config = {
|
||||
'BARK_ARCHIVE': '', # bark 推送是否存档
|
||||
'BARK_GROUP': '', # bark 推送分组
|
||||
'BARK_SOUND': '', # bark 推送声音
|
||||
'BARK_ICON': '', # bark 推送图标
|
||||
|
||||
'CONSOLE': True, # 控制台输出
|
||||
|
||||
@@ -59,6 +60,8 @@ push_config = {
|
||||
|
||||
'PUSH_KEY': '', # server 酱的 PUSH_KEY,兼容旧版与 Turbo 版
|
||||
|
||||
'DEER_KEY': '', # PushDeer 的 PUSHDEER_KEY
|
||||
|
||||
'PUSH_PLUS_TOKEN': '', # push+ 微信推送的用户令牌
|
||||
'PUSH_PLUS_USER': '', # push+ 微信推送的群组编码
|
||||
|
||||
@@ -104,6 +107,7 @@ def bark(title: str, content: str) -> None:
|
||||
"BARK_ARCHIVE": "isArchive",
|
||||
"BARK_GROUP": "group",
|
||||
"BARK_SOUND": "sound",
|
||||
"BARK_ICON": "icon",
|
||||
}
|
||||
params = ""
|
||||
for pair in filter(
|
||||
@@ -259,6 +263,24 @@ def serverJ(title: str, content: str) -> None:
|
||||
print(f'serverJ 推送失败!错误码:{response["message"]}')
|
||||
|
||||
|
||||
def pushdeer(title: str, content: str) -> None:
|
||||
"""
|
||||
通过PushDeer 推送消息
|
||||
"""
|
||||
if not push_config.get("DEER_KEY"):
|
||||
print("PushDeer 服务的 DEER_KEY 未设置!!\n取消推送")
|
||||
return
|
||||
print("PushDeer 服务启动")
|
||||
data = {"text": title, "desp": content, "type": "markdown", "pushkey": push_config.get("DEER_KEY")}
|
||||
url = 'https://api2.pushdeer.com/message/push'
|
||||
response = requests.post(url, data=data).json()
|
||||
|
||||
if len(response.get("content").get("result")) > 0:
|
||||
print("PushDeer 推送成功!")
|
||||
else:
|
||||
print("PushDeer 推送失败!错误信息:", response)
|
||||
|
||||
|
||||
def pushplus_bot(title: str, content: str) -> None:
|
||||
"""
|
||||
通过 push+ 推送消息。
|
||||
@@ -503,6 +525,8 @@ if push_config.get("IGOT_PUSH_KEY"):
|
||||
notify_function.append(iGot)
|
||||
if push_config.get("PUSH_KEY"):
|
||||
notify_function.append(serverJ)
|
||||
if push_config.get("DEER_KEY"):
|
||||
notify_function.append(pushdeer)
|
||||
if push_config.get("PUSH_PLUS_TOKEN"):
|
||||
notify_function.append(pushplus_bot)
|
||||
if push_config.get("QMSG_KEY") and push_config.get("QMSG_TYPE"):
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import * as qiniu from 'qiniu';
|
||||
import dotenv from 'dotenv';
|
||||
const envFound = dotenv.config();
|
||||
|
||||
const accessKey = process.env.QINIU_AK;
|
||||
const secretKey = process.env.QINIU_SK;
|
||||
const mac = new qiniu.auth.digest.Mac(accessKey, secretKey);
|
||||
const key = 'version.ts';
|
||||
const options = {
|
||||
scope: `${process.env.QINIU_SCOPE}:${key}`,
|
||||
};
|
||||
const putPolicy = new qiniu.rs.PutPolicy(options);
|
||||
const uploadToken = putPolicy.uploadToken(mac);
|
||||
|
||||
const localFile = 'src/version.ts';
|
||||
const config = new qiniu.conf.Config({ zone: qiniu.zone.Zone_z1 });
|
||||
const formUploader = new qiniu.form_up.FormUploader(config);
|
||||
const putExtra = new qiniu.form_up.PutExtra(
|
||||
'',
|
||||
'',
|
||||
'text/plain; charset=utf-8',
|
||||
);
|
||||
// 文件上传
|
||||
formUploader.putFile(
|
||||
uploadToken,
|
||||
key,
|
||||
localFile,
|
||||
putExtra,
|
||||
function (respErr, respBody, respInfo) {
|
||||
if (respErr) {
|
||||
throw respErr;
|
||||
}
|
||||
if (respInfo.statusCode == 200) {
|
||||
console.log(respBody);
|
||||
} else {
|
||||
console.log(respInfo.statusCode);
|
||||
console.log(respBody);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -176,4 +176,30 @@ update_cron() {
|
||||
fi
|
||||
}
|
||||
|
||||
notify_api() {
|
||||
local title=$1
|
||||
local content=$2
|
||||
local currentTimeStamp=$(date +%s)
|
||||
local api=$(
|
||||
curl -s --noproxy "*" "http://0.0.0.0:5600/api/system/notify?t=$currentTimeStamp" \
|
||||
-X 'PUT' \
|
||||
-H "Accept: application/json" \
|
||||
-H "Authorization: Bearer $token" \
|
||||
-H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" \
|
||||
-H "Content-Type: application/json;charset=UTF-8" \
|
||||
-H "Origin: http://0.0.0.0:5700" \
|
||||
-H "Referer: http://0.0.0.0:5700/crontab" \
|
||||
-H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7" \
|
||||
--data-raw "{\"title\":\"$title\",\"content\":\"$content\"}" \
|
||||
--compressed
|
||||
)
|
||||
code=$(echo $api | jq -r .code)
|
||||
message=$(echo $api | jq -r .message)
|
||||
if [[ $code == 200 ]]; then
|
||||
echo -e "通知发送成功"
|
||||
else
|
||||
echo -e "通知失败(${message})"
|
||||
fi
|
||||
}
|
||||
|
||||
get_token
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## 导入通用变量与函数
|
||||
dir_shell=/ql/shell
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
|
||||
if [[ -z ${BotRepoUrl} ]]; then
|
||||
@@ -22,9 +22,9 @@ if [[ ! -d ${repo_path}/.git ]]; then
|
||||
git_clone_scripts ${url} ${repo_path} "main"
|
||||
fi
|
||||
|
||||
cp -rf "$repo_path/jbot" $dir_root
|
||||
if [[ ! -f "$dir_root/config/bot.json" ]]; then
|
||||
cp -f "$repo_path/config/bot.json" "$dir_root/config"
|
||||
cp -rf "$repo_path/jbot" $dir_data
|
||||
if [[ ! -f "$dir_config/bot.json" ]]; then
|
||||
cp -f "$repo_path/config/bot.json" "$dir_config"
|
||||
fi
|
||||
echo -e "\nbot文件下载成功...\n"
|
||||
|
||||
@@ -32,9 +32,9 @@ echo -e "3、安装python3依赖...\n"
|
||||
if [[ $PipMirror ]]; then
|
||||
pip3 config set global.index-url $PipMirror
|
||||
fi
|
||||
cp -f "$repo_path/jbot/requirements.txt" "$dir_root"
|
||||
cp -f "$repo_path/jbot/requirements.txt" "$dir_data"
|
||||
|
||||
cd $dir_root
|
||||
cd $dir_data
|
||||
cat requirements.txt | while read LREAD
|
||||
do
|
||||
if [[ ! $(pip3 show "${LREAD%%=*}" 2>/dev/null) ]]; then
|
||||
@@ -46,7 +46,7 @@ echo -e "\npython3依赖安装成功...\n"
|
||||
|
||||
echo -e "4、启动bot程序...\n"
|
||||
make_dir $dir_log/bot
|
||||
cd $dir_root
|
||||
cd $dir_data
|
||||
ps -ef | grep "python3 -m jbot" | grep -v grep | awk '{print $1}' | xargs kill -9 2>/dev/null
|
||||
nohup python3 -m jbot >$dir_log/bot/nohup.log 2>&1 &
|
||||
echo -e "bot启动成功...\n"
|
||||
|
||||
+6
-7
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
dir_shell=/ql/shell
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
. $dir_shell/api.sh
|
||||
|
||||
@@ -10,13 +10,11 @@ reset_env() {
|
||||
echo -e "---> 配置文件检测完成\n"
|
||||
|
||||
echo -e "---> 2. 开始安装青龙依赖\n"
|
||||
rm -rf $dir_root/node_modules
|
||||
npm_install_2 $dir_root
|
||||
echo -e "---> 青龙依赖安装完成\n"
|
||||
|
||||
echo -e "---> 3. 开始安装脚本依赖\n"
|
||||
cp -f $dir_sample/package.json $dir_scripts/package.json
|
||||
rm -rf $dir_scripts/node_modules
|
||||
npm_install_2 $dir_scripts
|
||||
echo -e "---> 脚本依赖安装完成\n"
|
||||
}
|
||||
@@ -40,18 +38,18 @@ reload_pm2() {
|
||||
pm2 l &>/dev/null
|
||||
|
||||
pm2 delete panel --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_static/build/app.js -n panel --source-map-support --time &>/dev/null
|
||||
|
||||
pm2 delete schedule --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_static/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
||||
}
|
||||
|
||||
pm2_log() {
|
||||
echo -e "---> pm2日志"
|
||||
local panelOut="/root/.pm2/logs/panel-out.log"
|
||||
local panelError="/root/.pm2/logs/panel-error.log"
|
||||
tail -n 20 "$panelOut"
|
||||
tail -n 20 "$panelError"
|
||||
tail -n 100 "$panelOut"
|
||||
tail -n 100 "$panelError"
|
||||
}
|
||||
|
||||
check_nginx() {
|
||||
@@ -100,6 +98,7 @@ check_pm2() {
|
||||
|
||||
main() {
|
||||
echo -e "=====> 开始检测"
|
||||
pnpm install -g pm2
|
||||
copy_dep
|
||||
check_ql
|
||||
check_nginx
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
const notify = require('/ql/scripts/sendNotify.js');
|
||||
const title = process.argv[2];
|
||||
const content = process.argv[3];
|
||||
|
||||
notify.sendNotify(`${title}`, `${content}`);
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
#author:spark thanks to: https://github.com/sparkssssssss/scripts
|
||||
|
||||
. /ql/config/config.sh
|
||||
title=$(echo $1|sed 's/-/_/g')
|
||||
msg=$(echo -e $2)
|
||||
|
||||
node /ql/shell/notify.js "$title" "$msg"
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
echo -e "开始发布"
|
||||
|
||||
echo -e "切换master分支"
|
||||
git checkout master
|
||||
|
||||
echo -e "合并develop代码"
|
||||
git merge origin/develop
|
||||
|
||||
echo -e "提交master代码"
|
||||
git push
|
||||
|
||||
echo -e "更新cdn文件"
|
||||
ts-node sample/tool.ts
|
||||
|
||||
string=$(cat src/version.ts | grep "version" | egrep "[^\']*" -o | egrep "\d\.*")
|
||||
version="v$string"
|
||||
echo -e "当前版本$version"
|
||||
|
||||
echo -e "删除已经存在的本地tag"
|
||||
git tag -d "$version" &>/dev/null
|
||||
|
||||
echo -e "删除已经存在的远程tag"
|
||||
git push origin :refs/tags/$version &>/dev/null
|
||||
|
||||
echo -e "创建新tag"
|
||||
git tag -a "$version" -m "release $version"
|
||||
|
||||
echo -e "提交tag"
|
||||
git push --tags
|
||||
|
||||
echo -e "完成发布"
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## 导入通用变量与函数
|
||||
dir_shell=/ql/shell
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
|
||||
days=$1
|
||||
|
||||
+38
-22
@@ -1,16 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## 目录
|
||||
dir_root=/ql
|
||||
dir_root=$QL_DIR
|
||||
dir_data=$dir_root/data
|
||||
dir_shell=$dir_root/shell
|
||||
dir_sample=$dir_root/sample
|
||||
dir_config=$dir_root/config
|
||||
dir_scripts=$dir_root/scripts
|
||||
dir_repo=$dir_root/repo
|
||||
dir_raw=$dir_root/raw
|
||||
dir_log=$dir_root/log
|
||||
dir_db=$dir_root/db
|
||||
dir_dep=$dir_root/deps
|
||||
dir_static=$dir_root/static
|
||||
dir_config=$dir_data/config
|
||||
dir_scripts=$dir_data/scripts
|
||||
dir_repo=$dir_data/repo
|
||||
dir_raw=$dir_data/raw
|
||||
dir_log=$dir_data/log
|
||||
dir_db=$dir_data/db
|
||||
dir_dep=$dir_data/deps
|
||||
dir_list_tmp=$dir_log/.tmp
|
||||
dir_code=$dir_log/code
|
||||
dir_update_log=$dir_log/update
|
||||
@@ -60,6 +62,7 @@ original_name=(
|
||||
|
||||
init_env() {
|
||||
export NODE_PATH=/usr/local/bin:/usr/local/pnpm-global/5/node_modules:/usr/local/lib/node_modules
|
||||
export PYTHONUNBUFFERED=1
|
||||
}
|
||||
|
||||
import_config() {
|
||||
@@ -69,6 +72,7 @@ import_config() {
|
||||
command_timeout_time=${CommandTimeoutTime:-"1h"}
|
||||
proxy_url=${ProxyUrl:-""}
|
||||
file_extensions=${RepoFileExtensions:-"js py"}
|
||||
current_branch=${QL_BRANCH}
|
||||
|
||||
if [[ -n "${DefaultCronRule}" ]]; then
|
||||
default_cron="${DefaultCronRule}"
|
||||
@@ -161,6 +165,8 @@ define_cmd() {
|
||||
}
|
||||
|
||||
fix_config() {
|
||||
make_dir $dir_static
|
||||
make_dir $dir_data
|
||||
make_dir $dir_config
|
||||
make_dir $dir_log
|
||||
make_dir $dir_db
|
||||
@@ -221,7 +227,7 @@ fix_config() {
|
||||
|
||||
if [[ -s /etc/nginx/conf.d/default.conf ]]; then
|
||||
echo -e "检测到默认nginx配置文件,清空...\n"
|
||||
cat /dev/null > /etc/nginx/conf.d/default.conf
|
||||
cat /dev/null >/etc/nginx/conf.d/default.conf
|
||||
echo
|
||||
fi
|
||||
|
||||
@@ -236,10 +242,11 @@ fix_config() {
|
||||
cp -fv $file_notify_py_sample $dep_notify_py
|
||||
echo
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
npm_install_sub() {
|
||||
set_proxy
|
||||
if [ $is_termux -eq 1 ]; then
|
||||
npm install --production --no-bin-links --registry=https://registry.npm.taobao.org || npm install --production --no-bin-links
|
||||
elif ! type pnpm &>/dev/null; then
|
||||
@@ -247,6 +254,7 @@ npm_install_sub() {
|
||||
else
|
||||
pnpm install --production --registry=https://registry.npm.taobao.org || pnpm install --production
|
||||
fi
|
||||
unset_proxy
|
||||
}
|
||||
|
||||
npm_install_1() {
|
||||
@@ -299,29 +307,27 @@ git_clone_scripts() {
|
||||
local branch=$3
|
||||
[[ $branch ]] && local part_cmd="-b $branch "
|
||||
echo -e "开始克隆仓库 $url 到 $dir\n"
|
||||
|
||||
|
||||
set_proxy
|
||||
git clone $part_cmd $url $dir
|
||||
unset_proxy
|
||||
|
||||
exit_status=$?
|
||||
unset_proxy
|
||||
}
|
||||
|
||||
git_pull_scripts() {
|
||||
local dir_current=$(pwd)
|
||||
local dir_work="$1"
|
||||
local branch="$2"
|
||||
[[ $branch ]] && local part_cmd="origin/${branch}"
|
||||
cd $dir_work
|
||||
echo -e "开始更新仓库:$dir_work\n"
|
||||
|
||||
set_proxy
|
||||
git fetch --all
|
||||
exit_status=$?
|
||||
git reset --hard $part_cmd
|
||||
git pull
|
||||
git pull &>/dev/null
|
||||
unset_proxy
|
||||
|
||||
reset_branch "$branch"
|
||||
|
||||
cd $dir_current
|
||||
}
|
||||
|
||||
@@ -331,17 +337,27 @@ reset_romote_url() {
|
||||
local url=$2
|
||||
local branch="$3"
|
||||
|
||||
[[ $branch ]] && local part_cmd="origin/${branch}"
|
||||
|
||||
if [[ -d "$dir_work/.git" ]]; then
|
||||
cd $dir_work
|
||||
[[ -f ".git/index.lock" ]] && rm -f .git/index.lock >/dev/null
|
||||
git remote set-url origin $url >/dev/null
|
||||
git reset --hard $part_cmd >/dev/null
|
||||
git remote set-url origin $url &>/dev/null
|
||||
|
||||
local part_cmd=""
|
||||
reset_branch "$branch"
|
||||
cd $dir_current
|
||||
fi
|
||||
}
|
||||
|
||||
reset_branch() {
|
||||
local branch="$1"
|
||||
if [[ $branch ]]; then
|
||||
part_cmd="origin/${branch}"
|
||||
git checkout -B "$branch"
|
||||
git branch --set-upstream-to=$part_cmd $branch
|
||||
fi
|
||||
git reset --hard $part_cmd &>/dev/null
|
||||
}
|
||||
|
||||
random_range() {
|
||||
local beg=$1
|
||||
local end=$2
|
||||
@@ -354,4 +370,4 @@ detect_macos
|
||||
define_cmd
|
||||
fix_config
|
||||
|
||||
import_config $1 > $task_error_log_path 2>&1
|
||||
import_config $1 >$task_error_log_path 2>&1
|
||||
|
||||
+72
-46
@@ -1,20 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
## 导入通用变量与函数
|
||||
dir_shell=/ql/shell
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
. $dir_shell/api.sh
|
||||
|
||||
## 选择python3还是node
|
||||
define_program() {
|
||||
local first_param=$1
|
||||
if [[ $first_param == *.js ]]; then
|
||||
local file_param=$1
|
||||
if [[ $file_param == *.js ]]; then
|
||||
which_program="node"
|
||||
elif [[ $first_param == *.py ]] || [[ $first_param == *.pyc ]]; then
|
||||
elif [[ $file_param == *.py ]] || [[ $file_param == *.pyc ]]; then
|
||||
which_program="python3"
|
||||
elif [[ $first_param == *.sh ]]; then
|
||||
elif [[ $file_param == *.sh ]]; then
|
||||
which_program="bash"
|
||||
elif [[ $first_param == *.ts ]]; then
|
||||
elif [[ $file_param == *.ts ]]; then
|
||||
which_program="ts-node-transpile-only"
|
||||
else
|
||||
which_program=""
|
||||
@@ -76,41 +76,48 @@ run_nohup() {
|
||||
|
||||
## 正常运行单个脚本,$1:传入参数
|
||||
run_normal() {
|
||||
local first_param=$1
|
||||
define_program "$first_param"
|
||||
if [[ $first_param == *.js ]]; then
|
||||
local file_param=$1
|
||||
define_program "$file_param"
|
||||
if [[ $file_param == *.js ]]; then
|
||||
if [[ $# -eq 1 ]]; then
|
||||
random_delay
|
||||
fi
|
||||
fi
|
||||
|
||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||
log_dir_tmp="${first_param##*/}"
|
||||
log_dir_tmp_path="${first_param%%/*}"
|
||||
log_dir_tmp="${file_param##*/}"
|
||||
if [[ $file_param =~ "/" ]]; then
|
||||
if [[ $file_param == /* ]]; then
|
||||
log_dir_tmp_path="${file_param:1}"
|
||||
else
|
||||
log_dir_tmp_path="${file_param}"
|
||||
fi
|
||||
fi
|
||||
log_dir_tmp_path="${log_dir_tmp_path%/*}"
|
||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
||||
log_dir="${log_dir_tmp%.*}"
|
||||
log_path="$log_dir/$log_time.log"
|
||||
cmd="&>> $log_path"
|
||||
cmd="&>> $dir_log/$log_path"
|
||||
[[ "$show_log" == "true" ]] && cmd=""
|
||||
make_dir "$log_dir"
|
||||
make_dir "$dir_log/$log_dir"
|
||||
|
||||
local begin_time=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
local begin_timestamp=$(date "+%s")
|
||||
eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd
|
||||
[[ -f $task_error_log_path ]] && eval cat $task_error_log_path $cmd
|
||||
|
||||
local id=$(cat $list_crontab_user | grep -E "$cmd_task $first_param" | perl -pe "s|.*ID=(.*) $cmd_task $first_param\.*|\1|" | head -1 | awk -F " " '{print $1}')
|
||||
local id=$(cat $list_crontab_user | grep -E "$cmd_task $file_param" | perl -pe "s|.*ID=(.*) $cmd_task $file_param\.*|\1|" | head -1 | awk -F " " '{print $1}')
|
||||
[[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" "$begin_timestamp"
|
||||
eval . $file_task_before "$@" $cmd
|
||||
|
||||
cd $dir_scripts
|
||||
local relative_path="${first_param%/*}"
|
||||
if [[ ! -z ${relative_path} ]] && [[ ${first_param} =~ "/" ]]; then
|
||||
local relative_path="${file_param%/*}"
|
||||
if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then
|
||||
cd ${relative_path}
|
||||
first_param=${first_param/$relative_path\//}
|
||||
file_param=${file_param/$relative_path\//}
|
||||
fi
|
||||
eval timeout -k 10s $command_timeout_time $which_program $first_param $cmd
|
||||
eval timeout -k 10s $command_timeout_time $which_program $file_param $cmd
|
||||
|
||||
eval . $file_task_after "$@" $cmd
|
||||
local end_time=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
@@ -122,7 +129,7 @@ run_normal() {
|
||||
|
||||
## 并发执行时,设定的 RandomDelay 不会生效,即所有任务立即执行
|
||||
run_concurrent() {
|
||||
local first_param="$1"
|
||||
local file_param="$1"
|
||||
local env_param="$2"
|
||||
local num_param=$(echo "$3" | perl -pe "s|.*$2(.*)|\1|")
|
||||
if [[ ! $env_param ]]; then
|
||||
@@ -143,18 +150,26 @@ run_concurrent() {
|
||||
done
|
||||
|
||||
local cookieStr=$(echo ${array_run[*]} | sed 's/\ /\&/g')
|
||||
[[ ! -z $cookieStr ]] && export ${env_param}=${cookieStr}
|
||||
|
||||
define_program "$first_param"
|
||||
define_program "$file_param"
|
||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||
log_dir_tmp="${first_param##*/}"
|
||||
log_dir_tmp_path="${first_param%%/*}"
|
||||
log_dir_tmp="${file_param##*/}"
|
||||
if [[ $file_param =~ "/" ]]; then
|
||||
if [[ $file_param == /* ]]; then
|
||||
log_dir_tmp_path="${file_param:1}"
|
||||
else
|
||||
log_dir_tmp_path="${file_param}"
|
||||
fi
|
||||
fi
|
||||
log_dir_tmp_path="${log_dir_tmp_path%/*}"
|
||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
||||
log_dir="${log_dir_tmp%.*}"
|
||||
log_path="$log_dir/$log_time.log"
|
||||
cmd="&>> $log_path"
|
||||
cmd="&>> $dir_log/$log_path"
|
||||
[[ "$show_log" == "true" ]] && cmd=""
|
||||
make_dir $log_dir
|
||||
make_dir "$dir_log/$log_dir"
|
||||
|
||||
local begin_time=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
local begin_timestamp=$(date "+%s")
|
||||
@@ -162,31 +177,29 @@ run_concurrent() {
|
||||
eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd
|
||||
[[ -f $task_error_log_path ]] && eval cat $task_error_log_path $cmd
|
||||
|
||||
local id=$(cat $list_crontab_user | grep -E "$cmd_task $first_param" | perl -pe "s|.*ID=(.*) $cmd_task $first_param\.*|\1|" | head -1 | awk -F " " '{print $1}')
|
||||
local id=$(cat $list_crontab_user | grep -E "$cmd_task $file_param" | perl -pe "s|.*ID=(.*) $cmd_task $file_param\.*|\1|" | head -1 | awk -F " " '{print $1}')
|
||||
[[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" "$begin_timestamp"
|
||||
eval . $file_task_before "$@" $cmd
|
||||
|
||||
[[ ! -z $cookieStr ]] && export ${env_param}=${cookieStr}
|
||||
|
||||
local envs=$(eval echo "\$${env_param}")
|
||||
local array=($(echo $envs | sed 's/&/ /g'))
|
||||
single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N")
|
||||
|
||||
cd $dir_scripts
|
||||
local relative_path="${first_param%/*}"
|
||||
if [[ ! -z ${relative_path} ]] && [[ ${first_param} =~ "/" ]]; then
|
||||
local relative_path="${file_param%/*}"
|
||||
if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then
|
||||
cd ${relative_path}
|
||||
first_param=${first_param/$relative_path\//}
|
||||
file_param=${file_param/$relative_path\//}
|
||||
fi
|
||||
for i in "${!array[@]}"; do
|
||||
export ${env_param}=${array[i]}
|
||||
single_log_path="$log_dir/${single_log_time}_$((i + 1)).log"
|
||||
timeout -k 10s $command_timeout_time $which_program $first_param &>$single_log_path &
|
||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
|
||||
timeout -k 10s $command_timeout_time $which_program $file_param &>$single_log_path &
|
||||
done
|
||||
|
||||
wait
|
||||
for i in "${!array[@]}"; do
|
||||
single_log_path="$log_dir/${single_log_time}_$((i + 1)).log"
|
||||
single_log_path="$dir_log/$log_dir/${single_log_time}_$((i + 1)).log"
|
||||
eval cat $single_log_path $cmd
|
||||
[[ -f $single_log_path ]] && rm -f $single_log_path
|
||||
done
|
||||
@@ -211,14 +224,21 @@ run_designated() {
|
||||
define_program "$file_param"
|
||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||
log_dir_tmp="${file_param##*/}"
|
||||
log_dir_tmp_path="${file_param%%/*}"
|
||||
if [[ $file_param =~ "/" ]]; then
|
||||
if [[ $file_param == /* ]]; then
|
||||
log_dir_tmp_path="${file_param:1}"
|
||||
else
|
||||
log_dir_tmp_path="${file_param}"
|
||||
fi
|
||||
fi
|
||||
log_dir_tmp_path="${log_dir_tmp_path%/*}"
|
||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
||||
log_dir="${log_dir_tmp%.*}"
|
||||
log_path="$log_dir/$log_time.log"
|
||||
cmd="&>> $log_path"
|
||||
cmd="&>> $dir_log/$log_path"
|
||||
[[ "$show_log" == "true" ]] && cmd=""
|
||||
make_dir $log_dir
|
||||
make_dir "$dir_log/$log_dir"
|
||||
|
||||
local begin_time=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
local begin_timestamp=$(date "+%s")
|
||||
@@ -236,6 +256,7 @@ run_designated() {
|
||||
done
|
||||
|
||||
local cookieStr=$(echo ${array_run[*]} | sed 's/\ /\&/g')
|
||||
[[ ! -z $cookieStr ]] && export ${env_param}=${cookieStr}
|
||||
|
||||
eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd
|
||||
[[ -f $task_error_log_path ]] && eval cat $task_error_log_path $cmd
|
||||
@@ -244,8 +265,6 @@ run_designated() {
|
||||
[[ $id ]] && update_cron "\"$id\"" "0" "$$" "$log_path" "$begin_timestamp"
|
||||
eval . $file_task_before "$@" $cmd
|
||||
|
||||
[[ ! -z $cookieStr ]] && export ${env_param}=${cookieStr}
|
||||
|
||||
cd $dir_scripts
|
||||
local relative_path="${file_param%/*}"
|
||||
if [[ ! -z ${relative_path} ]] && [[ ${file_param} =~ "/" ]]; then
|
||||
@@ -268,14 +287,21 @@ run_else() {
|
||||
define_program "$file_param"
|
||||
log_time=$(date "+%Y-%m-%d-%H-%M-%S")
|
||||
log_dir_tmp="${file_param##*/}"
|
||||
log_dir_tmp_path="${file_param%%/*}"
|
||||
if [[ $file_param =~ "/" ]]; then
|
||||
if [[ $file_param == /* ]]; then
|
||||
log_dir_tmp_path="${file_param:1}"
|
||||
else
|
||||
log_dir_tmp_path="${file_param}"
|
||||
fi
|
||||
fi
|
||||
log_dir_tmp_path="${log_dir_tmp_path%/*}"
|
||||
log_dir_tmp_path="${log_dir_tmp_path##*/}"
|
||||
[[ $log_dir_tmp_path ]] && log_dir_tmp="${log_dir_tmp_path}_${log_dir_tmp}"
|
||||
log_dir="$dir_log/${log_dir_tmp%%.*}"
|
||||
log_dir="${log_dir_tmp%.*}"
|
||||
log_path="$log_dir/$log_time.log"
|
||||
cmd="&>> $log_path"
|
||||
cmd="&>> $dir_log/$log_path"
|
||||
[[ "$show_log" == "true" ]] && cmd=""
|
||||
make_dir $log_dir
|
||||
make_dir "$dir_log/$log_dir"
|
||||
|
||||
local begin_time=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
local begin_timestamp=$(date "+%s")
|
||||
@@ -340,7 +366,7 @@ main() {
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
[[ -f $log_path ]] && cat $log_path
|
||||
[[ -f "$dir_log/$log_path" ]] && cat "$dir_log/$log_path"
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
echo
|
||||
usage
|
||||
|
||||
+56
-32
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
dir_shell=/ql/shell
|
||||
dir_shell=$QL_DIR/shell
|
||||
. $dir_shell/share.sh
|
||||
. $dir_shell/api.sh
|
||||
|
||||
@@ -43,7 +43,7 @@ detect_config_version() {
|
||||
local notify_title="配置文件更新通知"
|
||||
local notify_content="更新日期: $update_date\n用户版本: $ver_config_user\n新的版本: $ver_config_sample\n更新内容: $update_content\n更新说明: 如需使用新功能请对照config.sample.sh,将相关新参数手动增加到你自己的config.sh中,否则请无视本消息。本消息只在该新版本配置文件更新当天发送一次。\n"
|
||||
echo -e $notify_content
|
||||
notify "$notify_title" "$notify_content"
|
||||
notify_api "$notify_title" "$notify_content"
|
||||
[[ $? -eq 0 ]] && echo $ver_config_sample >$send_mark
|
||||
fi
|
||||
else
|
||||
@@ -91,7 +91,7 @@ del_cron() {
|
||||
done
|
||||
if [[ $ids ]]; then
|
||||
result=$(del_cron_api "$ids")
|
||||
notify "$path 删除任务${result}" "$detail"
|
||||
notify_api "$path 删除任务${result}" "$detail"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ add_cron() {
|
||||
fi
|
||||
fi
|
||||
done
|
||||
notify "$path 新增任务" "$detail"
|
||||
notify_api "$path 新增任务" "$detail"
|
||||
}
|
||||
|
||||
## 更新仓库
|
||||
@@ -161,15 +161,7 @@ update_repo() {
|
||||
echo -e "\n更新${repo_path}成功...\n"
|
||||
diff_scripts "$repo_path" "$author" "$path" "$blackword" "$dependence"
|
||||
else
|
||||
echo -e "\n更新${repo_path}失败,重新下载全新仓库...\n"
|
||||
rm -rf ${repo_path}
|
||||
git_clone_scripts "${formatUrl}" ${repo_path} "${branch}"
|
||||
if [[ $exit_status -eq 0 ]]; then
|
||||
echo -e "\n更新${repo_path}成功...\n"
|
||||
diff_scripts "$repo_path" "$author" "$path" "$blackword" "$dependence"
|
||||
else
|
||||
echo -e "\n更新${repo_path}失败,请检查网络...\n"
|
||||
fi
|
||||
echo -e "\n更新${repo_path}失败,请检查网络...\n"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -211,7 +203,7 @@ update_raw() {
|
||||
if [[ -z $cron_id ]]; then
|
||||
result=$(add_cron_api "$cron_line:$cmd_task $filename:$cron_name")
|
||||
echo -e "$result\n"
|
||||
notify "新增任务通知" "\n$result"
|
||||
notify_api "新增任务通知" "\n$result"
|
||||
# update_cron_api "$cron_line:$cmd_task $filename:$cron_name:$cron_id"
|
||||
fi
|
||||
else
|
||||
@@ -252,12 +244,17 @@ update_qinglong() {
|
||||
patch_version
|
||||
|
||||
local no_restart="$1"
|
||||
local all_branch=$(git branch -a)
|
||||
local primary_branch="master"
|
||||
if [[ "${all_branch}" =~ "${current_branch}" ]]; then
|
||||
primary_branch="${current_branch}"
|
||||
fi
|
||||
[[ -f $dir_root/package.json ]] && ql_depend_old=$(cat $dir_root/package.json)
|
||||
reset_romote_url ${dir_root} "https://github.com/whyour/qinglong.git" "master"
|
||||
git_pull_scripts $dir_root "master"
|
||||
reset_romote_url ${dir_root} "https://github.com/whyour/qinglong.git" ${primary_branch}
|
||||
git_pull_scripts $dir_root ${primary_branch}
|
||||
|
||||
if [[ $exit_status -eq 0 ]]; then
|
||||
echo -e "\n更新$dir_root成功...\n"
|
||||
echo -e "\n更新青龙源文件成功...\n"
|
||||
cp -f $file_config_sample $dir_config/config.sample.sh
|
||||
detect_config_version
|
||||
update_depend
|
||||
@@ -265,23 +262,23 @@ update_qinglong() {
|
||||
[[ -f $dir_root/package.json ]] && ql_depend_new=$(cat $dir_root/package.json)
|
||||
[[ "$ql_depend_old" != "$ql_depend_new" ]] && npm_install_2 $dir_root
|
||||
else
|
||||
echo -e "\n更新$dir_root失败,请检查原因...\n"
|
||||
echo -e "\n更新青龙源文件失败,请检查原因...\n"
|
||||
fi
|
||||
|
||||
local url="https://github.com/whyour/qinglong-static.git"
|
||||
if [[ -d ${ql_static_repo}/.git ]]; then
|
||||
reset_romote_url ${ql_static_repo} ${url} "master"
|
||||
git_pull_scripts ${ql_static_repo} "master"
|
||||
reset_romote_url ${ql_static_repo} ${url} ${primary_branch}
|
||||
git_pull_scripts ${ql_static_repo} ${primary_branch}
|
||||
else
|
||||
git_clone_scripts ${url} ${ql_static_repo}
|
||||
git_clone_scripts ${url} ${ql_static_repo} ${primary_branch}
|
||||
fi
|
||||
if [[ $exit_status -eq 0 ]]; then
|
||||
echo -e "\n更新$ql_static_repo成功...\n"
|
||||
local static_version=$(cat /ql/src/version.ts | perl -pe "s|.*\'(.*)\';\.*|\1|" | head -1)
|
||||
echo -e "\n更新青龙静态资源成功...\n"
|
||||
local static_version=$(cat $dir_root/src/version.ts | perl -pe "s|.*\'(.*)\';\.*|\1|" | head -1)
|
||||
echo -e "\n当前版本 $static_version...\n"
|
||||
cd $dir_root
|
||||
rm -rf $dir_root/build && rm -rf $dir_root/dist
|
||||
cp -rf $ql_static_repo/* $dir_root
|
||||
|
||||
rm -rf $dir_static/*
|
||||
cp -rf $ql_static_repo/* $dir_static
|
||||
if [[ $no_restart != "no-restart" ]]; then
|
||||
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
||||
echo -e "重启面板中..."
|
||||
@@ -289,16 +286,16 @@ update_qinglong() {
|
||||
reload_pm2
|
||||
fi
|
||||
else
|
||||
echo -e "\n更新$dir_root失败,请检查原因...\n"
|
||||
echo -e "\n更新青龙静态资源失败,请检查原因...\n"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
patch_version() {
|
||||
if [[ -f "/ql/db/cookie.db" ]]; then
|
||||
if [[ -f "$dir_root/db/cookie.db" ]]; then
|
||||
echo -e "检测到旧的db文件,拷贝为新db...\n"
|
||||
mv /ql/db/cookie.db /ql/db/env.db
|
||||
rm -rf /ql/db/cookie.db
|
||||
mv $dir_root/db/cookie.db $dir_root/db/env.db
|
||||
rm -rf $dir_root/db/cookie.db
|
||||
echo
|
||||
fi
|
||||
|
||||
@@ -307,16 +304,43 @@ patch_version() {
|
||||
fi
|
||||
|
||||
git config --global pull.rebase false
|
||||
|
||||
cp -f $dir_root/.env.example $dir_root/.env
|
||||
|
||||
if [[ -d "$dir_root/db" ]]; then
|
||||
echo -e "检测到旧的db目录,拷贝到data目录...\n"
|
||||
cp -rf $dir_root/config $dir_root/data
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ -d "$dir_root/scripts" ]]; then
|
||||
echo -e "检测到旧的scripts目录,拷贝到data目录...\n"
|
||||
cp -rf $dir_root/scripts $dir_root/data
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ -d "$dir_root/log" ]]; then
|
||||
echo -e "检测到旧的log目录,拷贝到data目录...\n"
|
||||
cp -rf $dir_root/log $dir_root/data
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ -d "$dir_root/config" ]]; then
|
||||
echo -e "检测到旧的config目录,拷贝到data目录...\n"
|
||||
cp -rf $dir_root/config $dir_root/data
|
||||
echo
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
reload_pm2() {
|
||||
pm2 l &>/dev/null
|
||||
|
||||
pm2 delete panel --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_root/build/app.js -n panel --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_static/build/app.js -n panel --source-map-support --time &>/dev/null
|
||||
|
||||
pm2 delete schedule --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_root/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
||||
pm2 start $dir_static/build/schedule.js -n schedule --source-map-support --time &>/dev/null
|
||||
}
|
||||
|
||||
## 对比脚本
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
.react-terminal-wrapper {
|
||||
width: 100%;
|
||||
background: #252a33;
|
||||
color: #eee;
|
||||
font-size: 18px;
|
||||
font-family: 'Fira Mono', Consolas, Menlo, Monaco, 'Courier New', Courier,
|
||||
monospace;
|
||||
border-radius: 4px;
|
||||
padding: 75px 45px 35px;
|
||||
position: relative;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.react-terminal {
|
||||
overflow: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.react-terminal-wrapper.react-terminal-light {
|
||||
background: #ddd;
|
||||
color: #1a1e24;
|
||||
}
|
||||
|
||||
.react-terminal-wrapper:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
background: #d9515d;
|
||||
-webkit-box-shadow: 25px 0 0 #f4c025, 50px 0 0 #3ec930;
|
||||
box-shadow: 25px 0 0 #f4c025, 50px 0 0 #3ec930;
|
||||
}
|
||||
|
||||
.react-terminal-wrapper:after {
|
||||
content: attr(data-terminal-name);
|
||||
position: absolute;
|
||||
color: #a2a2a2;
|
||||
top: 5px;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.react-terminal-wrapper.react-terminal-light:after {
|
||||
color: #d76d77;
|
||||
}
|
||||
|
||||
.react-terminal-line {
|
||||
display: block;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.react-terminal-line:before {
|
||||
content: '';
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
color: #a2a2a2;
|
||||
}
|
||||
|
||||
.react-terminal-light .react-terminal-line:before {
|
||||
color: #d76d77;
|
||||
}
|
||||
|
||||
.react-terminal-input:before {
|
||||
margin-right: 0.75em;
|
||||
content: '$';
|
||||
}
|
||||
|
||||
.react-terminal-input[data-terminal-prompt]:before {
|
||||
content: attr(data-terminal-prompt);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import './index.less';
|
||||
|
||||
export enum LineType {
|
||||
Input,
|
||||
Output,
|
||||
}
|
||||
|
||||
export enum ColorMode {
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
|
||||
export interface Props {
|
||||
name?: string;
|
||||
prompt?: string;
|
||||
colorMode?: ColorMode;
|
||||
lineData: Array<{ type: LineType; value: string | React.ReactNode }>;
|
||||
startingInputValue?: string;
|
||||
}
|
||||
|
||||
const Terminal = ({
|
||||
name,
|
||||
prompt,
|
||||
colorMode,
|
||||
lineData,
|
||||
startingInputValue = '',
|
||||
}: Props) => {
|
||||
const lastLineRef = useRef<null | HTMLElement>(null);
|
||||
|
||||
// An effect that handles scrolling into view the last line of terminal input or output
|
||||
const performScrolldown = useRef(false);
|
||||
useEffect(() => {
|
||||
if (performScrolldown.current) {
|
||||
// skip scrolldown when the component first loads
|
||||
setTimeout(
|
||||
() =>
|
||||
lastLineRef?.current?.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'nearest',
|
||||
}),
|
||||
500,
|
||||
);
|
||||
}
|
||||
performScrolldown.current = true;
|
||||
}, [lineData.length]);
|
||||
|
||||
const renderedLineData = lineData.map((ld, i) => {
|
||||
const classes = ['react-terminal-line'];
|
||||
if (ld.type === LineType.Input) {
|
||||
classes.push('react-terminal-input');
|
||||
}
|
||||
// `lastLineRef` is used to ensure the terminal scrolls into view to the last line; make sure to add the ref to the last
|
||||
if (lineData.length === i + 1) {
|
||||
return (
|
||||
<span className={classes.join(' ')} key={i} ref={lastLineRef}>
|
||||
{ld.value}
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<span className={classes.join(' ')} key={i}>
|
||||
{ld.value}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const classes = ['react-terminal-wrapper'];
|
||||
if (colorMode === ColorMode.Light) {
|
||||
classes.push('react-terminal-light');
|
||||
}
|
||||
return (
|
||||
<div className={classes.join(' ')} data-terminal-name={name}>
|
||||
<div className="react-terminal">{renderedLineData}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Terminal;
|
||||
@@ -25,6 +25,12 @@ export default {
|
||||
hideInMenu: true,
|
||||
component: '@/pages/initialization/index',
|
||||
},
|
||||
{
|
||||
name: '错误',
|
||||
path: '/error',
|
||||
hideInMenu: true,
|
||||
component: '@/pages/error/index',
|
||||
},
|
||||
{
|
||||
path: '/crontab',
|
||||
name: '定时任务',
|
||||
|
||||
+23
-9
@@ -26,6 +26,7 @@
|
||||
.monaco-editor:not(.rename-box) {
|
||||
height: calc(100vh - 128px) !important;
|
||||
height: calc(100vh - var(--vh-offset, 0px) - 128px) !important;
|
||||
|
||||
.view-overlays .current-line {
|
||||
border-width: 0;
|
||||
}
|
||||
@@ -33,6 +34,7 @@
|
||||
|
||||
.rename-box {
|
||||
height: 0;
|
||||
|
||||
.rename-input {
|
||||
height: 0;
|
||||
padding: 0 !important;
|
||||
@@ -43,6 +45,7 @@
|
||||
.ant-pro-grid-content.wide {
|
||||
max-width: unset !important;
|
||||
overflow: auto;
|
||||
|
||||
.ant-pro-page-container-children-content {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
@@ -57,6 +60,7 @@
|
||||
|
||||
.ant-tooltip {
|
||||
max-width: 500px !important;
|
||||
|
||||
.ant-tooltip-inner {
|
||||
word-break: break-all !important;
|
||||
}
|
||||
@@ -72,6 +76,7 @@
|
||||
.log-select {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.ant-page-header-heading-left {
|
||||
min-width: 100px;
|
||||
}
|
||||
@@ -81,6 +86,7 @@
|
||||
.config-select {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.ant-page-header-heading-left {
|
||||
min-width: 100px;
|
||||
}
|
||||
@@ -119,10 +125,13 @@
|
||||
flex-direction: column;
|
||||
height: calc(100vh - 48px);
|
||||
height: calc(100vh - var(--vh-offset, 0px) - 48px);
|
||||
|
||||
.ant-pro-grid-content.wide {
|
||||
flex: 1;
|
||||
|
||||
.ant-pro-grid-content-children {
|
||||
height: calc(100% - 36px);
|
||||
|
||||
> div,
|
||||
.log-container,
|
||||
.react-codemirror2,
|
||||
@@ -197,6 +206,7 @@
|
||||
.Resizer.disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.Resizer.disabled:hover {
|
||||
border-color: transparent;
|
||||
}
|
||||
@@ -209,6 +219,7 @@
|
||||
|
||||
.inline-countdown.ant-statistic {
|
||||
display: inline-block;
|
||||
|
||||
.ant-statistic-content {
|
||||
font-size: 14px;
|
||||
padding: 0 3px;
|
||||
@@ -253,6 +264,7 @@
|
||||
|
||||
.ant-pro-basicLayout-content {
|
||||
margin: 18px;
|
||||
|
||||
.ant-pro-page-container {
|
||||
margin: -18px -18px -18px;
|
||||
}
|
||||
@@ -280,25 +292,27 @@
|
||||
|
||||
.side-menu-user-drop-menu {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding: 4px 0;
|
||||
text-align: left;
|
||||
background-clip: padding-box;
|
||||
outline: none;
|
||||
background-color: #fff;
|
||||
padding: 4px 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 6px 16px -8px rgb(0 0 0 / 8%), 0 9px 28px 0 rgb(0 0 0 / 5%),
|
||||
0 12px 48px 16px rgb(0 0 0 / 3%);
|
||||
.ant-dropdown-menu-item:hover {
|
||||
color: #1890ff;
|
||||
}
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
overflow: auto;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
[data-dark='true'] .side-menu-user-drop-menu {
|
||||
background-color: #373739;
|
||||
}
|
||||
|
||||
.ant-pro-sider-logo {
|
||||
padding: 16px 8px !important;
|
||||
|
||||
h1 {
|
||||
margin-left: 5px !important;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 32px !important;
|
||||
border-radius: 52% !important;
|
||||
|
||||
+11
-22
@@ -24,14 +24,7 @@ import { message, Badge, Modal, Avatar, Dropdown, Menu, Image } from 'antd';
|
||||
// @ts-ignore
|
||||
import SockJS from 'sockjs-client';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
|
||||
Sentry.init({
|
||||
dsn: 'https://3406424fb1dc4813a62d39e844a9d0ac@o1098464.ingest.sentry.io/6122818',
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
release: version,
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
import { init } from '../utils/init';
|
||||
|
||||
export default function (props: any) {
|
||||
const ctx = useCtx();
|
||||
@@ -107,10 +100,6 @@ export default function (props: any) {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
vhCheck();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (systemInfo && systemInfo.isInitialized && !user) {
|
||||
getUser();
|
||||
@@ -128,6 +117,9 @@ export default function (props: any) {
|
||||
}, [theme.theme]);
|
||||
|
||||
useEffect(() => {
|
||||
vhCheck();
|
||||
init();
|
||||
|
||||
const _theme = localStorage.getItem('qinglong_dark_theme') || 'auto';
|
||||
setFetchMethod(window.fetch);
|
||||
if (_theme === 'dark') {
|
||||
@@ -187,7 +179,9 @@ export default function (props: any) {
|
||||
};
|
||||
}, []);
|
||||
|
||||
if (['/login', '/initialization'].includes(props.location.pathname)) {
|
||||
if (
|
||||
['/login', '/initialization', '/error'].includes(props.location.pathname)
|
||||
) {
|
||||
document.title = `${
|
||||
(config.documentTitleMap as any)[props.location.pathname]
|
||||
} - 控制面板`;
|
||||
@@ -198,7 +192,7 @@ export default function (props: any) {
|
||||
history.push('/crontab');
|
||||
}
|
||||
|
||||
if (systemInfo) {
|
||||
if (systemInfo || props.location.pathname === '/error') {
|
||||
return React.Children.map(props.children, (child) => {
|
||||
return React.cloneElement(child, {
|
||||
...ctx,
|
||||
@@ -232,12 +226,7 @@ export default function (props: any) {
|
||||
selectedKeys={[props.location.pathname]}
|
||||
loading={loading}
|
||||
ErrorBoundary={Sentry.ErrorBoundary}
|
||||
logo={
|
||||
<Image
|
||||
preview={false}
|
||||
src="https://pic.imgdb.cn/item/61acd0dd2ab3f51d912b1986.png"
|
||||
/>
|
||||
}
|
||||
logo={<Image preview={false} src="http://qn.whyour.cn/logo.png" />}
|
||||
title={
|
||||
<>
|
||||
<span style={{ fontSize: 16 }}>控制面板</span>
|
||||
@@ -283,7 +272,7 @@ export default function (props: any) {
|
||||
collapsed={collapsed}
|
||||
rightContentRender={() =>
|
||||
ctx.isPhone && (
|
||||
<Dropdown overlay={menu} trigger={['click']}>
|
||||
<Dropdown overlay={menu} placement="bottomRight" trigger={['click']}>
|
||||
<span className="side-menu-user-wrapper">
|
||||
<Avatar shape="square" size="small" icon={<UserOutlined />} />
|
||||
<span style={{ marginLeft: 5 }}>admin</span>
|
||||
@@ -300,7 +289,7 @@ export default function (props: any) {
|
||||
}}
|
||||
>
|
||||
{!collapsed && !ctx.isPhone && (
|
||||
<Dropdown overlay={menu} trigger={['hover']}>
|
||||
<Dropdown overlay={menu} placement="topLeft" trigger={['hover']}>
|
||||
<span className="side-menu-user-wrapper">
|
||||
<Avatar shape="square" size="small" icon={<UserOutlined />} />
|
||||
<span style={{ marginLeft: 5 }}>admin</span>
|
||||
|
||||
@@ -0,0 +1,340 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
Modal,
|
||||
message,
|
||||
Input,
|
||||
Form,
|
||||
Button,
|
||||
Card,
|
||||
Tag,
|
||||
List,
|
||||
Divider,
|
||||
Typography,
|
||||
} from 'antd';
|
||||
import {
|
||||
ClockCircleOutlined,
|
||||
CloseCircleOutlined,
|
||||
FieldTimeOutlined,
|
||||
Loading3QuartersOutlined,
|
||||
FileOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { CrontabStatus } from './index';
|
||||
import { diffTime } from '@/utils/date';
|
||||
import { request } from '@/utils/http';
|
||||
import config from '@/utils/config';
|
||||
import CronLogModal from './logModal';
|
||||
import Editor from '@monaco-editor/react';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const tabList = [
|
||||
{
|
||||
key: 'log',
|
||||
tab: '日志',
|
||||
},
|
||||
{
|
||||
key: 'script',
|
||||
tab: '脚本',
|
||||
},
|
||||
];
|
||||
|
||||
interface LogItem {
|
||||
directory: string;
|
||||
filename: string;
|
||||
}
|
||||
|
||||
const language = navigator.language || navigator.languages[0];
|
||||
|
||||
const CronDetailModal = ({
|
||||
cron = {},
|
||||
handleCancel,
|
||||
visible,
|
||||
theme,
|
||||
isPhone,
|
||||
}: {
|
||||
cron?: any;
|
||||
visible: boolean;
|
||||
handleCancel: (needUpdate?: boolean) => void;
|
||||
theme: string;
|
||||
isPhone: boolean;
|
||||
}) => {
|
||||
const [activeTabKey, setActiveTabKey] = useState('log');
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [logs, setLogs] = useState<LogItem[]>([]);
|
||||
const [log, setLog] = useState('');
|
||||
const [value, setValue] = useState('');
|
||||
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
|
||||
const editorRef = useRef<any>(null);
|
||||
const [scriptInfo, setScriptInfo] = useState<any>({});
|
||||
const [logUrl, setLogUrl] = useState('');
|
||||
const [validTabs, setValidTabs] = useState(tabList);
|
||||
|
||||
const contentList: any = {
|
||||
log: (
|
||||
<List
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
renderItem={(item) => (
|
||||
<List.Item className="log-item" onClick={() => onClickItem(item)}>
|
||||
<FileOutlined style={{ marginRight: 10 }} />
|
||||
{item.directory}/{item.filename}
|
||||
</List.Item>
|
||||
)}
|
||||
/>
|
||||
),
|
||||
script: (
|
||||
<Editor
|
||||
language="shell"
|
||||
theme={theme}
|
||||
value={value}
|
||||
options={{
|
||||
fontSize: 12,
|
||||
lineNumbersMinChars: 3,
|
||||
fontFamily: 'Source Code Pro',
|
||||
folding: false,
|
||||
glyphMargin: false,
|
||||
wordWrap: 'on',
|
||||
}}
|
||||
onMount={(editor) => {
|
||||
editorRef.current = editor;
|
||||
}}
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
const onClickItem = (item: LogItem) => {
|
||||
localStorage.setItem('logCron', cron.id);
|
||||
setLogUrl(`${config.apiPrefix}logs/${item.directory}/${item.filename}`);
|
||||
request
|
||||
.get(`${config.apiPrefix}logs/${item.directory}/${item.filename}`)
|
||||
.then((data) => {
|
||||
setLog(data.data);
|
||||
setIsLogModalVisible(true);
|
||||
});
|
||||
};
|
||||
|
||||
const onTabChange = (key: string) => {
|
||||
setActiveTabKey(key);
|
||||
};
|
||||
|
||||
const getLogs = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.get(`${config.apiPrefix}crons/${cron.id}/logs`)
|
||||
.then((data: any) => {
|
||||
if (data.code === 200) {
|
||||
setLogs(data.data);
|
||||
}
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
const getScript = () => {
|
||||
const cmd = cron.command.split(' ') as string[];
|
||||
if (cmd[0] === 'task') {
|
||||
setValidTabs(validTabs);
|
||||
if (cmd[1].startsWith('/ql/data/scripts')) {
|
||||
cmd[1] = cmd[1].replace('/ql/data/scripts/', '');
|
||||
}
|
||||
|
||||
let [p, s] = cmd[1].split('/');
|
||||
if (!s) {
|
||||
s = p;
|
||||
p = '';
|
||||
}
|
||||
setScriptInfo({ parent: p, filename: s });
|
||||
request
|
||||
.get(`${config.apiPrefix}scripts/${s}?path=${p || ''}`)
|
||||
.then((data) => {
|
||||
setValue(data.data);
|
||||
});
|
||||
} else {
|
||||
setValidTabs([validTabs[0]]);
|
||||
}
|
||||
};
|
||||
|
||||
const saveFile = () => {
|
||||
Modal.confirm({
|
||||
title: `确认保存`,
|
||||
content: (
|
||||
<>
|
||||
确认保存文件
|
||||
<Text style={{ wordBreak: 'break-all' }} type="warning">
|
||||
{scriptInfo.filename}
|
||||
</Text>{' '}
|
||||
,保存后不可恢复
|
||||
</>
|
||||
),
|
||||
onOk() {
|
||||
const content = editorRef.current
|
||||
? editorRef.current.getValue().replace(/\r\n/g, '\n')
|
||||
: value;
|
||||
return new Promise((resolve, reject) => {
|
||||
request
|
||||
.put(`${config.apiPrefix}scripts`, {
|
||||
data: {
|
||||
filename: scriptInfo.filename,
|
||||
path: scriptInfo.parent || '',
|
||||
content,
|
||||
},
|
||||
})
|
||||
.then((_data: any) => {
|
||||
if (_data.code === 200) {
|
||||
setValue(content);
|
||||
message.success(`保存成功`);
|
||||
} else {
|
||||
message.error(_data);
|
||||
}
|
||||
resolve(null);
|
||||
})
|
||||
.catch((e) => reject(e));
|
||||
});
|
||||
},
|
||||
onCancel() {
|
||||
console.log('Cancel');
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (cron && cron.id) {
|
||||
getLogs();
|
||||
getScript();
|
||||
}
|
||||
}, [cron]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
<>
|
||||
<span>{cron.name}</span>
|
||||
{cron.labels?.length > 0 && cron.labels[0] !== '' && (
|
||||
<Divider type="vertical"></Divider>
|
||||
)}
|
||||
{cron.labels?.length > 0 &&
|
||||
cron.labels[0] !== '' &&
|
||||
cron.labels?.map((label: string, i: number) => (
|
||||
<Tag color="blue" style={{ marginRight: 5 }}>
|
||||
{label}
|
||||
</Tag>
|
||||
))}
|
||||
</>
|
||||
}
|
||||
centered
|
||||
visible={visible}
|
||||
forceRender
|
||||
footer={false}
|
||||
onCancel={() => handleCancel()}
|
||||
wrapClassName="crontab-detail"
|
||||
width={!isPhone ? '80vw' : ''}
|
||||
>
|
||||
<div className="card-wrapper">
|
||||
<Card>
|
||||
<div className="cron-detail-info-item">
|
||||
<div className="cron-detail-info-title">任务</div>
|
||||
<div className="cron-detail-info-value">{cron.command}</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card style={{ marginTop: 10 }}>
|
||||
<div className="cron-detail-info-item">
|
||||
<div className="cron-detail-info-title">状态</div>
|
||||
<div className="cron-detail-info-value">
|
||||
{(!cron.isDisabled || cron.status !== CrontabStatus.idle) && (
|
||||
<>
|
||||
{cron.status === CrontabStatus.idle && (
|
||||
<Tag icon={<ClockCircleOutlined />} color="default">
|
||||
空闲中
|
||||
</Tag>
|
||||
)}
|
||||
{cron.status === CrontabStatus.running && (
|
||||
<Tag
|
||||
icon={<Loading3QuartersOutlined spin />}
|
||||
color="processing"
|
||||
>
|
||||
运行中
|
||||
</Tag>
|
||||
)}
|
||||
{cron.status === CrontabStatus.queued && (
|
||||
<Tag icon={<FieldTimeOutlined />} color="default">
|
||||
队列中
|
||||
</Tag>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{cron.isDisabled === 1 && cron.status === CrontabStatus.idle && (
|
||||
<Tag icon={<CloseCircleOutlined />} color="error">
|
||||
已禁用
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cron-detail-info-item">
|
||||
<div className="cron-detail-info-title">定时</div>
|
||||
<div className="cron-detail-info-value">{cron.schedule}</div>
|
||||
</div>
|
||||
<div className="cron-detail-info-item">
|
||||
<div className="cron-detail-info-title">最后运行时间</div>
|
||||
<div className="cron-detail-info-value">
|
||||
{cron.last_execution_time
|
||||
? new Date(cron.last_execution_time * 1000)
|
||||
.toLocaleString(language, {
|
||||
hour12: false,
|
||||
})
|
||||
.replace(' 24:', ' 00:')
|
||||
: '-'}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cron-detail-info-item">
|
||||
<div className="cron-detail-info-title">最后运行时长</div>
|
||||
<div className="cron-detail-info-value">
|
||||
{cron.last_running_time ? diffTime(cron.last_running_time) : '-'}
|
||||
</div>
|
||||
</div>
|
||||
<div className="cron-detail-info-item">
|
||||
<div className="cron-detail-info-title">下次运行时间</div>
|
||||
<div className="cron-detail-info-value">
|
||||
{cron.nextRunTime &&
|
||||
cron.nextRunTime
|
||||
.toLocaleString(language, {
|
||||
hour12: false,
|
||||
})
|
||||
.replace(' 24:', ' 00:')}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<Card
|
||||
style={{ marginTop: 10 }}
|
||||
tabList={validTabs}
|
||||
activeTabKey={activeTabKey}
|
||||
onTabChange={(key) => {
|
||||
onTabChange(key);
|
||||
}}
|
||||
tabBarExtraContent={
|
||||
activeTabKey === 'script' && (
|
||||
<Button
|
||||
type="primary"
|
||||
style={{ marginRight: 8 }}
|
||||
onClick={saveFile}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
>
|
||||
{contentList[activeTabKey]}
|
||||
</Card>
|
||||
</div>
|
||||
<CronLogModal
|
||||
visible={isLogModalVisible}
|
||||
handleCancel={() => {
|
||||
setIsLogModalVisible(false);
|
||||
}}
|
||||
cron={cron}
|
||||
data={log}
|
||||
logUrl={logUrl}
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default CronDetailModal;
|
||||
@@ -1,3 +1,87 @@
|
||||
.ant-table-pagination.ant-pagination {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.cron {
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.crontab-detail {
|
||||
.card-wrapper {
|
||||
height: 80vh;
|
||||
height: calc(80vh - var(--vh-offset, 0px));
|
||||
|
||||
.ant-card:last-child {
|
||||
.ant-card-body {
|
||||
height: calc(80vh - 238px);
|
||||
height: calc(80vh - var(--vh-offset, 0px) - 238px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-modal-body {
|
||||
background: #eee;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.ant-card-body {
|
||||
padding: 18px;
|
||||
}
|
||||
.ant-card-head {
|
||||
padding: 0 18px;
|
||||
}
|
||||
|
||||
.ant-card:first-child {
|
||||
max-height: 66px;
|
||||
overflow: auto;
|
||||
|
||||
.ant-card-body {
|
||||
min-width: 600px;
|
||||
}
|
||||
|
||||
.cron-detail-info-item {
|
||||
display: flex;
|
||||
|
||||
.cron-detail-info-title {
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.cron-detail-info-value {
|
||||
flex: 1;
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-card:nth-child(2) {
|
||||
overflow-x: auto;
|
||||
|
||||
.ant-card-body {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
min-width: 600px;
|
||||
}
|
||||
}
|
||||
|
||||
.cron-detail-info-item {
|
||||
flex: auto;
|
||||
|
||||
.cron-detail-info-title {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.cron-detail-info-value {
|
||||
margin-top: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.log-item {
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
background: #fafafa;
|
||||
}
|
||||
}
|
||||
|
||||
+95
-49
@@ -31,25 +31,26 @@ import {
|
||||
import config from '@/utils/config';
|
||||
import { PageContainer } from '@ant-design/pro-layout';
|
||||
import { request } from '@/utils/http';
|
||||
import CronModal,{ CronLabelModal } from './modal';
|
||||
import CronModal, { CronLabelModal } from './modal';
|
||||
import CronLogModal from './logModal';
|
||||
import CronDetailModal from './detail';
|
||||
import cron_parser from 'cron-parser';
|
||||
import { diffTime } from '@/utils/date';
|
||||
import { getTableScroll } from '@/utils/index';
|
||||
import { history } from 'umi';
|
||||
import './index.less';
|
||||
|
||||
const { Text } = Typography;
|
||||
const { Text, Paragraph } = Typography;
|
||||
const { Search } = Input;
|
||||
|
||||
enum CrontabStatus {
|
||||
export enum CrontabStatus {
|
||||
'running',
|
||||
'idle',
|
||||
'disabled',
|
||||
'queued',
|
||||
}
|
||||
|
||||
const CrontabSort: any = { 0: 0, 3: 1, 1: 2, 4: 3 };
|
||||
const CrontabSort: any = { 0: 0, 5: 1, 3: 2, 1: 3, 4: 4 };
|
||||
|
||||
enum OperationName {
|
||||
'启用',
|
||||
@@ -69,7 +70,7 @@ enum OperationPath {
|
||||
'unpin',
|
||||
}
|
||||
|
||||
const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
const Crontab = ({ headerStyle, isPhone, theme }: any) => {
|
||||
const columns: any = [
|
||||
{
|
||||
title: '任务名',
|
||||
@@ -84,7 +85,32 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
goToScriptManager(record);
|
||||
}}
|
||||
>
|
||||
{record.name || record._id}{' '}
|
||||
{record.labels?.length > 0 && record.labels[0] !== '' ? (
|
||||
<Popover
|
||||
placement="right"
|
||||
trigger={isPhone ? 'click' : 'hover'}
|
||||
content={
|
||||
<div>
|
||||
{record.labels?.map((label: string) => (
|
||||
<Tag
|
||||
color="blue"
|
||||
style={{ cursor: 'point' }}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setSearchValue(`label:${label}`);
|
||||
}}
|
||||
>
|
||||
<a>{label}</a>
|
||||
</Tag>
|
||||
))}
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{record.name || '-'}
|
||||
</Popover>
|
||||
) : (
|
||||
record.name || '-'
|
||||
)}
|
||||
{record.isPinned ? (
|
||||
<span>
|
||||
<PushpinOutlined />
|
||||
@@ -93,23 +119,6 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
''
|
||||
)}
|
||||
</a>
|
||||
<span>
|
||||
{record.labels?.length > 0 && record.labels[0] !== '' ?
|
||||
<Popover placement='right' trigger={isPhone ? 'click' : 'hover'}
|
||||
content={
|
||||
<div>
|
||||
{record.labels?.map((label: string, i: number) => (
|
||||
<Tag color="blue"
|
||||
onClick={() => { onSearch(`label:${label}`) }}>
|
||||
{label}
|
||||
</Tag>
|
||||
))}
|
||||
</div>
|
||||
}>
|
||||
<Tag color="blue">{record.labels[0]}</Tag>
|
||||
</Popover>
|
||||
: ''}
|
||||
</span>
|
||||
</>
|
||||
),
|
||||
sorter: {
|
||||
@@ -125,16 +134,16 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
align: 'center' as const,
|
||||
render: (text: string, record: any) => {
|
||||
return (
|
||||
<span
|
||||
<Paragraph
|
||||
style={{
|
||||
textAlign: 'left',
|
||||
width: '100%',
|
||||
display: 'inline-block',
|
||||
wordBreak: 'break-all',
|
||||
marginBottom: 0,
|
||||
textAlign: 'left',
|
||||
}}
|
||||
ellipsis={{ tooltip: text, rows: 2 }}
|
||||
>
|
||||
{text}
|
||||
</span>
|
||||
</Paragraph>
|
||||
);
|
||||
},
|
||||
sorter: {
|
||||
@@ -307,7 +316,8 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
{record.status === CrontabStatus.idle && (
|
||||
<Tooltip title={isPc ? '运行' : ''}>
|
||||
<a
|
||||
onClick={() => {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
runCron(record, index);
|
||||
}}
|
||||
>
|
||||
@@ -318,7 +328,8 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
{record.status !== CrontabStatus.idle && (
|
||||
<Tooltip title={isPc ? '停止' : ''}>
|
||||
<a
|
||||
onClick={() => {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
stopCron(record, index);
|
||||
}}
|
||||
>
|
||||
@@ -328,7 +339,8 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
)}
|
||||
<Tooltip title={isPc ? '日志' : ''}>
|
||||
<a
|
||||
onClick={() => {
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setLogCron({ ...record, timestamp: Date.now() });
|
||||
}}
|
||||
>
|
||||
@@ -345,7 +357,7 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
const [value, setValue] = useState<any[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||
const [isLabelModalVisible, setisLabelModalVisible] = useState(false);
|
||||
const [isLabelModalVisible, setIsLabelModalVisible] = useState(false);
|
||||
const [editedCron, setEditedCron] = useState();
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [isLogModalVisible, setIsLogModalVisible] = useState(false);
|
||||
@@ -354,12 +366,15 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [tableScrollHeight, setTableScrollHeight] = useState<number>();
|
||||
const [isDetailModalVisible, setIsDetailModalVisible] = useState(false);
|
||||
const [detailCron, setDetailCron] = useState<any>();
|
||||
const [searchValue, setSearchValue] = useState('');
|
||||
|
||||
const goToScriptManager = (record: any) => {
|
||||
const cmd = record.command.split(' ') as string[];
|
||||
if (cmd[0] === 'task') {
|
||||
if (cmd[1].startsWith('/ql/scripts')) {
|
||||
cmd[1] = cmd[1].replace('/ql/scripts/', '');
|
||||
if (cmd[1].startsWith('/ql/data/scripts')) {
|
||||
cmd[1] = cmd[1].replace('/ql/data/scripts/', '');
|
||||
}
|
||||
|
||||
let [p, s] = cmd[1].split('/');
|
||||
@@ -381,14 +396,19 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
setValue(
|
||||
data.data
|
||||
.sort((a: any, b: any) => {
|
||||
const sortA = a.isDisabled ? 4 : a.status;
|
||||
const sortB = b.isDisabled ? 4 : b.status;
|
||||
a.isPinned = a.isPinned ? a.isPinned : 0;
|
||||
b.isPinned = b.isPinned ? b.isPinned : 0;
|
||||
if (a.isPinned === b.isPinned) {
|
||||
return CrontabSort[sortA] - CrontabSort[sortB];
|
||||
}
|
||||
return b.isPinned - a.isPinned;
|
||||
const sortA =
|
||||
a.isPinned && a.status !== 0
|
||||
? 5
|
||||
: a.isDisabled && a.status !== 0
|
||||
? 4
|
||||
: a.status;
|
||||
const sortB =
|
||||
b.isPinned && b.status !== 0
|
||||
? 5
|
||||
: b.isDisabled && b.status !== 0
|
||||
? 4
|
||||
: b.status;
|
||||
return CrontabSort[sortA] - CrontabSort[sortB];
|
||||
})
|
||||
.map((x) => {
|
||||
return {
|
||||
@@ -612,10 +632,16 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
index: number;
|
||||
}> = ({ record, index }) => (
|
||||
<Dropdown
|
||||
arrow
|
||||
arrow={{ pointAtCenter: true }}
|
||||
placement="bottomRight"
|
||||
trigger={['click']}
|
||||
overlay={
|
||||
<Menu onClick={({ key }) => action(key, record, index)}>
|
||||
<Menu
|
||||
onClick={({ key, domEvent }) => {
|
||||
domEvent.stopPropagation();
|
||||
action(key, record, index);
|
||||
}}
|
||||
>
|
||||
<Menu.Item key="edit" icon={<EditOutlined />}>
|
||||
编辑
|
||||
</Menu.Item>
|
||||
@@ -645,7 +671,7 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
</Menu>
|
||||
}
|
||||
>
|
||||
<a>
|
||||
<a onClick={(e) => e.stopPropagation()}>
|
||||
<EllipsisOutlined />
|
||||
</a>
|
||||
</Dropdown>
|
||||
@@ -790,7 +816,7 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
};
|
||||
|
||||
const getRowClassName = (record: any, index: number) => {
|
||||
return record.isPinned ? 'pinned-cron' : '';
|
||||
return record.isPinned ? 'pinned-cron cron' : 'cron';
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -820,7 +846,10 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
placeholder="请输入名称或者关键词"
|
||||
style={{ width: 'auto' }}
|
||||
enterButton
|
||||
allowClear
|
||||
loading={loading}
|
||||
value={searchValue}
|
||||
onChange={(e) => setSearchValue(e.target.value)}
|
||||
onSearch={onSearch}
|
||||
/>,
|
||||
<Button key="2" type="primary" onClick={() => addCron()}>
|
||||
@@ -876,7 +905,7 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => setisLabelModalVisible(true)}
|
||||
onClick={() => setIsLabelModalVisible(true)}
|
||||
style={{ marginLeft: 8, marginRight: 8 }}
|
||||
>
|
||||
批量修改标签
|
||||
@@ -898,7 +927,15 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
defaultPageSize: 20,
|
||||
showTotal: (total: number, range: number[]) =>
|
||||
`第 ${range[0]}-${range[1]} 条/总共 ${total} 条`,
|
||||
pageSizeOptions: [10, 20, 50, 100, 200, 500, 1000],
|
||||
pageSizeOptions: [20, 100, 500, 1000] as any,
|
||||
}}
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: (event) => {
|
||||
setDetailCron(record);
|
||||
setIsDetailModalVisible(true);
|
||||
},
|
||||
};
|
||||
}}
|
||||
dataSource={value}
|
||||
rowKey="id"
|
||||
@@ -924,13 +961,22 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
|
||||
<CronLabelModal
|
||||
visible={isLabelModalVisible}
|
||||
handleCancel={(needUpdate?: boolean) => {
|
||||
setisLabelModalVisible(false);
|
||||
setIsLabelModalVisible(false);
|
||||
if (needUpdate) {
|
||||
getCrons();
|
||||
}
|
||||
}}
|
||||
ids={selectedRowIds}
|
||||
/>
|
||||
<CronDetailModal
|
||||
visible={isDetailModalVisible}
|
||||
handleCancel={() => {
|
||||
setIsDetailModalVisible(false);
|
||||
}}
|
||||
cron={detailCron}
|
||||
theme={theme}
|
||||
isPhone={isPhone}
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -20,10 +20,14 @@ const CronLogModal = ({
|
||||
cron,
|
||||
handleCancel,
|
||||
visible,
|
||||
data,
|
||||
logUrl,
|
||||
}: {
|
||||
cron?: any;
|
||||
visible: boolean;
|
||||
handleCancel: () => void;
|
||||
data?: string;
|
||||
logUrl?: string;
|
||||
}) => {
|
||||
const [value, setValue] = useState<string>('启动中...');
|
||||
const [loading, setLoading] = useState<any>(true);
|
||||
@@ -36,7 +40,7 @@ const CronLogModal = ({
|
||||
setLoading(true);
|
||||
}
|
||||
request
|
||||
.get(`${config.apiPrefix}crons/${cron.id}/log`)
|
||||
.get(logUrl ? logUrl : `${config.apiPrefix}crons/${cron.id}/log`)
|
||||
.then((data: any) => {
|
||||
if (localStorage.getItem('logCron') === String(cron.id)) {
|
||||
const log = data.data as string;
|
||||
@@ -90,17 +94,23 @@ const CronLogModal = ({
|
||||
return (
|
||||
<>
|
||||
{(executing || loading) && <Loading3QuartersOutlined spin />}
|
||||
{!executing && <CheckCircleOutlined />}
|
||||
{!executing && !loading && <CheckCircleOutlined />}
|
||||
<span style={{ marginLeft: 5 }}>日志-{cron && cron.name}</span>{' '}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (cron) {
|
||||
if (cron && cron.id && visible) {
|
||||
getCronLog(true);
|
||||
}
|
||||
}, [cron]);
|
||||
}, [cron, visible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
setValue(data);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
useEffect(() => {
|
||||
setIsPhone(document.body.clientWidth < 768);
|
||||
|
||||
Vendored
+17
-10
@@ -27,7 +27,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
import './index.less';
|
||||
import { getTableScroll } from '@/utils/index';
|
||||
|
||||
const { Text } = Typography;
|
||||
const { Text, Paragraph } = Typography;
|
||||
const { Search } = Input;
|
||||
|
||||
enum Status {
|
||||
@@ -119,18 +119,18 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
||||
key: 'value',
|
||||
align: 'center' as const,
|
||||
width: '35%',
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
render: (text: string, record: any) => {
|
||||
return (
|
||||
<Tooltip
|
||||
placement="topLeft"
|
||||
title={text}
|
||||
trigger={['hover', 'click']}
|
||||
<Paragraph
|
||||
style={{
|
||||
wordBreak: 'break-all',
|
||||
marginBottom: 0,
|
||||
textAlign: 'left',
|
||||
}}
|
||||
ellipsis={{ tooltip: text, rows: 2 }}
|
||||
>
|
||||
<span>{text}</span>
|
||||
</Tooltip>
|
||||
{text}
|
||||
</Paragraph>
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -149,6 +149,13 @@ const Env = ({ headerStyle, isPhone, theme }: any) => {
|
||||
ellipsis: {
|
||||
showTitle: false,
|
||||
},
|
||||
sorter: {
|
||||
compare: (a: any, b: any) => {
|
||||
const updatedAtA = new Date(a.updatedAt || a.timestamp).getTime();
|
||||
const updatedAtB = new Date(b.updatedAt || b.timestamp).getTime();
|
||||
return updatedAtA - updatedAtB;
|
||||
},
|
||||
},
|
||||
render: (text: string, record: any) => {
|
||||
const language = navigator.language || navigator.languages[0];
|
||||
const time = record.updatedAt || record.timestamp;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
.error-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
|
||||
.react-terminal-wrapper {
|
||||
max-width: 90%;
|
||||
height: calc(100vh - 80px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import config from '@/utils/config';
|
||||
import { request } from '@/utils/http';
|
||||
import Terminal, { ColorMode, LineType } from '../../components/terminal';
|
||||
import { PageLoading } from '@ant-design/pro-layout';
|
||||
import { history } from 'umi';
|
||||
import Ansi from 'ansi-to-react';
|
||||
import './index.less';
|
||||
|
||||
const Error = ({ user, theme }: any) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [data, setData] = useState('暂无日志');
|
||||
|
||||
const getLog = () => {
|
||||
setLoading(true);
|
||||
request
|
||||
.get(`${config.apiPrefix}public/panel/log`)
|
||||
.then((data: any) => {
|
||||
setData(data.data);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (user) {
|
||||
history.push('/crontab');
|
||||
}
|
||||
}, [user]);
|
||||
|
||||
useEffect(() => {
|
||||
getLog();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="error-wrapper">
|
||||
{loading ? (
|
||||
<PageLoading />
|
||||
) : (
|
||||
<Terminal
|
||||
name="服务错误"
|
||||
colorMode={theme === 'vs-dark' ? ColorMode.Dark : ColorMode.Light}
|
||||
lineData={[
|
||||
{ type: LineType.Input, value: 'pm2 logs panel' },
|
||||
{
|
||||
type: LineType.Output,
|
||||
value: (
|
||||
<pre>
|
||||
<Ansi>{data}</Ansi>
|
||||
</pre>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Error;
|
||||
@@ -233,7 +233,7 @@ const Initialization = () => {
|
||||
<img
|
||||
alt="logo"
|
||||
className={styles.logo}
|
||||
src="https://pic.imgdb.cn/item/61acd0dd2ab3f51d912b1986.png"
|
||||
src="http://qn.whyour.cn/logo.png"
|
||||
/>
|
||||
<span className={styles.title}>初始化配置</span>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
&-scroller {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
border-right: 1px dashed #f0f0f0;
|
||||
padding-top: 6px;
|
||||
}
|
||||
}
|
||||
@@ -22,3 +21,10 @@
|
||||
display: flex;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:global {
|
||||
.Pane.vertical.Pane1 {
|
||||
padding-right: 5px;
|
||||
border-right: 1px dashed #f0f0f0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ const Log = ({ headerStyle, isPhone, theme }: any) => {
|
||||
value={select}
|
||||
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
||||
treeData={data}
|
||||
placeholder="请选择日志文件"
|
||||
placeholder="请选择日志"
|
||||
showSearch
|
||||
onSelect={onSelect}
|
||||
/>,
|
||||
@@ -147,6 +147,8 @@ const Log = ({ headerStyle, isPhone, theme }: any) => {
|
||||
<Input.Search
|
||||
className={styles['left-tree-search']}
|
||||
onChange={onSearch}
|
||||
placeholder="请输入日志名"
|
||||
allowClear
|
||||
></Input.Search>
|
||||
<div className={styles['left-tree-scroller']} ref={treeDom}>
|
||||
<Tree
|
||||
|
||||
@@ -135,7 +135,7 @@ const Login = () => {
|
||||
<img
|
||||
alt="logo"
|
||||
className={styles.logo}
|
||||
src="https://pic.imgdb.cn/item/61acd0dd2ab3f51d912b1986.png"
|
||||
src="http://qn.whyour.cn/logo.png"
|
||||
/>
|
||||
<span className={styles.title}>
|
||||
{twoFactor ? '两步验证' : config.siteName}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
&-scroller {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
border-right: 1px dashed #f0f0f0;
|
||||
padding-top: 6px;
|
||||
}
|
||||
}
|
||||
@@ -22,3 +21,10 @@
|
||||
display: flex;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:global {
|
||||
.Pane.vertical.Pane1 {
|
||||
padding-right: 5px;
|
||||
border-right: 1px dashed #f0f0f0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ const Script = ({ headerStyle, isPhone, theme, socketMessage }: any) => {
|
||||
value={select}
|
||||
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
||||
treeData={data}
|
||||
placeholder="请选择脚本文件"
|
||||
placeholder="请选择脚本"
|
||||
showSearch
|
||||
onSelect={onSelect}
|
||||
/>,
|
||||
@@ -477,6 +477,8 @@ const Script = ({ headerStyle, isPhone, theme, socketMessage }: any) => {
|
||||
<Input.Search
|
||||
className={styles['left-tree-search']}
|
||||
onChange={onSearch}
|
||||
placeholder="请输入脚本名"
|
||||
allowClear
|
||||
></Input.Search>
|
||||
<div className={styles['left-tree-scroller']} ref={treeDom}>
|
||||
<Tree
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Typography, Input, Form, Button, message } from 'antd';
|
||||
import styles from './index.less';
|
||||
|
||||
const { Link } = Typography;
|
||||
|
||||
const About = () => {
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<img
|
||||
alt="logo"
|
||||
style={{ width: 140, marginRight: 20 }}
|
||||
src="http://qn.whyour.cn/logo.png"
|
||||
/>
|
||||
<div className={styles.right}>
|
||||
<span className={styles.title}>青龙</span>
|
||||
<span className={styles.desc}>
|
||||
支持python3、javaScript、shell、typescript 的定时任务管理面板(A timed
|
||||
task management panel that supports typescript, javaScript, python3,
|
||||
and shell.)
|
||||
</span>
|
||||
<div>
|
||||
<Link
|
||||
href="https://github.com/whyour/qinglong"
|
||||
target="_blank"
|
||||
style={{ marginRight: 15 }}
|
||||
>
|
||||
Github
|
||||
</Link>
|
||||
<Link
|
||||
href="https://t.me/jiao_long"
|
||||
target="_blank"
|
||||
style={{ marginRight: 15 }}
|
||||
>
|
||||
Telegram频道
|
||||
</Link>
|
||||
<Link
|
||||
href="https://github.com/whyour/qinglong/issues"
|
||||
target="_blank"
|
||||
>
|
||||
提交BUG
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default About;
|
||||
@@ -177,7 +177,7 @@ const CheckUpdate = ({ socketMessage }: any) => {
|
||||
秒后自动刷新
|
||||
</span>
|
||||
),
|
||||
duration: 10,
|
||||
duration: 30,
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
.container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
max-width: 800px;
|
||||
margin: 20px auto;
|
||||
|
||||
.right {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-direction: column;
|
||||
|
||||
.title {
|
||||
font-size: 25px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.desc {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-13
@@ -12,6 +12,7 @@ import {
|
||||
Modal,
|
||||
message,
|
||||
Typography,
|
||||
Input,
|
||||
} from 'antd';
|
||||
import config from '@/utils/config';
|
||||
import { PageContainer } from '@ant-design/pro-layout';
|
||||
@@ -32,7 +33,7 @@ import SecuritySettings from './security';
|
||||
import LoginLog from './loginLog';
|
||||
import NotificationSetting from './notification';
|
||||
import CheckUpdate from './checkUpdate';
|
||||
import { useForm } from 'antd/lib/form/Form';
|
||||
import About from './about';
|
||||
|
||||
const { Text } = Typography;
|
||||
const optionsWithDisabled = [
|
||||
@@ -119,12 +120,12 @@ const Setting = ({
|
||||
const [theme, setTheme] = useState(defaultDarken);
|
||||
const [dataSource, setDataSource] = useState<any[]>([]);
|
||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||
const [editedApp, setEditedApp] = useState();
|
||||
const [editedApp, setEditedApp] = useState<any>();
|
||||
const [tabActiveKey, setTabActiveKey] = useState('security');
|
||||
const [loginLogData, setLoginLogData] = useState<any[]>([]);
|
||||
const [notificationInfo, setNotificationInfo] = useState<any>();
|
||||
const [logRemoveFrequency, setLogRemoveFrequency] = useState<number>();
|
||||
const [form] = useForm();
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const themeChange = (e: any) => {
|
||||
setTheme(e.target.value);
|
||||
@@ -142,6 +143,7 @@ const Setting = ({
|
||||
};
|
||||
|
||||
const addApp = () => {
|
||||
setEditedApp(null);
|
||||
setIsModalVisible(true);
|
||||
};
|
||||
|
||||
@@ -273,8 +275,10 @@ const Setting = ({
|
||||
request
|
||||
.get(`${config.apiPrefix}system/log/remove`)
|
||||
.then((data: any) => {
|
||||
setLogRemoveFrequency(data.data.frequency);
|
||||
form.setFieldsValue({ frequency: data.data.frequency });
|
||||
if (data.data.info) {
|
||||
const { frequency } = data.data.info;
|
||||
setLogRemoveFrequency(frequency);
|
||||
}
|
||||
})
|
||||
.catch((error: any) => {
|
||||
console.log(error);
|
||||
@@ -367,20 +371,28 @@ const Setting = ({
|
||||
name="frequency"
|
||||
tooltip="每x天自动删除x天以前的日志"
|
||||
>
|
||||
<InputNumber
|
||||
addonBefore="每"
|
||||
addonAfter="天"
|
||||
style={{ width: 150 }}
|
||||
min={0}
|
||||
onBlur={updateRemoveLogFrequency}
|
||||
onChange={(value) => setLogRemoveFrequency(value)}
|
||||
/>
|
||||
<Input.Group compact>
|
||||
<InputNumber
|
||||
addonBefore="每"
|
||||
addonAfter="天"
|
||||
style={{ width: 150 }}
|
||||
min={0}
|
||||
value={logRemoveFrequency}
|
||||
onChange={(value) => setLogRemoveFrequency(value)}
|
||||
/>
|
||||
<Button type="primary" onClick={updateRemoveLogFrequency}>
|
||||
确认
|
||||
</Button>
|
||||
</Input.Group>
|
||||
</Form.Item>
|
||||
<Form.Item label="检查更新" name="update">
|
||||
<CheckUpdate socketMessage={socketMessage} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane tab="关于" key="about">
|
||||
<About />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<AppModal
|
||||
visible={isModalVisible}
|
||||
|
||||
@@ -77,6 +77,7 @@ export default {
|
||||
{ value: 'gotify', label: 'Gotify' },
|
||||
{ value: 'goCqHttpBot', label: 'GoCqHttpBot' },
|
||||
{ value: 'serverChan', label: 'Server酱' },
|
||||
{ value: 'pushDeer', label: 'PushDeer' },
|
||||
{ value: 'bark', label: 'Bark' },
|
||||
{ value: 'telegramBot', label: 'Telegram机器人' },
|
||||
{ value: 'dingtalkBot', label: '钉钉机器人' },
|
||||
@@ -113,12 +114,23 @@ export default {
|
||||
serverChan: [
|
||||
{ label: 'serverChanKey', tip: 'Server酱SENDKEY', required: true },
|
||||
],
|
||||
pushDeer: [
|
||||
{
|
||||
label: 'pushDeerKey',
|
||||
tip: 'PushDeer的Key,https://github.com/easychen/pushdeer',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
bark: [
|
||||
{
|
||||
label: 'barkPush',
|
||||
tip: 'Bark的信息IP/设备码,例如:https://api.day.app/XXXXXXXX',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: 'barkIcon',
|
||||
tip: 'BARK推送图标,自定义推送图标 (需iOS15或以上才能显示)',
|
||||
},
|
||||
{ label: 'barkSound', tip: 'BARK推送铃声,铃声列表去APP查看复制填写' },
|
||||
{ label: 'barkGroup', tip: 'BARK推送消息的分组, 默认为qinglong' },
|
||||
],
|
||||
@@ -207,6 +219,7 @@ export default {
|
||||
'/diff': '对比工具',
|
||||
'/log': '任务日志',
|
||||
'/setting': '系统设置',
|
||||
'/error': '错误日志',
|
||||
},
|
||||
dependenceTypes: ['nodejs', 'python3', 'linux'],
|
||||
};
|
||||
|
||||
+2
-2
@@ -14,8 +14,8 @@ const errorHandler = function (error: any) {
|
||||
? error.data.message || error.data
|
||||
: error.response.statusText;
|
||||
const responseStatus = error.response.status;
|
||||
if (responseStatus === 502) {
|
||||
message.error('服务异常,请手动执行ql check检查服务状态');
|
||||
if ([502, 504].includes(responseStatus)) {
|
||||
history.push('/error');
|
||||
} else if (responseStatus === 401) {
|
||||
if (history.location.pathname !== '/login') {
|
||||
message.error('登录已过期,请重新登录');
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import * as Sentry from '@sentry/react';
|
||||
import { Integrations } from '@sentry/tracing';
|
||||
import { loader } from '@monaco-editor/react';
|
||||
import { version } from '../version';
|
||||
|
||||
export function init() {
|
||||
// sentry监控 init
|
||||
Sentry.init({
|
||||
dsn: 'https://3406424fb1dc4813a62d39e844a9d0ac@o1098464.ingest.sentry.io/6122818',
|
||||
integrations: [new Integrations.BrowserTracing()],
|
||||
release: version,
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
|
||||
// monaco 编辑器配置cdn和locale
|
||||
loader.config({
|
||||
paths: {
|
||||
vs: 'https://cdn.staticfile.org/monaco-editor/0.32.1/min/vs',
|
||||
},
|
||||
'vs/nls': {
|
||||
availableLanguages: {
|
||||
'*': 'zh-cn',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
+9
-12
@@ -1,13 +1,10 @@
|
||||
export const version = '2.11.1';
|
||||
export const changeLogLink = 'https://t.me/jiao_long/261';
|
||||
export const changeLog = `2.11.1 版本说明
|
||||
1. 修复openapi获取token,token认证
|
||||
2. 修复环境变量搜索,排序,更新
|
||||
3. 修复重置应用秘钥
|
||||
4. 修复环境变量更新时间显示
|
||||
5. 修复定时默认任务排序
|
||||
6. task支持运行pyc文件,感谢https://github.com/chiupam
|
||||
6. 移除ghproxy默认代理,增加新配置ProxyUrl,支持http或者socks代理。例如 http://127.0.0.1:7890
|
||||
7. 更换JavaScript cdn地址
|
||||
8. 其他bug修复
|
||||
export const version = '2.12.1';
|
||||
export const changeLogLink = 'https://t.me/jiao_long/289';
|
||||
export const changeLog = `2.12.1 版本说明
|
||||
1. 修复定时任务详情获取日志
|
||||
2. 修复系统通知pushdeer
|
||||
3. 修复python pushDeer推送,感谢 https://github.com/chen310 PR
|
||||
3. nodejs telegram推送改为json方式,感谢 https://github.com/kan3Git PR
|
||||
4. 修复日志目录拼接规则
|
||||
5. 其他bug修复
|
||||
`;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
"module": "commonjs",
|
||||
"pretty": true,
|
||||
"sourceMap": true,
|
||||
"outDir": "./build",
|
||||
"outDir": "./static/build",
|
||||
"allowJs": true,
|
||||
"noEmit": false,
|
||||
"esModuleInterop": true
|
||||
|
||||
+2
-1
@@ -32,7 +32,8 @@
|
||||
"node_modules",
|
||||
"lib",
|
||||
"es",
|
||||
"dist",
|
||||
"static",
|
||||
"data",
|
||||
"typings",
|
||||
"**/__test__",
|
||||
"test",
|
||||
|
||||
Reference in New Issue
Block a user