diff --git a/back/services/schedule.ts b/back/services/schedule.ts index 5794b360..d713da26 100644 --- a/back/services/schedule.ts +++ b/back/services/schedule.ts @@ -27,6 +27,7 @@ export interface TaskCallbacks { endTime: dayjs.Dayjs, diff: number, ) => void; + onLog?: (message: string) => void; onError?: (message: string) => void; } @@ -48,9 +49,13 @@ export default class ScheduleService { callbacks.onStart?.(cp, startTime); + cp.stdout.on('data', (data) => { + callbacks.onLog?.(data.toString()); + }); + cp.stderr.on('data', (data) => { this.logger.error( - '执行任务%s失败,时间:%s, 错误信息:%j', + '执行任务 %s 失败,时间:%s, 错误信息:%j', command, new Date().toLocaleString(), data.toString(), @@ -60,7 +65,7 @@ export default class ScheduleService { cp.on('error', (err) => { this.logger.error( - '执行任务%s失败,时间:%s, 错误信息:%j', + '创建任务 %s 失败,时间:%s, 错误信息:%j', command, new Date().toLocaleString(), err, diff --git a/back/services/subscription.ts b/back/services/subscription.ts index f69da5bc..215e0ad9 100644 --- a/back/services/subscription.ts +++ b/back/services/subscription.ts @@ -181,6 +181,11 @@ export default class SubscriptionService { const absolutePath = await this.handleLogPath(sub.log_path as string); fs.appendFileSync(absolutePath, `\n${message}`); }, + onLog: async (message: string) => { + const sub = await this.getDb({ id: doc.id }); + const absolutePath = await this.handleLogPath(sub.log_path as string); + fs.appendFileSync(absolutePath, `\n${message}`); + }, }; } diff --git a/shell/update.sh b/shell/update.sh index 1e8287b7..2fcebb9a 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -529,7 +529,9 @@ main() { esac local end_time=$(date '+%Y-%m-%d %H:%M:%S') local diff_time=$(($(date +%s -d "$end_time") - $(date +%s -d "$begin_time"))) - echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" >>$log_path + if [[ $p1 != "repo" ]] && [[ $p1 != "raw" ]]; then + echo -e "\n## 执行结束... $end_time 耗时 $diff_time 秒" >>$log_path + fi cat $log_path } diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 726b987a..7cb4d830 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -29,7 +29,7 @@ import { init } from '../utils/init'; export default function (props: any) { const ctx = useCtx(); const theme = useTheme(); - const [user, setUser] = useState(); + const [user, setUser] = useState({}); const [loading, setLoading] = useState(true); const [systemInfo, setSystemInfo] = useState<{ isInitialized: boolean }>(); const ws = useRef(null); diff --git a/src/pages/setting/security.tsx b/src/pages/setting/security.tsx index 8e3ab7e2..d33285fb 100644 --- a/src/pages/setting/security.tsx +++ b/src/pages/setting/security.tsx @@ -99,7 +99,7 @@ const SecuritySettings = ({ user, userChange }: any) => { useEffect(() => { setTwoFactorActivated(user && user.twoFactorActivated); - setAvatar(user && `/api/static/${user.avatar}`); + setAvatar(user.avatar && `/api/static/${user.avatar}`); }, [user]); return twoFactoring ? (