mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 19:35:50 +00:00
perf: 优化预览消息
This commit is contained in:
parent
ccb31a81f8
commit
fbd662e400
4
resources/assets/js/functions/web.js
vendored
4
resources/assets/js/functions/web.js
vendored
@ -1,3 +1,5 @@
|
||||
import {MarkdownPreview} from "../store/markdown";
|
||||
|
||||
/**
|
||||
* 页面专用
|
||||
*/
|
||||
@ -819,7 +821,7 @@
|
||||
if ($A.isJson(data)) {
|
||||
switch (data.type) {
|
||||
case 'text':
|
||||
return $A.getMsgTextPreview(data.msg.text, imgClassName)
|
||||
return $A.getMsgTextPreview(data.msg.type === 'md' ? MarkdownPreview(data.msg.text) : data.msg.text, imgClassName)
|
||||
case 'word-chain':
|
||||
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
|
||||
case 'vote':
|
||||
|
||||
@ -326,6 +326,7 @@ import ApproveExport from "./manage/components/ApproveExport";
|
||||
import notificationKoro from "notification-koro1";
|
||||
import {Store} from "le5le-store";
|
||||
import MicroApps from "../components/MicroApps.vue";
|
||||
import {MarkdownPreview} from "../store/markdown";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -986,7 +987,7 @@ export default {
|
||||
let body;
|
||||
switch (type) {
|
||||
case 'text':
|
||||
body = $A.getMsgTextPreview(msg.text)
|
||||
body = $A.getMsgTextPreview(msg.type === 'md' ? MarkdownPreview(msg.text) : msg.text)
|
||||
break;
|
||||
case 'file':
|
||||
body = '[' + this.$L(msg.type == 'img' ? '图片信息' : '文件信息') + ']'
|
||||
|
||||
8
resources/assets/js/store/markdown.js
vendored
8
resources/assets/js/store/markdown.js
vendored
@ -8,6 +8,7 @@ import mdKatex from "@traptitech/markdown-it-katex";
|
||||
*/
|
||||
const MarkdownUtils = {
|
||||
mdi: null,
|
||||
mds: null,
|
||||
formatMsg: (text) => {
|
||||
const array = text.match(/<img\s+[^>]*?>/g);
|
||||
if (array) {
|
||||
@ -43,3 +44,10 @@ export function MarkdownConver(text) {
|
||||
}
|
||||
return MarkdownUtils.formatMsg(MarkdownUtils.mdi.render(text))
|
||||
}
|
||||
|
||||
export function MarkdownPreview(text) {
|
||||
if (MarkdownUtils.mds === null) {
|
||||
MarkdownUtils.mds = MarkdownIt()
|
||||
}
|
||||
return MarkdownUtils.mds.render(text)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user