diff --git a/back/api/system.ts b/back/api/system.ts index 20e90d74..8074e6ff 100644 --- a/back/api/system.ts +++ b/back/api/system.ts @@ -279,14 +279,14 @@ export default (app: Router) => { res.end(); }, onError: async (message: string) => { - res.write(`\n${message}`); + res.write(message); const absolutePath = await handleLogPath(logPath); - await fs.appendFile(absolutePath, `\n${message}`); + await fs.appendFile(absolutePath, message); }, onLog: async (message: string) => { - res.write(`\n${message}`); + res.write(message); const absolutePath = await handleLogPath(logPath); - await fs.appendFile(absolutePath, `\n${message}`); + await fs.appendFile(absolutePath, message); }, }, ); diff --git a/back/services/cron.ts b/back/services/cron.ts index 0519c797..28cad2cd 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -573,7 +573,7 @@ export default class CronService { return typeof doc.status === 'number' && [CrontabStatus.queued, CrontabStatus.running].includes(doc.status) ? '运行中...' - : '任务空闲中'; + : '日志不存在...'; } } diff --git a/back/services/system.ts b/back/services/system.ts index 6c90461a..f7d83797 100644 --- a/back/services/system.ts +++ b/back/services/system.ts @@ -47,7 +47,7 @@ export default class SystemService { @Inject('logger') private logger: winston.Logger, private scheduleService: ScheduleService, private sockService: SockService, - ) {} + ) { } public async getSystemConfig() { const doc = await this.getDb({ type: AuthDataType.systemConfig }); @@ -287,7 +287,7 @@ export default class SystemService { ); const text = await body.text(); lastVersionContent = parseContentVersion(text); - } catch (error) {} + } catch (error) { } if (!lastVersionContent) { lastVersionContent = currentVersionContent; @@ -401,11 +401,12 @@ export default class SystemService { } } - public async run({ command }: { command: string }, callback: TaskCallbacks) { + public async run({ command, logPath }: { command: string; logPath?: string }, callback: TaskCallbacks) { if (!command.startsWith(TASK_COMMAND)) { command = `${TASK_COMMAND} ${command}`; } - this.scheduleService.runTask(`real_time=true ${command}`, callback, { + const logPathPrefix = logPath ? `real_log_path=${logPath}` : '' + this.scheduleService.runTask(`${logPathPrefix} real_time=true ${command}`, callback, { command, id: command.replace(/ /g, '-'), runOrigin: 'system', @@ -442,8 +443,7 @@ export default class SystemService { } const dataPaths = dataDirs.map((dir) => `data/${dir}`); await promiseExec( - `cd ${config.dataPath} && cd ../ && tar -zcvf ${ - config.dataTgzFile + `cd ${config.dataPath} && cd ../ && tar -zcvf ${config.dataTgzFile } ${dataPaths.join(' ')}`, ); res.download(config.dataTgzFile); @@ -537,7 +537,7 @@ export default class SystemService { try { const finalPath = path.join(config.dependenceCachePath, type); await fs.promises.rm(finalPath, { recursive: true }); - } catch (error) {} + } catch (error) { } return { code: 200 }; } } diff --git a/shell/pub.sh b/shell/pub.sh index e591e59b..1d126bc6 100755 --- a/shell/pub.sh +++ b/shell/pub.sh @@ -2,13 +2,9 @@ echo -e "开始发布" echo -e "切换master分支" -git checkout master - -echo -e "合并develop代码" -git merge origin/develop - -echo -e "提交master代码" -git push +git branch -D master +git checkout -b master +git push --set-upstream origin master -f echo -e "更新cdn文件" ts-node-transpile-only sample/tool.ts diff --git a/src/pages/crontab/logModal.tsx b/src/pages/crontab/logModal.tsx index 80c2aa86..59844305 100644 --- a/src/pages/crontab/logModal.tsx +++ b/src/pages/crontab/logModal.tsx @@ -1,5 +1,5 @@ -import intl from 'react-intl-universal'; -import React, { useEffect, useRef, useState } from 'react'; +import intl from "react-intl-universal"; +import React, { useEffect, useRef, useState } from "react"; import { Modal, message, @@ -8,17 +8,17 @@ import { Statistic, Button, Typography, -} from 'antd'; -import { request } from '@/utils/http'; -import config from '@/utils/config'; +} from "antd"; +import { request } from "@/utils/http"; +import config from "@/utils/config"; import { Loading3QuartersOutlined, CheckCircleOutlined, -} from '@ant-design/icons'; -import { PageLoading } from '@ant-design/pro-layout'; -import { logEnded } from '@/utils'; -import { CrontabStatus } from './type'; -import Ansi from 'ansi-to-react'; +} from "@ant-design/icons"; +import { PageLoading } from "@ant-design/pro-layout"; +import { logEnded } from "@/utils"; +import { CrontabStatus } from "./type"; +import Ansi from "ansi-to-react"; const { Countdown } = Statistic; @@ -33,7 +33,7 @@ const CronLogModal = ({ data?: string; logUrl?: string; }) => { - const [value, setValue] = useState(intl.get('启动中...')); + const [value, setValue] = useState(intl.get("启动中...")); const [loading, setLoading] = useState(true); const [executing, setExecuting] = useState(true); const [isPhone, setIsPhone] = useState(false); @@ -49,15 +49,15 @@ const CronLogModal = ({ .then(({ code, data }) => { if ( code === 200 && - localStorage.getItem('logCron') === uniqPath && + localStorage.getItem("logCron") === uniqPath && data !== value ) { const log = data as string; - setValue(log || intl.get('暂无日志')); + setValue(log || intl.get("暂无日志")); const hasNext = Boolean( - log && !logEnded(log) && !log.includes('任务未运行'), + log && !logEnded(log) && !log.includes("日志不存在"), ); - if (!hasNext && !logEnded(value) && value !== intl.get('启动中...')) { + if (!hasNext && !logEnded(value) && value !== intl.get("启动中...")) { setTimeout(() => { autoScroll(); }); @@ -85,13 +85,13 @@ const CronLogModal = ({ setTimeout(() => { document - .querySelector('#log-flag')! - .scrollIntoView({ behavior: 'smooth' }); + .querySelector("#log-flag") + ?.scrollIntoView({ behavior: "smooth" }); }, 600); }; const cancel = () => { - localStorage.removeItem('logCron'); + localStorage.removeItem("logCron"); handleCancel(); }; @@ -107,7 +107,7 @@ const CronLogModal = ({ const titleElement = () => { return ( -
+
{(executing || loading) && } {!executing && !loading && } @@ -144,7 +144,7 @@ const CronLogModal = ({ onCancel={() => cancel()} footer={[ , ]} > @@ -156,9 +156,9 @@ const CronLogModal = ({ style={ isPhone ? { - fontFamily: 'Source Code Pro', - zoom: 0.83, - } + fontFamily: "Source Code Pro", + zoom: 0.83, + } : {} } > diff --git a/src/pages/setting/checkUpdate.tsx b/src/pages/setting/checkUpdate.tsx index a87a44b8..16e320fc 100644 --- a/src/pages/setting/checkUpdate.tsx +++ b/src/pages/setting/checkUpdate.tsx @@ -1,23 +1,23 @@ -import { disableBody } from '@/utils'; -import config from '@/utils/config'; -import { request } from '@/utils/http'; -import WebSocketManager from '@/utils/websocket'; -import Ansi from 'ansi-to-react'; -import { Button, Modal, Statistic, message } from 'antd'; -import { useCallback, useEffect, useRef, useState } from 'react'; -import intl from 'react-intl-universal'; +import { disableBody } from "@/utils"; +import config from "@/utils/config"; +import { request } from "@/utils/http"; +import WebSocketManager from "@/utils/websocket"; +import Ansi from "ansi-to-react"; +import { Button, Modal, Statistic, message } from "antd"; +import { useCallback, useEffect, useRef, useState } from "react"; +import intl from "react-intl-universal"; const { Countdown } = Statistic; const CheckUpdate = ({ systemInfo }: any) => { const [updateLoading, setUpdateLoading] = useState(false); - const [value, setValue] = useState(''); + const [value, setValue] = useState(""); const modalRef = useRef(); const checkUpgrade = () => { if (updateLoading) return; setUpdateLoading(true); - message.loading(intl.get('检查更新中...'), 0); + message.loading(intl.get("检查更新中..."), 0); request .put(`${config.apiPrefix}system/update-check`) .then(({ code, data }) => { @@ -42,22 +42,22 @@ const CheckUpdate = ({ systemInfo }: any) => { const showForceUpdateModal = (data: any) => { Modal.confirm({ width: 500, - title: intl.get('更新'), + title: intl.get("更新"), content: ( <> -
{intl.get('已经是最新版了!')}
+
{intl.get("已经是最新版了!")}
- {intl.get('青龙')} {data.lastVersion}{' '} - {intl.get('是目前检测到的最新可用版本了。')} + {intl.get("青龙")} {data.lastVersion}{" "} + {intl.get("是目前检测到的最新可用版本了。")}
), - okText: intl.get('重新下载'), + okText: intl.get("重新下载"), onOk() { showUpdatingModal(); request .put(`${config.apiPrefix}system/update`) - .then((_data: any) => {}) + .then((_data: any) => { }) .catch((error: any) => { console.log(error); }); @@ -71,10 +71,10 @@ const CheckUpdate = ({ systemInfo }: any) => { width: 500, title: ( <> -
{intl.get('更新可用')}
+
{intl.get("更新可用")}
- {intl.get('新版本')} {lastVersion}{' '} - {intl.get('可用,你使用的版本为')} {systemInfo.version}。 + {intl.get("新版本")} {lastVersion}{" "} + {intl.get("可用,你使用的版本为")} {systemInfo.version}。
), @@ -83,13 +83,13 @@ const CheckUpdate = ({ systemInfo }: any) => { {lastLog} ), - okText: intl.get('下载更新'), - cancelText: intl.get('以后再说'), + okText: intl.get("下载更新"), + cancelText: intl.get("以后再说"), onOk() { showUpdatingModal(); request .put(`${config.apiPrefix}system/update`) - .then((_data: any) => {}) + .then((_data: any) => { }) .catch((error: any) => { console.log(error); }); @@ -98,14 +98,14 @@ const CheckUpdate = ({ systemInfo }: any) => { }; const showUpdatingModal = () => { - setValue(''); + setValue(""); modalRef.current = Modal.info({ width: 600, maskClosable: false, closable: false, keyboard: false, okButtonProps: { disabled: true }, - title: intl.get('下载更新中...'), + title: intl.get("下载更新中..."), centered: true, content: (
@@ -122,13 +122,13 @@ const CheckUpdate = ({ systemInfo }: any) => {
         message.success({
           content: (
             
-              {intl.get('系统将在')}
+              {intl.get("系统将在")}
               
-              {intl.get('秒后自动刷新')}
+              {intl.get("秒后自动刷新")}
             
           ),
           duration: 30,
@@ -147,12 +147,12 @@ const CheckUpdate = ({ systemInfo }: any) => {
     Modal.confirm({
       width: 600,
       maskClosable: false,
-      title: intl.get('确认重启'),
+      title: intl.get("确认重启"),
       centered: true,
-      content: intl.get('系统安装包下载成功,确认重启'),
-      okText: intl.get('重启'),
+      content: intl.get("系统安装包下载成功,确认重启"),
+      okText: intl.get("重启"),
       onOk() {
-        reloadSystem('system');
+        reloadSystem("system");
       },
       onCancel() {
         modalRef.current.update({
@@ -166,7 +166,7 @@ const CheckUpdate = ({ systemInfo }: any) => {
 
   useEffect(() => {
     if (!value) return;
-    const updateFailed = value.includes('失败,请检查');
+    const updateFailed = value.includes("失败,请检查");
 
     modalRef.current.update({
       maskClosable: updateFailed,
@@ -185,19 +185,19 @@ const CheckUpdate = ({ systemInfo }: any) => {
 
   const handleMessage = useCallback((payload: any) => {
     let { message: _message } = payload;
-    const updateFailed = _message.includes('失败,请检查');
+    const updateFailed = _message.includes("失败,请检查");
 
     if (updateFailed) {
-      message.error(intl.get('更新失败,请检查网络及日志或稍后再试'));
+      message.error(intl.get("更新失败,请检查网络及日志或稍后再试"));
     }
 
     setTimeout(() => {
       document
-        .querySelector('#log-identifier')!
-        .scrollIntoView({ behavior: 'smooth' });
+        .querySelector("#log-identifier")
+        ?.scrollIntoView({ behavior: "smooth" });
     }, 600);
 
-    if (_message.includes('更新包下载成功')) {
+    if (_message.includes("更新包下载成功")) {
       setTimeout(() => {
         showReloadModal();
       }, 1000);
@@ -208,24 +208,24 @@ const CheckUpdate = ({ systemInfo }: any) => {
 
   useEffect(() => {
     const ws = WebSocketManager.getInstance();
-    ws.subscribe('updateSystemVersion', handleMessage);
+    ws.subscribe("updateSystemVersion", handleMessage);
 
     return () => {
-      ws.unsubscribe('updateSystemVersion', handleMessage);
+      ws.unsubscribe("updateSystemVersion", handleMessage);
     };
   }, []);
 
   return (
     <>
       
       
     
   );