askAi进度条支持markdown

This commit is contained in:
fofolee
2025-03-15 14:12:58 +08:00
parent 2fce45e13b
commit 07babda68e
13 changed files with 146 additions and 52 deletions

View File

@@ -41,7 +41,6 @@
<script>
import { defineComponent } from "vue";
import DOMPurify from "dompurify";
export default defineComponent({
name: "AIChatHistory",
@@ -82,15 +81,7 @@ export default defineComponent({
},
getAssistantMsg(content) {
const markedContent = quickcommand.markdownParse(content.trim());
const processedContent = markedContent
.replace("<p><think>", "<think><p>")
.replace("</think></p>", "</p></think>")
.replace("<think>\n\n</think>", "");
const purifiedContent = DOMPurify.sanitize(processedContent, {
ADD_TAGS: ["think"],
});
return purifiedContent;
return window.aiResponseParser(content);
},
getUserMsg(content) {

View File

@@ -56,7 +56,6 @@
import CommandTypeTag from "../CommandTypeTag.vue";
import platformTypes from "js/options/platformTypes.js";
import programs from "js/options/programs.js";
import DOMPurify from "dompurify";
export default {
name: "DenseLayout",
@@ -90,7 +89,7 @@ export default {
},
methods: {
purify(content) {
return DOMPurify.sanitize(content);
return window.DOMPurify.sanitize(content);
},
},
};

View File

@@ -51,7 +51,6 @@
import CommandTypeTag from "../CommandTypeTag.vue";
import platformTypes from "js/options/platformTypes.js";
import programs from "js/options/programs.js";
import DOMPurify from "dompurify";
export default {
name: "ListLayout",
@@ -82,7 +81,7 @@ export default {
},
methods: {
purify(content) {
return DOMPurify.sanitize(content);
return window.DOMPurify.sanitize(content);
},
},
};

View File

@@ -35,7 +35,6 @@
<script>
import CommandTypeTag from "../CommandTypeTag.vue";
import platformTypes from "js/options/platformTypes.js";
import DOMPurify from "dompurify";
export default {
name: "MiniLayout",
@@ -52,7 +51,7 @@ export default {
},
methods: {
purify(content) {
return DOMPurify.sanitize(content);
return window.DOMPurify.sanitize(content);
},
},
};

View File

@@ -11,7 +11,7 @@
</q-card-section>
<q-card-section
v-if="options.isHtml"
v-html="options.message"
v-html="purify(options.message)"
class="content"
/>
<q-card-section v-else v-text="options.message" class="content" />
@@ -32,6 +32,9 @@ export default {
this.$emit("clickOK", true);
this.hide();
},
purify(html) {
return window.DOMPurify.sanitize(html);
},
},
props: {
options: Object,

View File

@@ -85,3 +85,8 @@
color: #007bff;
text-decoration: none;
}
.markdown hr {
border-style: solid;
border-width: 0.5px;
}