feat: 兼容老的长文本
This commit is contained in:
@@ -8,25 +8,29 @@
|
||||
<!-- ✅ 滚动区域 -->
|
||||
<scroll-view class="flex-full overflow-hidden chat-scroll" scroll-y :scroll-into-view="scrollIntoViewId" scroll-with-animation @scroll="onScroll" @touchstart="onTouchStart" @touchend="onTouchEnd" @touchcancel="onTouchEnd">
|
||||
<view class="flex flex-col pt-12 px-16 pb-24 border-box gap-8">
|
||||
<view v-if="headerSections.title || headerSections.tag" class="long-answer-header">
|
||||
<view v-if="headerSections.title" class="long-answer-title">
|
||||
{{ headerSections.title.contentValue }}
|
||||
<template v-if="hasStructuredLongTextData">
|
||||
<view v-if="headerSections.title || headerSections.tag" class="long-answer-header">
|
||||
<view v-if="headerSections.title" class="long-answer-title">
|
||||
{{ headerSections.title.contentValue }}
|
||||
</view>
|
||||
<view v-if="headerSections.tag" class="long-answer-tag" :style="longAnswerTagStyle">
|
||||
{{ headerSections.tag.contentValue }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="headerSections.tag" class="long-answer-tag" :style="longAnswerTagStyle">
|
||||
{{ headerSections.tag.contentValue }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<template v-for="section in contentSections" :key="section.contentKey">
|
||||
<ParsedValueView
|
||||
v-if="shouldUseParsedValueView(section)"
|
||||
:field-key="section.contentKey"
|
||||
:value="section.parsedValue !== null ? section.parsedValue : section.contentValue"
|
||||
/>
|
||||
<template v-for="section in contentSections" :key="section.contentKey">
|
||||
<ParsedValueView
|
||||
v-if="shouldUseParsedValueView(section)"
|
||||
:field-key="section.contentKey"
|
||||
:value="section.parsedValue !== null ? section.parsedValue : section.contentValue"
|
||||
/>
|
||||
|
||||
<ChatMarkdown v-else :text="section.contentValue" />
|
||||
<ChatMarkdown v-else :text="section.contentValue" />
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<ChatMarkdown v-else-if="answerText" :text="answerText" />
|
||||
|
||||
<!-- ✅ 底部锚点(必须存在) -->
|
||||
<view id="bottom-anchor"></view>
|
||||
</view>
|
||||
@@ -64,6 +68,10 @@ const longAnswerTagStyle = computed(() => buildTagToneStyle(longAnswerTagColor.v
|
||||
let unsubscribe = null;
|
||||
|
||||
const HIDDEN_DETAIL_SECTION_KEYS = [];
|
||||
const hasStructuredLongTextData = computed(() => {
|
||||
const values = longTextData.value?.values;
|
||||
return !!(values && Object.keys(values).length > 0);
|
||||
});
|
||||
|
||||
const shouldUseParsedValueView = (section) => {
|
||||
return (
|
||||
@@ -75,19 +83,14 @@ const shouldUseParsedValueView = (section) => {
|
||||
};
|
||||
|
||||
const renderSections = computed(() => {
|
||||
const data = longTextData.value;
|
||||
if (data && data.values) {
|
||||
return getLongTextSections(data)
|
||||
.filter((section) => section.contentValue)
|
||||
.map((section) => ({
|
||||
...section,
|
||||
fromLongTextData: true,
|
||||
}));
|
||||
}
|
||||
if (!hasStructuredLongTextData.value) return [];
|
||||
|
||||
return answerText.value
|
||||
? [{ contentKey: "content", contentValue: answerText.value }]
|
||||
: [];
|
||||
return getLongTextSections(longTextData.value)
|
||||
.filter((section) => section.contentValue)
|
||||
.map((section) => ({
|
||||
...section,
|
||||
fromLongTextData: true,
|
||||
}));
|
||||
});
|
||||
|
||||
const headerSections = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user