mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-11 19:05:20 +08:00
Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c17dbdc28f | ||
|
|
da8089aaac | ||
|
|
c063619763 | ||
|
|
73f8f3c5fa | ||
|
|
494ccb3c08 | ||
|
|
399728b433 | ||
|
|
52a1de5063 | ||
|
|
18f27a9a69 | ||
|
|
07951964a1 | ||
|
|
a1f888af59 | ||
|
|
f7472b6e74 | ||
|
|
a7baeba755 | ||
|
|
e4f733320d | ||
|
|
55c92dc320 | ||
|
|
50769c43dd | ||
|
|
0587644a6b | ||
|
|
87b934aafe | ||
|
|
7a92e7c6ab | ||
|
|
1d8403c0ec | ||
|
|
ef9e38f167 | ||
|
|
c9bd053fbd | ||
|
|
57939391b9 | ||
|
|
394e96bbf8 | ||
|
|
47c194c1f4 | ||
|
|
7d65d96ebd | ||
|
|
224000b63b | ||
|
|
1c18668bad | ||
|
|
f94582b68d | ||
|
|
eb1c00984c | ||
|
|
1a185f5682 |
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
GRPC_PORT=5500
|
GRPC_PORT=5500
|
||||||
BACK_PORT=5600
|
BACK_PORT=5700
|
||||||
PORT=5700
|
|
||||||
|
|
||||||
LOG_LEVEL='info'
|
LOG_LEVEL='info'
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
name: Bug Fixer
|
||||||
|
description: Fix this issue following our error handling pattern.
|
||||||
|
---
|
||||||
+28
-20
@@ -20,12 +20,14 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: wearerequired/git-mirror-action@v1
|
- uses: Yikun/hub-mirror-action@master
|
||||||
env:
|
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.GITLAB_SSH_PK }}
|
|
||||||
with:
|
with:
|
||||||
source-repo: https://github.com/whyour/qinglong.git
|
src: github/whyour
|
||||||
destination-repo: git@gitlab.com:whyour/qinglong.git
|
dst: gitlab/whyour
|
||||||
|
dst_key: ${{ secrets.GITLAB_SSH_PK }}
|
||||||
|
dst_token: ${{ secrets.GITLAB_TOKEN }}
|
||||||
|
static_list: "qinglong"
|
||||||
|
force_update: true
|
||||||
|
|
||||||
code_gitee:
|
code_gitee:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -33,12 +35,14 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: wearerequired/git-mirror-action@v1
|
- uses: Yikun/hub-mirror-action@master
|
||||||
env:
|
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.GITLAB_SSH_PK }}
|
|
||||||
with:
|
with:
|
||||||
source-repo: https://github.com/whyour/qinglong.git
|
src: github/whyour
|
||||||
destination-repo: git@gitee.com:whyour/qinglong.git
|
dst: gitee/whyour
|
||||||
|
dst_key: ${{ secrets.GITLAB_SSH_PK }}
|
||||||
|
dst_token: ${{ secrets.GITEE_TOKEN }}
|
||||||
|
static_list: "qinglong"
|
||||||
|
force_update: true
|
||||||
|
|
||||||
build-static:
|
build-static:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -82,12 +86,14 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: wearerequired/git-mirror-action@v1
|
- uses: Yikun/hub-mirror-action@master
|
||||||
env:
|
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.GITLAB_SSH_PK }}
|
|
||||||
with:
|
with:
|
||||||
source-repo: https://github.com/whyour/qinglong-static.git
|
src: github/whyour
|
||||||
destination-repo: git@gitlab.com:whyour/qinglong-static.git
|
dst: gitlab/whyour
|
||||||
|
dst_key: ${{ secrets.GITLAB_SSH_PK }}
|
||||||
|
dst_token: ${{ secrets.GITLAB_TOKEN }}
|
||||||
|
static_list: "qinglong-static"
|
||||||
|
force_update: true
|
||||||
|
|
||||||
static_gitee:
|
static_gitee:
|
||||||
needs: build-static
|
needs: build-static
|
||||||
@@ -96,12 +102,14 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: wearerequired/git-mirror-action@v1
|
- uses: Yikun/hub-mirror-action@master
|
||||||
env:
|
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.GITLAB_SSH_PK }}
|
|
||||||
with:
|
with:
|
||||||
source-repo: https://github.com/whyour/qinglong-static.git
|
src: github/whyour
|
||||||
destination-repo: git@gitee.com:whyour/qinglong-static.git
|
dst: gitee/whyour
|
||||||
|
dst_key: ${{ secrets.GITLAB_SSH_PK }}
|
||||||
|
dst_token: ${{ secrets.GITEE_TOKEN }}
|
||||||
|
static_list: "qinglong-static"
|
||||||
|
force_update: true
|
||||||
|
|
||||||
build:
|
build:
|
||||||
needs: build-static
|
needs: build-static
|
||||||
@@ -17,7 +17,7 @@ export default defineConfig({
|
|||||||
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
|
publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
|
||||||
proxy: {
|
proxy: {
|
||||||
[`${baseUrl}api`]: {
|
[`${baseUrl}api`]: {
|
||||||
target: 'http://127.0.0.1:5600/',
|
target: 'http://127.0.0.1:5700/',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
ws: true,
|
ws: true,
|
||||||
pathRewrite: { [`^${baseUrl}api`]: '/api' },
|
pathRewrite: { [`^${baseUrl}api`]: '/api' },
|
||||||
|
|||||||
+2
-2
@@ -18,9 +18,9 @@ Timed task management platform supporting Python3, JavaScript, Shell, Typescript
|
|||||||
[docker-image-size-image]: https://img.shields.io/docker/image-size/whyour/qinglong?style=flat
|
[docker-image-size-image]: https://img.shields.io/docker/image-size/whyour/qinglong?style=flat
|
||||||
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
||||||
|
|
||||||
[Demo](http://demo.ninesix.cc:4433/) / [Issues](https://github.com/whyour/qinglong/issues) / [Telegram Channel](https://t.me/jiao_long) / [Buy Me a Coffee](https://www.buymeacoffee.com/qinglong)
|
[Demo](http://demo.qinglong.online:4433/) / [Issues](https://github.com/whyour/qinglong/issues) / [Telegram Channel](https://t.me/jiao_long) / [Buy Me a Coffee](https://www.buymeacoffee.com/qinglong)
|
||||||
|
|
||||||
[演示](http://demo.ninesix.cc:4433/) / [反馈](https://github.com/whyour/qinglong/issues) / [Telegram 频道](https://t.me/jiao_long) / [打赏开发者](https://user-images.githubusercontent.com/22700758/244744295-29cd0cd1-c8bb-4ea1-adf6-29bd390ad4dd.jpg)
|
[演示](http://demo.qinglong.online:4433/) / [反馈](https://github.com/whyour/qinglong/issues) / [Telegram 频道](https://t.me/jiao_long) / [打赏开发者](https://user-images.githubusercontent.com/22700758/244744295-29cd0cd1-c8bb-4ea1-adf6-29bd390ad4dd.jpg)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -20,9 +20,9 @@ Timed task management platform supporting Python3, JavaScript, Shell, Typescript
|
|||||||
[docker-image-size-image]: https://img.shields.io/docker/image-size/whyour/qinglong?style=flat
|
[docker-image-size-image]: https://img.shields.io/docker/image-size/whyour/qinglong?style=flat
|
||||||
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
[docker-image-size-url]: https://hub.docker.com/r/whyour/qinglong
|
||||||
|
|
||||||
[Demo](http://demo.ninesix.cc:4433/) / [Issues](https://github.com/whyour/qinglong/issues) / [Telegram Channel](https://t.me/jiao_long) / [Buy Me a Coffee](https://www.buymeacoffee.com/qinglong)
|
[Demo](http://demo.qinglong.online:4433/) / [Issues](https://github.com/whyour/qinglong/issues) / [Telegram Channel](https://t.me/jiao_long) / [Buy Me a Coffee](https://www.buymeacoffee.com/qinglong)
|
||||||
|
|
||||||
[演示](http://demo.ninesix.cc:4433/) / [反馈](https://github.com/whyour/qinglong/issues) / [Telegram 频道](https://t.me/jiao_long) / [打赏开发者](https://user-images.githubusercontent.com/22700758/244744295-29cd0cd1-c8bb-4ea1-adf6-29bd390ad4dd.jpg)
|
[演示](http://demo.qinglong.online:4433/) / [反馈](https://github.com/whyour/qinglong/issues) / [Telegram 频道](https://t.me/jiao_long) / [打赏开发者](https://user-images.githubusercontent.com/22700758/244744295-29cd0cd1-c8bb-4ea1-adf6-29bd390ad4dd.jpg)
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
+13
-2
@@ -8,7 +8,17 @@ const route = Router();
|
|||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
app.use('/dependencies', route);
|
app.use('/dependencies', route);
|
||||||
|
|
||||||
route.get('/', async (req: Request, res: Response, next: NextFunction) => {
|
route.get(
|
||||||
|
'/',
|
||||||
|
celebrate({
|
||||||
|
query:
|
||||||
|
Joi.object({
|
||||||
|
searchValue: Joi.string().optional().allow(''),
|
||||||
|
type: Joi.string().optional().allow(''),
|
||||||
|
status: Joi.string().optional().allow(''),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
try {
|
try {
|
||||||
const dependenceService = Container.get(DependenceService);
|
const dependenceService = Container.get(DependenceService);
|
||||||
@@ -18,7 +28,8 @@ export default (app: Router) => {
|
|||||||
logger.error('🔥 error: %o', e);
|
logger.error('🔥 error: %o', e);
|
||||||
return next(e);
|
return next(e);
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
route.post(
|
route.post(
|
||||||
'/',
|
'/',
|
||||||
|
|||||||
+51
-7
@@ -24,7 +24,14 @@ const upload = multer({ storage: storage });
|
|||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
app.use('/scripts', route);
|
app.use('/scripts', route);
|
||||||
|
|
||||||
route.get('/', async (req: Request, res: Response, next: NextFunction) => {
|
route.get(
|
||||||
|
'/',
|
||||||
|
celebrate({
|
||||||
|
query: Joi.object({
|
||||||
|
path: Joi.string().optional().allow(''),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
try {
|
try {
|
||||||
let result: IFile[] = [];
|
let result: IFile[] = [];
|
||||||
@@ -68,11 +75,17 @@ export default (app: Router) => {
|
|||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
'/detail',
|
'/detail',
|
||||||
|
celebrate({
|
||||||
|
query: Joi.object({
|
||||||
|
path: Joi.string().optional().allow(''),
|
||||||
|
file: Joi.string().required(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const scriptService = Container.get(ScriptService);
|
const scriptService = Container.get(ScriptService);
|
||||||
const content = await scriptService.getFile(
|
const content = await scriptService.getFile(
|
||||||
req.query.path as string,
|
req.query?.path as string || '',
|
||||||
req.query.file as string,
|
req.query.file as string,
|
||||||
);
|
);
|
||||||
res.send({ code: 200, data: content });
|
res.send({ code: 200, data: content });
|
||||||
@@ -84,11 +97,19 @@ export default (app: Router) => {
|
|||||||
|
|
||||||
route.get(
|
route.get(
|
||||||
'/:file',
|
'/:file',
|
||||||
|
celebrate({
|
||||||
|
params: Joi.object({
|
||||||
|
file: Joi.string().required(),
|
||||||
|
}),
|
||||||
|
query: Joi.object({
|
||||||
|
path: Joi.string().optional().allow(''),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const scriptService = Container.get(ScriptService);
|
const scriptService = Container.get(ScriptService);
|
||||||
const content = await scriptService.getFile(
|
const content = await scriptService.getFile(
|
||||||
req.query.path as string,
|
req.query?.path as string || '',
|
||||||
req.params.file,
|
req.params.file,
|
||||||
);
|
);
|
||||||
res.send({ code: 200, data: content });
|
res.send({ code: 200, data: content });
|
||||||
@@ -101,6 +122,15 @@ export default (app: Router) => {
|
|||||||
route.post(
|
route.post(
|
||||||
'/',
|
'/',
|
||||||
upload.single('file'),
|
upload.single('file'),
|
||||||
|
celebrate({
|
||||||
|
body: Joi.object({
|
||||||
|
filename: Joi.string().required(),
|
||||||
|
path: Joi.string().optional().allow(''),
|
||||||
|
content: Joi.string().optional().allow(''),
|
||||||
|
originFilename: Joi.string().optional().allow(''),
|
||||||
|
directory: Joi.string().optional().allow(''),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
let { filename, path, content, originFilename, directory } =
|
let { filename, path, content, originFilename, directory } =
|
||||||
@@ -201,7 +231,7 @@ export default (app: Router) => {
|
|||||||
celebrate({
|
celebrate({
|
||||||
body: Joi.object({
|
body: Joi.object({
|
||||||
filename: Joi.string().required(),
|
filename: Joi.string().required(),
|
||||||
path: Joi.string().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
type: Joi.string().optional(),
|
type: Joi.string().optional(),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
@@ -211,6 +241,9 @@ export default (app: Router) => {
|
|||||||
filename: string;
|
filename: string;
|
||||||
path: string;
|
path: string;
|
||||||
};
|
};
|
||||||
|
if (!path) {
|
||||||
|
path = '';
|
||||||
|
}
|
||||||
const scriptService = Container.get(ScriptService);
|
const scriptService = Container.get(ScriptService);
|
||||||
const filePath = scriptService.checkFilePath(path, filename);
|
const filePath = scriptService.checkFilePath(path, filename);
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
@@ -232,7 +265,7 @@ export default (app: Router) => {
|
|||||||
celebrate({
|
celebrate({
|
||||||
body: Joi.object({
|
body: Joi.object({
|
||||||
filename: Joi.string().required(),
|
filename: Joi.string().required(),
|
||||||
path: Joi.string().allow(''),
|
path: Joi.string().optional().allow(''),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
@@ -241,6 +274,9 @@ export default (app: Router) => {
|
|||||||
filename: string;
|
filename: string;
|
||||||
path: string;
|
path: string;
|
||||||
};
|
};
|
||||||
|
if (!path) {
|
||||||
|
path = '';
|
||||||
|
}
|
||||||
const scriptService = Container.get(ScriptService);
|
const scriptService = Container.get(ScriptService);
|
||||||
const filePath = scriptService.checkFilePath(path, filename);
|
const filePath = scriptService.checkFilePath(path, filename);
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
@@ -273,6 +309,9 @@ export default (app: Router) => {
|
|||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
try {
|
try {
|
||||||
let { filename, content, path } = req.body;
|
let { filename, content, path } = req.body;
|
||||||
|
if (!path) {
|
||||||
|
path = '';
|
||||||
|
}
|
||||||
const { name, ext } = parse(filename);
|
const { name, ext } = parse(filename);
|
||||||
const filePath = join(config.scriptPath, path, `${name}.swap${ext}`);
|
const filePath = join(config.scriptPath, path, `${name}.swap${ext}`);
|
||||||
await writeFileWithLock(filePath, content || '');
|
await writeFileWithLock(filePath, content || '');
|
||||||
@@ -298,6 +337,9 @@ export default (app: Router) => {
|
|||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
let { filename, path, pid } = req.body;
|
let { filename, path, pid } = req.body;
|
||||||
|
if (!path) {
|
||||||
|
path = '';
|
||||||
|
}
|
||||||
const { name, ext } = parse(filename);
|
const { name, ext } = parse(filename);
|
||||||
const filePath = join(config.scriptPath, path, `${name}.swap${ext}`);
|
const filePath = join(config.scriptPath, path, `${name}.swap${ext}`);
|
||||||
const logPath = join(config.logPath, path, `${name}.swap`);
|
const logPath = join(config.logPath, path, `${name}.swap`);
|
||||||
@@ -325,12 +367,14 @@ export default (app: Router) => {
|
|||||||
}),
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
let { filename, path, type, newFilename } = req.body as {
|
let { filename, path, newFilename } = req.body as {
|
||||||
filename: string;
|
filename: string;
|
||||||
path: string;
|
path: string;
|
||||||
type: string;
|
|
||||||
newFilename: string;
|
newFilename: string;
|
||||||
};
|
};
|
||||||
|
if (!path) {
|
||||||
|
path = '';
|
||||||
|
}
|
||||||
const filePath = join(config.scriptPath, path, filename);
|
const filePath = join(config.scriptPath, path, filename);
|
||||||
const newPath = join(config.scriptPath, path, newFilename);
|
const newPath = join(config.scriptPath, path, newFilename);
|
||||||
await fs.rename(filePath, newPath);
|
await fs.rename(filePath, newPath);
|
||||||
|
|||||||
+29
-5
@@ -273,19 +273,20 @@ export default (app: Router) => {
|
|||||||
{
|
{
|
||||||
onStart: async (cp, startTime) => {
|
onStart: async (cp, startTime) => {
|
||||||
res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
res.setHeader('QL-Task-Pid', `${cp.pid}`);
|
||||||
|
res.setHeader('QL-Task-Log', `${logPath}`);
|
||||||
},
|
},
|
||||||
onEnd: async (cp, endTime, diff) => {
|
onEnd: async (cp, endTime, diff) => {
|
||||||
res.end();
|
res.end();
|
||||||
},
|
},
|
||||||
onError: async (message: string) => {
|
onError: async (message: string) => {
|
||||||
res.write(`\n${message}`);
|
res.write(message);
|
||||||
const absolutePath = await handleLogPath(logPath);
|
const absolutePath = await handleLogPath(logPath);
|
||||||
await fs.appendFile(absolutePath, `\n${message}`);
|
await fs.appendFile(absolutePath, message);
|
||||||
},
|
},
|
||||||
onLog: async (message: string) => {
|
onLog: async (message: string) => {
|
||||||
res.write(`\n${message}`);
|
res.write(message);
|
||||||
const absolutePath = await handleLogPath(logPath);
|
const absolutePath = await handleLogPath(logPath);
|
||||||
await fs.appendFile(absolutePath, `\n${message}`);
|
await fs.appendFile(absolutePath, message);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -316,10 +317,15 @@ export default (app: Router) => {
|
|||||||
|
|
||||||
route.put(
|
route.put(
|
||||||
'/data/export',
|
'/data/export',
|
||||||
|
celebrate({
|
||||||
|
body: Joi.object({
|
||||||
|
type: Joi.array().items(Joi.string()).optional(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const systemService = Container.get(SystemService);
|
const systemService = Container.get(SystemService);
|
||||||
await systemService.exportData(res);
|
await systemService.exportData(res, req.body.type);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return next(e);
|
return next(e);
|
||||||
}
|
}
|
||||||
@@ -416,4 +422,22 @@ export default (app: Router) => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
route.put(
|
||||||
|
'/config/dependence-clean',
|
||||||
|
celebrate({
|
||||||
|
body: Joi.object({
|
||||||
|
type: Joi.string().allow(''),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
const systemService = Container.get(SystemService);
|
||||||
|
const result = await systemService.cleanDependence(req.body.type);
|
||||||
|
res.send(result);
|
||||||
|
} catch (e) {
|
||||||
|
return next(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+178
-32
@@ -1,4 +1,5 @@
|
|||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
|
import cluster, { type Worker } from 'cluster';
|
||||||
import compression from 'compression';
|
import compression from 'compression';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
@@ -10,76 +11,142 @@ import { monitoringMiddleware } from './middlewares/monitoring';
|
|||||||
import { type GrpcServerService } from './services/grpc';
|
import { type GrpcServerService } from './services/grpc';
|
||||||
import { type HttpServerService } from './services/http';
|
import { type HttpServerService } from './services/http';
|
||||||
|
|
||||||
|
interface WorkerMetadata {
|
||||||
|
id: number;
|
||||||
|
pid: number;
|
||||||
|
serviceType: string;
|
||||||
|
startTime: Date;
|
||||||
|
}
|
||||||
|
|
||||||
class Application {
|
class Application {
|
||||||
private app: express.Application;
|
private app: express.Application;
|
||||||
private httpServerService?: HttpServerService;
|
private httpServerService?: HttpServerService;
|
||||||
private grpcServerService?: GrpcServerService;
|
private grpcServerService?: GrpcServerService;
|
||||||
private isShuttingDown = false;
|
private isShuttingDown = false;
|
||||||
|
private workerMetadataMap = new Map<number, WorkerMetadata>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = express();
|
this.app = express();
|
||||||
|
// 创建一个全局中间件,删除查询参数中的t
|
||||||
|
this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||||
|
if (req.query.t) {
|
||||||
|
delete req.query.t;
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
try {
|
try {
|
||||||
|
if (cluster.isPrimary) {
|
||||||
await this.initializeDatabase();
|
await this.initializeDatabase();
|
||||||
await this.initServer();
|
}
|
||||||
this.setupMiddlewares();
|
if (cluster.isPrimary) {
|
||||||
await this.initializeServices();
|
this.startMasterProcess();
|
||||||
this.setupGracefulShutdown();
|
} else {
|
||||||
|
await this.startWorkerProcess();
|
||||||
process.send?.('ready');
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('Failed to start application:', error);
|
Logger.error('Failed to start application:', error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async initServer() {
|
private startMasterProcess() {
|
||||||
const { HttpServerService } = await import('./services/http');
|
this.forkWorker('http');
|
||||||
const { GrpcServerService } = await import('./services/grpc');
|
this.forkWorker('grpc');
|
||||||
this.httpServerService = Container.get(HttpServerService);
|
|
||||||
this.grpcServerService = Container.get(GrpcServerService);
|
cluster.on('exit', (worker, code, signal) => {
|
||||||
|
const metadata = this.workerMetadataMap.get(worker.id);
|
||||||
|
if (metadata) {
|
||||||
|
if (!this.isShuttingDown) {
|
||||||
|
Logger.error(
|
||||||
|
`${metadata.serviceType} worker ${worker.process.pid} died (${signal || code
|
||||||
|
}). Restarting...`,
|
||||||
|
);
|
||||||
|
const newWorker = this.forkWorker(metadata.serviceType);
|
||||||
|
Logger.info(
|
||||||
|
`Restarted ${metadata.serviceType} worker (New PID: ${newWorker.process.pid})`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.workerMetadataMap.delete(worker.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setupMasterShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private forkWorker(serviceType: string): Worker {
|
||||||
|
const worker = cluster.fork({ SERVICE_TYPE: serviceType });
|
||||||
|
|
||||||
|
this.workerMetadataMap.set(worker.id, {
|
||||||
|
id: worker.id,
|
||||||
|
pid: worker.process.pid!,
|
||||||
|
serviceType,
|
||||||
|
startTime: new Date(),
|
||||||
|
});
|
||||||
|
|
||||||
|
return worker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initializeDatabase() {
|
private async initializeDatabase() {
|
||||||
await require('./loaders/db').default();
|
const dbLoader = await import('./loaders/db');
|
||||||
|
await dbLoader.default();
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupMiddlewares() {
|
private setupMiddlewares() {
|
||||||
this.app.use(helmet());
|
this.app.use(helmet({
|
||||||
|
contentSecurityPolicy: false,
|
||||||
|
}));
|
||||||
this.app.use(cors(config.cors));
|
this.app.use(cors(config.cors));
|
||||||
this.app.use(compression());
|
this.app.use(compression());
|
||||||
this.app.use(monitoringMiddleware);
|
this.app.use(monitoringMiddleware);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initializeServices() {
|
private setupMasterShutdown() {
|
||||||
await this.grpcServerService?.initialize();
|
|
||||||
|
|
||||||
await require('./loaders/app').default({ app: this.app });
|
|
||||||
|
|
||||||
const server = await this.httpServerService?.initialize(
|
|
||||||
this.app,
|
|
||||||
config.port,
|
|
||||||
);
|
|
||||||
|
|
||||||
await require('./loaders/server').default({ server });
|
|
||||||
}
|
|
||||||
|
|
||||||
private setupGracefulShutdown() {
|
|
||||||
const shutdown = async () => {
|
const shutdown = async () => {
|
||||||
if (this.isShuttingDown) return;
|
if (this.isShuttingDown) return;
|
||||||
this.isShuttingDown = true;
|
this.isShuttingDown = true;
|
||||||
|
|
||||||
Logger.info('Shutting down services...');
|
const workers = Object.values(cluster.workers || {});
|
||||||
|
const workerPromises: Promise<void>[] = [];
|
||||||
|
|
||||||
|
workers.forEach((worker) => {
|
||||||
|
if (worker) {
|
||||||
|
const exitPromise = new Promise<void>((resolve) => {
|
||||||
|
worker.once('exit', () => {
|
||||||
|
Logger.info(`Worker ${worker.process.pid} exited`);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Promise.all([
|
worker.send('shutdown');
|
||||||
this.grpcServerService?.shutdown(),
|
} catch (error) {
|
||||||
this.httpServerService?.shutdown(),
|
Logger.warn(
|
||||||
|
`Failed to send shutdown to worker ${worker.process.pid}:`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
workerPromises.push(exitPromise);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.race([
|
||||||
|
Promise.all(workerPromises),
|
||||||
|
new Promise<void>((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
Logger.warn('Worker shutdown timeout reached');
|
||||||
|
resolve();
|
||||||
|
}, 10000);
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('Error during shutdown:', error);
|
Logger.error('Error during worker shutdown:', error);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -87,6 +154,85 @@ class Application {
|
|||||||
process.on('SIGTERM', shutdown);
|
process.on('SIGTERM', shutdown);
|
||||||
process.on('SIGINT', shutdown);
|
process.on('SIGINT', shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async startWorkerProcess() {
|
||||||
|
const serviceType = process.env.SERVICE_TYPE;
|
||||||
|
if (!serviceType || !['http', 'grpc'].includes(serviceType)) {
|
||||||
|
Logger.error('Invalid SERVICE_TYPE:', serviceType);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.info(`✌️ ${serviceType} worker started (PID: ${process.pid})`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (serviceType === 'http') {
|
||||||
|
await this.startHttpService();
|
||||||
|
} else {
|
||||||
|
await this.startGrpcService();
|
||||||
|
}
|
||||||
|
|
||||||
|
process.send?.('ready');
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(`${serviceType} worker failed:`, error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async startHttpService() {
|
||||||
|
this.setupMiddlewares();
|
||||||
|
|
||||||
|
const { HttpServerService } = await import('./services/http');
|
||||||
|
this.httpServerService = Container.get(HttpServerService);
|
||||||
|
|
||||||
|
const appLoader = await import('./loaders/app');
|
||||||
|
await appLoader.default({ app: this.app });
|
||||||
|
|
||||||
|
const server = await this.httpServerService.initialize(
|
||||||
|
this.app,
|
||||||
|
config.port,
|
||||||
|
);
|
||||||
|
|
||||||
|
const serverLoader = await import('./loaders/server');
|
||||||
|
await (serverLoader.default as any)({ server });
|
||||||
|
this.setupWorkerShutdown('http');
|
||||||
|
}
|
||||||
|
|
||||||
|
private async startGrpcService() {
|
||||||
|
const { GrpcServerService } = await import('./services/grpc');
|
||||||
|
this.grpcServerService = Container.get(GrpcServerService);
|
||||||
|
|
||||||
|
await this.grpcServerService.initialize();
|
||||||
|
this.setupWorkerShutdown('grpc');
|
||||||
|
}
|
||||||
|
|
||||||
|
private setupWorkerShutdown(serviceType: string) {
|
||||||
|
process.on('message', (msg) => {
|
||||||
|
if (msg === 'shutdown') {
|
||||||
|
this.gracefulShutdown(serviceType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const shutdown = () => this.gracefulShutdown(serviceType);
|
||||||
|
process.on('SIGTERM', shutdown);
|
||||||
|
process.on('SIGINT', shutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async gracefulShutdown(serviceType: string) {
|
||||||
|
if (this.isShuttingDown) return;
|
||||||
|
this.isShuttingDown = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (serviceType === 'http') {
|
||||||
|
await this.httpServerService?.shutdown();
|
||||||
|
} else {
|
||||||
|
await this.grpcServerService?.shutdown();
|
||||||
|
}
|
||||||
|
process.exit(0);
|
||||||
|
} catch (error) {
|
||||||
|
Logger.error(`[${serviceType}] Error during shutdown:`, error);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new Application();
|
const app = new Application();
|
||||||
|
|||||||
@@ -25,3 +25,27 @@ export const SAMPLE_FILES = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const PYTHON_INSTALL_DIR = process.env.PYTHON_HOME;
|
export const PYTHON_INSTALL_DIR = process.env.PYTHON_HOME;
|
||||||
|
|
||||||
|
export const NotificationModeStringMap = {
|
||||||
|
0: 'gotify',
|
||||||
|
1: 'goCqHttpBot',
|
||||||
|
2: 'serverChan',
|
||||||
|
3: 'pushDeer',
|
||||||
|
4: 'bark',
|
||||||
|
5: 'chat',
|
||||||
|
6: 'telegramBot',
|
||||||
|
7: 'dingtalkBot',
|
||||||
|
8: 'weWorkBot',
|
||||||
|
9: 'weWorkApp',
|
||||||
|
10: 'aibotk',
|
||||||
|
11: 'iGot',
|
||||||
|
12: 'pushPlus',
|
||||||
|
13: 'wePlusBot',
|
||||||
|
14: 'email',
|
||||||
|
15: 'pushMe',
|
||||||
|
16: 'feishu',
|
||||||
|
17: 'webhook',
|
||||||
|
18: 'chronocat',
|
||||||
|
19: 'ntfy',
|
||||||
|
20: 'wxPusherBot',
|
||||||
|
} as const;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ interface Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const config: Config = {
|
const config: Config = {
|
||||||
port: parseInt(process.env.BACK_PORT || '5600', 10),
|
port: parseInt(process.env.BACK_PORT || '5700', 10),
|
||||||
grpcPort: parseInt(process.env.GRPC_PORT || '5500', 10),
|
grpcPort: parseInt(process.env.GRPC_PORT || '5500', 10),
|
||||||
nodeEnv: process.env.NODE_ENV || 'development',
|
nodeEnv: process.env.NODE_ENV || 'development',
|
||||||
isDevelopment: process.env.NODE_ENV === 'development',
|
isDevelopment: process.env.NODE_ENV === 'development',
|
||||||
@@ -41,7 +41,7 @@ const config: Config = {
|
|||||||
prefix: '/api',
|
prefix: '/api',
|
||||||
},
|
},
|
||||||
jwt: {
|
jwt: {
|
||||||
secret: process.env.JWT_SECRET || createRandomString(16, 32),
|
secret: process.env.JWT_SECRET || 'whyour-secret',
|
||||||
expiresIn: process.env.JWT_EXPIRES_IN,
|
expiresIn: process.env.JWT_EXPIRES_IN,
|
||||||
},
|
},
|
||||||
cors: {
|
cors: {
|
||||||
@@ -86,6 +86,7 @@ const dbPath = path.join(dataPath, 'db/');
|
|||||||
const uploadPath = path.join(dataPath, 'upload/');
|
const uploadPath = path.join(dataPath, 'upload/');
|
||||||
const sshdPath = path.join(dataPath, 'ssh.d/');
|
const sshdPath = path.join(dataPath, 'ssh.d/');
|
||||||
const systemLogPath = path.join(dataPath, 'syslog/');
|
const systemLogPath = path.join(dataPath, 'syslog/');
|
||||||
|
const dependenceCachePath = path.join(dataPath, 'dep_cache/');
|
||||||
|
|
||||||
const envFile = path.join(preloadPath, 'env.sh');
|
const envFile = path.join(preloadPath, 'env.sh');
|
||||||
const jsEnvFile = path.join(preloadPath, 'env.js');
|
const jsEnvFile = path.join(preloadPath, 'env.js');
|
||||||
@@ -174,4 +175,5 @@ export default {
|
|||||||
sqliteFile,
|
sqliteFile,
|
||||||
sshdPath,
|
sshdPath,
|
||||||
systemLogPath,
|
systemLogPath,
|
||||||
|
dependenceCachePath,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -514,6 +514,27 @@ export async function setSystemTimezone(timezone: string): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getGetCommand(type: DependenceTypes, name: string): string {
|
||||||
|
const baseCommands = {
|
||||||
|
[DependenceTypes.nodejs]: `pnpm ls -g | grep "${name}" | head -1`,
|
||||||
|
[DependenceTypes.python3]: `
|
||||||
|
python3 -c "exec('''
|
||||||
|
name='${name}'
|
||||||
|
try:
|
||||||
|
from importlib.metadata import version
|
||||||
|
print(version(name))
|
||||||
|
except:
|
||||||
|
import importlib.util as u
|
||||||
|
import importlib.metadata as m
|
||||||
|
spec=u.find_spec(name)
|
||||||
|
print(name if spec else '')
|
||||||
|
''')"`,
|
||||||
|
[DependenceTypes.linux]: `apk info -es ${name}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return baseCommands[type];
|
||||||
|
}
|
||||||
|
|
||||||
export function getInstallCommand(type: DependenceTypes, name: string): string {
|
export function getInstallCommand(type: DependenceTypes, name: string): string {
|
||||||
const baseCommands = {
|
const baseCommands = {
|
||||||
[DependenceTypes.nodejs]: 'pnpm add -g',
|
[DependenceTypes.nodejs]: 'pnpm add -g',
|
||||||
|
|||||||
@@ -41,12 +41,6 @@ export enum DependenceTypes {
|
|||||||
'linux',
|
'linux',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum GetDependenceCommandTypes {
|
|
||||||
'pnpm ls -g ',
|
|
||||||
'pip3 show --disable-pip-version-check',
|
|
||||||
'apk info -es',
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum versionDependenceCommandTypes {
|
export enum versionDependenceCommandTypes {
|
||||||
'@',
|
'@',
|
||||||
'==',
|
'==',
|
||||||
|
|||||||
+4
-2
@@ -1,5 +1,3 @@
|
|||||||
import { IncomingHttpHeaders } from 'http';
|
|
||||||
|
|
||||||
export enum NotificationMode {
|
export enum NotificationMode {
|
||||||
'gotify' = 'gotify',
|
'gotify' = 'gotify',
|
||||||
'goCqHttpBot' = 'goCqHttpBot',
|
'goCqHttpBot' = 'goCqHttpBot',
|
||||||
@@ -150,6 +148,10 @@ export class NtfyNotification extends NotificationBaseInfo {
|
|||||||
public ntfyUrl = '';
|
public ntfyUrl = '';
|
||||||
public ntfyTopic = '';
|
public ntfyTopic = '';
|
||||||
public ntfyPriority = '';
|
public ntfyPriority = '';
|
||||||
|
public ntfyToken = '';
|
||||||
|
public ntfyUsername = '';
|
||||||
|
public ntfyPassword = '';
|
||||||
|
public ntfyActions = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WxPusherBotNotification extends NotificationBaseInfo {
|
export class WxPusherBotNotification extends NotificationBaseInfo {
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ async function linkCommand() {
|
|||||||
const source = path.join(config.rootPath, 'shell', link.src);
|
const source = path.join(config.rootPath, 'shell', link.src);
|
||||||
const target = path.join(commandDir, link.dest);
|
const target = path.join(commandDir, link.dest);
|
||||||
const tmpTarget = path.join(commandDir, link.tmp);
|
const tmpTarget = path.join(commandDir, link.tmp);
|
||||||
|
try {
|
||||||
|
const stats = await fs.lstat(tmpTarget);
|
||||||
|
if (stats) {
|
||||||
|
await fs.unlink(tmpTarget);
|
||||||
|
}
|
||||||
|
} catch (error) { }
|
||||||
await fs.symlink(source, tmpTarget);
|
await fs.symlink(source, tmpTarget);
|
||||||
await fs.rename(tmpTarget, target);
|
await fs.rename(tmpTarget, target);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-2
@@ -9,6 +9,7 @@ import rewrite from 'express-urlrewrite';
|
|||||||
import { errors } from 'celebrate';
|
import { errors } from 'celebrate';
|
||||||
import { serveEnv } from '../config/serverEnv';
|
import { serveEnv } from '../config/serverEnv';
|
||||||
import { IKeyvStore, shareStore } from '../shared/store';
|
import { IKeyvStore, shareStore } from '../shared/store';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
export default ({ app }: { app: Application }) => {
|
export default ({ app }: { app: Application }) => {
|
||||||
app.set('trust proxy', 'loopback');
|
app.set('trust proxy', 'loopback');
|
||||||
@@ -19,12 +20,15 @@ export default ({ app }: { app: Application }) => {
|
|||||||
app.use(bodyParser.json({ limit: '50mb' }));
|
app.use(bodyParser.json({ limit: '50mb' }));
|
||||||
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
|
||||||
|
|
||||||
|
const frontendPath = path.join(config.rootPath, 'static/dist');
|
||||||
|
app.use(express.static(frontendPath));
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
expressjwt({
|
expressjwt({
|
||||||
secret: config.jwt.secret,
|
secret: config.jwt.secret,
|
||||||
algorithms: ['HS384'],
|
algorithms: ['HS384'],
|
||||||
}).unless({
|
}).unless({
|
||||||
path: [...config.apiWhiteList, /^\/open\//],
|
path: [...config.apiWhiteList, /^\/(?!api\/).*/],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -39,6 +43,10 @@ export default ({ app }: { app: Application }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.use(async (req: Request, res, next) => {
|
app.use(async (req: Request, res, next) => {
|
||||||
|
if (!['/open/', '/api/'].some((x) => req.path.startsWith(x))) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
const headerToken = getToken(req);
|
const headerToken = getToken(req);
|
||||||
if (req.path.startsWith('/open/')) {
|
if (req.path.startsWith('/open/')) {
|
||||||
const apps = await shareStore.getApps();
|
const apps = await shareStore.getApps();
|
||||||
@@ -110,10 +118,15 @@ export default ({ app }: { app: Application }) => {
|
|||||||
app.use(rewrite('/open/*', '/api/$1'));
|
app.use(rewrite('/open/*', '/api/$1'));
|
||||||
app.use(config.api.prefix, routes());
|
app.use(config.api.prefix, routes());
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.get('*', (_, res, next) => {
|
||||||
|
const indexPath = path.join(frontendPath, 'index.html');
|
||||||
|
res.sendFile(indexPath, (err) => {
|
||||||
|
if (err) {
|
||||||
const err: any = new Error('Not Found');
|
const err: any = new Error('Not Found');
|
||||||
err['status'] = 404;
|
err['status'] = 404;
|
||||||
next(err);
|
next(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(errors());
|
app.use(errors());
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ export default async () => {
|
|||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await dependenceService.installDependenceOneByOne(docs);
|
await dependenceService.installDependenceOneByOne(docs);
|
||||||
|
|
||||||
require('./bootAfter').default();
|
const bootAfterLoader = await import('./bootAfter');
|
||||||
|
bootAfterLoader.default();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ export default async () => {
|
|||||||
`Neither content nor source specified for ${item.target}`,
|
`Neither content nor source specified for ${item.target}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const content = item.content || (await fs.readFile(item.source!));
|
const content =
|
||||||
|
item.content ||
|
||||||
|
(await fs.readFile(item.source!, { encoding: 'utf-8' }));
|
||||||
await writeFileWithLock(item.target, content);
|
await writeFileWithLock(item.target, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+123
-8
@@ -53,14 +53,7 @@ message Response {
|
|||||||
optional string message = 2;
|
optional string message = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message SystemNotifyRequest {
|
message ExtraScheduleItem { string schedule = 1; }
|
||||||
string title = 1;
|
|
||||||
string content = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ExtraScheduleItem {
|
|
||||||
string schedule = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CronItem {
|
message CronItem {
|
||||||
optional int32 id = 1;
|
optional int32 id = 1;
|
||||||
@@ -124,6 +117,128 @@ message CronDetailResponse {
|
|||||||
optional string message = 3;
|
optional string message = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum NotificationMode {
|
||||||
|
gotify = 0;
|
||||||
|
goCqHttpBot = 1;
|
||||||
|
serverChan = 2;
|
||||||
|
pushDeer = 3;
|
||||||
|
bark = 4;
|
||||||
|
chat = 5;
|
||||||
|
telegramBot = 6;
|
||||||
|
dingtalkBot = 7;
|
||||||
|
weWorkBot = 8;
|
||||||
|
weWorkApp = 9;
|
||||||
|
aibotk = 10;
|
||||||
|
iGot = 11;
|
||||||
|
pushPlus = 12;
|
||||||
|
wePlusBot = 13;
|
||||||
|
email = 14;
|
||||||
|
pushMe = 15;
|
||||||
|
feishu = 16;
|
||||||
|
webhook = 17;
|
||||||
|
chronocat = 18;
|
||||||
|
ntfy = 19;
|
||||||
|
wxPusherBot = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NotificationInfo {
|
||||||
|
NotificationMode type = 1;
|
||||||
|
|
||||||
|
optional string gotifyUrl = 2;
|
||||||
|
optional string gotifyToken = 3;
|
||||||
|
optional int32 gotifyPriority = 4;
|
||||||
|
|
||||||
|
optional string goCqHttpBotUrl = 5;
|
||||||
|
optional string goCqHttpBotToken = 6;
|
||||||
|
optional string goCqHttpBotQq = 7;
|
||||||
|
|
||||||
|
optional string serverChanKey = 8;
|
||||||
|
|
||||||
|
optional string pushDeerKey = 9;
|
||||||
|
optional string pushDeerUrl = 10;
|
||||||
|
|
||||||
|
optional string synologyChatUrl = 11;
|
||||||
|
|
||||||
|
optional string barkPush = 12;
|
||||||
|
optional string barkIcon = 13;
|
||||||
|
optional string barkSound = 14;
|
||||||
|
optional string barkGroup = 15;
|
||||||
|
optional string barkLevel = 16;
|
||||||
|
optional string barkUrl = 17;
|
||||||
|
optional string barkArchive = 18;
|
||||||
|
|
||||||
|
optional string telegramBotToken = 19;
|
||||||
|
optional string telegramBotUserId = 20;
|
||||||
|
optional string telegramBotProxyHost = 21;
|
||||||
|
optional string telegramBotProxyPort = 22;
|
||||||
|
optional string telegramBotProxyAuth = 23;
|
||||||
|
optional string telegramBotApiHost = 24;
|
||||||
|
|
||||||
|
optional string dingtalkBotToken = 25;
|
||||||
|
optional string dingtalkBotSecret = 26;
|
||||||
|
|
||||||
|
optional string weWorkBotKey = 27;
|
||||||
|
optional string weWorkOrigin = 28;
|
||||||
|
|
||||||
|
optional string weWorkAppKey = 29;
|
||||||
|
|
||||||
|
optional string aibotkKey = 30;
|
||||||
|
optional string aibotkType = 31;
|
||||||
|
optional string aibotkName = 32;
|
||||||
|
|
||||||
|
optional string iGotPushKey = 33;
|
||||||
|
|
||||||
|
optional string pushPlusToken = 34;
|
||||||
|
optional string pushPlusUser = 35;
|
||||||
|
optional string pushPlusTemplate = 36;
|
||||||
|
optional string pushplusChannel = 37;
|
||||||
|
optional string pushplusWebhook = 38;
|
||||||
|
optional string pushplusCallbackUrl = 39;
|
||||||
|
optional string pushplusTo = 40;
|
||||||
|
|
||||||
|
optional string wePlusBotToken = 41;
|
||||||
|
optional string wePlusBotReceiver = 42;
|
||||||
|
optional string wePlusBotVersion = 43;
|
||||||
|
|
||||||
|
optional string emailService = 44;
|
||||||
|
optional string emailUser = 45;
|
||||||
|
optional string emailPass = 46;
|
||||||
|
optional string emailTo = 47;
|
||||||
|
|
||||||
|
optional string pushMeKey = 48;
|
||||||
|
optional string pushMeUrl = 49;
|
||||||
|
|
||||||
|
optional string chronocatURL = 50;
|
||||||
|
optional string chronocatQQ = 51;
|
||||||
|
optional string chronocatToken = 52;
|
||||||
|
|
||||||
|
optional string webhookHeaders = 53;
|
||||||
|
optional string webhookBody = 54;
|
||||||
|
optional string webhookUrl = 55;
|
||||||
|
optional string webhookMethod = 56;
|
||||||
|
optional string webhookContentType = 57;
|
||||||
|
|
||||||
|
optional string larkKey = 58;
|
||||||
|
|
||||||
|
optional string ntfyUrl = 59;
|
||||||
|
optional string ntfyTopic = 60;
|
||||||
|
optional string ntfyPriority = 61;
|
||||||
|
optional string ntfyToken = 62;
|
||||||
|
optional string ntfyUsername = 63;
|
||||||
|
optional string ntfyPassword = 64;
|
||||||
|
optional string ntfyActions = 65;
|
||||||
|
|
||||||
|
optional string wxPusherBotAppToken = 66;
|
||||||
|
optional string wxPusherBotTopicIds = 67;
|
||||||
|
optional string wxPusherBotUids = 68;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SystemNotifyRequest {
|
||||||
|
string title = 1;
|
||||||
|
string content = 2;
|
||||||
|
optional NotificationInfo notificationInfo = 3;
|
||||||
|
}
|
||||||
|
|
||||||
service Api {
|
service Api {
|
||||||
rpc GetEnvs(GetEnvsRequest) returns (EnvsResponse) {}
|
rpc GetEnvs(GetEnvsRequest) returns (EnvsResponse) {}
|
||||||
rpc CreateEnv(CreateEnvRequest) returns (EnvsResponse) {}
|
rpc CreateEnv(CreateEnvRequest) returns (EnvsResponse) {}
|
||||||
|
|||||||
+1531
-81
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@ const addCron = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.info(
|
Logger.info(
|
||||||
'[schedule][创建定时任务], 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
'[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
schedule,
|
schedule,
|
||||||
@@ -26,7 +26,7 @@ const addCron = (
|
|||||||
if (extra_schedules?.length) {
|
if (extra_schedules?.length) {
|
||||||
extra_schedules.forEach((x) => {
|
extra_schedules.forEach((x) => {
|
||||||
Logger.info(
|
Logger.info(
|
||||||
'[schedule][创建定时任务], 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
'[schedule][创建定时任务] 任务ID: %s, 名称: %s, cron: %s, 执行命令: %s',
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
x.schedule,
|
x.schedule,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
DeleteCronsRequest,
|
DeleteCronsRequest,
|
||||||
CronResponse,
|
CronResponse,
|
||||||
} from '../protos/api';
|
} from '../protos/api';
|
||||||
|
import { NotificationInfo } from '../data/notify';
|
||||||
|
|
||||||
Container.set('logger', LoggerInstance);
|
Container.set('logger', LoggerInstance);
|
||||||
|
|
||||||
@@ -227,7 +228,11 @@ export const systemNotify = async (
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const systemService = Container.get(SystemService);
|
const systemService = Container.get(SystemService);
|
||||||
const data = await systemService.notify(call.request);
|
const data = await systemService.notify({
|
||||||
|
title: call.request.title,
|
||||||
|
content: call.request.content,
|
||||||
|
notificationInfo: call.request.notificationInfo as unknown as NotificationInfo,
|
||||||
|
});
|
||||||
callback(null, data);
|
callback(null, data);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
callback(e);
|
callback(e);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const delCron = (
|
|||||||
for (const id of call.request.ids) {
|
for (const id of call.request.ids) {
|
||||||
if (scheduleStacks.has(id)) {
|
if (scheduleStacks.has(id)) {
|
||||||
Logger.info(
|
Logger.info(
|
||||||
'[schedule][取消定时任务], 任务ID: %s',
|
'[schedule][取消定时任务] 任务ID: %s',
|
||||||
id,
|
id,
|
||||||
);
|
);
|
||||||
scheduleStacks.get(id)?.forEach(x => x.cancel());
|
scheduleStacks.get(id)?.forEach(x => x.cancel());
|
||||||
|
|||||||
+17
-3
@@ -215,14 +215,24 @@ export default class CronService {
|
|||||||
operate2 = Op.and;
|
operate2 = Op.and;
|
||||||
break;
|
break;
|
||||||
case 'In':
|
case 'In':
|
||||||
|
if (
|
||||||
|
property === 'status' &&
|
||||||
|
!value.includes(CrontabStatus.disabled)
|
||||||
|
) {
|
||||||
|
q[Op.and] = [
|
||||||
|
{ [property]: Array.isArray(value) ? value : [value] },
|
||||||
|
{ isDisabled: 0 },
|
||||||
|
];
|
||||||
|
} else {
|
||||||
q[Op.or] = [
|
q[Op.or] = [
|
||||||
{
|
{
|
||||||
[property]: Array.isArray(value) ? value : [value],
|
[property]: Array.isArray(value) ? value : [value],
|
||||||
},
|
},
|
||||||
property === 'status' && value.includes(2)
|
property === 'status' && value.includes(CrontabStatus.disabled)
|
||||||
? { isDisabled: 1 }
|
? { isDisabled: 1 }
|
||||||
: {},
|
: {},
|
||||||
];
|
];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'Nin':
|
case 'Nin':
|
||||||
q[Op.and] = [
|
q[Op.and] = [
|
||||||
@@ -560,7 +570,10 @@ export default class CronService {
|
|||||||
if (logFileExist) {
|
if (logFileExist) {
|
||||||
return await getFileContentByName(`${absolutePath}`);
|
return await getFileContentByName(`${absolutePath}`);
|
||||||
} else {
|
} else {
|
||||||
return '任务未运行';
|
return typeof doc.status === 'number' &&
|
||||||
|
[CrontabStatus.queued, CrontabStatus.running].includes(doc.status)
|
||||||
|
? '运行中...'
|
||||||
|
: '日志不存在...';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,7 +593,7 @@ export default class CronService {
|
|||||||
files.map(async (x) => ({
|
files.map(async (x) => ({
|
||||||
filename: x,
|
filename: x,
|
||||||
directory: relativeDir.replace(config.logPath, ''),
|
directory: relativeDir.replace(config.logPath, ''),
|
||||||
time: (await fs.lstat(`${dir}/${x}`)).mtime.getTime(),
|
time: (await fs.lstat(`${dir}/${x}`)).birthtimeMs,
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
).sort((a, b) => b.time - a.time);
|
).sort((a, b) => b.time - a.time);
|
||||||
@@ -694,6 +707,7 @@ export default class CronService {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if (isDemoEnv()) {
|
if (isDemoEnv()) {
|
||||||
|
await writeFileWithLock(config.crontabFile, '');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await cronClient.addCron(regularCrons);
|
await cronClient.addCron(regularCrons);
|
||||||
|
|||||||
+16
-26
@@ -6,7 +6,6 @@ import {
|
|||||||
DependenceStatus,
|
DependenceStatus,
|
||||||
DependenceTypes,
|
DependenceTypes,
|
||||||
DependenceModel,
|
DependenceModel,
|
||||||
GetDependenceCommandTypes,
|
|
||||||
versionDependenceCommandTypes,
|
versionDependenceCommandTypes,
|
||||||
} from '../data/dependence';
|
} from '../data/dependence';
|
||||||
import { spawn } from 'cross-spawn';
|
import { spawn } from 'cross-spawn';
|
||||||
@@ -19,6 +18,7 @@ import {
|
|||||||
promiseExecSuccess,
|
promiseExecSuccess,
|
||||||
getInstallCommand,
|
getInstallCommand,
|
||||||
getUninstallCommand,
|
getUninstallCommand,
|
||||||
|
getGetCommand,
|
||||||
} from '../config/util';
|
} from '../config/util';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import taskLimit from '../shared/pLimit';
|
import taskLimit from '../shared/pLimit';
|
||||||
@@ -98,34 +98,32 @@ export default class DependenceService {
|
|||||||
searchValue,
|
searchValue,
|
||||||
type,
|
type,
|
||||||
status,
|
status,
|
||||||
}: { searchValue: string; type: string; status: string },
|
}: {
|
||||||
|
searchValue: string;
|
||||||
|
type: keyof typeof DependenceTypes;
|
||||||
|
status: string;
|
||||||
|
},
|
||||||
sort: any = [],
|
sort: any = [],
|
||||||
query: any = {},
|
query: any = {},
|
||||||
): Promise<Dependence[]> {
|
): Promise<Dependence[]> {
|
||||||
let condition = {
|
let condition = query;
|
||||||
...query,
|
if (DependenceTypes[type]) {
|
||||||
type: DependenceTypes[type as any],
|
condition.type = DependenceTypes[type];
|
||||||
};
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
condition.status = status.split(',').map(Number);
|
condition.status = status.split(',').map(Number);
|
||||||
}
|
}
|
||||||
if (searchValue) {
|
if (searchValue) {
|
||||||
const encodeText = encodeURI(searchValue);
|
const encodeText = encodeURI(searchValue);
|
||||||
const reg = {
|
condition.name = {
|
||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ [Op.like]: `%${searchValue}%` },
|
{ [Op.like]: `%${searchValue}%` },
|
||||||
{ [Op.like]: `%${encodeText}%` },
|
{ [Op.like]: `%${encodeText}%` },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
condition = {
|
|
||||||
...condition,
|
|
||||||
name: reg,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const result = await this.find(condition, sort);
|
return await this.find(condition, sort);
|
||||||
return result as any;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -163,11 +161,9 @@ export default class DependenceService {
|
|||||||
taskLimit.removeQueuedDependency(doc);
|
taskLimit.removeQueuedDependency(doc);
|
||||||
const depInstallCommand = getInstallCommand(doc.type, doc.name);
|
const depInstallCommand = getInstallCommand(doc.type, doc.name);
|
||||||
const depUnInstallCommand = getUninstallCommand(doc.type, doc.name);
|
const depUnInstallCommand = getUninstallCommand(doc.type, doc.name);
|
||||||
const installCmd = `${depInstallCommand} ${doc.name.trim()}`;
|
|
||||||
const unInstallCmd = `${depUnInstallCommand} ${doc.name.trim()}`;
|
|
||||||
const pids = await Promise.all([
|
const pids = await Promise.all([
|
||||||
getPid(installCmd),
|
getPid(depInstallCommand),
|
||||||
getPid(unInstallCmd),
|
getPid(depUnInstallCommand),
|
||||||
]);
|
]);
|
||||||
for (const pid of pids) {
|
for (const pid of pids) {
|
||||||
pid && (await killTask(pid));
|
pid && (await killTask(pid));
|
||||||
@@ -252,7 +248,7 @@ export default class DependenceService {
|
|||||||
|
|
||||||
// 判断是否已经安装过依赖
|
// 判断是否已经安装过依赖
|
||||||
if (isInstall && !force) {
|
if (isInstall && !force) {
|
||||||
const getCommandPrefix = GetDependenceCommandTypes[dependency.type];
|
const getCommand = getGetCommand(dependency.type, depName);
|
||||||
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
const depVersionStr = versionDependenceCommandTypes[dependency.type];
|
||||||
let depVersion = '';
|
let depVersion = '';
|
||||||
if (depName.includes(depVersionStr)) {
|
if (depName.includes(depVersionStr)) {
|
||||||
@@ -269,13 +265,7 @@ export default class DependenceService {
|
|||||||
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
const isLinuxDependence = dependency.type === DependenceTypes.linux;
|
||||||
const isPythonDependence =
|
const isPythonDependence =
|
||||||
dependency.type === DependenceTypes.python3;
|
dependency.type === DependenceTypes.python3;
|
||||||
const depInfo = (
|
const depInfo = (await promiseExecSuccess(getCommand))
|
||||||
await promiseExecSuccess(
|
|
||||||
isNodeDependence
|
|
||||||
? `${getCommandPrefix} | grep "${depName}" | head -1`
|
|
||||||
: `${getCommandPrefix} ${depName}`,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.replace(/\s{2,}/, ' ')
|
.replace(/\s{2,}/, ' ')
|
||||||
.replace(/\s+$/, '');
|
.replace(/\s+$/, '');
|
||||||
|
|
||||||
|
|||||||
+36
-5
@@ -49,12 +49,21 @@ export default class NotificationService {
|
|||||||
public async notify(
|
public async notify(
|
||||||
title: string,
|
title: string,
|
||||||
content: string,
|
content: string,
|
||||||
|
notificationInfo?: NotificationInfo,
|
||||||
): Promise<boolean | undefined> {
|
): Promise<boolean | undefined> {
|
||||||
const { type, ...rest } = await this.userService.getNotificationMode();
|
let { type, ...rest } = await this.userService.getNotificationMode();
|
||||||
|
if (notificationInfo?.type) {
|
||||||
|
type = notificationInfo?.type;
|
||||||
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.params = rest;
|
let params = rest;
|
||||||
|
if (notificationInfo) {
|
||||||
|
const { type: _, ...others } = notificationInfo;
|
||||||
|
params = { ...rest, ...others };
|
||||||
|
}
|
||||||
|
this.params = params;
|
||||||
const notificationModeAction = this.modeMap.get(type);
|
const notificationModeAction = this.modeMap.get(type);
|
||||||
try {
|
try {
|
||||||
return await notificationModeAction?.call(this);
|
return await notificationModeAction?.call(this);
|
||||||
@@ -623,20 +632,42 @@ export default class NotificationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async ntfy() {
|
private async ntfy() {
|
||||||
const { ntfyUrl, ntfyTopic, ntfyPriority } = this.params;
|
const {
|
||||||
|
ntfyUrl,
|
||||||
|
ntfyTopic,
|
||||||
|
ntfyPriority,
|
||||||
|
ntfyToken,
|
||||||
|
ntfyUsername,
|
||||||
|
ntfyPassword,
|
||||||
|
ntfyActions,
|
||||||
|
} = this.params;
|
||||||
// 编码函数
|
// 编码函数
|
||||||
const encodeRfc2047 = (text: string, charset: string = 'UTF-8'): string => {
|
const encodeRfc2047 = (text: string, charset: string = 'UTF-8'): string => {
|
||||||
const encodedText = Buffer.from(text).toString('base64');
|
const encodedText = Buffer.from(text).toString('base64');
|
||||||
return `=?${charset}?B?${encodedText}?=`;
|
return `=?${charset}?B?${encodedText}?=`;
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const encodedTitle = encodeRfc2047(this.title);
|
const headers: Record<string, string> = {
|
||||||
|
Title: encodeRfc2047(this.title),
|
||||||
|
Priority: `${ntfyPriority || '3'}`,
|
||||||
|
Icon: 'https://qn.whyour.cn/logo.png',
|
||||||
|
};
|
||||||
|
if (ntfyToken) {
|
||||||
|
headers['Authorization'] = `Bearer ${ntfyToken}`;
|
||||||
|
} else if (ntfyUsername && ntfyPassword) {
|
||||||
|
headers['Authorization'] = `Basic ${Buffer.from(
|
||||||
|
`${ntfyUsername}:${ntfyPassword}`,
|
||||||
|
).toString('base64')}`;
|
||||||
|
}
|
||||||
|
if (ntfyActions) {
|
||||||
|
headers['Actions'] = encodeRfc2047(ntfyActions);
|
||||||
|
}
|
||||||
const res = await httpClient.request(
|
const res = await httpClient.request(
|
||||||
`${ntfyUrl || 'https://ntfy.sh'}/${ntfyTopic}`,
|
`${ntfyUrl || 'https://ntfy.sh'}/${ntfyTopic}`,
|
||||||
{
|
{
|
||||||
...this.gotOption,
|
...this.gotOption,
|
||||||
body: `${this.content}`,
|
body: `${this.content}`,
|
||||||
headers: { Title: encodedTitle, Priority: `${ntfyPriority || '3'}` },
|
headers: headers,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ export default class ScheduleService {
|
|||||||
) {
|
) {
|
||||||
const _id = this.formatId(id);
|
const _id = this.formatId(id);
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
'[panel][创建cron任务], 任务ID: %s, cron: %s, 任务名: %s, 执行命令: %s',
|
'[panel][创建cron任务] 任务ID: %s, cron: %s, 任务名: %s, 执行命令: %s',
|
||||||
_id,
|
_id,
|
||||||
schedule,
|
schedule,
|
||||||
name,
|
name,
|
||||||
@@ -172,7 +172,7 @@ export default class ScheduleService {
|
|||||||
|
|
||||||
async cancelCronTask({ id = 0, name }: ScheduleTaskType) {
|
async cancelCronTask({ id = 0, name }: ScheduleTaskType) {
|
||||||
const _id = this.formatId(id);
|
const _id = this.formatId(id);
|
||||||
this.logger.info('[panel][取消定时任务], 任务名: %s', name);
|
this.logger.info('[panel][取消定时任务] 任务名: %s', name);
|
||||||
if (this.scheduleStacks.has(_id)) {
|
if (this.scheduleStacks.has(_id)) {
|
||||||
this.scheduleStacks.get(_id)?.cancel();
|
this.scheduleStacks.get(_id)?.cancel();
|
||||||
this.scheduleStacks.delete(_id);
|
this.scheduleStacks.delete(_id);
|
||||||
@@ -187,7 +187,7 @@ export default class ScheduleService {
|
|||||||
) {
|
) {
|
||||||
const _id = this.formatId(id);
|
const _id = this.formatId(id);
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
'[panel][创建interval任务], 任务ID: %s, 任务名: %s, 执行命令: %s',
|
'[panel][创建interval任务] 任务ID: %s, 任务名: %s, 执行命令: %s',
|
||||||
_id,
|
_id,
|
||||||
name,
|
name,
|
||||||
command,
|
command,
|
||||||
@@ -232,7 +232,7 @@ export default class ScheduleService {
|
|||||||
async cancelIntervalTask({ id = 0, name }: ScheduleTaskType) {
|
async cancelIntervalTask({ id = 0, name }: ScheduleTaskType) {
|
||||||
const _id = this.formatId(id);
|
const _id = this.formatId(id);
|
||||||
this.logger.info(
|
this.logger.info(
|
||||||
'[panel][取消interval任务], 任务ID: %s, 任务名: %s',
|
'[panel][取消interval任务] 任务ID: %s, 任务名: %s',
|
||||||
_id,
|
_id,
|
||||||
name,
|
name,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -26,12 +26,13 @@ export default class SshKeyService {
|
|||||||
if (_exist) {
|
if (_exist) {
|
||||||
config = await fs.readFile(this.sshConfigFilePath, { encoding: 'utf-8' });
|
config = await fs.readFile(this.sshConfigFilePath, { encoding: 'utf-8' });
|
||||||
} else {
|
} else {
|
||||||
await writeFileWithLock(this.sshConfigFilePath, '');
|
await writeFileWithLock(this.sshConfigFilePath, '', { mode: '600' });
|
||||||
}
|
}
|
||||||
if (!config.includes(this.sshConfigHeader)) {
|
if (!config.includes(this.sshConfigHeader)) {
|
||||||
await writeFileWithLock(
|
await writeFileWithLock(
|
||||||
this.sshConfigFilePath,
|
this.sshConfigFilePath,
|
||||||
`${this.sshConfigHeader}\n\n${config}`,
|
`${this.sshConfigHeader}\n\n${config}`,
|
||||||
|
{ mode: '600' },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +46,6 @@ export default class SshKeyService {
|
|||||||
path.join(this.sshPath, alias),
|
path.join(this.sshPath, alias),
|
||||||
`${key}${os.EOL}`,
|
`${key}${os.EOL}`,
|
||||||
{
|
{
|
||||||
encoding: 'utf8',
|
|
||||||
mode: '400',
|
mode: '400',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -81,6 +81,10 @@ export default class SshKeyService {
|
|||||||
await writeFileWithLock(
|
await writeFileWithLock(
|
||||||
`${path.join(this.sshPath, `${alias}.config`)}`,
|
`${path.join(this.sshPath, `${alias}.config`)}`,
|
||||||
config,
|
config,
|
||||||
|
{
|
||||||
|
encoding: 'utf8',
|
||||||
|
mode: '600',
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ export default class SubscriptionService {
|
|||||||
files.map(async (x) => ({
|
files.map(async (x) => ({
|
||||||
filename: x,
|
filename: x,
|
||||||
directory: relativeDir.replace(config.logPath, ''),
|
directory: relativeDir.replace(config.logPath, ''),
|
||||||
time: (await fs.lstat(`${dir}/${x}`)).mtime.getTime(),
|
time: (await fs.lstat(`${dir}/${x}`)).birthtimeMs,
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
).sort((a, b) => b.time - a.time);
|
).sort((a, b) => b.time - a.time);
|
||||||
|
|||||||
+44
-7
@@ -7,7 +7,7 @@ import path from 'path';
|
|||||||
import { Inject, Service } from 'typedi';
|
import { Inject, Service } from 'typedi';
|
||||||
import winston from 'winston';
|
import winston from 'winston';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import { TASK_COMMAND } from '../config/const';
|
import { NotificationModeStringMap, TASK_COMMAND } from '../config/const';
|
||||||
import {
|
import {
|
||||||
getPid,
|
getPid,
|
||||||
killTask,
|
killTask,
|
||||||
@@ -373,8 +373,27 @@ export default class SystemService {
|
|||||||
return { code: 200 };
|
return { code: 200 };
|
||||||
}
|
}
|
||||||
|
|
||||||
public async notify({ title, content }: { title: string; content: string }) {
|
public async notify({
|
||||||
const isSuccess = await this.notificationService.notify(title, content);
|
title,
|
||||||
|
content,
|
||||||
|
notificationInfo,
|
||||||
|
}: {
|
||||||
|
title: string;
|
||||||
|
content: string;
|
||||||
|
notificationInfo?: NotificationInfo;
|
||||||
|
}) {
|
||||||
|
const typeString =
|
||||||
|
typeof notificationInfo?.type === 'number'
|
||||||
|
? NotificationModeStringMap[notificationInfo.type]
|
||||||
|
: undefined;
|
||||||
|
if (notificationInfo && typeString) {
|
||||||
|
notificationInfo.type = typeString;
|
||||||
|
}
|
||||||
|
const isSuccess = await this.notificationService.notify(
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
notificationInfo,
|
||||||
|
);
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
return { code: 200, message: '通知发送成功' };
|
return { code: 200, message: '通知发送成功' };
|
||||||
} else {
|
} else {
|
||||||
@@ -382,11 +401,12 @@ export default class SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run({ command }: { command: string }, callback: TaskCallbacks) {
|
public async run({ command, logPath }: { command: string; logPath?: string }, callback: TaskCallbacks) {
|
||||||
if (!command.startsWith(TASK_COMMAND)) {
|
if (!command.startsWith(TASK_COMMAND)) {
|
||||||
command = `${TASK_COMMAND} ${command}`;
|
command = `${TASK_COMMAND} ${command}`;
|
||||||
}
|
}
|
||||||
this.scheduleService.runTask(`real_time=true ${command}`, callback, {
|
const logPathPrefix = logPath ? `real_log_path=${logPath}` : ''
|
||||||
|
this.scheduleService.runTask(`${logPathPrefix} real_time=true ${command}`, callback, {
|
||||||
command,
|
command,
|
||||||
id: command.replace(/ /g, '-'),
|
id: command.replace(/ /g, '-'),
|
||||||
runOrigin: 'system',
|
runOrigin: 'system',
|
||||||
@@ -415,10 +435,16 @@ export default class SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async exportData(res: Response) {
|
public async exportData(res: Response, type?: string[]) {
|
||||||
try {
|
try {
|
||||||
|
let dataDirs = ['db', 'upload'];
|
||||||
|
if (type && type.length) {
|
||||||
|
dataDirs = dataDirs.concat(type.filter((x) => x !== 'base'));
|
||||||
|
}
|
||||||
|
const dataPaths = dataDirs.map((dir) => `data/${dir}`);
|
||||||
await promiseExec(
|
await promiseExec(
|
||||||
`cd ${config.dataPath} && cd ../ && tar -zcvf ${config.dataTgzFile} data/`,
|
`cd ${config.dataPath} && cd ../ && tar -zcvf ${config.dataTgzFile
|
||||||
|
} ${dataPaths.join(' ')}`,
|
||||||
);
|
);
|
||||||
res.download(config.dataTgzFile);
|
res.download(config.dataTgzFile);
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -503,4 +529,15 @@ export default class SystemService {
|
|||||||
return { code: 400, message: '设置时区失败' };
|
return { code: 400, message: '设置时区失败' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async cleanDependence(type: 'node' | 'python3') {
|
||||||
|
if (!type || !['node', 'python3'].includes(type)) {
|
||||||
|
return { code: 400, message: '参数错误' };
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const finalPath = path.join(config.dependenceCachePath, type);
|
||||||
|
await fs.promises.rm(finalPath, { recursive: true });
|
||||||
|
} catch (error) { }
|
||||||
|
return { code: 200 };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function getUniqueLockPath(filePath: string) {
|
|||||||
|
|
||||||
export async function writeFileWithLock(
|
export async function writeFileWithLock(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
content: string | Buffer,
|
content: string,
|
||||||
options: Parameters<typeof writeFile>[2] = {},
|
options: Parameters<typeof writeFile>[2] = {},
|
||||||
) {
|
) {
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ RUN set -x \
|
|||||||
tzdata \
|
tzdata \
|
||||||
perl \
|
perl \
|
||||||
openssl \
|
openssl \
|
||||||
nginx \
|
|
||||||
nodejs \
|
nodejs \
|
||||||
jq \
|
jq \
|
||||||
openssh \
|
openssh \
|
||||||
@@ -84,6 +83,6 @@ COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
|||||||
WORKDIR ${QL_DIR}
|
WORKDIR ${QL_DIR}
|
||||||
|
|
||||||
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
||||||
CMD curl -sf --noproxy '*' http://127.0.0.1:5600/api/health || exit 1
|
CMD curl -sf --noproxy '*' http://127.0.0.1:5700/api/health || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
||||||
|
|||||||
+1
-2
@@ -39,7 +39,6 @@ RUN set -x \
|
|||||||
tzdata \
|
tzdata \
|
||||||
perl \
|
perl \
|
||||||
openssl \
|
openssl \
|
||||||
nginx \
|
|
||||||
nodejs \
|
nodejs \
|
||||||
jq \
|
jq \
|
||||||
openssh \
|
openssh \
|
||||||
@@ -84,6 +83,6 @@ COPY --from=builder /tmp/build/node_modules/. /ql/node_modules/
|
|||||||
WORKDIR ${QL_DIR}
|
WORKDIR ${QL_DIR}
|
||||||
|
|
||||||
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
HEALTHCHECK --interval=5s --timeout=2s --retries=20 \
|
||||||
CMD curl -sf --noproxy '*' http://127.0.0.1:5600/api/health || exit 1
|
CMD curl -sf --noproxy '*' http://127.0.0.1:5700/api/health || exit 1
|
||||||
|
|
||||||
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
ENTRYPOINT ["./docker/docker-entrypoint.sh"]
|
||||||
|
|||||||
@@ -14,26 +14,20 @@ log_with_style() {
|
|||||||
|
|
||||||
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
log_with_style "INFO" "🚀 1. 检测配置文件..."
|
||||||
import_config "$@"
|
import_config "$@"
|
||||||
make_dir /etc/nginx/conf.d
|
|
||||||
make_dir /run/nginx
|
|
||||||
init_nginx
|
|
||||||
fix_config
|
fix_config
|
||||||
|
|
||||||
pm2 l &>/dev/null
|
pm2 l &>/dev/null
|
||||||
|
|
||||||
log_with_style "INFO" "🔄 2. 启动 nginx..."
|
log_with_style "INFO" "⚙️ 2. 启动 pm2 服务..."
|
||||||
nginx -s reload 2>/dev/null || nginx -c /etc/nginx/nginx.conf
|
|
||||||
|
|
||||||
log_with_style "INFO" "⚙️ 3. 启动 pm2 服务..."
|
|
||||||
reload_pm2
|
reload_pm2
|
||||||
|
|
||||||
if [[ $AutoStartBot == true ]]; then
|
if [[ $AutoStartBot == true ]]; then
|
||||||
log_with_style "INFO" "🤖 4. 启动 bot..."
|
log_with_style "INFO" "🤖 3. 启动 bot..."
|
||||||
nohup ql bot >$dir_log/bot.log 2>&1 &
|
nohup ql bot >$dir_log/bot.log 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $EnableExtraShell == true ]]; then
|
if [[ $EnableExtraShell == true ]]; then
|
||||||
log_with_style "INFO" "🛠️ 5. 执行自定义脚本..."
|
log_with_style "INFO" "🛠️ 4. 执行自定义脚本..."
|
||||||
nohup ql extra >$dir_log/extra.log 2>&1 &
|
nohup ql extra >$dir_log/extra.log 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
upstream baseApi {
|
|
||||||
server 0.0.0.0:5600;
|
|
||||||
}
|
|
||||||
|
|
||||||
map $http_upgrade $connection_upgrade {
|
|
||||||
default keep-alive;
|
|
||||||
'websocket' upgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
IPV4_CONFIG
|
|
||||||
IPV6_CONFIG
|
|
||||||
ssl_session_timeout 5m;
|
|
||||||
|
|
||||||
location QL_BASE_URLapi/ {
|
|
||||||
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://baseApi/api/;
|
|
||||||
proxy_buffering off;
|
|
||||||
proxy_redirect default;
|
|
||||||
proxy_connect_timeout 1800;
|
|
||||||
proxy_send_timeout 1800;
|
|
||||||
proxy_read_timeout 1800;
|
|
||||||
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection $connection_upgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
location QL_BASE_URLopen/ {
|
|
||||||
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://baseApi/open/;
|
|
||||||
proxy_buffering off;
|
|
||||||
proxy_redirect default;
|
|
||||||
proxy_connect_timeout 1800;
|
|
||||||
proxy_send_timeout 1800;
|
|
||||||
proxy_read_timeout 1800;
|
|
||||||
}
|
|
||||||
|
|
||||||
gzip on;
|
|
||||||
gzip_static on;
|
|
||||||
gzip_types text/plain application/json application/javascript application/x-javascript text/css application/xml text/javascript;
|
|
||||||
gzip_proxied any;
|
|
||||||
gzip_vary on;
|
|
||||||
gzip_comp_level 6;
|
|
||||||
gzip_buffers 16 8k;
|
|
||||||
gzip_http_version 1.0;
|
|
||||||
QL_ROOT_CONFIG
|
|
||||||
|
|
||||||
location QL_BASE_URL_LOCATION {
|
|
||||||
QL_ALIAS_CONFIG
|
|
||||||
index index.html index.htm;
|
|
||||||
try_files $uri QL_BASE_URLindex.html;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ .*\.(html)$ {
|
|
||||||
add_header Cache-Control no-cache;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
user root;
|
|
||||||
worker_processes auto;
|
|
||||||
pcre_jit on;
|
|
||||||
error_log /var/log/nginx/error.log warn;
|
|
||||||
include /etc/nginx/modules/*.conf;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
|
|
||||||
server_tokens off;
|
|
||||||
|
|
||||||
client_max_body_size 4096m;
|
|
||||||
client_body_buffer_size 20m;
|
|
||||||
|
|
||||||
keepalive_timeout 65;
|
|
||||||
|
|
||||||
sendfile on;
|
|
||||||
|
|
||||||
tcp_nodelay on;
|
|
||||||
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
|
|
||||||
ssl_session_cache shared:SSL:2m;
|
|
||||||
|
|
||||||
gzip on;
|
|
||||||
gzip_static on;
|
|
||||||
gzip_types text/plain application/json application/javascript application/x-javascript text/css application/xml text/javascript;
|
|
||||||
gzip_proxied any;
|
|
||||||
gzip_vary on;
|
|
||||||
gzip_comp_level 6;
|
|
||||||
gzip_buffers 16 8k;
|
|
||||||
gzip_http_version 1.0;
|
|
||||||
|
|
||||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
||||||
'$status $body_bytes_sent "$http_referer" '
|
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
||||||
|
|
||||||
access_log /var/log/nginx/access.log main;
|
|
||||||
include /etc/nginx/conf.d/*.conf;
|
|
||||||
}
|
|
||||||
+12
-2
@@ -1,5 +1,15 @@
|
|||||||
{
|
{
|
||||||
"watch": ["back", ".env"],
|
"watch": [
|
||||||
|
"back",
|
||||||
|
".env"
|
||||||
|
],
|
||||||
"ext": "js,ts,json",
|
"ext": "js,ts,json",
|
||||||
"exec": "ts-node -P ./back/tsconfig.json ./back/app.ts"
|
"env": {
|
||||||
|
"NODE_ENV": "development",
|
||||||
|
"TS_NODE_PROJECT": "./back/tsconfig.json"
|
||||||
|
},
|
||||||
|
"verbose": true,
|
||||||
|
"execMap": {
|
||||||
|
"ts": "node --require ts-node/register"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-7
@@ -2,13 +2,12 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "concurrently -n w: npm:start:*",
|
"start": "concurrently -n w: npm:start:*",
|
||||||
"start:back": "nodemon",
|
"start:back": "nodemon ./back/app.ts",
|
||||||
"start:front": "max dev",
|
"start:front": "max dev",
|
||||||
"build:front": "max build",
|
"build:front": "max build",
|
||||||
"build:back": "tsc -p back/tsconfig.json",
|
"build:back": "tsc -p back/tsconfig.json",
|
||||||
"panel": "npm run build:back && node static/build/app.js",
|
"panel": "npm run build:back && node static/build/app.js",
|
||||||
"gen:proto": "protoc --experimental_allow_proto3_optional --plugin=./node_modules/.bin/protoc-gen-ts_proto ./back/protos/*.proto --ts_proto_out=./ --ts_proto_opt=outputServices=grpc-js,env=node,esModuleInterop=true,snakeToCamel=false",
|
"gen:proto": "protoc --experimental_allow_proto3_optional --plugin=./node_modules/.bin/protoc-gen-ts_proto ./back/protos/*.proto --ts_proto_out=./ --ts_proto_opt=outputServices=grpc-js,env=node,esModuleInterop=true,snakeToCamel=false",
|
||||||
"gen:api": "python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ./back/protos/api.proto",
|
|
||||||
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
|
||||||
"postinstall": "max setup 2>/dev/null || true",
|
"postinstall": "max setup 2>/dev/null || true",
|
||||||
"test": "umi-test",
|
"test": "umi-test",
|
||||||
@@ -55,8 +54,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@grpc/grpc-js": "^1.12.3",
|
"@grpc/grpc-js": "^1.14.0",
|
||||||
"@grpc/proto-loader": "^0.7.13",
|
"@grpc/proto-loader": "^0.8.0",
|
||||||
"@otplib/preset-default": "^12.0.1",
|
"@otplib/preset-default": "^12.0.1",
|
||||||
"body-parser": "^1.20.3",
|
"body-parser": "^1.20.3",
|
||||||
"celebrate": "^15.0.3",
|
"celebrate": "^15.0.3",
|
||||||
@@ -81,11 +80,10 @@
|
|||||||
"node-schedule": "^2.1.0",
|
"node-schedule": "^2.1.0",
|
||||||
"nodemailer": "^6.9.16",
|
"nodemailer": "^6.9.16",
|
||||||
"p-queue-cjs": "7.3.4",
|
"p-queue-cjs": "7.3.4",
|
||||||
"@bufbuild/protobuf": "^2.2.3",
|
"@bufbuild/protobuf": "^2.10.0",
|
||||||
"ps-tree": "^1.2.0",
|
"ps-tree": "^1.2.0",
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"sequelize": "^6.37.5",
|
"sequelize": "^6.37.5",
|
||||||
"serve-handler": "^6.1.6",
|
|
||||||
"sockjs": "^0.3.24",
|
"sockjs": "^0.3.24",
|
||||||
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
|
"sqlite3": "git+https://github.com/whyour/node-sqlite3.git#v1.0.3",
|
||||||
"toad-scheduler": "^3.0.1",
|
"toad-scheduler": "^3.0.1",
|
||||||
@@ -99,7 +97,7 @@
|
|||||||
"@keyv/sqlite": "^4.0.1",
|
"@keyv/sqlite": "^4.0.1",
|
||||||
"proper-lockfile": "^4.1.2",
|
"proper-lockfile": "^4.1.2",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"helmet": "^6.0.1"
|
"helmet": "^8.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
|
|||||||
Generated
+24
-74
@@ -9,14 +9,14 @@ overrides:
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@bufbuild/protobuf':
|
'@bufbuild/protobuf':
|
||||||
specifier: ^2.2.3
|
specifier: ^2.10.0
|
||||||
version: 2.2.3
|
version: 2.10.0
|
||||||
'@grpc/grpc-js':
|
'@grpc/grpc-js':
|
||||||
specifier: ^1.12.3
|
specifier: ^1.14.0
|
||||||
version: 1.12.3
|
version: 1.14.0
|
||||||
'@grpc/proto-loader':
|
'@grpc/proto-loader':
|
||||||
specifier: ^0.7.13
|
specifier: ^0.8.0
|
||||||
version: 0.7.13
|
version: 0.8.0
|
||||||
'@keyv/sqlite':
|
'@keyv/sqlite':
|
||||||
specifier: ^4.0.1
|
specifier: ^4.0.1
|
||||||
version: 4.0.1
|
version: 4.0.1
|
||||||
@@ -63,8 +63,8 @@ dependencies:
|
|||||||
specifier: ^2.0.3
|
specifier: ^2.0.3
|
||||||
version: 2.0.3
|
version: 2.0.3
|
||||||
helmet:
|
helmet:
|
||||||
specifier: ^6.0.1
|
specifier: ^8.1.0
|
||||||
version: 6.2.0
|
version: 8.1.0
|
||||||
hpagent:
|
hpagent:
|
||||||
specifier: ^1.2.0
|
specifier: ^1.2.0
|
||||||
version: 1.2.0
|
version: 1.2.0
|
||||||
@@ -116,9 +116,6 @@ dependencies:
|
|||||||
sequelize:
|
sequelize:
|
||||||
specifier: ^6.37.5
|
specifier: ^6.37.5
|
||||||
version: 6.37.5(@whyour/sqlite3@1.0.3)
|
version: 6.37.5(@whyour/sqlite3@1.0.3)
|
||||||
serve-handler:
|
|
||||||
specifier: ^6.1.6
|
|
||||||
version: 6.1.6
|
|
||||||
sockjs:
|
sockjs:
|
||||||
specifier: ^0.3.24
|
specifier: ^0.3.24
|
||||||
version: 0.3.24
|
version: 0.3.24
|
||||||
@@ -1389,8 +1386,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-h0OYmPR3A5Dfbetra/GzxBAzQk8sH7LhRkRUTdagX6nrtlUgJGYCTv4bBK33jsTQw9HDd8PE2x1Ma+iRKEDUsw==}
|
resolution: {integrity: sha512-h0OYmPR3A5Dfbetra/GzxBAzQk8sH7LhRkRUTdagX6nrtlUgJGYCTv4bBK33jsTQw9HDd8PE2x1Ma+iRKEDUsw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@bufbuild/protobuf@2.2.3:
|
/@bufbuild/protobuf@2.10.0:
|
||||||
resolution: {integrity: sha512-tFQoXHJdkEOSwj5tRIZSPNUuXK3RaR7T1nUrPgbYX1pUbvqqaaZAsfo+NXBPsz5rZMSKVFrgK1WL8Q/MSLvprg==}
|
resolution: {integrity: sha512-fdRs9PSrBF7QUntpZpq6BTw58fhgGJojgg39m9oFOJGZT+nip9b0so5cYY1oWl5pvemDLr0cPPsH46vwThEbpQ==}
|
||||||
|
|
||||||
/@chenshuai2144/sketch-color@1.0.9(react@18.3.1):
|
/@chenshuai2144/sketch-color@1.0.9(react@18.3.1):
|
||||||
resolution: {integrity: sha512-obzSy26cb7Pm7OprWyVpgMpIlrZpZ0B7vbrU0RMbvRg0YAI890S5Xy02Aj1Nhl4+KTbi1lVYHt6HQP8Hm9s+1w==}
|
resolution: {integrity: sha512-obzSy26cb7Pm7OprWyVpgMpIlrZpZ0B7vbrU0RMbvRg0YAI890S5Xy02Aj1Nhl4+KTbi1lVYHt6HQP8Hm9s+1w==}
|
||||||
@@ -2585,22 +2582,22 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/@grpc/grpc-js@1.12.3:
|
/@grpc/grpc-js@1.14.0:
|
||||||
resolution: {integrity: sha512-iaxAZnANdCwMNpJlyhkI1W1jQZIDZKFNtU2OpQDdgd+pBcU3t7G+PT7svobkW4WSZTdis+CVV6y8KIwu83HDYQ==}
|
resolution: {integrity: sha512-N8Jx6PaYzcTRNzirReJCtADVoq4z7+1KQ4E70jTg/koQiMoUSN1kbNjPOqpPbhMFhfU1/l7ixspPl8dNY+FoUg==}
|
||||||
engines: {node: '>=12.10.0'}
|
engines: {node: '>=12.10.0'}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@grpc/proto-loader': 0.7.13
|
'@grpc/proto-loader': 0.8.0
|
||||||
'@js-sdsl/ordered-map': 4.4.2
|
'@js-sdsl/ordered-map': 4.4.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@grpc/proto-loader@0.7.13:
|
/@grpc/proto-loader@0.8.0:
|
||||||
resolution: {integrity: sha512-AiXO/bfe9bmxBjxxtYxFAXGZvMaN5s8kO+jBHAJCON8rJoB5YS/D6X7ZNc6XQkuHNmyl4CYaMI1fJ/Gn27RGGw==}
|
resolution: {integrity: sha512-rc1hOQtjIWGxcxpb9aHAfLpIctjEnsDehj0DAiVfBlmT84uvR0uUtN2hEi/ecvWVjXUGf5qPF4qEgiLOx1YIMQ==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash.camelcase: 4.3.0
|
lodash.camelcase: 4.3.0
|
||||||
long: 5.2.3
|
long: 5.2.3
|
||||||
protobufjs: 7.4.0
|
protobufjs: 7.5.4
|
||||||
yargs: 17.7.2
|
yargs: 17.7.2
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
@@ -3876,7 +3873,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-ONIn/nSNQA57yRge3oaMQESef/6QhoeX7llWeDli0UZIfz8TQMkfNPTXA8VnnyeA1WUjG2pGqdjEIueYonMdfQ==}
|
resolution: {integrity: sha512-ONIn/nSNQA57yRge3oaMQESef/6QhoeX7llWeDli0UZIfz8TQMkfNPTXA8VnnyeA1WUjG2pGqdjEIueYonMdfQ==}
|
||||||
deprecated: This is a stub types definition. helmet provides its own type definitions, so you do not need this installed.
|
deprecated: This is a stub types definition. helmet provides its own type definitions, so you do not need this installed.
|
||||||
dependencies:
|
dependencies:
|
||||||
helmet: 6.2.0
|
helmet: 8.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/hoist-non-react-statics@3.3.5:
|
/@types/hoist-non-react-statics@3.3.5:
|
||||||
@@ -5962,11 +5959,6 @@ packages:
|
|||||||
streamsearch: 1.1.0
|
streamsearch: 1.1.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/bytes@3.0.0:
|
|
||||||
resolution: {integrity: sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw==}
|
|
||||||
engines: {node: '>= 0.8'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/bytes@3.1.2:
|
/bytes@3.1.2:
|
||||||
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
|
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
|
||||||
engines: {node: '>= 0.8'}
|
engines: {node: '>= 0.8'}
|
||||||
@@ -6384,11 +6376,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==}
|
resolution: {integrity: sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/content-disposition@0.5.2:
|
|
||||||
resolution: {integrity: sha512-kRGRZw3bLlFISDBgwTSA1TMBFN6J6GWDeubmDE3AF+3+yXL8hTWv8r5rkLbqYXY4RjPk/EzHnClI3zQf1cFmHA==}
|
|
||||||
engines: {node: '>= 0.6'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/content-disposition@0.5.4:
|
/content-disposition@0.5.4:
|
||||||
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
|
resolution: {integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
@@ -8480,9 +8467,9 @@ packages:
|
|||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/helmet@6.2.0:
|
/helmet@8.1.0:
|
||||||
resolution: {integrity: sha512-DWlwuXLLqbrIOltR6tFQXShj/+7Cyp0gLi6uAb8qMdFh/YBBFbKSgQ6nbXmScYd8emMctuthmgIa7tUfo9Rtyg==}
|
resolution: {integrity: sha512-jOiHyAZsmnr8LqoPGmCjYAaiuWwjAPLgY8ZX2XrmHawt99/u1y6RgrZMTeoPfpUbV96HOalYgz1qzkRbw54Pmg==}
|
||||||
engines: {node: '>=14.0.0'}
|
engines: {node: '>=18.0.0'}
|
||||||
|
|
||||||
/history@5.3.0:
|
/history@5.3.0:
|
||||||
resolution: {integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==}
|
resolution: {integrity: sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==}
|
||||||
@@ -9961,11 +9948,6 @@ packages:
|
|||||||
brorand: 1.1.0
|
brorand: 1.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/mime-db@1.33.0:
|
|
||||||
resolution: {integrity: sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==}
|
|
||||||
engines: {node: '>= 0.6'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/mime-db@1.52.0:
|
/mime-db@1.52.0:
|
||||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
@@ -9974,13 +9956,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg==}
|
resolution: {integrity: sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
/mime-types@2.1.18:
|
|
||||||
resolution: {integrity: sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==}
|
|
||||||
engines: {node: '>= 0.6'}
|
|
||||||
dependencies:
|
|
||||||
mime-db: 1.33.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/mime-types@2.1.35:
|
/mime-types@2.1.35:
|
||||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
@@ -10776,10 +10751,6 @@ packages:
|
|||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
|
|
||||||
/path-is-inside@1.0.2:
|
|
||||||
resolution: {integrity: sha512-DUWJr3+ULp4zXmol/SZkFf3JGsS9/SIv+Y3Rt93/UjPpDpklB5f1er4O3POIbUuUJ3FXgqte2Q7SrU6zAqwk8w==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/path-key@3.1.1:
|
/path-key@3.1.1:
|
||||||
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
|
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
@@ -10814,10 +10785,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==}
|
resolution: {integrity: sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/path-to-regexp@3.3.0:
|
|
||||||
resolution: {integrity: sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/path-to-regexp@6.3.0:
|
/path-to-regexp@6.3.0:
|
||||||
resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==}
|
resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==}
|
||||||
dev: false
|
dev: false
|
||||||
@@ -11603,8 +11570,8 @@ packages:
|
|||||||
signal-exit: 3.0.7
|
signal-exit: 3.0.7
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/protobufjs@7.4.0:
|
/protobufjs@7.5.4:
|
||||||
resolution: {integrity: sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==}
|
resolution: {integrity: sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -11808,11 +11775,6 @@ packages:
|
|||||||
safe-buffer: 5.2.1
|
safe-buffer: 5.2.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/range-parser@1.2.0:
|
|
||||||
resolution: {integrity: sha512-kA5WQoNVo4t9lNx2kQNFCxKeBl5IbbSNBl1M/tLkw9WCn+hxNBAW5Qh8gdhs63CJnhjJ2zQWFoqPJP2sK1AV5A==}
|
|
||||||
engines: {node: '>= 0.6'}
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/range-parser@1.2.1:
|
/range-parser@1.2.1:
|
||||||
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
|
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
|
||||||
engines: {node: '>= 0.6'}
|
engines: {node: '>= 0.6'}
|
||||||
@@ -13412,18 +13374,6 @@ packages:
|
|||||||
randombytes: 2.1.0
|
randombytes: 2.1.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/serve-handler@6.1.6:
|
|
||||||
resolution: {integrity: sha512-x5RL9Y2p5+Sh3D38Fh9i/iQ5ZK+e4xuXRd/pGbM4D13tgo/MGwbttUk8emytcr1YYzBYs+apnUngBDFYfpjPuQ==}
|
|
||||||
dependencies:
|
|
||||||
bytes: 3.0.0
|
|
||||||
content-disposition: 0.5.2
|
|
||||||
mime-types: 2.1.18
|
|
||||||
minimatch: 3.1.2
|
|
||||||
path-is-inside: 1.0.2
|
|
||||||
path-to-regexp: 3.3.0
|
|
||||||
range-parser: 1.2.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/serve-static@1.16.2:
|
/serve-static@1.16.2:
|
||||||
resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==}
|
resolution: {integrity: sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
@@ -14383,14 +14333,14 @@ packages:
|
|||||||
/ts-proto-descriptors@2.0.0:
|
/ts-proto-descriptors@2.0.0:
|
||||||
resolution: {integrity: sha512-wHcTH3xIv11jxgkX5OyCSFfw27agpInAd6yh89hKG6zqIXnjW9SYqSER2CVQxdPj4czeOhGagNvZBEbJPy7qkw==}
|
resolution: {integrity: sha512-wHcTH3xIv11jxgkX5OyCSFfw27agpInAd6yh89hKG6zqIXnjW9SYqSER2CVQxdPj4czeOhGagNvZBEbJPy7qkw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@bufbuild/protobuf': 2.2.3
|
'@bufbuild/protobuf': 2.10.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/ts-proto@2.6.1:
|
/ts-proto@2.6.1:
|
||||||
resolution: {integrity: sha512-4LTT99MkwkF1+fIA0b2mZu/58Qlpq3Q1g53TwEMZZgR1w/uX00PoVT4Z8aKJxMw0LeKQD4s9NrJYsF27Clckrg==}
|
resolution: {integrity: sha512-4LTT99MkwkF1+fIA0b2mZu/58Qlpq3Q1g53TwEMZZgR1w/uX00PoVT4Z8aKJxMw0LeKQD4s9NrJYsF27Clckrg==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dependencies:
|
dependencies:
|
||||||
'@bufbuild/protobuf': 2.2.3
|
'@bufbuild/protobuf': 2.10.0
|
||||||
case-anything: 2.1.13
|
case-anything: 2.1.13
|
||||||
ts-poet: 6.9.0
|
ts-poet: 6.9.0
|
||||||
ts-proto-descriptors: 2.0.0
|
ts-proto-descriptors: 2.0.0
|
||||||
|
|||||||
@@ -226,9 +226,17 @@ export QMSG_TYPE=""
|
|||||||
## ntfy_url 填写ntfy地址,如https://ntfy.sh
|
## ntfy_url 填写ntfy地址,如https://ntfy.sh
|
||||||
## ntfy_topic 填写ntfy的消息应用topic
|
## ntfy_topic 填写ntfy的消息应用topic
|
||||||
## ntfy_priority 填写推送消息优先级,默认为3
|
## ntfy_priority 填写推送消息优先级,默认为3
|
||||||
|
## ntfy_token 填写推送token,可选
|
||||||
|
## ntfy_username 填写推送用户名称,可选
|
||||||
|
## ntfy_password 填写推送用户密码,可选
|
||||||
|
## ntfy_actions 填写推送用户动作,可选
|
||||||
export NTFY_URL=""
|
export NTFY_URL=""
|
||||||
export NTFY_TOPIC=""
|
export NTFY_TOPIC=""
|
||||||
export NTFY_PRIORITY="3"
|
export NTFY_PRIORITY="3"
|
||||||
|
export NTFY_TOKEN=""
|
||||||
|
export NTFY_USERNAME=""
|
||||||
|
export NTFY_PASSWORD=""
|
||||||
|
export NTFY_ACTIONS=""
|
||||||
|
|
||||||
## 21. wxPusher
|
## 21. wxPusher
|
||||||
## 官方文档: https://wxpusher.zjiecode.com/docs/
|
## 官方文档: https://wxpusher.zjiecode.com/docs/
|
||||||
|
|||||||
+15
-1
@@ -140,6 +140,10 @@ const push_config = {
|
|||||||
NTFY_URL: '', // ntfy地址,如https://ntfy.sh,默认为https://ntfy.sh
|
NTFY_URL: '', // ntfy地址,如https://ntfy.sh,默认为https://ntfy.sh
|
||||||
NTFY_TOPIC: '', // ntfy的消息应用topic
|
NTFY_TOPIC: '', // ntfy的消息应用topic
|
||||||
NTFY_PRIORITY: '3', // 推送消息优先级,默认为3
|
NTFY_PRIORITY: '3', // 推送消息优先级,默认为3
|
||||||
|
NTFY_TOKEN: '', // 推送token,可选
|
||||||
|
NTFY_USERNAME: '', // 推送用户名称,可选
|
||||||
|
NTFY_PASSWORD: '', // 推送用户密码,可选
|
||||||
|
NTFY_ACTIONS: '', // 推送用户动作,可选
|
||||||
|
|
||||||
// 官方文档: https://wxpusher.zjiecode.com/docs/
|
// 官方文档: https://wxpusher.zjiecode.com/docs/
|
||||||
// 管理后台: https://wxpusher.zjiecode.com/admin/
|
// 管理后台: https://wxpusher.zjiecode.com/admin/
|
||||||
@@ -1258,7 +1262,7 @@ function ntfyNotify(text, desp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY } = push_config;
|
const { NTFY_URL, NTFY_TOPIC, NTFY_PRIORITY, NTFY_TOKEN, NTFY_USERNAME, NTFY_PASSWORD, NTFY_ACTIONS } = push_config;
|
||||||
if (NTFY_TOPIC) {
|
if (NTFY_TOPIC) {
|
||||||
const options = {
|
const options = {
|
||||||
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
url: `${NTFY_URL || 'https://ntfy.sh'}/${NTFY_TOPIC}`,
|
||||||
@@ -1266,9 +1270,19 @@ function ntfyNotify(text, desp) {
|
|||||||
headers: {
|
headers: {
|
||||||
Title: `${encodeRFC2047(text)}`,
|
Title: `${encodeRFC2047(text)}`,
|
||||||
Priority: NTFY_PRIORITY || '3',
|
Priority: NTFY_PRIORITY || '3',
|
||||||
|
Icon: 'https://qn.whyour.cn/logo.png',
|
||||||
},
|
},
|
||||||
timeout,
|
timeout,
|
||||||
};
|
};
|
||||||
|
if (NTFY_TOKEN) {
|
||||||
|
options.headers['Authorization'] = `Bearer ${NTFY_TOKEN}`;
|
||||||
|
} else if (NTFY_USERNAME && NTFY_PASSWORD) {
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`${NTFY_USERNAME}:${NTFY_PASSWORD}`).toString('base64')}`;
|
||||||
|
}
|
||||||
|
if (NTFY_ACTIONS) {
|
||||||
|
options.headers['Actions'] = encodeRFC2047(NTFY_ACTIONS);
|
||||||
|
}
|
||||||
|
|
||||||
$.post(options, (err, resp, data) => {
|
$.post(options, (err, resp, data) => {
|
||||||
try {
|
try {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
+12
-1
@@ -126,6 +126,10 @@ push_config = {
|
|||||||
'NTFY_URL': '', # ntfy地址,如https://ntfy.sh
|
'NTFY_URL': '', # ntfy地址,如https://ntfy.sh
|
||||||
'NTFY_TOPIC': '', # ntfy的消息应用topic
|
'NTFY_TOPIC': '', # ntfy的消息应用topic
|
||||||
'NTFY_PRIORITY':'3', # 推送消息优先级,默认为3
|
'NTFY_PRIORITY':'3', # 推送消息优先级,默认为3
|
||||||
|
'NTFY_TOKEN': '', # 推送token,可选
|
||||||
|
'NTFY_USERNAME': '', # 推送用户名称,可选
|
||||||
|
'NTFY_PASSWORD': '', # 推送用户密码,可选
|
||||||
|
'NTFY_ACTIONS': '', # 推送用户动作,可选
|
||||||
|
|
||||||
'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
|
'WXPUSHER_APP_TOKEN': '', # wxpusher 的 appToken 官方文档: https://wxpusher.zjiecode.com/docs/ 管理后台: https://wxpusher.zjiecode.com/admin/
|
||||||
'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
'WXPUSHER_TOPIC_IDS': '', # wxpusher 的 主题ID,多个用英文分号;分隔 topic_ids 与 uids 至少配置一个才行
|
||||||
@@ -806,7 +810,14 @@ def ntfy(title: str, content: str) -> None:
|
|||||||
encoded_title = encode_rfc2047(title)
|
encoded_title = encode_rfc2047(title)
|
||||||
|
|
||||||
data = content.encode(encoding="utf-8")
|
data = content.encode(encoding="utf-8")
|
||||||
headers = {"Title": encoded_title, "Priority": priority} # 使用编码后的 title
|
headers = {"Title": encoded_title, "Priority": priority, "Icon": "https://qn.whyour.cn/logo.png"} # 使用编码后的 title
|
||||||
|
if push_config.get("NTFY_TOKEN"):
|
||||||
|
headers['Authorization'] = "Bearer " + push_config.get("NTFY_TOKEN")
|
||||||
|
elif push_config.get("NTFY_USERNAME") and push_config.get("NTFY_PASSWORD"):
|
||||||
|
authStr = push_config.get("NTFY_USERNAME") + ":" + push_config.get("NTFY_PASSWORD")
|
||||||
|
headers['Authorization'] = "Basic " + base64.b64encode(authStr.encode('utf-8')).decode('utf-8')
|
||||||
|
if push_config.get("NTFY_ACTIONS"):
|
||||||
|
headers['Actions'] = encode_rfc2047(push_config.get("NTFY_ACTIONS"))
|
||||||
|
|
||||||
url = push_config.get("NTFY_URL") + "/" + push_config.get("NTFY_TOPIC")
|
url = push_config.get("NTFY_URL") + "/" + push_config.get("NTFY_TOPIC")
|
||||||
response = requests.post(url, data=data, headers=headers)
|
response = requests.post(url, data=data, headers=headers)
|
||||||
|
|||||||
+8
-48
@@ -41,14 +41,9 @@ add_cron_api() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/crons?t=$currentTimeStamp" \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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 "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"sub_id\":$sub_id}" \
|
--data-raw "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"sub_id\":$sub_id}" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
@@ -76,15 +71,10 @@ update_cron_api() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/crons?t=$currentTimeStamp" \
|
||||||
-X 'PUT' \
|
-X 'PUT' \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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 "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"id\":\"$id\"}" \
|
--data-raw "{\"name\":\"${name//\"/\\\"}\",\"command\":\"${command//\"/\\\"}\",\"schedule\":\"$schedule\",\"id\":\"$id\"}" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
@@ -108,15 +98,10 @@ update_cron_command_api() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/crons?t=$currentTimeStamp" \
|
||||||
-X 'PUT' \
|
-X 'PUT' \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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 "{\"command\":\"${command//\"/\\\"}\",\"id\":\"$id\"}" \
|
--data-raw "{\"command\":\"${command//\"/\\\"}\",\"id\":\"$id\"}" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
@@ -133,15 +118,10 @@ del_cron_api() {
|
|||||||
local ids="$1"
|
local ids="$1"
|
||||||
local currentTimeStamp=$(date +%s)
|
local currentTimeStamp=$(date +%s)
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/crons?t=$currentTimeStamp" \
|
||||||
-X 'DELETE' \
|
-X 'DELETE' \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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 "[$ids]" \
|
--data-raw "[$ids]" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
@@ -163,15 +143,10 @@ update_cron() {
|
|||||||
local runningTime="${6:-0}"
|
local runningTime="${6:-0}"
|
||||||
local currentTimeStamp=$(date +%s)
|
local currentTimeStamp=$(date +%s)
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons/status?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/crons/status?t=$currentTimeStamp" \
|
||||||
-X 'PUT' \
|
-X 'PUT' \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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 "{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime}" \
|
--data-raw "{\"ids\":[$ids],\"status\":\"$status\",\"pid\":\"$pid\",\"log_path\":\"$logPath\",\"last_execution_time\":$lastExecutingTime,\"last_running_time\":$runningTime}" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
@@ -190,15 +165,10 @@ notify_api() {
|
|||||||
local content="$2"
|
local content="$2"
|
||||||
local currentTimeStamp=$(date +%s)
|
local currentTimeStamp=$(date +%s)
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/system/notify?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/system/notify?t=$currentTimeStamp" \
|
||||||
-X 'PUT' \
|
-X 'PUT' \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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//\"/\\\"}\"}" \
|
--data-raw "{\"title\":\"${title//\"/\\\"}\",\"content\":\"${content//\"/\\\"}\"}" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
@@ -215,14 +185,9 @@ find_cron_api() {
|
|||||||
local params="$1"
|
local params="$1"
|
||||||
local currentTimeStamp=$(date +%s)
|
local currentTimeStamp=$(date +%s)
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/crons/detail?$params&t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/crons/detail?$params&t=$currentTimeStamp" \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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" \
|
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
data=$(echo "$api" | jq -r .data)
|
data=$(echo "$api" | jq -r .data)
|
||||||
@@ -239,15 +204,10 @@ update_auth_config() {
|
|||||||
local tip="$2"
|
local tip="$2"
|
||||||
local currentTimeStamp=$(date +%s)
|
local currentTimeStamp=$(date +%s)
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/open/system/auth/reset?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/open/system/auth/reset?t=$currentTimeStamp" \
|
||||||
-X 'PUT' \
|
-X 'PUT' \
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${__ql_token__}" \
|
-H "Authorization: Bearer ${__ql_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 "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 "{$body}" \
|
--data-raw "{$body}" \
|
||||||
--compressed
|
--compressed
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-18
@@ -20,10 +20,6 @@ copy_dep() {
|
|||||||
echo -e "---> 复制一份 $file_notify_js_sample 为 $file_notify_js\n"
|
echo -e "---> 复制一份 $file_notify_js_sample 为 $file_notify_js\n"
|
||||||
cp -fv $file_notify_js_sample $file_notify_js
|
cp -fv $file_notify_js_sample $file_notify_js
|
||||||
echo -e "---> 通知文件复制完成\n"
|
echo -e "---> 通知文件复制完成\n"
|
||||||
|
|
||||||
echo -e "---> 2. 复制nginx配置文件\n"
|
|
||||||
init_nginx
|
|
||||||
echo -e "---> 配置文件复制完成\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pm2_log() {
|
pm2_log() {
|
||||||
@@ -34,18 +30,6 @@ pm2_log() {
|
|||||||
tail -n 300 "$panelError"
|
tail -n 300 "$panelError"
|
||||||
}
|
}
|
||||||
|
|
||||||
check_nginx() {
|
|
||||||
local nginxPid=$(ps -eo pid,command | grep nginx | grep -v grep)
|
|
||||||
echo -e "=====> 检测nginx服务\n$nginxPid"
|
|
||||||
if [[ $nginxPid ]]; then
|
|
||||||
echo -e "\n=====> nginx服务正常\n"
|
|
||||||
nginx -s reload
|
|
||||||
else
|
|
||||||
echo -e "\n=====> nginx服务异常,重新启动nginx\n"
|
|
||||||
nginx -c /etc/nginx/nginx.conf
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_ql() {
|
check_ql() {
|
||||||
local api=$(curl -s --noproxy "*" "http://0.0.0.0:5700")
|
local api=$(curl -s --noproxy "*" "http://0.0.0.0:5700")
|
||||||
echo -e "\n=====> 检测面板\n\n$api\n"
|
echo -e "\n=====> 检测面板\n\n$api\n"
|
||||||
@@ -58,7 +42,7 @@ check_pm2() {
|
|||||||
pm2_log
|
pm2_log
|
||||||
local currentTimeStamp=$(date +%s)
|
local currentTimeStamp=$(date +%s)
|
||||||
local api=$(
|
local api=$(
|
||||||
curl -s --noproxy "*" "http://0.0.0.0:5600/api/system?t=$currentTimeStamp" \
|
curl -s --noproxy "*" "http://0.0.0.0:5700/api/system?t=$currentTimeStamp" \
|
||||||
-H 'Accept: */*' \
|
-H 'Accept: */*' \
|
||||||
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
|
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \
|
||||||
-H 'Referer: http://0.0.0.0:5700/crontab' \
|
-H 'Referer: http://0.0.0.0:5700/crontab' \
|
||||||
@@ -78,7 +62,6 @@ main() {
|
|||||||
reset_env
|
reset_env
|
||||||
copy_dep
|
copy_dep
|
||||||
check_ql
|
check_ql
|
||||||
check_nginx
|
|
||||||
check_pm2
|
check_pm2
|
||||||
reload_pm2
|
reload_pm2
|
||||||
echo -e "\n=====> 检测结束\n"
|
echo -e "\n=====> 检测结束\n"
|
||||||
|
|||||||
@@ -0,0 +1,352 @@
|
|||||||
|
# Qinglong Python API (QLAPI) Documentation
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The Qinglong Python API provides a convenient way to interact with the Qinglong system from Python scripts. The `QLAPI` object is automatically available in your Python scripts when they run within the Qinglong environment.
|
||||||
|
|
||||||
|
## Availability
|
||||||
|
|
||||||
|
The Python QLAPI is available starting from **version 2.8.0+**. If you're using an older version (e.g., v2.7.11), please upgrade to access these features.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Qinglong version 2.8.0 or higher
|
||||||
|
- Python 3.6 or higher
|
||||||
|
- Running within Qinglong environment (scripts executed through Qinglong task system)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The `QLAPI` object is automatically injected into your Python script's global namespace. You don't need to import anything - just use it directly:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# QLAPI is automatically available
|
||||||
|
result = QLAPI.getEnvs({"searchValue": "USER"})
|
||||||
|
print(result)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Available Methods
|
||||||
|
|
||||||
|
### Environment Variables Management
|
||||||
|
|
||||||
|
#### getEnvs
|
||||||
|
Get environment variables with optional search filter.
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Get all environment variables
|
||||||
|
envs = QLAPI.getEnvs()
|
||||||
|
|
||||||
|
# Search for specific environment variables
|
||||||
|
envs = QLAPI.getEnvs({"searchValue": "USER"})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `searchValue` (optional): String to search for in environment variable names or values
|
||||||
|
|
||||||
|
**Returns:** `EnvsResponse` with list of environment variables
|
||||||
|
|
||||||
|
#### createEnv
|
||||||
|
Create new environment variables.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.createEnv({
|
||||||
|
"envs": [
|
||||||
|
{
|
||||||
|
"name": "MY_VAR",
|
||||||
|
"value": "my_value",
|
||||||
|
"remarks": "My custom variable"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `envs`: List of environment variable objects to create
|
||||||
|
|
||||||
|
**Returns:** `EnvsResponse`
|
||||||
|
|
||||||
|
#### updateEnv
|
||||||
|
Update an existing environment variable.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.updateEnv({
|
||||||
|
"env": {
|
||||||
|
"id": 123,
|
||||||
|
"name": "MY_VAR",
|
||||||
|
"value": "new_value",
|
||||||
|
"remarks": "Updated variable"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `env`: Environment variable object with id and updated fields
|
||||||
|
|
||||||
|
**Returns:** `EnvResponse`
|
||||||
|
|
||||||
|
#### deleteEnvs
|
||||||
|
Delete environment variables by IDs.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.deleteEnvs({"ids": [123, 456]})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `ids`: List of environment variable IDs to delete
|
||||||
|
|
||||||
|
**Returns:** `Response`
|
||||||
|
|
||||||
|
#### enableEnvs
|
||||||
|
Enable environment variables.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.enableEnvs({"ids": [123, 456]})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `ids`: List of environment variable IDs to enable
|
||||||
|
|
||||||
|
**Returns:** `Response`
|
||||||
|
|
||||||
|
#### disableEnvs
|
||||||
|
Disable environment variables.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.disableEnvs({"ids": [123, 456]})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `ids`: List of environment variable IDs to disable
|
||||||
|
|
||||||
|
**Returns:** `Response`
|
||||||
|
|
||||||
|
#### updateEnvNames
|
||||||
|
Update names of multiple environment variables.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.updateEnvNames({
|
||||||
|
"ids": [123, 456],
|
||||||
|
"name": "NEW_NAME"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `ids`: List of environment variable IDs
|
||||||
|
- `name`: New name to set
|
||||||
|
|
||||||
|
**Returns:** `Response`
|
||||||
|
|
||||||
|
#### getEnvById
|
||||||
|
Get a specific environment variable by ID.
|
||||||
|
|
||||||
|
```python
|
||||||
|
env = QLAPI.getEnvById({"id": 123})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `id`: Environment variable ID
|
||||||
|
|
||||||
|
**Returns:** `EnvResponse`
|
||||||
|
|
||||||
|
#### moveEnv
|
||||||
|
Change the position/order of an environment variable.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.moveEnv({
|
||||||
|
"id": 123,
|
||||||
|
"fromIndex": 0,
|
||||||
|
"toIndex": 5
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `id`: Environment variable ID
|
||||||
|
- `fromIndex`: Current position index
|
||||||
|
- `toIndex`: Target position index
|
||||||
|
|
||||||
|
**Returns:** `EnvResponse`
|
||||||
|
|
||||||
|
### Scheduled Tasks (Cron) Management
|
||||||
|
|
||||||
|
#### getCronDetail
|
||||||
|
Get details of a scheduled task.
|
||||||
|
|
||||||
|
```python
|
||||||
|
cron = QLAPI.getCronDetail({"log_path": "/path/to/log"})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `log_path`: Path to the task log file
|
||||||
|
|
||||||
|
**Returns:** `CronResponse`
|
||||||
|
|
||||||
|
#### createCron
|
||||||
|
Create a new scheduled task.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.createCron({
|
||||||
|
"command": "node script.js",
|
||||||
|
"schedule": "0 0 * * *",
|
||||||
|
"name": "Daily Task",
|
||||||
|
"labels": ["tag1", "tag2"],
|
||||||
|
"sub_id": None,
|
||||||
|
"extra_schedules": [],
|
||||||
|
"task_before": "",
|
||||||
|
"task_after": ""
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `command`: Command to execute
|
||||||
|
- `schedule`: Cron expression
|
||||||
|
- `name`: Task name (optional)
|
||||||
|
- `labels`: List of labels (optional)
|
||||||
|
- Other optional fields
|
||||||
|
|
||||||
|
**Returns:** `CronResponse`
|
||||||
|
|
||||||
|
#### updateCron
|
||||||
|
Update an existing scheduled task.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.updateCron({
|
||||||
|
"id": 123,
|
||||||
|
"command": "node updated_script.js",
|
||||||
|
"schedule": "0 0 * * *",
|
||||||
|
"name": "Updated Task",
|
||||||
|
"labels": [],
|
||||||
|
"sub_id": None,
|
||||||
|
"extra_schedules": [],
|
||||||
|
"task_before": "",
|
||||||
|
"task_after": ""
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Returns:** `CronResponse`
|
||||||
|
|
||||||
|
#### deleteCrons
|
||||||
|
Delete scheduled tasks by IDs.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.deleteCrons({"ids": [123, 456]})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `ids`: List of task IDs to delete
|
||||||
|
|
||||||
|
**Returns:** `Response`
|
||||||
|
|
||||||
|
### Notifications
|
||||||
|
|
||||||
|
#### notify
|
||||||
|
Send a notification using configured notification channels.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.notify("Notification Title", "Notification Content")
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- First argument: Notification title
|
||||||
|
- Second argument: Notification content
|
||||||
|
|
||||||
|
**Returns:** Notification result
|
||||||
|
|
||||||
|
#### systemNotify
|
||||||
|
Send a system notification with custom parameters.
|
||||||
|
|
||||||
|
```python
|
||||||
|
result = QLAPI.systemNotify({
|
||||||
|
"title": "System Alert",
|
||||||
|
"content": "This is a system notification"
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Parameters:**
|
||||||
|
- `title`: Notification title
|
||||||
|
- `content`: Notification content
|
||||||
|
|
||||||
|
**Returns:** `Response`
|
||||||
|
|
||||||
|
## Complete Example
|
||||||
|
|
||||||
|
```python
|
||||||
|
"""
|
||||||
|
Example Qinglong Python script demonstrating QLAPI usage
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Get environment variables
|
||||||
|
print("Fetching environment variables...")
|
||||||
|
envs = QLAPI.getEnvs({"searchValue": "TOKEN"})
|
||||||
|
print(f"Found {len(envs.get('data', []))} environment variables")
|
||||||
|
|
||||||
|
# Create a new environment variable
|
||||||
|
print("Creating new environment variable...")
|
||||||
|
result = QLAPI.createEnv({
|
||||||
|
"envs": [
|
||||||
|
{
|
||||||
|
"name": "MY_TEST_VAR",
|
||||||
|
"value": "test_value_123",
|
||||||
|
"remarks": "Created by script"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
print(f"Create result: {result}")
|
||||||
|
|
||||||
|
# Send notification
|
||||||
|
print("Sending notification...")
|
||||||
|
QLAPI.notify("Script Completed", "The script has finished executing successfully")
|
||||||
|
|
||||||
|
# Send system notification
|
||||||
|
QLAPI.systemNotify({
|
||||||
|
"title": "Task Report",
|
||||||
|
"content": f"Processed {len(envs.get('data', []))} environment variables"
|
||||||
|
})
|
||||||
|
|
||||||
|
print("Done!")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Error Handling
|
||||||
|
|
||||||
|
All QLAPI methods may raise exceptions if there are errors communicating with the backend. It's recommended to use try-except blocks:
|
||||||
|
|
||||||
|
```python
|
||||||
|
try:
|
||||||
|
envs = QLAPI.getEnvs({"searchValue": "USER"})
|
||||||
|
print(f"Success: {envs}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
QLAPI.notify("Script Error", str(e))
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### AttributeError: 'BaseApi' object has no attribute 'getEnvs'
|
||||||
|
|
||||||
|
This error occurs when using an older version of Qinglong (before v2.8.0). Solutions:
|
||||||
|
|
||||||
|
1. **Upgrade Qinglong**: Update to version 2.8.0 or higher
|
||||||
|
2. **Check Installation**: Ensure `shell/preload/client.py` exists
|
||||||
|
3. **Verify Environment**: Make sure scripts are running within Qinglong environment
|
||||||
|
|
||||||
|
### Module Import Errors
|
||||||
|
|
||||||
|
The QLAPI is only available when scripts run within the Qinglong environment. If you're testing locally, you won't have access to QLAPI.
|
||||||
|
|
||||||
|
## Technical Details
|
||||||
|
|
||||||
|
The Python QLAPI is a wrapper around the Node.js gRPC API client. When you call a method like `QLAPI.getEnvs()`:
|
||||||
|
|
||||||
|
1. Python Client creates a temporary Node.js script
|
||||||
|
2. Executes the corresponding Node.js API method
|
||||||
|
3. Returns the JSON result back to Python
|
||||||
|
|
||||||
|
This architecture ensures consistency between JavaScript and Python APIs.
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
For more information and examples:
|
||||||
|
|
||||||
|
- [JavaScript API Client Source](./client.js) - The underlying Node.js gRPC client
|
||||||
|
- [Python Sample Script](../../sample/ql_sample.py) - Example Python script using QLAPI
|
||||||
|
- [JavaScript Sample Script](../../sample/ql_sample.js) - Example JavaScript script for comparison
|
||||||
|
|
||||||
|
These files are located in the Qinglong repository under `shell/preload/` and `sample/` directories.
|
||||||
@@ -1,3 +1,20 @@
|
|||||||
|
"""
|
||||||
|
Qinglong Python API Client
|
||||||
|
|
||||||
|
This module provides a Python interface to the Qinglong API through a gRPC-based
|
||||||
|
Node.js client. It enables Python scripts to interact with Qinglong's environment
|
||||||
|
variables, scheduled tasks, and notification systems.
|
||||||
|
|
||||||
|
The Client class is used as a base for the QLAPI object that is automatically
|
||||||
|
available in Qinglong Python scripts. Users can call methods like:
|
||||||
|
|
||||||
|
QLAPI.getEnvs({"searchValue": "USER"})
|
||||||
|
QLAPI.createEnv({"envs": [{"name": "VAR", "value": "val"}]})
|
||||||
|
QLAPI.notify("Title", "Content")
|
||||||
|
|
||||||
|
For detailed documentation, see README_PYTHON_API.md
|
||||||
|
"""
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
@@ -176,6 +193,23 @@ class CronResponse(TypedDict):
|
|||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
|
"""
|
||||||
|
Qinglong API Client for Python.
|
||||||
|
|
||||||
|
This class provides methods to interact with Qinglong's API for managing
|
||||||
|
environment variables, scheduled tasks (crons), and notifications.
|
||||||
|
|
||||||
|
The client works by executing Node.js code that calls the actual gRPC API,
|
||||||
|
then returning the results to Python. This ensures consistency between
|
||||||
|
JavaScript and Python API interfaces.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
client = Client()
|
||||||
|
envs = client.getEnvs({"searchValue": "TOKEN"})
|
||||||
|
|
||||||
|
Note: This class is typically used through the QLAPI object which is
|
||||||
|
automatically available in Qinglong Python scripts.
|
||||||
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.temp_dir = tempfile.mkdtemp(prefix="node_client_")
|
self.temp_dir = tempfile.mkdtemp(prefix="node_client_")
|
||||||
self.temp_script = os.path.join(self.temp_dir, "temp_script.js")
|
self.temp_script = os.path.join(self.temp_dir, "temp_script.js")
|
||||||
|
|||||||
@@ -87,12 +87,10 @@ function run() {
|
|||||||
console.log('执行前置命令结束\n');
|
console.log('执行前置命令结束\n');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!error.message.includes('spawnSync /bin/sh E2BIG')) {
|
if (!error.message.includes('spawnSync /bin/bash E2BIG')) {
|
||||||
console.log(`\ue926 run task before error: `, error);
|
console.log(`\ue926 run task before error: `, error);
|
||||||
} else {
|
} else {
|
||||||
console.log(
|
// environment variable is too large
|
||||||
`\ue926 The environment variable is too large. It is recommended to use task_before.js instead of task_before.sh\n`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (task_before) {
|
if (task_before) {
|
||||||
console.log('执行前置命令结束\n');
|
console.log('执行前置命令结束\n');
|
||||||
|
|||||||
@@ -98,10 +98,8 @@ def run():
|
|||||||
error_message = str(error)
|
error_message = str(error)
|
||||||
if "Argument list too long" not in error_message:
|
if "Argument list too long" not in error_message:
|
||||||
print(f"\ue926 run task before error: {error}")
|
print(f"\ue926 run task before error: {error}")
|
||||||
else:
|
# else:
|
||||||
print(
|
# environment variable is too large
|
||||||
"\ue926 The environment variable is too large. It is recommended to use task_before.py instead of task_before.sh\n"
|
|
||||||
)
|
|
||||||
if task_before:
|
if task_before:
|
||||||
print("执行前置命令结束\n")
|
print("执行前置命令结束\n")
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
@@ -133,10 +131,14 @@ try:
|
|||||||
|
|
||||||
from __ql_notify__ import send
|
from __ql_notify__ import send
|
||||||
|
|
||||||
|
# BaseApi inherits all methods from Client (getEnvs, createEnv, etc.)
|
||||||
|
# and adds the notify method for sending notifications
|
||||||
class BaseApi(Client):
|
class BaseApi(Client):
|
||||||
def notify(self, *args, **kwargs):
|
def notify(self, *args, **kwargs):
|
||||||
return send(*args, **kwargs)
|
return send(*args, **kwargs)
|
||||||
|
|
||||||
|
# Create QLAPI instance and make it globally available
|
||||||
|
# This allows scripts to use: QLAPI.getEnvs(), QLAPI.notify(), etc.
|
||||||
QLAPI = BaseApi()
|
QLAPI = BaseApi()
|
||||||
builtins.QLAPI = QLAPI
|
builtins.QLAPI = QLAPI
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Validation script for QLAPI Client functionality.
|
||||||
|
Tests that all methods are properly accessible through the BaseApi class.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from client import Client
|
||||||
|
|
||||||
|
|
||||||
|
def test_client_has_required_methods():
|
||||||
|
"""Test that Client class has all required API methods."""
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
required_methods = [
|
||||||
|
'getEnvs',
|
||||||
|
'createEnv',
|
||||||
|
'updateEnv',
|
||||||
|
'deleteEnvs',
|
||||||
|
'moveEnv',
|
||||||
|
'disableEnvs',
|
||||||
|
'enableEnvs',
|
||||||
|
'updateEnvNames',
|
||||||
|
'getEnvById',
|
||||||
|
'systemNotify',
|
||||||
|
'getCronDetail',
|
||||||
|
'createCron',
|
||||||
|
'updateCron',
|
||||||
|
'deleteCrons',
|
||||||
|
]
|
||||||
|
|
||||||
|
print("Testing Client class methods...")
|
||||||
|
for method in required_methods:
|
||||||
|
assert hasattr(client, method), f"Client missing method: {method}"
|
||||||
|
assert callable(getattr(client, method)), f"Client.{method} is not callable"
|
||||||
|
print(f" ✓ {method}")
|
||||||
|
|
||||||
|
print(f"\n✓ All {len(required_methods)} methods are present and callable")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def test_baseapi_inheritance():
|
||||||
|
"""Test that BaseApi properly inherits from Client."""
|
||||||
|
|
||||||
|
# Simulate the BaseApi class from sitecustomize.py
|
||||||
|
class BaseApi(Client):
|
||||||
|
def notify(self, *args, **kwargs):
|
||||||
|
return "mock_notify_result"
|
||||||
|
|
||||||
|
api = BaseApi()
|
||||||
|
|
||||||
|
print("\nTesting BaseApi inheritance...")
|
||||||
|
|
||||||
|
# Test that BaseApi has all Client methods
|
||||||
|
assert hasattr(api, 'getEnvs'), "BaseApi missing getEnvs"
|
||||||
|
assert callable(api.getEnvs), "BaseApi.getEnvs is not callable"
|
||||||
|
print(" ✓ getEnvs is accessible")
|
||||||
|
|
||||||
|
# Test that BaseApi also has its own method
|
||||||
|
assert hasattr(api, 'notify'), "BaseApi missing notify"
|
||||||
|
assert callable(api.notify), "BaseApi.notify is not callable"
|
||||||
|
print(" ✓ notify is accessible")
|
||||||
|
|
||||||
|
# Verify getEnvs has type annotations (either params or return)
|
||||||
|
annotations = api.getEnvs.__annotations__
|
||||||
|
assert len(annotations) > 0, "getEnvs should have type annotations"
|
||||||
|
assert 'return' in annotations, "getEnvs should have return type annotation"
|
||||||
|
print(" ✓ getEnvs has correct signature with type annotations")
|
||||||
|
|
||||||
|
print("\n✓ BaseApi properly inherits from Client and adds notify method")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def test_method_signatures():
|
||||||
|
"""Test that methods have correct type annotations."""
|
||||||
|
client = Client()
|
||||||
|
|
||||||
|
print("\nTesting method signatures...")
|
||||||
|
|
||||||
|
# Test getEnvs signature
|
||||||
|
getEnvs_annotations = client.getEnvs.__annotations__
|
||||||
|
# Check that annotations exist - could be 'params', or just 'return'
|
||||||
|
assert len(getEnvs_annotations) > 0, "getEnvs should have type annotations"
|
||||||
|
assert 'return' in getEnvs_annotations, "getEnvs should have return type annotation"
|
||||||
|
print(" ✓ getEnvs has type annotations")
|
||||||
|
|
||||||
|
# Test other critical methods
|
||||||
|
assert hasattr(client, 'createEnv'), "Missing createEnv"
|
||||||
|
assert hasattr(client, 'updateEnv'), "Missing updateEnv"
|
||||||
|
print(" ✓ Critical methods present")
|
||||||
|
|
||||||
|
print("\n✓ All method signatures are correct")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
"""Run all validation tests."""
|
||||||
|
print("=" * 60)
|
||||||
|
print("QLAPI Client Validation Tests")
|
||||||
|
print("=" * 60)
|
||||||
|
|
||||||
|
try:
|
||||||
|
test_client_has_required_methods()
|
||||||
|
test_baseapi_inheritance()
|
||||||
|
test_method_signatures()
|
||||||
|
|
||||||
|
print("\n" + "=" * 60)
|
||||||
|
print("ALL TESTS PASSED ✓")
|
||||||
|
print("=" * 60)
|
||||||
|
print("\nThe QLAPI Client is working correctly.")
|
||||||
|
print("Users can safely use: QLAPI.getEnvs({'searchValue': 'USER'})")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
except AssertionError as e:
|
||||||
|
print(f"\n❌ TEST FAILED: {e}")
|
||||||
|
return 1
|
||||||
|
except Exception as e:
|
||||||
|
print(f"\n❌ UNEXPECTED ERROR: {e}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
+3
-7
@@ -2,13 +2,9 @@
|
|||||||
echo -e "开始发布"
|
echo -e "开始发布"
|
||||||
|
|
||||||
echo -e "切换master分支"
|
echo -e "切换master分支"
|
||||||
git checkout master
|
git branch -D master
|
||||||
|
git checkout -b master
|
||||||
echo -e "合并develop代码"
|
git push --set-upstream origin master -f
|
||||||
git merge origin/develop
|
|
||||||
|
|
||||||
echo -e "提交master代码"
|
|
||||||
git push
|
|
||||||
|
|
||||||
echo -e "更新cdn文件"
|
echo -e "更新cdn文件"
|
||||||
ts-node-transpile-only sample/tool.ts
|
ts-node-transpile-only sample/tool.ts
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ export file_notify_py=$dir_scripts/notify.py
|
|||||||
export file_notify_js=$dir_scripts/sendNotify.js
|
export file_notify_js=$dir_scripts/sendNotify.js
|
||||||
export file_test_js=$dir_scripts/ql_sample.js
|
export file_test_js=$dir_scripts/ql_sample.js
|
||||||
export file_test_py=$dir_scripts/ql_sample.py
|
export file_test_py=$dir_scripts/ql_sample.py
|
||||||
export nginx_app_conf=$dir_root/docker/front.conf
|
|
||||||
export nginx_conf=$dir_root/docker/nginx.conf
|
|
||||||
export dep_notify_py=$dir_dep/notify.py
|
export dep_notify_py=$dir_dep/notify.py
|
||||||
export dep_notify_js=$dir_dep/sendNotify.js
|
export dep_notify_js=$dir_dep/sendNotify.js
|
||||||
|
|
||||||
@@ -211,10 +209,6 @@ fix_config() {
|
|||||||
cp -f $file_test_py_sample $file_test_py
|
cp -f $file_test_py_sample $file_test_py
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -s /etc/nginx/conf.d/default.conf ]]; then
|
|
||||||
cat /dev/null >/etc/nginx/conf.d/default.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ! -s $dep_notify_js ]]; then
|
if [[ ! -s $dep_notify_js ]]; then
|
||||||
cp -f $file_notify_js_sample $dep_notify_js
|
cp -f $file_notify_js_sample $dep_notify_js
|
||||||
fi
|
fi
|
||||||
@@ -334,44 +328,6 @@ format_timestamp() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
init_nginx() {
|
|
||||||
cp -f $nginx_conf /etc/nginx/nginx.conf
|
|
||||||
cp -f $nginx_app_conf /etc/nginx/conf.d/front.conf
|
|
||||||
local location_url="/"
|
|
||||||
local aliasStr=""
|
|
||||||
local rootStr=""
|
|
||||||
if [[ $ql_base_url != "/" ]]; then
|
|
||||||
if [[ $ql_base_url != /* ]]; then
|
|
||||||
ql_base_url="/$ql_base_url"
|
|
||||||
fi
|
|
||||||
if [[ $ql_base_url != */ ]]; then
|
|
||||||
ql_base_url="$ql_base_url/"
|
|
||||||
fi
|
|
||||||
location_url="^~${ql_base_url%*/}"
|
|
||||||
aliasStr="alias ${dir_static}/dist;"
|
|
||||||
if ! grep -q "<base href=\"$ql_base_url\">" "${dir_static}/dist/index.html"; then
|
|
||||||
awk -v text="<base href=\"$ql_base_url\">" '/<link/ && !inserted {print text; inserted=1} 1' "${dir_static}/dist/index.html" >temp.html
|
|
||||||
mv temp.html "${dir_static}/dist/index.html"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
rootStr="root ${dir_static}/dist;"
|
|
||||||
fi
|
|
||||||
sed -i "s,QL_ALIAS_CONFIG,${aliasStr},g" /etc/nginx/conf.d/front.conf
|
|
||||||
sed -i "s,QL_ROOT_CONFIG,${rootStr},g" /etc/nginx/conf.d/front.conf
|
|
||||||
sed -i "s,QL_BASE_URL_LOCATION,${location_url},g" /etc/nginx/conf.d/front.conf
|
|
||||||
sed -i "s,QL_BASE_URL,${ql_base_url},g" /etc/nginx/conf.d/front.conf
|
|
||||||
|
|
||||||
local ipv6=$(ip a | grep inet6)
|
|
||||||
local ipv6Str=""
|
|
||||||
if [[ $ipv6 ]]; then
|
|
||||||
ipv6Str="listen [::]:${ql_port} ipv6only=on;"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local ipv4Str="listen ${ql_port};"
|
|
||||||
sed -i "s,IPV6_CONFIG,${ipv6Str},g" /etc/nginx/conf.d/front.conf
|
|
||||||
sed -i "s,IPV4_CONFIG,${ipv4Str},g" /etc/nginx/conf.d/front.conf
|
|
||||||
}
|
|
||||||
|
|
||||||
get_env_array() {
|
get_env_array() {
|
||||||
exported_variables=()
|
exported_variables=()
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ export default function () {
|
|||||||
const responseStatus = error.response.status;
|
const responseStatus = error.response.status;
|
||||||
if (responseStatus !== 401) {
|
if (responseStatus !== 401) {
|
||||||
history.push('/error');
|
history.push('/error');
|
||||||
|
} else {
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => setInitLoading(false));
|
.finally(() => setInitLoading(false));
|
||||||
|
|||||||
+17
-2
@@ -395,7 +395,11 @@
|
|||||||
"PushMe的Key,https://push.i-i.me/": "PushMe key, https://push.i-i.me/",
|
"PushMe的Key,https://push.i-i.me/": "PushMe key, https://push.i-i.me/",
|
||||||
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "The self built PushMeServer message interface address, for example: http://127.0.0.1:3010 If left blank, use the official message interface",
|
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "The self built PushMeServer message interface address, for example: http://127.0.0.1:3010 If left blank, use the official message interface",
|
||||||
"ntfy的url地址,例如 https://ntfy.sh": "The URL address of ntfy, for example, https://ntfy.sh.",
|
"ntfy的url地址,例如 https://ntfy.sh": "The URL address of ntfy, for example, https://ntfy.sh.",
|
||||||
"ntfy的消息应用topic": "The topic for ntfy's messaging application.",
|
"ntfy应用topic": "The topic for ntfy's application.",
|
||||||
|
"ntfy应用token": "The token for ntfy's application, see https://docs.ntfy.sh/config/#access-tokens",
|
||||||
|
"ntfy应用用户名": "The username for ntfy's application, see https://docs.ntfy.sh/config/#users-and-roles",
|
||||||
|
"ntfy应用密码": "The password for ntfy's application, see https://docs.ntfy.sh/config/#users-and-roles",
|
||||||
|
"ntfy用户动作": "The user actions for ntfy's application, up to three actions, see https://docs.ntfy.sh/publish/?h=actions#action-buttons",
|
||||||
"wxPusherBot的appToken": "wxPusherBot's appToken, obtain according to docs https://wxpusher.zjiecode.com/docs/",
|
"wxPusherBot的appToken": "wxPusherBot's appToken, obtain according to docs https://wxpusher.zjiecode.com/docs/",
|
||||||
"wxPusherBot的topicIds": "wxPusherBot's topicIds, at least one of topicIds or uids must be configured",
|
"wxPusherBot的topicIds": "wxPusherBot's topicIds, at least one of topicIds or uids must be configured",
|
||||||
"wxPusherBot的uids": "wxPusherBot's uids, at least one of topicIds or uids must be configured",
|
"wxPusherBot的uids": "wxPusherBot's uids, at least one of topicIds or uids must be configured",
|
||||||
@@ -506,5 +510,16 @@
|
|||||||
"强制打开可能会导致编辑器显示异常": "Force opening may cause display issues in the editor",
|
"强制打开可能会导致编辑器显示异常": "Force opening may cause display issues in the editor",
|
||||||
"确认离开": "Confirm Leave",
|
"确认离开": "Confirm Leave",
|
||||||
"当前文件未保存,确认离开吗": "Current file is not saved, are you sure to leave?",
|
"当前文件未保存,确认离开吗": "Current file is not saved, are you sure to leave?",
|
||||||
"收件邮箱地址,多个分号分隔,默认发送给发件邮箱地址": "Receiving email address, multiple semicolon separated, sent to the sending email address by default"
|
"收件邮箱地址,多个分号分隔,默认发送给发件邮箱地址": "Receiving email address, multiple semicolon separated, sent to the sending email address by default",
|
||||||
|
"选择备份模块": "Select backup module",
|
||||||
|
"开始备份": "Start backup",
|
||||||
|
"基础数据": "Basic data",
|
||||||
|
"脚本文件": "Script files",
|
||||||
|
"日志文件": "Log files",
|
||||||
|
"依赖缓存": "Dependency cache",
|
||||||
|
"远程脚本缓存": "Remote script cache",
|
||||||
|
"远程仓库缓存": "Remote repository cache",
|
||||||
|
"SSH 文件缓存": "SSH file cache",
|
||||||
|
"清除依赖缓存": "Clean dependency cache",
|
||||||
|
"清除成功": "Clean successful"
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-3
@@ -395,7 +395,11 @@
|
|||||||
"PushMe的Key,https://push.i-i.me/": "PushMe的Key,https://push.i-i.me/",
|
"PushMe的Key,https://push.i-i.me/": "PushMe的Key,https://push.i-i.me/",
|
||||||
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口",
|
"自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口": "自建的PushMeServer消息接口地址,例如:http://127.0.0.1:3010,不填则使用官方消息接口",
|
||||||
"ntfy的url地址,例如 https://ntfy.sh": "ntfy的url地址,例如 https://ntfy.sh",
|
"ntfy的url地址,例如 https://ntfy.sh": "ntfy的url地址,例如 https://ntfy.sh",
|
||||||
"ntfy的消息应用topic": "ntfy的消息应用topic",
|
"ntfy应用topic": "ntfy应用topic",
|
||||||
|
"ntfy应用token": "ntfy应用token,参考 https://docs.ntfy.sh/config/#access-tokens",
|
||||||
|
"ntfy应用用户名": "ntfy应用用户名,参考 https://docs.ntfy.sh/config/#users-and-roles",
|
||||||
|
"ntfy应用密码": "ntfy应用密码,参考 https://docs.ntfy.sh/config/#users-and-roles",
|
||||||
|
"ntfy用户动作": "ntfy用户动作,最多三个动作,参考 https://docs.ntfy.sh/publish/?h=actions#action-buttons",
|
||||||
"wxPusherBot的appToken": "wxPusherBot的appToken, 按照文档获取 https://wxpusher.zjiecode.com/docs/",
|
"wxPusherBot的appToken": "wxPusherBot的appToken, 按照文档获取 https://wxpusher.zjiecode.com/docs/",
|
||||||
"wxPusherBot的topicIds": "wxPusherBot的topicIds, topicIds 和 uids 至少配置一个才行",
|
"wxPusherBot的topicIds": "wxPusherBot的topicIds, topicIds 和 uids 至少配置一个才行",
|
||||||
"wxPusherBot的uids": "wxPusherBot的uids, topicIds 和 uids 至少配置一个才行",
|
"wxPusherBot的uids": "wxPusherBot的uids, topicIds 和 uids 至少配置一个才行",
|
||||||
@@ -506,6 +510,16 @@
|
|||||||
"强制打开可能会导致编辑器显示异常": "强制打开可能会导致编辑器显示异常",
|
"强制打开可能会导致编辑器显示异常": "强制打开可能会导致编辑器显示异常",
|
||||||
"确认离开": "确认离开",
|
"确认离开": "确认离开",
|
||||||
"当前文件未保存,确认离开吗": "当前文件未保存,确认离开吗",
|
"当前文件未保存,确认离开吗": "当前文件未保存,确认离开吗",
|
||||||
"收件邮箱地址,多个分号分隔,默认发送给发件邮箱地址": "收件邮箱地址,多个分号分隔,默认发送给发件邮箱地址"
|
"收件邮箱地址,多个分号分隔,默认发送给发件邮箱地址": "收件邮箱地址,多个分号分隔,默认发送给发件邮箱地址",
|
||||||
|
"选择备份模块": "选择备份模块",
|
||||||
|
"开始备份": "开始备份",
|
||||||
|
"基础数据": "基础数据",
|
||||||
|
"脚本文件": "脚本文件",
|
||||||
|
"日志文件": "日志文件",
|
||||||
|
"依赖缓存": "依赖缓存",
|
||||||
|
"远程脚本缓存": "远程脚本缓存",
|
||||||
|
"远程仓库缓存": "远程仓库缓存",
|
||||||
|
"SSH 文件缓存": "SSH 文件缓存",
|
||||||
|
"清除依赖缓存": "清除依赖缓存",
|
||||||
|
"清除成功": "清除成功"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,12 +56,10 @@ interface LogItem {
|
|||||||
const CronDetailModal = ({
|
const CronDetailModal = ({
|
||||||
cron = {},
|
cron = {},
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
theme,
|
theme,
|
||||||
isPhone,
|
isPhone,
|
||||||
}: {
|
}: {
|
||||||
cron?: any;
|
cron?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (needUpdate?: boolean) => void;
|
handleCancel: (needUpdate?: boolean) => void;
|
||||||
theme: string;
|
theme: string;
|
||||||
isPhone: boolean;
|
isPhone: boolean;
|
||||||
@@ -440,7 +438,7 @@ const CronDetailModal = ({
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
centered
|
centered
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
footer={false}
|
footer={false}
|
||||||
onCancel={() => handleCancel()}
|
onCancel={() => handleCancel()}
|
||||||
@@ -559,8 +557,8 @@ const CronDetailModal = ({
|
|||||||
{contentList[activeTabKey]}
|
{contentList[activeTabKey]}
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
|
{isLogModalVisible && (
|
||||||
<CronLogModal
|
<CronLogModal
|
||||||
visible={isLogModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setIsLogModalVisible(false);
|
setIsLogModalVisible(false);
|
||||||
}}
|
}}
|
||||||
@@ -568,6 +566,7 @@ const CronDetailModal = ({
|
|||||||
data={log}
|
data={log}
|
||||||
logUrl={logUrl}
|
logUrl={logUrl}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+13
-10
@@ -1037,21 +1037,20 @@ const Crontab = () => {
|
|||||||
components={isPhone || pageConf.size < 50 ? undefined : vt}
|
components={isPhone || pageConf.size < 50 ? undefined : vt}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{isLogModalVisible && (
|
||||||
<CronLogModal
|
<CronLogModal
|
||||||
visible={isLogModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
getCronDetail(logCron);
|
getCronDetail(logCron);
|
||||||
setIsLogModalVisible(false);
|
setIsLogModalVisible(false);
|
||||||
}}
|
}}
|
||||||
cron={logCron}
|
cron={logCron}
|
||||||
/>
|
/>
|
||||||
<CronModal
|
)}
|
||||||
visible={isModalVisible}
|
{isModalVisible && (
|
||||||
handleCancel={handleCancel}
|
<CronModal handleCancel={handleCancel} cron={editedCron} />
|
||||||
cron={editedCron}
|
)}
|
||||||
/>
|
{isLabelModalVisible && (
|
||||||
<CronLabelModal
|
<CronLabelModal
|
||||||
visible={isLabelModalVisible}
|
|
||||||
handleCancel={(needUpdate?: boolean) => {
|
handleCancel={(needUpdate?: boolean) => {
|
||||||
setIsLabelModalVisible(false);
|
setIsLabelModalVisible(false);
|
||||||
if (needUpdate) {
|
if (needUpdate) {
|
||||||
@@ -1060,8 +1059,9 @@ const Crontab = () => {
|
|||||||
}}
|
}}
|
||||||
ids={selectedRowIds}
|
ids={selectedRowIds}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{isDetailModalVisible && (
|
||||||
<CronDetailModal
|
<CronDetailModal
|
||||||
visible={isDetailModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setIsDetailModalVisible(false);
|
setIsDetailModalVisible(false);
|
||||||
}}
|
}}
|
||||||
@@ -1069,16 +1069,18 @@ const Crontab = () => {
|
|||||||
theme={theme}
|
theme={theme}
|
||||||
isPhone={isPhone}
|
isPhone={isPhone}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{isCreateViewModalVisible && (
|
||||||
<ViewCreateModal
|
<ViewCreateModal
|
||||||
visible={isCreateViewModalVisible}
|
|
||||||
handleCancel={(data) => {
|
handleCancel={(data) => {
|
||||||
setIsCreateViewModalVisible(false);
|
setIsCreateViewModalVisible(false);
|
||||||
getCronViews();
|
getCronViews();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{isViewManageModalVisible && (
|
||||||
<ViewManageModal
|
<ViewManageModal
|
||||||
cronViews={cronViews}
|
cronViews={cronViews}
|
||||||
visible={isViewManageModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setIsViewManageModalVisible(false);
|
setIsViewManageModalVisible(false);
|
||||||
}}
|
}}
|
||||||
@@ -1086,6 +1088,7 @@ const Crontab = () => {
|
|||||||
getCronViews();
|
getCronViews();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import intl from 'react-intl-universal';
|
import intl from "react-intl-universal";
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Modal,
|
Modal,
|
||||||
message,
|
message,
|
||||||
@@ -8,34 +8,32 @@ import {
|
|||||||
Statistic,
|
Statistic,
|
||||||
Button,
|
Button,
|
||||||
Typography,
|
Typography,
|
||||||
} from 'antd';
|
} from "antd";
|
||||||
import { request } from '@/utils/http';
|
import { request } from "@/utils/http";
|
||||||
import config from '@/utils/config';
|
import config from "@/utils/config";
|
||||||
import {
|
import {
|
||||||
Loading3QuartersOutlined,
|
Loading3QuartersOutlined,
|
||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
} from '@ant-design/icons';
|
} from "@ant-design/icons";
|
||||||
import { PageLoading } from '@ant-design/pro-layout';
|
import { PageLoading } from "@ant-design/pro-layout";
|
||||||
import { logEnded } from '@/utils';
|
import { logEnded } from "@/utils";
|
||||||
import { CrontabStatus } from './type';
|
import { CrontabStatus } from "./type";
|
||||||
import Ansi from 'ansi-to-react';
|
import Ansi from "ansi-to-react";
|
||||||
|
|
||||||
const { Countdown } = Statistic;
|
const { Countdown } = Statistic;
|
||||||
|
|
||||||
const CronLogModal = ({
|
const CronLogModal = ({
|
||||||
cron,
|
cron,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
data,
|
data,
|
||||||
logUrl,
|
logUrl,
|
||||||
}: {
|
}: {
|
||||||
cron?: any;
|
cron?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
data?: string;
|
data?: string;
|
||||||
logUrl?: string;
|
logUrl?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState<string>(intl.get('启动中...'));
|
const [value, setValue] = useState<string>(intl.get("启动中..."));
|
||||||
const [loading, setLoading] = useState<any>(true);
|
const [loading, setLoading] = useState<any>(true);
|
||||||
const [executing, setExecuting] = useState<any>(true);
|
const [executing, setExecuting] = useState<any>(true);
|
||||||
const [isPhone, setIsPhone] = useState(false);
|
const [isPhone, setIsPhone] = useState(false);
|
||||||
@@ -51,15 +49,15 @@ const CronLogModal = ({
|
|||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
if (
|
if (
|
||||||
code === 200 &&
|
code === 200 &&
|
||||||
localStorage.getItem('logCron') === uniqPath &&
|
localStorage.getItem("logCron") === uniqPath &&
|
||||||
data !== value
|
data !== value
|
||||||
) {
|
) {
|
||||||
const log = data as string;
|
const log = data as string;
|
||||||
setValue(log || intl.get('暂无日志'));
|
setValue(log || intl.get("暂无日志"));
|
||||||
const hasNext = Boolean(
|
const hasNext = Boolean(
|
||||||
log && !logEnded(log) && !log.includes('任务未运行'),
|
log && !logEnded(log) && !log.includes("日志不存在"),
|
||||||
);
|
);
|
||||||
if (!hasNext && !logEnded(value) && value !== intl.get('启动中...')) {
|
if (!hasNext && !logEnded(value) && value !== intl.get("启动中...")) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
autoScroll();
|
autoScroll();
|
||||||
});
|
});
|
||||||
@@ -87,13 +85,13 @@ const CronLogModal = ({
|
|||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document
|
document
|
||||||
.querySelector('#log-flag')!
|
.querySelector("#log-flag")
|
||||||
.scrollIntoView({ behavior: 'smooth' });
|
?.scrollIntoView({ behavior: "smooth" });
|
||||||
}, 600);
|
}, 600);
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
localStorage.removeItem('logCron');
|
localStorage.removeItem("logCron");
|
||||||
handleCancel();
|
handleCancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,7 +107,7 @@ const CronLogModal = ({
|
|||||||
|
|
||||||
const titleElement = () => {
|
const titleElement = () => {
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', alignItems: 'center' }}>
|
<div style={{ display: "flex", alignItems: "center" }}>
|
||||||
{(executing || loading) && <Loading3QuartersOutlined spin />}
|
{(executing || loading) && <Loading3QuartersOutlined spin />}
|
||||||
{!executing && !loading && <CheckCircleOutlined />}
|
{!executing && !loading && <CheckCircleOutlined />}
|
||||||
<Typography.Text ellipsis={true} style={{ marginLeft: 5 }}>
|
<Typography.Text ellipsis={true} style={{ marginLeft: 5 }}>
|
||||||
@@ -120,11 +118,10 @@ const CronLogModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (cron && cron.id && visible) {
|
if (cron && cron.id) {
|
||||||
getCronLog(true);
|
getCronLog(true);
|
||||||
scrollInfoRef.current.down = true;
|
|
||||||
}
|
}
|
||||||
}, [cron, visible]);
|
}, [cron]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -139,7 +136,7 @@ const CronLogModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={titleElement()}
|
title={titleElement()}
|
||||||
open={visible}
|
open={true}
|
||||||
centered
|
centered
|
||||||
className="log-modal"
|
className="log-modal"
|
||||||
forceRender
|
forceRender
|
||||||
@@ -147,7 +144,7 @@ const CronLogModal = ({
|
|||||||
onCancel={() => cancel()}
|
onCancel={() => cancel()}
|
||||||
footer={[
|
footer={[
|
||||||
<Button type="primary" onClick={() => cancel()}>
|
<Button type="primary" onClick={() => cancel()}>
|
||||||
{intl.get('知道了')}
|
{intl.get("知道了")}
|
||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
@@ -159,7 +156,7 @@ const CronLogModal = ({
|
|||||||
style={
|
style={
|
||||||
isPhone
|
isPhone
|
||||||
? {
|
? {
|
||||||
fontFamily: 'Source Code Pro',
|
fontFamily: "Source Code Pro",
|
||||||
zoom: 0.83,
|
zoom: 0.83,
|
||||||
}
|
}
|
||||||
: {}
|
: {}
|
||||||
|
|||||||
@@ -12,10 +12,8 @@ import { ScheduleType } from './type';
|
|||||||
const CronModal = ({
|
const CronModal = ({
|
||||||
cron,
|
cron,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
cron?: any;
|
cron?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (needUpdate?: boolean) => void;
|
handleCancel: (needUpdate?: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -58,11 +56,6 @@ const CronModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
setScheduleType(getScheduleType(cron?.schedule));
|
|
||||||
}, [cron, visible]);
|
|
||||||
|
|
||||||
const handleScheduleTypeChange = (type: ScheduleType) => {
|
const handleScheduleTypeChange = (type: ScheduleType) => {
|
||||||
setScheduleType(type);
|
setScheduleType(type);
|
||||||
form.setFieldValue('schedule', '');
|
form.setFieldValue('schedule', '');
|
||||||
@@ -146,7 +139,7 @@ const CronModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={cron?.id ? intl.get('编辑任务') : intl.get('创建任务')}
|
title={cron?.id ? intl.get('编辑任务') : intl.get('创建任务')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
@@ -251,10 +244,8 @@ const CronModal = ({
|
|||||||
const CronLabelModal = ({
|
const CronLabelModal = ({
|
||||||
ids,
|
ids,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
ids: Array<string>;
|
ids: Array<string>;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (needUpdate?: boolean) => void;
|
handleCancel: (needUpdate?: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -290,10 +281,6 @@ const CronLabelModal = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [ids, visible]);
|
|
||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
<Button onClick={() => handleCancel(false)}>{intl.get('取消')}</Button>,
|
<Button onClick={() => handleCancel(false)}>{intl.get('取消')}</Button>,
|
||||||
<Button type="primary" danger onClick={() => update('delete')}>
|
<Button type="primary" danger onClick={() => update('delete')}>
|
||||||
@@ -307,7 +294,7 @@ const CronLabelModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('批量修改标签')}
|
title={intl.get('批量修改标签')}
|
||||||
open={visible}
|
open={true}
|
||||||
footer={buttons}
|
footer={buttons}
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
@@ -56,10 +56,8 @@ enum ViewFilterRelation {
|
|||||||
const ViewCreateModal = ({
|
const ViewCreateModal = ({
|
||||||
view,
|
view,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
view?: any;
|
view?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (param?: any) => void;
|
handleCancel: (param?: any) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -101,17 +99,6 @@ const ViewCreateModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!view) {
|
|
||||||
form.resetFields();
|
|
||||||
}
|
|
||||||
form.setFieldsValue(
|
|
||||||
view || {
|
|
||||||
filters: [{ property: 'command' }],
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}, [view, visible]);
|
|
||||||
|
|
||||||
const OperationElement = ({ name, ...others }: { name: number }) => {
|
const OperationElement = ({ name, ...others }: { name: number }) => {
|
||||||
const property = form.getFieldValue(['filters', name, 'property']);
|
const property = form.getFieldValue(['filters', name, 'property']);
|
||||||
return (
|
return (
|
||||||
@@ -172,7 +159,7 @@ const ViewCreateModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={view ? intl.get('编辑视图') : intl.get('创建视图')}
|
title={view ? intl.get('编辑视图') : intl.get('创建视图')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
width={580}
|
width={580}
|
||||||
centered
|
centered
|
||||||
@@ -190,7 +177,16 @@ const ViewCreateModal = ({
|
|||||||
onCancel={() => handleCancel()}
|
onCancel={() => handleCancel()}
|
||||||
confirmLoading={loading}
|
confirmLoading={loading}
|
||||||
>
|
>
|
||||||
<Form form={form} layout="vertical" name="env_modal">
|
<Form
|
||||||
|
form={form}
|
||||||
|
layout="vertical"
|
||||||
|
initialValues={
|
||||||
|
view || {
|
||||||
|
filters: [{ property: 'command' }],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
name="env_modal"
|
||||||
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label={intl.get('视图名称')}
|
label={intl.get('视图名称')}
|
||||||
|
|||||||
@@ -68,11 +68,9 @@ const DragableBodyRow = ({
|
|||||||
const ViewManageModal = ({
|
const ViewManageModal = ({
|
||||||
cronViews,
|
cronViews,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
cronViewChange,
|
cronViewChange,
|
||||||
}: {
|
}: {
|
||||||
cronViews: any[];
|
cronViews: any[];
|
||||||
visible: boolean;
|
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
cronViewChange: (data?: any) => void;
|
cronViewChange: (data?: any) => void;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -218,7 +216,7 @@ const ViewManageModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('视图管理')}
|
title={intl.get('视图管理')}
|
||||||
open={visible}
|
open={true}
|
||||||
centered
|
centered
|
||||||
width={620}
|
width={620}
|
||||||
onCancel={() => handleCancel()}
|
onCancel={() => handleCancel()}
|
||||||
@@ -263,14 +261,15 @@ const ViewManageModal = ({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</DndProvider>
|
</DndProvider>
|
||||||
|
{isCreateViewModalVisible && (
|
||||||
<ViewCreateModal
|
<ViewCreateModal
|
||||||
view={editedView}
|
view={editedView}
|
||||||
visible={isCreateViewModalVisible}
|
|
||||||
handleCancel={(data) => {
|
handleCancel={(data) => {
|
||||||
setIsCreateViewModalVisible(false);
|
setIsCreateViewModalVisible(false);
|
||||||
cronViewChange(data);
|
cronViewChange(data);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -618,15 +618,15 @@ const Dependence = () => {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
{children}
|
{children}
|
||||||
|
{isModalVisible && (
|
||||||
<DependenceModal
|
<DependenceModal
|
||||||
visible={isModalVisible}
|
|
||||||
handleCancel={handleCancel}
|
handleCancel={handleCancel}
|
||||||
dependence={editedDependence}
|
dependence={editedDependence}
|
||||||
defaultType={type}
|
defaultType={type}
|
||||||
/>
|
/>
|
||||||
{logDependence && (
|
)}
|
||||||
|
{logDependence && isLogModalVisible && (
|
||||||
<DependenceLogModal
|
<DependenceLogModal
|
||||||
visible={isLogModalVisible}
|
|
||||||
handleCancel={(needRemove?: boolean) => {
|
handleCancel={(needRemove?: boolean) => {
|
||||||
setIsLogModalVisible(false);
|
setIsLogModalVisible(false);
|
||||||
if (needRemove) {
|
if (needRemove) {
|
||||||
|
|||||||
@@ -15,10 +15,8 @@ import { Status } from './type';
|
|||||||
const DependenceLogModal = ({
|
const DependenceLogModal = ({
|
||||||
dependence,
|
dependence,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
dependence?: any;
|
dependence?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (needRemove?: boolean) => void;
|
handleCancel: (needRemove?: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState<string>('');
|
const [value, setValue] = useState<string>('');
|
||||||
@@ -128,7 +126,7 @@ const DependenceLogModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={titleElement()}
|
title={titleElement()}
|
||||||
open={visible}
|
open={true}
|
||||||
centered
|
centered
|
||||||
className="log-modal"
|
className="log-modal"
|
||||||
forceRender
|
forceRender
|
||||||
|
|||||||
@@ -14,11 +14,9 @@ enum DependenceTypes {
|
|||||||
const DependenceModal = ({
|
const DependenceModal = ({
|
||||||
dependence,
|
dependence,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
defaultType,
|
defaultType,
|
||||||
}: {
|
}: {
|
||||||
dependence?: any;
|
dependence?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (cks?: any[]) => void;
|
handleCancel: (cks?: any[]) => void;
|
||||||
defaultType: string;
|
defaultType: string;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -61,14 +59,10 @@ const DependenceModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [dependence, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={dependence ? intl.get('编辑依赖') : intl.get('创建依赖')}
|
title={dependence ? intl.get('编辑依赖') : intl.get('创建依赖')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
Vendored
+1
-7
@@ -7,10 +7,8 @@ import config from '@/utils/config';
|
|||||||
const EditNameModal = ({
|
const EditNameModal = ({
|
||||||
ids,
|
ids,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
ids?: string[];
|
ids?: string[];
|
||||||
visible: boolean;
|
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -34,14 +32,10 @@ const EditNameModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [ids, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('修改环境变量名称')}
|
title={intl.get('修改环境变量名称')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
Vendored
+5
-6
@@ -616,16 +616,15 @@ const Env = () => {
|
|||||||
/>
|
/>
|
||||||
</DndProvider>
|
</DndProvider>
|
||||||
</div>
|
</div>
|
||||||
<EnvModal
|
{isModalVisible && (
|
||||||
visible={isModalVisible}
|
<EnvModal handleCancel={handleCancel} env={editedEnv} />
|
||||||
handleCancel={handleCancel}
|
)}
|
||||||
env={editedEnv}
|
{isEditNameModalVisible && (
|
||||||
/>
|
|
||||||
<EditNameModal
|
<EditNameModal
|
||||||
visible={isEditNameModalVisible}
|
|
||||||
handleCancel={handleEditNameCancel}
|
handleCancel={handleEditNameCancel}
|
||||||
ids={selectedRowIds}
|
ids={selectedRowIds}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+1
-7
@@ -7,10 +7,8 @@ import config from '@/utils/config';
|
|||||||
const EnvModal = ({
|
const EnvModal = ({
|
||||||
env,
|
env,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
env?: any;
|
env?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (cks?: any[]) => void;
|
handleCancel: (cks?: any[]) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -55,14 +53,10 @@ const EnvModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [env, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={env ? intl.get('编辑变量') : intl.get('创建变量')}
|
title={env ? intl.get('编辑变量') : intl.get('创建变量')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
@@ -14,6 +14,17 @@ const Error = () => {
|
|||||||
const [data, setData] = useState(intl.get('暂无日志'));
|
const [data, setData] = useState(intl.get('暂无日志'));
|
||||||
const retryTimes = useRef(1);
|
const retryTimes = useRef(1);
|
||||||
|
|
||||||
|
const loopStatus = (message: string) => {
|
||||||
|
if (retryTimes.current > 3) {
|
||||||
|
setData(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
retryTimes.current += 1;
|
||||||
|
setTimeout(() => {
|
||||||
|
getHealthStatus(false);
|
||||||
|
}, 3000);
|
||||||
|
};
|
||||||
|
|
||||||
const getHealthStatus = (needLoading: boolean = true) => {
|
const getHealthStatus = (needLoading: boolean = true) => {
|
||||||
needLoading && setLoading(true);
|
needLoading && setLoading(true);
|
||||||
request
|
request
|
||||||
@@ -27,19 +38,15 @@ const Error = () => {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (retryTimes.current > 3) {
|
|
||||||
setData(error?.details);
|
loopStatus(error?.details);
|
||||||
return;
|
|
||||||
}
|
|
||||||
retryTimes.current += 1;
|
|
||||||
setTimeout(() => {
|
|
||||||
getHealthStatus(false);
|
|
||||||
}, 3000);
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
const responseStatus = error.response.status;
|
const responseStatus = error.response.status;
|
||||||
if (responseStatus === 401) {
|
if (responseStatus === 401) {
|
||||||
history.push('/login');
|
history.push('/login');
|
||||||
|
} else {
|
||||||
|
loopStatus(error.response?.message || error?.message);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finally(() => needLoading && setLoading(false));
|
.finally(() => needLoading && setLoading(false));
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ const EditModal = ({
|
|||||||
currentNode,
|
currentNode,
|
||||||
content,
|
content,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
treeData?: any;
|
treeData?: any;
|
||||||
content?: string;
|
content?: string;
|
||||||
visible: boolean;
|
|
||||||
currentNode: any;
|
currentNode: any;
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
@@ -223,7 +221,7 @@ const EditModal = ({
|
|||||||
width={'100%'}
|
width={'100%'}
|
||||||
headerStyle={{ padding: '11px 24px' }}
|
headerStyle={{ padding: '11px 24px' }}
|
||||||
onClose={cancel}
|
onClose={cancel}
|
||||||
open={visible}
|
open={true}
|
||||||
>
|
>
|
||||||
{/* @ts-ignore */}
|
{/* @ts-ignore */}
|
||||||
<SplitPane
|
<SplitPane
|
||||||
@@ -256,8 +254,8 @@ const EditModal = ({
|
|||||||
<Ansi>{log}</Ansi>
|
<Ansi>{log}</Ansi>
|
||||||
</pre>
|
</pre>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
|
{saveModalVisible && (
|
||||||
<SaveModal
|
<SaveModal
|
||||||
visible={saveModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setSaveModalVisible(false);
|
setSaveModalVisible(false);
|
||||||
}}
|
}}
|
||||||
@@ -268,12 +266,14 @@ const EditModal = ({
|
|||||||
...cNode,
|
...cNode,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{settingModalVisible && (
|
||||||
<SettingModal
|
<SettingModal
|
||||||
visible={settingModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setSettingModalVisible(false);
|
setSettingModalVisible(false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Drawer>
|
</Drawer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ const { Option } = Select;
|
|||||||
const EditScriptNameModal = ({
|
const EditScriptNameModal = ({
|
||||||
handleCancel,
|
handleCancel,
|
||||||
treeData,
|
treeData,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
visible: boolean;
|
|
||||||
treeData: any[];
|
treeData: any[];
|
||||||
handleCancel: (file?: {
|
handleCancel: (file?: {
|
||||||
filename: string;
|
filename: string;
|
||||||
@@ -53,7 +51,7 @@ const EditScriptNameModal = ({
|
|||||||
directory ? intl.get('创建文件夹成功') : intl.get('创建文件成功'),
|
directory ? intl.get('创建文件夹成功') : intl.get('创建文件成功'),
|
||||||
);
|
);
|
||||||
const key = path ? `${path}/` : '';
|
const key = path ? `${path}/` : '';
|
||||||
const filename = file ? file.name : (directory || inputFilename);
|
const filename = file ? file.name : directory || inputFilename;
|
||||||
handleCancel({
|
handleCancel({
|
||||||
filename,
|
filename,
|
||||||
path,
|
path,
|
||||||
@@ -95,14 +93,10 @@ const EditScriptNameModal = ({
|
|||||||
setDirs(dirs);
|
setDirs(dirs);
|
||||||
}, [treeData]);
|
}, [treeData]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('创建')}
|
title={intl.get('创建')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
@@ -710,9 +710,8 @@ const Script = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isLogModalVisible && (
|
{isLogModalVisible && isLogModalVisible && (
|
||||||
<EditModal
|
<EditModal
|
||||||
visible={isLogModalVisible}
|
|
||||||
treeData={data}
|
treeData={data}
|
||||||
currentNode={currentNode}
|
currentNode={currentNode}
|
||||||
content={value}
|
content={value}
|
||||||
@@ -721,16 +720,18 @@ const Script = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{isAddFileModalVisible && (
|
||||||
<EditScriptNameModal
|
<EditScriptNameModal
|
||||||
visible={isAddFileModalVisible}
|
|
||||||
treeData={data}
|
treeData={data}
|
||||||
handleCancel={addFileModalClose}
|
handleCancel={addFileModalClose}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{isRenameFileModalVisible && (
|
||||||
<RenameModal
|
<RenameModal
|
||||||
visible={isRenameFileModalVisible}
|
|
||||||
handleCancel={handleRenameFileCancel}
|
handleCancel={handleRenameFileCancel}
|
||||||
currentNode={currentNode}
|
currentNode={currentNode}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ import config from '@/utils/config';
|
|||||||
const RenameModal = ({
|
const RenameModal = ({
|
||||||
currentNode,
|
currentNode,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
currentNode?: any;
|
currentNode?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -38,14 +36,10 @@ const RenameModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [currentNode, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('重命名')}
|
title={intl.get('重命名')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ import config from '@/utils/config';
|
|||||||
const SaveModal = ({
|
const SaveModal = ({
|
||||||
file,
|
file,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
file?: any;
|
file?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (cks?: any[]) => void;
|
handleCancel: (cks?: any[]) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -32,15 +30,10 @@ const SaveModal = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
setLoading(false);
|
|
||||||
}, [file, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('保存文件')}
|
title={intl.get('保存文件')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ import config from '@/utils/config';
|
|||||||
const SettingModal = ({
|
const SettingModal = ({
|
||||||
file,
|
file,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
file?: any;
|
file?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (cks?: any[]) => void;
|
handleCancel: (cks?: any[]) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -30,15 +28,10 @@ const SettingModal = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
setLoading(false);
|
|
||||||
}, [file, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={intl.get('运行设置')}
|
title={intl.get('运行设置')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
onCancel={() => handleCancel()}
|
onCancel={() => handleCancel()}
|
||||||
|
|||||||
@@ -7,10 +7,8 @@ import config from '@/utils/config';
|
|||||||
const AppModal = ({
|
const AppModal = ({
|
||||||
app,
|
app,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
app?: any;
|
app?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (needUpdate?: boolean) => void;
|
handleCancel: (needUpdate?: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -41,14 +39,10 @@ const AppModal = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
form.resetFields();
|
|
||||||
}, [app, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={app ? intl.get('编辑应用') : intl.get('创建应用')}
|
title={app ? intl.get('编辑应用') : intl.get('创建应用')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
import { disableBody } from '@/utils';
|
import { disableBody } from "@/utils";
|
||||||
import config from '@/utils/config';
|
import config from "@/utils/config";
|
||||||
import { request } from '@/utils/http';
|
import { request } from "@/utils/http";
|
||||||
import WebSocketManager from '@/utils/websocket';
|
import WebSocketManager from "@/utils/websocket";
|
||||||
import Ansi from 'ansi-to-react';
|
import Ansi from "ansi-to-react";
|
||||||
import { Button, Modal, Statistic, message } from 'antd';
|
import { Button, Modal, Statistic, message } from "antd";
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import intl from 'react-intl-universal';
|
import intl from "react-intl-universal";
|
||||||
|
|
||||||
const { Countdown } = Statistic;
|
const { Countdown } = Statistic;
|
||||||
|
|
||||||
const CheckUpdate = ({ systemInfo }: any) => {
|
const CheckUpdate = ({ systemInfo }: any) => {
|
||||||
const [updateLoading, setUpdateLoading] = useState(false);
|
const [updateLoading, setUpdateLoading] = useState(false);
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState("");
|
||||||
const modalRef = useRef<any>();
|
const modalRef = useRef<any>();
|
||||||
|
|
||||||
const checkUpgrade = () => {
|
const checkUpgrade = () => {
|
||||||
if (updateLoading) return;
|
if (updateLoading) return;
|
||||||
setUpdateLoading(true);
|
setUpdateLoading(true);
|
||||||
message.loading(intl.get('检查更新中...'), 0);
|
message.loading(intl.get("检查更新中..."), 0);
|
||||||
request
|
request
|
||||||
.put(`${config.apiPrefix}system/update-check`)
|
.put(`${config.apiPrefix}system/update-check`)
|
||||||
.then(({ code, data }) => {
|
.then(({ code, data }) => {
|
||||||
@@ -42,17 +42,17 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
const showForceUpdateModal = (data: any) => {
|
const showForceUpdateModal = (data: any) => {
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
width: 500,
|
width: 500,
|
||||||
title: intl.get('更新'),
|
title: intl.get("更新"),
|
||||||
content: (
|
content: (
|
||||||
<>
|
<>
|
||||||
<div>{intl.get('已经是最新版了!')}</div>
|
<div>{intl.get("已经是最新版了!")}</div>
|
||||||
<div style={{ fontSize: 12, fontWeight: 400, marginTop: 5 }}>
|
<div style={{ fontSize: 12, fontWeight: 400, marginTop: 5 }}>
|
||||||
{intl.get('青龙')} {data.lastVersion}{' '}
|
{intl.get("青龙")} {data.lastVersion}{" "}
|
||||||
{intl.get('是目前检测到的最新可用版本了。')}
|
{intl.get("是目前检测到的最新可用版本了。")}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
okText: intl.get('重新下载'),
|
okText: intl.get("重新下载"),
|
||||||
onOk() {
|
onOk() {
|
||||||
showUpdatingModal();
|
showUpdatingModal();
|
||||||
request
|
request
|
||||||
@@ -71,10 +71,10 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
width: 500,
|
width: 500,
|
||||||
title: (
|
title: (
|
||||||
<>
|
<>
|
||||||
<div>{intl.get('更新可用')}</div>
|
<div>{intl.get("更新可用")}</div>
|
||||||
<div style={{ fontSize: 12, fontWeight: 400, marginTop: 5 }}>
|
<div style={{ fontSize: 12, fontWeight: 400, marginTop: 5 }}>
|
||||||
{intl.get('新版本')} {lastVersion}{' '}
|
{intl.get("新版本")} {lastVersion}{" "}
|
||||||
{intl.get('可用,你使用的版本为')} {systemInfo.version}。
|
{intl.get("可用,你使用的版本为")} {systemInfo.version}。
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
@@ -83,8 +83,8 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
<Ansi>{lastLog}</Ansi>
|
<Ansi>{lastLog}</Ansi>
|
||||||
</pre>
|
</pre>
|
||||||
),
|
),
|
||||||
okText: intl.get('下载更新'),
|
okText: intl.get("下载更新"),
|
||||||
cancelText: intl.get('以后再说'),
|
cancelText: intl.get("以后再说"),
|
||||||
onOk() {
|
onOk() {
|
||||||
showUpdatingModal();
|
showUpdatingModal();
|
||||||
request
|
request
|
||||||
@@ -98,14 +98,14 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const showUpdatingModal = () => {
|
const showUpdatingModal = () => {
|
||||||
setValue('');
|
setValue("");
|
||||||
modalRef.current = Modal.info({
|
modalRef.current = Modal.info({
|
||||||
width: 600,
|
width: 600,
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
closable: false,
|
closable: false,
|
||||||
keyboard: false,
|
keyboard: false,
|
||||||
okButtonProps: { disabled: true },
|
okButtonProps: { disabled: true },
|
||||||
title: intl.get('下载更新中...'),
|
title: intl.get("下载更新中..."),
|
||||||
centered: true,
|
centered: true,
|
||||||
content: (
|
content: (
|
||||||
<pre>
|
<pre>
|
||||||
@@ -122,13 +122,13 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
message.success({
|
message.success({
|
||||||
content: (
|
content: (
|
||||||
<span>
|
<span>
|
||||||
{intl.get('系统将在')}
|
{intl.get("系统将在")}
|
||||||
<Countdown
|
<Countdown
|
||||||
className="inline-countdown"
|
className="inline-countdown"
|
||||||
format="ss"
|
format="ss"
|
||||||
value={Date.now() + 1000 * 30}
|
value={Date.now() + 1000 * 30}
|
||||||
/>
|
/>
|
||||||
{intl.get('秒后自动刷新')}
|
{intl.get("秒后自动刷新")}
|
||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
duration: 30,
|
duration: 30,
|
||||||
@@ -147,12 +147,12 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
width: 600,
|
width: 600,
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
title: intl.get('确认重启'),
|
title: intl.get("确认重启"),
|
||||||
centered: true,
|
centered: true,
|
||||||
content: intl.get('系统安装包下载成功,确认重启'),
|
content: intl.get("系统安装包下载成功,确认重启"),
|
||||||
okText: intl.get('重启'),
|
okText: intl.get("重启"),
|
||||||
onOk() {
|
onOk() {
|
||||||
reloadSystem('system');
|
reloadSystem("system");
|
||||||
},
|
},
|
||||||
onCancel() {
|
onCancel() {
|
||||||
modalRef.current.update({
|
modalRef.current.update({
|
||||||
@@ -166,7 +166,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
const updateFailed = value.includes('失败,请检查');
|
const updateFailed = value.includes("失败,请检查");
|
||||||
|
|
||||||
modalRef.current.update({
|
modalRef.current.update({
|
||||||
maskClosable: updateFailed,
|
maskClosable: updateFailed,
|
||||||
@@ -185,19 +185,19 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
|
|
||||||
const handleMessage = useCallback((payload: any) => {
|
const handleMessage = useCallback((payload: any) => {
|
||||||
let { message: _message } = payload;
|
let { message: _message } = payload;
|
||||||
const updateFailed = _message.includes('失败,请检查');
|
const updateFailed = _message.includes("失败,请检查");
|
||||||
|
|
||||||
if (updateFailed) {
|
if (updateFailed) {
|
||||||
message.error(intl.get('更新失败,请检查网络及日志或稍后再试'));
|
message.error(intl.get("更新失败,请检查网络及日志或稍后再试"));
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
document
|
document
|
||||||
.querySelector('#log-identifier')!
|
.querySelector("#log-identifier")
|
||||||
.scrollIntoView({ behavior: 'smooth' });
|
?.scrollIntoView({ behavior: "smooth" });
|
||||||
}, 600);
|
}, 600);
|
||||||
|
|
||||||
if (_message.includes('更新包下载成功')) {
|
if (_message.includes("更新包下载成功")) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showReloadModal();
|
showReloadModal();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@@ -208,24 +208,24 @@ const CheckUpdate = ({ systemInfo }: any) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ws = WebSocketManager.getInstance();
|
const ws = WebSocketManager.getInstance();
|
||||||
ws.subscribe('updateSystemVersion', handleMessage);
|
ws.subscribe("updateSystemVersion", handleMessage);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
ws.unsubscribe('updateSystemVersion', handleMessage);
|
ws.unsubscribe("updateSystemVersion", handleMessage);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button type="primary" onClick={checkUpgrade}>
|
<Button type="primary" onClick={checkUpgrade}>
|
||||||
{intl.get('检查更新')}
|
{intl.get("检查更新")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
onClick={() => reloadSystem('reload')}
|
onClick={() => reloadSystem("reload")}
|
||||||
style={{ marginLeft: 8 }}
|
style={{ marginLeft: 8 }}
|
||||||
>
|
>
|
||||||
{intl.get('重新启动')}
|
{intl.get("重新启动")}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import React, { useState, useEffect, useRef } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import { Button, InputNumber, Form, message, Input, Alert } from 'antd';
|
import { Button, InputNumber, Form, message, Input, Alert, Select } from 'antd';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import './index.less';
|
import './index.less';
|
||||||
@@ -25,6 +25,7 @@ const Dependence = () => {
|
|||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [log, setLog] = useState<string>('');
|
const [log, setLog] = useState<string>('');
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
|
const [cleanType, setCleanType] = useState<string>('node');
|
||||||
|
|
||||||
const getSystemConfig = () => {
|
const getSystemConfig = () => {
|
||||||
request
|
request
|
||||||
@@ -84,6 +85,24 @@ const Dependence = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const cleanDependenceCache = (type: string) => {
|
||||||
|
setLoading(true);
|
||||||
|
setLog('');
|
||||||
|
request
|
||||||
|
.put(`${config.apiPrefix}system/config/dependence-clean`, {
|
||||||
|
type,
|
||||||
|
})
|
||||||
|
.then(({ code, data }) => {
|
||||||
|
if (code === 200) {
|
||||||
|
message.success(intl.get('清除成功'));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error: any) => {
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
.finally(() => setLoading(false));
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const ws = WebSocketManager.getInstance();
|
const ws = WebSocketManager.getInstance();
|
||||||
ws.subscribe('updateNodeMirror', handleMessage);
|
ws.subscribe('updateNodeMirror', handleMessage);
|
||||||
@@ -222,6 +241,38 @@ const Dependence = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Input.Group>
|
</Input.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label={intl.get('清除依赖缓存')}
|
||||||
|
name="clean"
|
||||||
|
tooltip={{
|
||||||
|
title: intl.get('清除依赖缓存'),
|
||||||
|
placement: 'topLeft',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Input.Group compact>
|
||||||
|
<Select
|
||||||
|
defaultValue={'node'}
|
||||||
|
style={{ width: 100 }}
|
||||||
|
onChange={(value) => {
|
||||||
|
setCleanType(value);
|
||||||
|
}}
|
||||||
|
options={[
|
||||||
|
{ label: 'node', value: 'node' },
|
||||||
|
{ label: 'python3', value: 'python3' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
loading={loading}
|
||||||
|
onClick={() => {
|
||||||
|
cleanDependenceCache(cleanType);
|
||||||
|
}}
|
||||||
|
style={{ width: 100 }}
|
||||||
|
>
|
||||||
|
{intl.get('确认')}
|
||||||
|
</Button>
|
||||||
|
</Input.Group>
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
<pre
|
<pre
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -363,11 +363,9 @@ const Setting = () => {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<AppModal
|
{isModalVisible && (
|
||||||
visible={isModalVisible}
|
<AppModal handleCancel={handleCancel} app={editedApp} />
|
||||||
handleCancel={handleCancel}
|
)}
|
||||||
app={editedApp}
|
|
||||||
/>
|
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
Upload,
|
Upload,
|
||||||
Modal,
|
Modal,
|
||||||
Select,
|
Select,
|
||||||
|
Checkbox,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import * as DarkReader from '@umijs/ssr-darkreader';
|
import * as DarkReader from '@umijs/ssr-darkreader';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
@@ -31,6 +32,19 @@ const dataMap = {
|
|||||||
timezone: 'timezone',
|
timezone: 'timezone',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const exportModules = [
|
||||||
|
{ value: 'base', label: intl.get('基础数据'), disabled: true },
|
||||||
|
{ value: 'config', label: intl.get('配置文件') },
|
||||||
|
{ value: 'scripts', label: intl.get('脚本文件') },
|
||||||
|
{ value: 'log', label: intl.get('日志文件') },
|
||||||
|
{ value: 'deps', label: intl.get('依赖文件') },
|
||||||
|
{ value: 'syslog', label: intl.get('系统日志') },
|
||||||
|
{ value: 'dep_cache', label: intl.get('依赖缓存') },
|
||||||
|
{ value: 'raw', label: intl.get('远程脚本缓存') },
|
||||||
|
{ value: 'repo', label: intl.get('远程仓库缓存') },
|
||||||
|
{ value: 'ssh.d', label: intl.get('SSH 文件缓存') },
|
||||||
|
];
|
||||||
|
|
||||||
const Other = ({
|
const Other = ({
|
||||||
systemInfo,
|
systemInfo,
|
||||||
reloadTheme,
|
reloadTheme,
|
||||||
@@ -45,6 +59,8 @@ const Other = ({
|
|||||||
const [exportLoading, setExportLoading] = useState(false);
|
const [exportLoading, setExportLoading] = useState(false);
|
||||||
const showUploadProgress = useProgress(intl.get('上传'));
|
const showUploadProgress = useProgress(intl.get('上传'));
|
||||||
const showDownloadProgress = useProgress(intl.get('下载'));
|
const showDownloadProgress = useProgress(intl.get('下载'));
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const [selectedModules, setSelectedModules] = useState<string[]>(['base']);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
enable: enableDarkMode,
|
enable: enableDarkMode,
|
||||||
@@ -110,7 +126,7 @@ const Other = ({
|
|||||||
request
|
request
|
||||||
.put<Blob>(
|
.put<Blob>(
|
||||||
`${config.apiPrefix}system/data/export`,
|
`${config.apiPrefix}system/data/export`,
|
||||||
{},
|
{ type: selectedModules },
|
||||||
{
|
{
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
timeout: 86400000,
|
timeout: 86400000,
|
||||||
@@ -127,7 +143,10 @@ const Other = ({
|
|||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
})
|
})
|
||||||
.finally(() => setExportLoading(false));
|
.finally(() => {
|
||||||
|
setExportLoading(false);
|
||||||
|
setVisible(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const showReloadModal = () => {
|
const showReloadModal = () => {
|
||||||
@@ -178,6 +197,7 @@ const Other = ({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Form layout="vertical" form={form}>
|
<Form layout="vertical" form={form}>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={intl.get('主题')}
|
label={intl.get('主题')}
|
||||||
@@ -196,7 +216,10 @@ const Other = ({
|
|||||||
>
|
>
|
||||||
{intl.get('亮色')}
|
{intl.get('亮色')}
|
||||||
</Radio.Button>
|
</Radio.Button>
|
||||||
<Radio.Button value="dark" style={{ width: 66, textAlign: 'center' }}>
|
<Radio.Button
|
||||||
|
value="dark"
|
||||||
|
style={{ width: 66, textAlign: 'center' }}
|
||||||
|
>
|
||||||
{intl.get('暗色')}
|
{intl.get('暗色')}
|
||||||
</Radio.Button>
|
</Radio.Button>
|
||||||
<Radio.Button
|
<Radio.Button
|
||||||
@@ -296,7 +319,14 @@ const Other = ({
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={intl.get('数据备份还原')} name="frequency">
|
<Form.Item label={intl.get('数据备份还原')} name="frequency">
|
||||||
<Button type="primary" onClick={exportData} loading={exportLoading}>
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedModules(['base']);
|
||||||
|
setVisible(true);
|
||||||
|
}}
|
||||||
|
loading={exportLoading}
|
||||||
|
>
|
||||||
{exportLoading ? intl.get('生成数据中...') : intl.get('备份')}
|
{exportLoading ? intl.get('生成数据中...') : intl.get('备份')}
|
||||||
</Button>
|
</Button>
|
||||||
<Upload
|
<Upload
|
||||||
@@ -332,6 +362,40 @@ const Other = ({
|
|||||||
<CheckUpdate systemInfo={systemInfo} />
|
<CheckUpdate systemInfo={systemInfo} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
|
<Modal
|
||||||
|
title={intl.get('选择备份模块')}
|
||||||
|
open={visible}
|
||||||
|
onOk={exportData}
|
||||||
|
onCancel={() => setVisible(false)}
|
||||||
|
okText={intl.get('开始备份')}
|
||||||
|
cancelText={intl.get('取消')}
|
||||||
|
okButtonProps={{ loading: exportLoading }} // 绑定加载状态到按钮
|
||||||
|
>
|
||||||
|
<Checkbox.Group
|
||||||
|
value={selectedModules}
|
||||||
|
onChange={(v) => {
|
||||||
|
setSelectedModules(v as string[]);
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
gap: '8px 16px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{exportModules.map((module) => (
|
||||||
|
<Checkbox
|
||||||
|
key={module.value}
|
||||||
|
value={module.value}
|
||||||
|
disabled={module.disabled}
|
||||||
|
style={{ marginLeft: 0 }}
|
||||||
|
>
|
||||||
|
{module.label}
|
||||||
|
</Checkbox>
|
||||||
|
))}
|
||||||
|
</Checkbox.Group>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -579,18 +579,20 @@ const Subscription = () => {
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
rowClassName={getRowClassName}
|
rowClassName={getRowClassName}
|
||||||
/>
|
/>
|
||||||
|
{isModalVisible && (
|
||||||
<SubscriptionModal
|
<SubscriptionModal
|
||||||
visible={isModalVisible}
|
|
||||||
handleCancel={handleCancel}
|
handleCancel={handleCancel}
|
||||||
subscription={editedSubscription}
|
subscription={editedSubscription}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{isLogModalVisible && (
|
||||||
<SubscriptionLogModal
|
<SubscriptionLogModal
|
||||||
visible={isLogModalVisible}
|
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setIsLogModalVisible(false);
|
setIsLogModalVisible(false);
|
||||||
}}
|
}}
|
||||||
subscription={logSubscription}
|
subscription={logSubscription}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ import Ansi from 'ansi-to-react';
|
|||||||
const SubscriptionLogModal = ({
|
const SubscriptionLogModal = ({
|
||||||
subscription,
|
subscription,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
data,
|
data,
|
||||||
logUrl,
|
logUrl,
|
||||||
}: {
|
}: {
|
||||||
subscription?: any;
|
subscription?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
data?: string;
|
data?: string;
|
||||||
logUrl?: string;
|
logUrl?: string;
|
||||||
@@ -79,10 +77,10 @@ const SubscriptionLogModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (subscription && subscription.id && visible) {
|
if (subscription && subscription.id) {
|
||||||
getCronLog(true);
|
getCronLog(true);
|
||||||
}
|
}
|
||||||
}, [subscription, visible]);
|
}, [subscription]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -97,7 +95,7 @@ const SubscriptionLogModal = ({
|
|||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={titleElement()}
|
title={titleElement()}
|
||||||
open={visible}
|
open={true}
|
||||||
centered
|
centered
|
||||||
className="log-modal"
|
className="log-modal"
|
||||||
forceRender
|
forceRender
|
||||||
|
|||||||
@@ -22,17 +22,19 @@ const fileUrlRegx = /([^\/\:]+\/[^\/\.]+)\.[a-z]+$/;
|
|||||||
const SubscriptionModal = ({
|
const SubscriptionModal = ({
|
||||||
subscription,
|
subscription,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
visible,
|
|
||||||
}: {
|
}: {
|
||||||
subscription?: any;
|
subscription?: any;
|
||||||
visible: boolean;
|
|
||||||
handleCancel: (needUpdate?: boolean) => void;
|
handleCancel: (needUpdate?: boolean) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [type, setType] = useState('public-repo');
|
const [type, setType] = useState(subscription?.type || 'public-repo');
|
||||||
const [scheduleType, setScheduleType] = useState('crontab');
|
const [scheduleType, setScheduleType] = useState(
|
||||||
const [pullType, setPullType] = useState<'ssh-key' | 'user-pwd'>('ssh-key');
|
subscription?.schedule_type || 'crontab',
|
||||||
|
);
|
||||||
|
const [pullType, setPullType] = useState<'ssh-key' | 'user-pwd'>(
|
||||||
|
subscription?.pull_type || 'ssh-key',
|
||||||
|
);
|
||||||
|
|
||||||
const handleOk = async (values: any) => {
|
const handleOk = async (values: any) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -255,29 +257,17 @@ const SubscriptionModal = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) {
|
|
||||||
window.addEventListener('paste', onPaste);
|
window.addEventListener('paste', onPaste);
|
||||||
} else {
|
|
||||||
window.removeEventListener('paste', onPaste);
|
|
||||||
}
|
|
||||||
}, [visible]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
return () => {
|
||||||
form.setFieldsValue(
|
window.removeEventListener('paste', onPaste);
|
||||||
{ ...subscription, ...formatParams(subscription) } || {},
|
};
|
||||||
);
|
}, []);
|
||||||
setType((subscription && subscription.type) || 'public-repo');
|
|
||||||
setScheduleType((subscription && subscription.schedule_type) || 'crontab');
|
|
||||||
setPullType((subscription && subscription.pull_type) || 'ssh-key');
|
|
||||||
if (!subscription) {
|
|
||||||
form.resetFields();
|
|
||||||
}
|
|
||||||
}, [subscription, visible]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={subscription ? intl.get('编辑订阅') : intl.get('创建订阅')}
|
title={subscription ? intl.get('编辑订阅') : intl.get('创建订阅')}
|
||||||
open={visible}
|
open={true}
|
||||||
forceRender
|
forceRender
|
||||||
centered
|
centered
|
||||||
maskClosable={false}
|
maskClosable={false}
|
||||||
@@ -294,7 +284,12 @@ const SubscriptionModal = ({
|
|||||||
onCancel={() => handleCancel()}
|
onCancel={() => handleCancel()}
|
||||||
confirmLoading={loading}
|
confirmLoading={loading}
|
||||||
>
|
>
|
||||||
<Form form={form} name="form_in_modal" layout="vertical">
|
<Form
|
||||||
|
form={form}
|
||||||
|
name="form_in_modal"
|
||||||
|
layout="vertical"
|
||||||
|
initialValues={{ ...subscription, ...formatParams(subscription) }}
|
||||||
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label={intl.get('名称')}
|
label={intl.get('名称')}
|
||||||
|
|||||||
+5
-1
@@ -128,10 +128,14 @@ export default {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'ntfyTopic',
|
label: 'ntfyTopic',
|
||||||
tip: intl.get('ntfy的消息应用topic'),
|
tip: intl.get('ntfy应用topic'),
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
{ label: 'ntfyPriority', tip: intl.get('推送消息的优先级') },
|
{ label: 'ntfyPriority', tip: intl.get('推送消息的优先级') },
|
||||||
|
{ label: 'ntfyToken', tip: intl.get('ntfy应用token') },
|
||||||
|
{ label: 'ntfyUsername', tip: intl.get('ntfy应用用户名') },
|
||||||
|
{ label: 'ntfyPassword', tip: intl.get('ntfy应用密码') },
|
||||||
|
{ label: 'ntfyActions', tip: intl.get('ntfy用户动作') },
|
||||||
],
|
],
|
||||||
chat: [
|
chat: [
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ export interface IResponseData {
|
|||||||
code?: number;
|
code?: number;
|
||||||
data?: any;
|
data?: any;
|
||||||
message?: string;
|
message?: string;
|
||||||
errors?: any[];
|
error?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Override<
|
export type Override<
|
||||||
|
|||||||
+9
-12
@@ -1,13 +1,10 @@
|
|||||||
version: 2.19.0
|
version: 2.19.2
|
||||||
changeLogLink: https://t.me/jiao_long/429
|
changeLogLink: https://t.me/jiao_long/431
|
||||||
publishTime: 2025-05-11 08:00
|
publishTime: 2025-06-27 23:59
|
||||||
changeLog: |
|
changeLog: |
|
||||||
1. 缓存 node 和 python 依赖,linux 依赖需要增加映射目录
|
1. 备份数据支持选择模块,支持清除依赖缓存
|
||||||
2. 减少启动服务数,节约启动内存约 50%
|
2. QLAPI 和 openapi 的 systemNotify 支持自定义通知类型和参数
|
||||||
3. 邮箱通知支持多个收件人
|
3. ntfy 增加可选的认证与用户动作,感谢 https://github.com/liheji
|
||||||
4. boot 任务改为在依赖安装完成后执行
|
4. 修复取消安装依赖
|
||||||
5. 修复脚本管理查询子目录逻辑
|
5. 修复环境变量过大解析报错
|
||||||
6. 修复脚本管理增加文件夹
|
6. 修改服务启动方式
|
||||||
7. 修复 QLAPI 修复环境变量 remarks
|
|
||||||
8. 修复 mjs 依赖查不到
|
|
||||||
9. 修复无法删除日志文件
|
|
||||||
Reference in New Issue
Block a user