|
|
@@ -2,6 +2,8 @@
|
|
|
import icon from '../images/icon_ai_test@2x.png'
|
|
|
import CodeBlock from './CodeBlock.vue'
|
|
|
import moment from 'moment'
|
|
|
+import MarkdownIt from 'markdown-it'
|
|
|
+import 'github-markdown-css/github-markdown.css'
|
|
|
|
|
|
const PromptdialogVisible = ref(false)
|
|
|
const testquestionvalue = ref('')
|
|
|
@@ -21,6 +23,17 @@ const props = defineProps({
|
|
|
|
|
|
})
|
|
|
|
|
|
+const md = new MarkdownIt({
|
|
|
+ html: true,
|
|
|
+ linkify: true,
|
|
|
+ typographer: true,
|
|
|
+ breaks: true
|
|
|
+})
|
|
|
+
|
|
|
+const renderedMessage = (content) => {
|
|
|
+ return md.render(content)
|
|
|
+}
|
|
|
+
|
|
|
const prompttext = ref(props.prompttext)
|
|
|
const testquestion = ref(props.testquestion)
|
|
|
watch(
|
|
|
@@ -59,6 +72,7 @@ const exporttxt = () => {
|
|
|
}
|
|
|
|
|
|
const unformattedJson = ref({})
|
|
|
+const testtype = ref('')
|
|
|
|
|
|
const PromptAITest = (val:any) => {
|
|
|
if(testquestion.value == false) {
|
|
|
@@ -71,7 +85,8 @@ const PromptAITest = (val:any) => {
|
|
|
}).then((res) => {
|
|
|
if (res.code === 200) {
|
|
|
previewLoading.value = false
|
|
|
- unformattedJson.value = res.data
|
|
|
+ unformattedJson.value = res.data.data
|
|
|
+ testtype.value = res.data.type
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -133,8 +148,11 @@ const PromptAITest = (val:any) => {
|
|
|
</div>
|
|
|
<div class="test_result" v-vloading="previewLoading">
|
|
|
<div v-if="Object.keys(unformattedJson).length == 0" class="test_result_text">暂无数据</div>
|
|
|
- <CodeBlock v-else language="json" :raw-code="JSON.stringify(unformattedJson)">
|
|
|
- </CodeBlock>
|
|
|
+ <div v-else style="width: 100%;">
|
|
|
+ <div style="padding: 8px;" v-if="testtype == 'markdown'" v-html="renderedMessage(unformattedJson)" class="markdown-body markdown-test"></div>
|
|
|
+ <CodeBlock v-else language="json" :raw-code="JSON.stringify(unformattedJson)">
|
|
|
+ </CodeBlock>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|