feat: 组件的调试

This commit is contained in:
2026-05-22 11:58:49 +08:00
parent e605d68d59
commit 1a331d2ae2
2 changed files with 155 additions and 19 deletions

View File

@@ -9,16 +9,18 @@
<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="pt-12 px-12 pb-24 border-box">
<template v-for="section in renderSections" :key="section.contentKey">
<view v-if="section.contentKey === 'tag'" class="long-answer-tag">
<view v-if="section.contentKey === LONG_TEXT_KEYS.tag" class="long-answer-tag">
{{ section.contentValue }}
</view>
<view v-else-if="section.contentKey === 'title'" class="long-answer-title">
<view v-else-if="section.contentKey === LONG_TEXT_KEYS.title" class="long-answer-title">
{{ section.contentValue }}
</view>
<ChatMarkdown v-else-if="section.contentKey === 'content'" :text="section.contentValue" />
<view v-else-if="section.parsedValue !== null" class="long-answer-block">
<ChatMarkdown :text="toMarkdownText(section.parsedValue)" />
<view v-else-if="shouldUseParsedValueView(section)" class="long-answer-block">
<ParsedValueView :field-key="section.contentKey" :value="section.parsedValue !== null ? section.parsedValue : section.contentValue" />
</view>
<ChatMarkdown v-else-if="section.contentKey === LONG_TEXT_KEYS.content" :text="section.contentValue" />
<ChatMarkdown v-else :text="section.contentValue" />
</template>
@@ -32,10 +34,12 @@
<script setup>
import TopNavBar from "@/components/TopNavBar/index.vue";
import ChatMarkdown from "../ChatMarkdown/index.vue";
import ParsedValueView from "./ParsedValueView.vue";
import { defineProps, ref, nextTick, computed } from "vue";
import { onLoad, onUnload } from "@dcloudio/uni-app";
import StreamManager from "@/utils/StreamManager.js";
import {
LONG_TEXT_KEYS,
getLongTextSections,
getLongTextValue,
} from "@/utils/longTextCard";
@@ -52,20 +56,10 @@ const title = ref("");
const longTextData = ref(null);
let unsubscribe = null;
const PARSED_VALUE_VIEW_KEYS = ["container_type"];
const toMarkdownText = (value) => {
if (value === undefined || value === null) return "";
if (Array.isArray(value)) {
return value.map((item) => toMarkdownText(item)).filter(Boolean).join("\n\n");
}
if (typeof value === "object") {
try {
return JSON.stringify(value, null, 2);
} catch (e) {
return String(value);
}
}
return String(value);
const shouldUseParsedValueView = (section) => {
return section.parsedValue !== null || PARSED_VALUE_VIEW_KEYS.includes(section.contentKey);
};
const renderSections = computed(() => {
@@ -250,7 +244,6 @@ onUnload(() => {
line-height: 18px;
}
.long-answer-title {
margin-bottom: 12px;
color: #111827;
font-size: 20px;
font-weight: 600;