From 73c53dbc8dc0a31bdaea09f32bdc4405861344c4 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 12 Mar 2023 20:53:15 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20typescript=20execute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/initTask.ts | 2 +- docker/Dockerfile | 2 +- package.json | 2 ++ pnpm-lock.yaml | 2 ++ shell/api.sh | 2 +- shell/pub.sh | 2 +- shell/share.sh | 11 ++++++----- shell/task.sh | 2 +- 8 files changed, 15 insertions(+), 10 deletions(-) diff --git a/back/loaders/initTask.ts b/back/loaders/initTask.ts index 17da8ad9..86e78833 100644 --- a/back/loaders/initTask.ts +++ b/back/loaders/initTask.ts @@ -11,7 +11,7 @@ export default async () => { const subscriptionService = Container.get(SubscriptionService); // 生成内置token - let tokenCommand = `ts-node-transpile-only ${config.rootPath}/back/token.ts`; + let tokenCommand = `tsx ${config.rootPath}/back/token.ts`; const tokenFile = `${config.rootPath}static/build/token.js`; if (await fileExist(tokenFile)) { tokenCommand = `node ${tokenFile}`; diff --git a/docker/Dockerfile b/docker/Dockerfile index 64f4cc67..ebe3c62d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -49,7 +49,7 @@ RUN set -x \ && git config --global user.name "qinglong" \ && git config --global http.postBuffer 524288000 \ && npm install -g pnpm \ - && pnpm add -g pm2 ts-node typescript tslib \ + && pnpm add -g pm2 tsx \ && rm -rf /root/.pnpm-store \ && rm -rf /root/.local/share/pnpm/store \ && rm -rf /root/.cache \ diff --git a/package.json b/package.json index 597b972e..9ba54a15 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "start:front": "max dev", "start:back": "nodemon", "start:public": "ts-node --transpile-only ./back/public.ts", + "start:schedule": "ts-node --transpile-only ./back/schedule.ts", "build:front": "max build", "build:back": "tsc -p tsconfig.back.json", "panel": "npm run build:back && node static/build/app.js", @@ -142,6 +143,7 @@ "sockjs-client": "^1.6.0", "ts-node": "^10.6.0", "tslib": "^2.4.0", + "tsx": "^3.12.3", "typescript": "4.8.4", "umi-request": "^1.4.0", "vh-check": "^2.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 02cde407..f7f9e0e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -84,6 +84,7 @@ specifiers: toad-scheduler: ^1.6.0 ts-node: ^10.6.0 tslib: ^2.4.0 + tsx: ^3.12.3 typedi: ^0.10.0 typescript: 4.8.4 umi-request: ^1.4.0 @@ -184,6 +185,7 @@ devDependencies: sockjs-client: 1.6.1 ts-node: 10.9.1_ksn4eycaeggbrckn3ykh37hwf4 tslib: 2.4.1 + tsx: 3.12.3 typescript: 4.8.4 umi-request: 1.4.0 vh-check: 2.0.5 diff --git a/shell/api.sh b/shell/api.sh index 92de8312..00809a0a 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -4,7 +4,7 @@ get_token() { if [[ -f $file_auth_token ]]; then token=$(cat $file_auth_token | jq -r .value) else - local token_command="ts-node-transpile-only ${dir_root}/back/token.ts" + 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}" diff --git a/shell/pub.sh b/shell/pub.sh index d9fba954..333b82d9 100755 --- a/shell/pub.sh +++ b/shell/pub.sh @@ -11,7 +11,7 @@ echo -e "提交master代码" git push echo -e "更新cdn文件" -ts-node sample/tool.ts +tsx sample/tool.ts string=$(cat version.yaml | grep "version" | egrep "[^ ]*" -o | egrep "\d\.*") version="v$string" diff --git a/shell/share.sh b/shell/share.sh index 3ea3b322..3d236b29 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -431,16 +431,17 @@ format_timestamp() { } patch_version() { + # 兼容pnpm@7 + pnpm setup &>/dev/null + source ~/.bashrc + if [[ $PipMirror ]]; then pip3 config set global.index-url $PipMirror fi if [[ $NpmMirror ]]; then - npm config set registry $NpmMirror + pnpm config set registry $NpmMirror fi - # 兼容pnpm@7 - pnpm setup &>/dev/null - source ~/.bashrc pnpm install -g &>/dev/null if [[ -f "$dir_root/db/cookie.db" ]]; then @@ -450,7 +451,7 @@ patch_version() { echo fi - pnpm add -g pm2 ts-node typescript tslib + pnpm add -g pm2 tsx git config --global pull.rebase false diff --git a/shell/task.sh b/shell/task.sh index 1e59b2ac..0c6c4ebc 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -15,7 +15,7 @@ define_program() { elif [[ $file_param == *.sh ]]; then which_program="bash" elif [[ $file_param == *.ts ]]; then - which_program="ts-node-transpile-only" + which_program="tsx" else which_program="" fi From 3a3b945de8030e494bbefffa17ac166c27ef11a5 Mon Sep 17 00:00:00 2001 From: adams549659584 <13760614423@163.com> Date: Sun, 12 Mar 2023 20:58:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20js=20=E4=B8=8B=20bark?= =?UTF-8?q?=20=E6=8E=A8=E9=80=81=E5=A3=B0=E9=9F=B3=20bug=20(#1847)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/notify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sample/notify.js b/sample/notify.js index d2e03ddd..a6fb4d06 100644 --- a/sample/notify.js +++ b/sample/notify.js @@ -296,7 +296,7 @@ async function sendNotify( ) { //提供6种通知 desp += author; //增加作者信息,防止被贩卖等 - + // 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔 let skipTitle = process.env.SKIP_PUSH_TITLE if(skipTitle) { @@ -533,7 +533,7 @@ function BarkNotify(text, desp, params = {}) { const options = { url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent( desp, - )}?icon=${BARK_ICON}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify( + )}?icon=${BARK_ICON}&sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify( params, )}`, headers: { From 955d815d14fe8189a6a6185d7ed93fa0a699e7f1 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 12 Mar 2023 21:33:46 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20task=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=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, From 39c40a328de86d1bf1dc3ff762f1d69224b7bd67 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 12 Mar 2023 21:48:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=B9=E6=A1=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/setting/checkUpdate.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/setting/checkUpdate.tsx b/src/pages/setting/checkUpdate.tsx index 081e32fe..64c0254f 100644 --- a/src/pages/setting/checkUpdate.tsx +++ b/src/pages/setting/checkUpdate.tsx @@ -47,9 +47,8 @@ const CheckUpdate = ({ socketMessage, systemInfo }: any) => { ), - okText: '确认', - cancelText: '强制更新', - onCancel() { + okText: '强制更新', + onOk() { showUpdatingModal(); request .put(`${config.apiPrefix}system/update`)