From 955d815d14fe8189a6a6185d7ed93fa0a699e7f1 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 12 Mar 2023 21:33:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20task=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=20token=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/api.sh | 21 +++++++++++++++------ shell/task.sh | 6 +++++- src/pages/setting/checkUpdate.tsx | 1 + 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/shell/api.sh b/shell/api.sh index 00809a0a..0f2a9d58 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -1,15 +1,24 @@ #!/usr/bin/env bash +create_token() { + local token_command="tsx ${dir_root}/back/token.ts" + local token_file="${dir_root}static/build/token.js" + if [[ -f $token_file ]]; then + token_command="node ${token_file}" + fi + token=$(eval "$token_command") +} + get_token() { if [[ -f $file_auth_token ]]; then token=$(cat $file_auth_token | jq -r .value) - else - local token_command="tsx ${dir_root}/back/token.ts" - local token_file="${dir_root}static/build/token.js" - if [[ -f $token_file ]]; then - token_command="node ${token_file}" + local expiration=$(cat $file_auth_token | jq -r .expiration) + local currentTimeStamp=$(date +%s) + if [[ $currentTimeStamp -ge $expiration ]]; then + create_token fi - token=$(eval "$token_command") + else + create_token fi } diff --git a/shell/task.sh b/shell/task.sh index 0c6c4ebc..46c99c64 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -15,7 +15,11 @@ define_program() { elif [[ $file_param == *.sh ]]; then which_program="bash" elif [[ $file_param == *.ts ]]; then - which_program="tsx" + if ! type tsx &>/dev/null; then + which_program="ts-node-transpile-only" + else + which_program="tsx" + fi else which_program="" fi diff --git a/src/pages/setting/checkUpdate.tsx b/src/pages/setting/checkUpdate.tsx index 11e3084a..081e32fe 100644 --- a/src/pages/setting/checkUpdate.tsx +++ b/src/pages/setting/checkUpdate.tsx @@ -103,6 +103,7 @@ const CheckUpdate = ({ socketMessage, systemInfo }: any) => { width: 600, maskClosable: false, closable: false, + keyboard: false, okButtonProps: { disabled: true }, title: '更新中...', centered: true,