From d97af83c9ecfe2b6e5a9d13bedf9f2ceb38a494d Mon Sep 17 00:00:00 2001 From: IndieKKY Date: Sat, 20 Jan 2024 13:35:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81gemini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/biz_util.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/biz_util.ts b/src/util/biz_util.ts index dc9911c..4fad38a 100644 --- a/src/util/biz_util.ts +++ b/src/util/biz_util.ts @@ -253,15 +253,15 @@ export const extractJsonObject = (content: string) => { const start = content.indexOf('```') const end = content.lastIndexOf('```') if (start >= 0 && end >= 0) { - // 异常情况 - if (start === end) { + if (start === end) { // 异常情况 if (content.startsWith('```')) { content = content.slice(3) } else { content = content.slice(0, -3) } + } else { + content = content.slice(start + 3, end) } - content = content.slice(start + 3, end) } // get content between { and } const start2 = content.indexOf('{') @@ -277,15 +277,15 @@ export const extractJsonArray = (content: string) => { const start = content.indexOf('```') const end = content.lastIndexOf('```') if (start >= 0 && end >= 0) { - // 异常情况 - if (start === end) { + if (start === end) { // 异常情况 if (content.startsWith('```')) { content = content.slice(3) } else { content = content.slice(0, -3) } + } else { + content = content.slice(start + 3, end) } - content = content.slice(start + 3, end) } // get content between [ and ] const start3 = content.indexOf('[')