修复定时任务命令补全

This commit is contained in:
whyour 2021-05-05 18:45:25 +08:00
parent 250fcf0b2a
commit 9185360482
6 changed files with 6 additions and 12 deletions

View File

@ -26,10 +26,6 @@ export default (app: Router) => {
case 'crontab': case 'crontab':
content = getFileContentByName(config.crontabFile); content = getFileContentByName(config.crontabFile);
break; break;
case 'shareCode':
let shareCodeFile = getLastModifyFilePath(config.shareCodeDir);
content = getFileContentByName(shareCodeFile);
break;
case 'extra': case 'extra':
content = getFileContentByName(config.extraFile); content = getFileContentByName(config.extraFile);
break; break;

View File

@ -7,11 +7,10 @@ const envFound = dotenv.config();
const rootPath = path.resolve(__dirname, '../../'); const rootPath = path.resolve(__dirname, '../../');
const cookieFile = path.join(rootPath, 'config/cookie.sh'); const cookieFile = path.join(rootPath, 'config/cookie.sh');
const confFile = path.join(rootPath, 'config/config.sh'); const confFile = path.join(rootPath, 'config/config.sh');
const sampleFile = path.join(rootPath, 'sample/config.sh.sample'); const sampleFile = path.join(rootPath, 'sample/config.sample.sh');
const crontabFile = path.join(rootPath, 'config/crontab.list'); const crontabFile = path.join(rootPath, 'config/crontab.list');
const confBakDir = path.join(rootPath, 'config/bak/'); const confBakDir = path.join(rootPath, 'config/bak/');
const authConfigFile = path.join(rootPath, 'config/auth.json'); const authConfigFile = path.join(rootPath, 'config/auth.json');
const shareCodeDir = path.join(rootPath, 'log/export_sharecodes/');
const extraFile = path.join(rootPath, 'config/extra.sh'); const extraFile = path.join(rootPath, 'config/extra.sh');
const logPath = path.join(rootPath, 'log/'); const logPath = path.join(rootPath, 'log/');
const authError = '错误的用户名密码,请重试'; const authError = '错误的用户名密码,请重试';
@ -40,7 +39,6 @@ export default {
authError, authError,
logPath, logPath,
extraFile, extraFile,
shareCodeDir,
authConfigFile, authConfigFile,
confBakDir, confBakDir,
crontabFile, crontabFile,

View File

@ -32,7 +32,7 @@ const run = async () => {
) { ) {
schedule.scheduleJob(task.schedule, function () { schedule.scheduleJob(task.schedule, function () {
let command = task.command as string; let command = task.command as string;
if (!command.startsWith('task ')) { if (!command.startsWith('task ') && !command.startsWith('ql ')) {
command = `task ${command}`; command = `task ${command}`;
} }
exec(command); exec(command);

View File

@ -124,10 +124,10 @@ export default class CronService {
fs.writeFileSync(logFile, `开始执行...\n\n${new Date().toString()}\n`); fs.writeFileSync(logFile, `开始执行...\n\n${new Date().toString()}\n`);
let cmdStr = res.command; let cmdStr = res.command;
if (!res.command.startsWith('task')) { if (!cmdStr.startsWith('task') && !cmdStr.startsWith('ql ')) {
cmdStr = `task ${cmdStr}`; cmdStr = `task ${cmdStr}`;
} }
if (res.command.endsWith('.js')) { if (cmdStr.endsWith('.js')) {
cmdStr = `${cmdStr} now`; cmdStr = `${cmdStr} now`;
} }
const cmd = spawn(cmdStr, { shell: true }); const cmd = spawn(cmdStr, { shell: true });

View File

@ -77,7 +77,7 @@ gen_array_scripts () {
usage () { usage () {
define_cmd define_cmd
gen_array_scripts gen_array_scripts
echo -e "\ntask命令运行本程序自动添加进crontab的脚本需要输入脚本的绝对路径或去掉 “$dir_scripts/” 目录后的相对路径(定时任务中请写作相对路径),用法为:" echo -e "task命令运行本程序自动添加进crontab的脚本需要输入脚本的绝对路径或去掉 “$dir_scripts/” 目录后的相对路径(定时任务中请写作相对路径),用法为:"
echo -e "1.$cmd_task <file_name> # 依次执行如果设置了随机延迟并且当时时间不在0-2、30-31、59分内将随机延迟一定秒数" echo -e "1.$cmd_task <file_name> # 依次执行如果设置了随机延迟并且当时时间不在0-2、30-31、59分内将随机延迟一定秒数"
echo -e "2.$cmd_task <file_name> now # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日志,同时记录在日志文件中" echo -e "2.$cmd_task <file_name> now # 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日志,同时记录在日志文件中"
echo -e "3.$cmd_task <file_name> conc # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日志,直接记录在日志文件中" echo -e "3.$cmd_task <file_name> conc # 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日志,直接记录在日志文件中"

View File

@ -87,7 +87,7 @@ const Crontab = () => {
newValue={sample} newValue={sample}
splitView={true} splitView={true}
leftTitle="config.sh" leftTitle="config.sh"
rightTitle="config.sh.sample" rightTitle="config.sample.sh"
disableWordDiff={true} disableWordDiff={true}
/> />
{/* <CodeDiff {/* <CodeDiff