mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
手机端使用codemirror
This commit is contained in:
+4
-4
@@ -35,7 +35,7 @@ export default (app: Router) => {
|
||||
);
|
||||
return res.send({
|
||||
code: 100,
|
||||
msg: '已初始化密码,请前往auth.json查看并重新登录',
|
||||
message: '已初始化密码,请前往auth.json查看并重新登录',
|
||||
});
|
||||
}
|
||||
if (
|
||||
@@ -57,10 +57,10 @@ export default (app: Router) => {
|
||||
);
|
||||
res.send({ code: 200, token });
|
||||
} else {
|
||||
res.send({ code: 400, msg: config.authError });
|
||||
res.send({ code: 400, message: config.authError });
|
||||
}
|
||||
} else {
|
||||
res.send({ err: 400, msg: '请输入用户名密码!' });
|
||||
res.send({ err: 400, message: '请输入用户名密码!' });
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -101,7 +101,7 @@ export default (app: Router) => {
|
||||
try {
|
||||
fs.writeFile(config.authConfigFile, JSON.stringify(req.body), (err) => {
|
||||
if (err) console.log(err);
|
||||
res.send({ code: 200, msg: '更新成功' });
|
||||
res.send({ code: 200, message: '更新成功' });
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error('🔥 error: %o', e);
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ export default (app: Router) => {
|
||||
const { name, content } = req.body;
|
||||
const path = `${config.configPath}${name}`;
|
||||
fs.writeFileSync(path, content);
|
||||
res.send({ code: 200, msg: '保存成功' });
|
||||
res.send({ code: 200, message: '保存成功' });
|
||||
} catch (e) {
|
||||
logger.error('🔥 error: %o', e);
|
||||
return next(e);
|
||||
|
||||
@@ -48,4 +48,44 @@ export default (app: Router) => {
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
route.post(
|
||||
'/scripts',
|
||||
celebrate({
|
||||
body: Joi.object({
|
||||
filename: Joi.string().required(),
|
||||
path: Joi.string().required(),
|
||||
content: Joi.string().required(),
|
||||
}),
|
||||
}),
|
||||
async (req: Request, res: Response, next: NextFunction) => {
|
||||
const logger: Logger = Container.get('logger');
|
||||
try {
|
||||
let { filename, path, content } = req.body as {
|
||||
filename: string;
|
||||
path: string;
|
||||
content: string;
|
||||
};
|
||||
if (!path.endsWith('/')) {
|
||||
path += '/';
|
||||
}
|
||||
if (config.writePathList.every((x) => !path.startsWith(x))) {
|
||||
return res.send({ code: 400, data: '文件路径错误,可保存目录/ql/scripts、/ql/config、/ql/jbot、/ql/bak' });
|
||||
}
|
||||
const filePath = `${path}${filename.replace(/\//g, '')}`;
|
||||
const bakPath = '/ql/bak';
|
||||
if (fs.existsSync(filePath)) {
|
||||
if (!fs.existsSync(bakPath)) {
|
||||
fs.mkdirSync(bakPath);
|
||||
}
|
||||
fs.copyFileSync(filePath, bakPath);
|
||||
}
|
||||
fs.writeFileSync(filePath, content);
|
||||
return res.send({ code: 200 });
|
||||
} catch (e) {
|
||||
logger.error('🔥 error: %o', e);
|
||||
return next(e);
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
@@ -67,4 +67,10 @@ export default {
|
||||
'crontab.list',
|
||||
'env.sh',
|
||||
],
|
||||
writePathList: [
|
||||
'/ql/scripts/',
|
||||
'/ql/config/',
|
||||
'/ql/jbot/',
|
||||
'/ql/bak/',
|
||||
],
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user