mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +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)) {
|
if ($A.isJson(data)) {
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'text':
|
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':
|
case 'word-chain':
|
||||||
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
|
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
|
||||||
case 'vote':
|
case 'vote':
|
||||||
|
|||||||
@ -326,6 +326,7 @@ import ApproveExport from "./manage/components/ApproveExport";
|
|||||||
import notificationKoro from "notification-koro1";
|
import notificationKoro from "notification-koro1";
|
||||||
import {Store} from "le5le-store";
|
import {Store} from "le5le-store";
|
||||||
import MicroApps from "../components/MicroApps.vue";
|
import MicroApps from "../components/MicroApps.vue";
|
||||||
|
import {MarkdownPreview} from "../store/markdown";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -986,7 +987,7 @@ export default {
|
|||||||
let body;
|
let body;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'text':
|
case 'text':
|
||||||
body = $A.getMsgTextPreview(msg.text)
|
body = $A.getMsgTextPreview(msg.type === 'md' ? MarkdownPreview(msg.text) : msg.text)
|
||||||
break;
|
break;
|
||||||
case 'file':
|
case 'file':
|
||||||
body = '[' + this.$L(msg.type == 'img' ? '图片信息' : '文件信息') + ']'
|
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 = {
|
const MarkdownUtils = {
|
||||||
mdi: null,
|
mdi: null,
|
||||||
|
mds: null,
|
||||||
formatMsg: (text) => {
|
formatMsg: (text) => {
|
||||||
const array = text.match(/<img\s+[^>]*?>/g);
|
const array = text.match(/<img\s+[^>]*?>/g);
|
||||||
if (array) {
|
if (array) {
|
||||||
@ -43,3 +44,10 @@ export function MarkdownConver(text) {
|
|||||||
}
|
}
|
||||||
return MarkdownUtils.formatMsg(MarkdownUtils.mdi.render(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