From 6f4736bddf2738eace135803faf7e0ff7f668a76 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 26 Jun 2022 22:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=AE=A1=E7=90=86=E6=8C=89?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 14 ++++++++++++-- shell/api.sh | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index a97f77a1..92609cb0 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -278,6 +278,11 @@ export async function concurrentRun( return replyList; } +enum FileType { + 'directory', + 'file', +} + export function readDirs( dir: string, baseDir: string = '', @@ -298,7 +303,10 @@ export function readDirs( type: 'directory', disabled: true, parent: relativePath, - children: readDirs(subPath, baseDir), + children: readDirs(subPath, baseDir).sort( + (a: any, b: any) => + (FileType as any)[a.type] - (FileType as any)[b.type], + ), }; } return { @@ -308,7 +316,9 @@ export function readDirs( parent: relativePath, }; }); - return result; + return result.sort( + (a: any, b: any) => (FileType as any)[a.type] - (FileType as any)[b.type], + ); } export function readDir( diff --git a/shell/api.sh b/shell/api.sh index ffb59ad7..30f69120 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -154,7 +154,7 @@ update_cron() { code=$(echo $api | jq -r .code) message=$(echo $api | jq -r .message) if [[ $code != 200 ]]; then - echo -e "\n## 更新任务状态失败(${message})\n" >> $log_path + echo -e "\n## 更新任务状态失败(${message})\n" >> $dir_log/$log_path fi }