feat: 兼容老的长文本
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<view v-if="longTextData?.values" class="w-full bg-white border-box border-ff overflow-hidden rounded-20 flex flex-col">
|
||||
<view v-if="shouldRenderCard" class="w-full bg-white border-box border-ff overflow-hidden rounded-20 flex flex-col">
|
||||
<!-- 占位撑开 -->
|
||||
<view class="w-vw"></view>
|
||||
<view class="flex flex-col px-16 pt-16 pb-12 border-box" @click="lookDetailAction">
|
||||
@@ -60,8 +60,20 @@ const tag = computed(() => getLongTextValue(props.longTextData, LONG_TEXT_KEYS.t
|
||||
const title = computed(() => getLongTextValue(props.longTextData, LONG_TEXT_KEYS.title));
|
||||
const longAnswerTagColor = ref(pickRandomTagToneColor());
|
||||
const longAnswerTagStyle = computed(() => buildTagToneStyle(longAnswerTagColor.value));
|
||||
const hasStructuredLongTextData = computed(() => {
|
||||
const values = props.longTextData?.values;
|
||||
return !!(values && Object.keys(values).length > 0);
|
||||
});
|
||||
const detailLongTextData = computed(() => {
|
||||
return hasStructuredLongTextData.value ? props.longTextData : null;
|
||||
});
|
||||
const previewContent = computed(() => {
|
||||
return getLongTextPreviewText(props.longTextData, [LONG_TEXT_KEYS.contentSummary]);
|
||||
const structuredPreview = getLongTextPreviewText(props.longTextData, [LONG_TEXT_KEYS.contentSummary]);
|
||||
if (structuredPreview) return structuredPreview;
|
||||
return hasStructuredLongTextData.value ? "" : props.content || "";
|
||||
});
|
||||
const shouldRenderCard = computed(() => {
|
||||
return hasStructuredLongTextData.value || !!previewContent.value || !props.finish;
|
||||
});
|
||||
|
||||
// 处理文本内容:按行截断以保证预览最多显示两行(更贴近视觉行数)
|
||||
@@ -92,7 +104,7 @@ const isOverflow = computed(() => {
|
||||
const contentStr = previewContent.value ? String(previewContent.value) : "";
|
||||
const lines = contentStr.split(/\r?\n/);
|
||||
return (
|
||||
hasLongTextExtraSections(props.longTextData) ||
|
||||
(hasStructuredLongTextData.value && hasLongTextExtraSections(props.longTextData)) ||
|
||||
lines.length > PREVIEW_LINES ||
|
||||
contentStr.length > PREVIEW_CHAR_LIMIT
|
||||
);
|
||||
@@ -128,11 +140,11 @@ const lookDetailAction = () => {
|
||||
streamId,
|
||||
previewContent.value ? String(previewContent.value) : "",
|
||||
!!props.finish,
|
||||
props.longTextData || null,
|
||||
detailLongTextData.value,
|
||||
);
|
||||
};
|
||||
|
||||
StreamManager.openStream(streamId, message, !!props.finish, props.longTextData || null);
|
||||
StreamManager.openStream(streamId, message, !!props.finish, detailLongTextData.value);
|
||||
|
||||
cleanupStreamWatchers();
|
||||
|
||||
@@ -154,7 +166,7 @@ const lookDetailAction = () => {
|
||||
streamId,
|
||||
previewContent.value ? String(previewContent.value) : "",
|
||||
!!f,
|
||||
props.longTextData || null,
|
||||
detailLongTextData.value,
|
||||
);
|
||||
if (f) {
|
||||
cleanupStreamWatchers();
|
||||
@@ -179,7 +191,7 @@ const lookDetailAction = () => {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
line-height: 16px;
|
||||
max-height: 52px;
|
||||
max-height: 62px;
|
||||
}
|
||||
.long-answer-tag {
|
||||
display: inline-flex;
|
||||
|
||||
Reference in New Issue
Block a user