<template>
  <view class="bg-F5F7FA flex flex-col h-screen overflow-hidden">
    <TopNavBar :title="title" backgroundColor="transparent" />
    <view class="flex-full overflow-hidden scroll-y p-12 border-box">
      <ChatMarkdown :text="answerText" />
    </view>
  </view>
</template>
<script setup>
import TopNavBar from "@/components/TopNavBar/index.vue";
import ChatMarkdown from "../index/components/chat/ChatMarkdown/index.vue";
import { defineProps, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";

const props = defineProps({
  answerText: {
    type: String,
    default: "",
  }
});

const answerText = ref(props.answerText || "");
const title = ref("");

onLoad(({ message = "" }) => {
  answerText.value = decodeURIComponent(message);
  if (answerText.value.length > 6) {
    title.value = answerText.value.substring(0, 6) + "...";
  }
});

</script>