From 881abda55e68db22a6c1a150087c84a52b95dcac Mon Sep 17 00:00:00 2001 From: zoujing Date: Thu, 4 Jun 2026 14:28:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/test-ParsedValueView-strict.mjs | 21 ++++ scripts/test-longTextCard.mjs | 21 ++++ .../ChatLongAnswer/ParsedValueView.vue | 92 +++++++++++++++++- .../styles/ParsedValueView.scss | 97 ++++++++++++++++++- src/utils/longTextCard.js | 14 +++ 5 files changed, 241 insertions(+), 4 deletions(-) diff --git a/scripts/test-ParsedValueView-strict.mjs b/scripts/test-ParsedValueView-strict.mjs index 32c6c14..4e5d1d2 100644 --- a/scripts/test-ParsedValueView-strict.mjs +++ b/scripts/test-ParsedValueView-strict.mjs @@ -40,4 +40,25 @@ for (const snippet of forbiddenCompatibilitySnippets) { ); } +const requiredStrictRenderingSnippets = [ + "LONG_TEXT_KEYS.sceneImage", + "LONG_TEXT_KEYS.commodityList", + "commodity.commodity_id", + "commodity.commodity_name", + "commodity.commodity_price", + "commodity.commodity_tag", + "commodity.commodity_photo", + "content-body-list-marker", + "entry.value.length > 1", + "formatListMarker(index)", +]; + +for (const snippet of requiredStrictRenderingSnippets) { + assert.equal( + source.includes(snippet), + true, + `ParsedValueView should render exact strict field: ${snippet}` + ); +} + console.log("ParsedValueView strict field checks passed"); diff --git a/scripts/test-longTextCard.mjs b/scripts/test-longTextCard.mjs index 9972902..c56d4dc 100644 --- a/scripts/test-longTextCard.mjs +++ b/scripts/test-longTextCard.mjs @@ -7,6 +7,8 @@ const moduleUrl = `data:text/javascript;base64,${Buffer.from(source).toString("b const longTextCard = await import(moduleUrl); const { + LONG_TEXT_FIELD_CONFIG, + LONG_TEXT_KEYS, parseLongTextDisplayValue, sanitizeLongTextDisplayValue, hasLongTextDisplayValue, @@ -51,4 +53,23 @@ assert.equal(hasLongTextDisplayValue({ a: "", b: [" ", null] }), false); assert.equal(formatLongTextDisplayValue(true), "\u662f"); assert.equal(formatLongTextDisplayValue({ title: "bridge" }), '{"title":"bridge"}'); +const expectedNewKeys = { + preparationSectionTitle: "preparation_section_title", + preparationSectionItems: "preparation_section_items", + sectionSuggestionTitle: "section_suggestion_title", + sectionSuggestionContent: "section_suggestion_content", + pitfallSectionTitle: "pitfall_section_title", + pitfallSectionItems: "pitfall_section_items", + commodityList: "commodity_list", +}; + +for (const [keyName, keyValue] of Object.entries(expectedNewKeys)) { + assert.equal(LONG_TEXT_KEYS[keyName], keyValue, `${keyName} should be registered`); + assert.equal( + LONG_TEXT_FIELD_CONFIG.some((item) => item.key === keyValue), + true, + `${keyValue} should be in LONG_TEXT_FIELD_CONFIG` + ); +} + console.log("longTextCard display helpers passed"); diff --git a/src/pages/ChatMain/ChatLongAnswer/ParsedValueView.vue b/src/pages/ChatMain/ChatLongAnswer/ParsedValueView.vue index aa0f706..529e667 100644 --- a/src/pages/ChatMain/ChatLongAnswer/ParsedValueView.vue +++ b/src/pages/ChatMain/ChatLongAnswer/ParsedValueView.vue @@ -1,6 +1,6 @@