From 70444af762511cccf0a28d86de65fe84978438e7 Mon Sep 17 00:00:00 2001 From: hanhh Date: Tue, 20 Jul 2021 00:10:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0codemirror=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .umirc.ts | 3 +++ shell/task.sh | 48 +++++++++++++++++++++++------------------- src/layouts/index.less | 1 + 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/.umirc.ts b/.umirc.ts index 976e87d6..de1437d9 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -39,5 +39,8 @@ export default defineConfig({ 'https://cdn.jsdelivr.net/npm/codemirror@5.62.0/mode/shell/shell.js', 'https://cdn.jsdelivr.net/npm/codemirror@5.62.0/mode/python/python.js', 'https://cdn.jsdelivr.net/npm/codemirror@5.62.0/mode/javascript/javascript.js', + 'https://cdn.jsdelivr.net/npm/codemirror@5.62.0/addon/dialog/dialog.js', + 'https://cdn.jsdelivr.net/npm/codemirror@5.62.0/addon/search/search.js', + 'https://cdn.jsdelivr.net/npm/codemirror@5.62.0/addon/search/searchcursor.js', ], }); diff --git a/shell/task.sh b/shell/task.sh index 1bfb6fc6..263565d3 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -99,7 +99,7 @@ run_normal() { echo -e "## task_before执行失败,自行检查\n" | tee -p -a $log_path fi - timeout $command_timeout_time $which_program $p1 2>&1 | tee -p -a $log_path + timeout -k 10s $command_timeout_time $which_program $p1 2>&1 | tee -p -a $log_path if [[ ! $(. $file_task_after 1>/dev/null) ]]; then . $file_task_after @@ -145,8 +145,8 @@ run_concurrent() { single_log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N") for i in "${!array[@]}"; do export ${p3}=${array[i]} - single_log_path="$log_dir/${single_log_time}_$((i+1)).log" - timeout $command_timeout_time $which_program $p1 &>$single_log_path & + single_log_path="$log_dir/${single_log_time}_$((i + 1)).log" + timeout -k 10s $command_timeout_time $which_program $p1 &>$single_log_path & done if [[ ! $(. $file_task_after 1>/dev/null) ]]; then @@ -178,7 +178,7 @@ run_else() { echo -e "## task_before执行失败,自行检查\n" | tee -p -a $log_path fi - timeout $command_timeout_time "$@" 2>&1 | tee -p -a $log_path + timeout -k 10s $command_timeout_time bash -c "$@" 2>&1 | tee -p -a $log_path if [[ ! $(. $file_task_after 1>/dev/null) ]]; then . $file_task_after @@ -193,31 +193,35 @@ run_else() { ## 命令检测 main() { - case $# in - 0) - echo - usage - ;; - 1) - run_normal $1 - ;; - 2|3) - case $2 in - now) - run_normal $1 $2 + if [[ $1 == *.js ]] || [[ $1 == *.py ]] || [[ $1 == *.sh ]] || [[ $1 == *.ts ]]; then + case $# in + 0) + echo + usage ;; - conc) - run_concurrent $1 $2 $3 + 1) + run_normal $1 + ;; + 2 | 3) + case $2 in + now) + run_normal $1 $2 + ;; + conc) + run_concurrent $1 $2 $3 + ;; + *) + run_else "$@" + ;; + esac ;; *) run_else "$@" ;; esac - ;; - *) + else run_else "$@" - ;; - esac + fi } main "$@" diff --git a/src/layouts/index.less b/src/layouts/index.less index 8c8985f1..fe57adbc 100644 --- a/src/layouts/index.less +++ b/src/layouts/index.less @@ -14,6 +14,7 @@ body { } @import '~codemirror/lib/codemirror.css'; +@import '~codemirror/addon/dialog/dialog.css'; .ql-container-wrapper { .CodeMirror {