修复脚本管理删除、新建增加选择父目录

This commit is contained in:
whyour
2021-11-16 00:15:49 +08:00
parent 68cc792d6c
commit 96b0127811
5 changed files with 104 additions and 40 deletions
+7 -2
View File
@@ -120,6 +120,9 @@ export default (app: Router) => {
if (!path.endsWith('/')) {
path += '/';
}
if (!path.startsWith('/')) {
path = `${config.scriptPath}${path}`;
}
if (config.writePathList.every((x) => !path.startsWith(x))) {
return res.send({
code: 430,
@@ -184,15 +187,17 @@ export default (app: Router) => {
celebrate({
body: Joi.object({
filename: Joi.string().required(),
path: Joi.string().allow(''),
}),
}),
async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger');
try {
let { filename } = req.body as {
let { filename, path } = req.body as {
filename: string;
path: string;
};
const filePath = `${config.scriptPath}${filename}`;
const filePath = `${config.scriptPath}${path}/${filename}`;
fs.unlinkSync(filePath);
res.send({ code: 200 });
} catch (e) {