Skip to content

Commit 80f1c08

Browse files
authored
Merge pull request #216 from People-Sea/fix/#213
fix(ma-editor): 修复同一时刻渲染多富文本无效
2 parents d891914 + dcf0449 commit 80f1c08

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/ma-editor/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const appStore = useAppStore()
6868
const props = defineProps({
6969
modelValue: {type: String},
7070
height: {type: Number, default: 400},
71-
id: {type: String, default: () => 'tinymce' + new Date().getTime().toString()},
71+
id: {type: String, default: () => tool.uuid()},
7272
plugins: {
7373
type: [String, Array],
7474
default:
@@ -132,7 +132,7 @@ const getStoreMode = (mode) => {
132132
return uploadConfig.storageMode[mode.toString()]
133133
}
134134

135-
const editorKey = ref(new Date().getTime())
135+
const editorKey = props.id
136136

137137
watch(
138138
() => list.value,

src/utils/tool.js

+12
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,16 @@ tool.arrSum = (arr) => {
359359
return sum
360360
}
361361

362+
tool.uuid = () => {
363+
const randomBytes = CryptoJS.lib.WordArray.random(16);
364+
const randomHex = randomBytes.toString(CryptoJS.enc.Hex);
365+
return [
366+
randomHex.substr(0, 8),
367+
randomHex.substr(8, 4),
368+
randomHex.substr(12, 4),
369+
randomHex.substr(16, 4),
370+
randomHex.substr(20, 12)
371+
].join('-');
372+
}
373+
362374
export default tool

0 commit comments

Comments
 (0)