From 07bba97ff967b834584cbca6a10f3443ce7db7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=BC=9F?= Date: Fri, 13 Mar 2026 15:29:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=BB=E6=8E=89parseK8sLog=E7=9A=84?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/utils/index.ts | 4 ++-- react-ui/tests/parseK8sLog.test.ts | 7 ------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/react-ui/src/utils/index.ts b/react-ui/src/utils/index.ts index a5bfc774..e2121282 100644 --- a/react-ui/src/utils/index.ts +++ b/react-ui/src/utils/index.ts @@ -501,10 +501,10 @@ export function toDecimals(num: number, decimals: number) { * 解析 k8s 日志 * * @param log - k8s 日志 - * @param isLine - 是否按行解析,默认按行解析 + * @param isLine - 是否按行解析 * @returns 解析后的日志 */ -export function parseK8sLog(log: string, isLine: boolean = true) { +export function parseK8sLog(log: string, isLine: boolean) { // 判断是否存在时间戳与stdout F/stderr P 前缀,如果有则去掉,并且末尾添加换行符 if (isLine) { const reg = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+\+\d{2}:\d{2} (stdout|stderr) [F|P] /; diff --git a/react-ui/tests/parseK8sLog.test.ts b/react-ui/tests/parseK8sLog.test.ts index 27dce4f7..acd8c854 100644 --- a/react-ui/tests/parseK8sLog.test.ts +++ b/react-ui/tests/parseK8sLog.test.ts @@ -37,11 +37,4 @@ describe('test parseK8sLog()', () => { expect(result).toBe(log); }); }); - - // 测试默认参数 - test('should use isLine = true by default', () => { - const log = '2023-01-01T00:00:00.000+00:00 stdout F test log'; - const result = parseK8sLog(log); - expect(result).toBe('test log\n'); - }); });