|
@@ -500,9 +500,9 @@
|
|
v-html="
|
|
v-html="
|
|
chapInfoList[courseType].chapterInfo[0].taskJson[taskCount]
|
|
chapInfoList[courseType].chapterInfo[0].taskJson[taskCount]
|
|
.taskDetail
|
|
.taskDetail
|
|
- ? renderedFormula(chapInfoList[courseType].chapterInfo[0].taskJson[
|
|
|
|
|
|
+ ? renderedFormula2(chapInfoList[courseType].chapterInfo[0].taskJson[
|
|
taskCount
|
|
taskCount
|
|
- ].taskDetail)
|
|
|
|
|
|
+ ].taskDetail)
|
|
: '暂无描述'
|
|
: '暂无描述'
|
|
"
|
|
"
|
|
></div>
|
|
></div>
|
|
@@ -4425,7 +4425,7 @@
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
"
|
|
"
|
|
>
|
|
>
|
|
- {{ index + 1 + "、" }} <span v-html="renderedFormula(item.teststitle)"></span>
|
|
|
|
|
|
+ {{ index + 1 + "、" }} <span v-html="renderedFormula(item.teststitle)"></span>
|
|
</div>
|
|
</div>
|
|
</el-tooltip>
|
|
</el-tooltip>
|
|
</div>
|
|
</div>
|
|
@@ -9603,7 +9603,7 @@
|
|
>
|
|
>
|
|
(多选题)
|
|
(多选题)
|
|
</div>
|
|
</div>
|
|
- <div>题目:<span v-html="renderedFormula(testJson.testJson[index1].teststitle)"></span></div>
|
|
|
|
|
|
+ <div>题目:<span v-html="renderedFormula(testJson.testJson[index1].teststitle)"></span></div>
|
|
</div>
|
|
</div>
|
|
<img
|
|
<img
|
|
v-if="testJson.testJson[index1].img"
|
|
v-if="testJson.testJson[index1].img"
|
|
@@ -13108,7 +13108,7 @@ export default {
|
|
{
|
|
{
|
|
role: "user",
|
|
role: "user",
|
|
content:
|
|
content:
|
|
- `Role: 你是一名小学英语作文的老师,根据这篇文章的内容你去批改这篇文章,然后仅输出一篇纠错好的文章。文章:${t}`,
|
|
|
|
|
|
+ `Role: 你是一名小学英语作文的老师,根据这篇文章的内容你去批改这篇文章,然后仅输出一篇纠错好的文章。文章:${t}`,
|
|
},
|
|
},
|
|
],
|
|
],
|
|
uid: this.userid,
|
|
uid: this.userid,
|
|
@@ -18146,10 +18146,9 @@ export default {
|
|
this.IsFollow = res.data[0][0].follow == 1 ? false : true;
|
|
this.IsFollow = res.data[0][0].follow == 1 ? false : true;
|
|
if (!this.IsLookOpen) {
|
|
if (!this.IsLookOpen) {
|
|
this.setNavList();
|
|
this.setNavList();
|
|
- }
|
|
|
|
- // else {
|
|
|
|
|
|
+ }else {
|
|
this.getCourseState(1);
|
|
this.getCourseState(1);
|
|
- // }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
if ((this.IsFollow && this.tType == 2)) {
|
|
if ((this.IsFollow && this.tType == 2)) {
|
|
this.setContent2(false);
|
|
this.setContent2(false);
|
|
@@ -21506,44 +21505,68 @@ export default {
|
|
this.updateSplitScreenData(1);
|
|
this.updateSplitScreenData(1);
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
|
|
+ renderedFormula2() {
|
|
|
|
+ return function(val){
|
|
|
|
+ // 处理换行符和HTML实体
|
|
|
|
+ const normalized = val
|
|
|
|
+ .replace(/&/g, '&')
|
|
|
|
+ .replace(/<br\/?>/g, '\n');
|
|
|
|
+
|
|
|
|
+ // 匹配行内公式($...$)和块级公式($$...$$)
|
|
|
|
+ return normalized.replace(/(\${1,2})([^$]+)(\${1,2})/g, (_, delim, expr) => {
|
|
|
|
+ try {
|
|
|
|
+ return katex.renderToString(expr.trim(), {
|
|
|
|
+ displayMode: false,
|
|
|
|
+ throwOnError: false,
|
|
|
|
+ macros: {
|
|
|
|
+ '\\aligned': '\\begin{aligned}#1\\end{aligned}'
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.warn('KaTeX渲染失败:', e);
|
|
|
|
+ return `<span style="color:red">${expr}</span>`;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
renderedFormula() {
|
|
renderedFormula() {
|
|
return function(val){
|
|
return function(val){
|
|
try {
|
|
try {
|
|
- // 判断是否含有HTML标签,<tag ...>...</tag>
|
|
|
|
|
|
+ // 判断是否含有HTML标签,<tag ...>...</tag>
|
|
const hasTag = /<([a-zA-Z][\w\-]*)([^>]*)>([\s\S]*?)<\/\1>/g.test(val);
|
|
const hasTag = /<([a-zA-Z][\w\-]*)([^>]*)>([\s\S]*?)<\/\1>/g.test(val);
|
|
if (!hasTag) {
|
|
if (!hasTag) {
|
|
|
|
+ val = val.trim().replace(/[\u200B-\u200D\uFEFF]/g, '');
|
|
|
|
+
|
|
|
|
+ // 纯文本,整体渲染
|
|
|
|
+ try {
|
|
|
|
+ return katex.renderToString(val.trim(), {
|
|
|
|
+ throwOnError: false,
|
|
|
|
+ strict: false,
|
|
|
|
+ output: "htmlAndMathml"
|
|
|
|
+ });
|
|
|
|
+ } catch (e) {
|
|
|
|
+ return val; // 渲染失败原样输出
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 有标签,对每个标签内容渲染
|
|
|
|
+ return val.replace(
|
|
|
|
+ /<([a-zA-Z][\w\-]*)([^>]*)>([\s\S]*?)<\/\1>/g,
|
|
|
|
+ (match, tag, attrs, inner) => {
|
|
|
|
+ let html;
|
|
val = val.trim().replace(/[\u200B-\u200D\uFEFF]/g, '');
|
|
val = val.trim().replace(/[\u200B-\u200D\uFEFF]/g, '');
|
|
-
|
|
|
|
- // 纯文本,整体渲染
|
|
|
|
try {
|
|
try {
|
|
- return katex.renderToString(val.trim(), {
|
|
|
|
- throwOnError: false,
|
|
|
|
- strict: false,
|
|
|
|
- output: "htmlAndMathml"
|
|
|
|
|
|
+ html = katex.renderToString(inner.trim(), {
|
|
|
|
+ throwOnError: false,
|
|
|
|
+ strict: false,
|
|
|
|
+ output: "htmlAndMathml"
|
|
});
|
|
});
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- return val; // 渲染失败原样输出
|
|
|
|
|
|
+ html = inner;
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- // 有标签,对每个标签内容渲染
|
|
|
|
- return val.replace(
|
|
|
|
- /<([a-zA-Z][\w\-]*)([^>]*)>([\s\S]*?)<\/\1>/g,
|
|
|
|
- (match, tag, attrs, inner) => {
|
|
|
|
- let html;
|
|
|
|
- val = val.trim().replace(/[\u200B-\u200D\uFEFF]/g, '');
|
|
|
|
- try {
|
|
|
|
- html = katex.renderToString(inner.trim(), {
|
|
|
|
- throwOnError: false,
|
|
|
|
- strict: false,
|
|
|
|
- output: "htmlAndMathml"
|
|
|
|
- });
|
|
|
|
- } catch (e) {
|
|
|
|
- html = inner;
|
|
|
|
- }
|
|
|
|
- return `<${tag}${attrs}>${html}</${tag}>`;
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
+ return `<${tag}${attrs}>${html}</${tag}>`;
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.error('KaTeX渲染错误:', e);
|
|
console.error('KaTeX渲染错误:', e);
|
|
return val;
|
|
return val;
|
|
@@ -21559,7 +21582,7 @@ export default {
|
|
? c
|
|
? c
|
|
.replaceAll(/\r\n/g, "<br/>")
|
|
.replaceAll(/\r\n/g, "<br/>")
|
|
.replaceAll(/\n/g, "<br/>")
|
|
.replaceAll(/\n/g, "<br/>")
|
|
- .replaceAll(/\s/g, "  ")
|
|
|
|
|
|
+ .replaceAll(/\s/g, " ")
|
|
: "";
|
|
: "";
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -26194,7 +26217,6 @@ div::-webkit-scrollbar {
|
|
}
|
|
}
|
|
.pb_content >>> .katex {
|
|
.pb_content >>> .katex {
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
- display: block;
|
|
|
|
width: 100%;
|
|
width: 100%;
|
|
white-space: normal;
|
|
white-space: normal;
|
|
}
|
|
}
|