优化layer组件的回收,避免在极端场景下的异常;更新meditor附件管理机制
parent
fead12b0d2
commit
99b95e67e1
|
@ -58,11 +58,16 @@ const close = function(id) {
|
|||
layerDom[id][1].classList.add('shift')
|
||||
layerDom[id][0].style.opacity = ''
|
||||
layerDom[id][1].style.opacity = 0
|
||||
setTimeout(_ => {
|
||||
document.body.removeChild(layerDom[id][0])
|
||||
delete layerDom[id]
|
||||
delete Anot.vmodels[id]
|
||||
}, 200)
|
||||
setTimeout(
|
||||
(_ => {
|
||||
return function() {
|
||||
document.body.removeChild(layerDom[_][0])
|
||||
delete layerDom[_]
|
||||
delete Anot.vmodels[_]
|
||||
}
|
||||
})(id),
|
||||
200
|
||||
)
|
||||
} catch (err) {}
|
||||
}
|
||||
document.body.style.overflow = ''
|
||||
|
|
|
@ -209,7 +209,7 @@ const fixCont = function(vm, tool) {
|
|||
</ul>
|
||||
</div>
|
||||
<ul class="manager" :visible="tab === 3">
|
||||
<li class="item" :repeat="attachList" :click="$insert(el)">
|
||||
<li class="item" :repeat="attachList" :click="insert(el)">
|
||||
<span class="thumb" :html="el.thumb"></span>
|
||||
<p class="name" :attr-title="el.name" :text="el.name"></p>
|
||||
</li>
|
||||
|
@ -359,25 +359,32 @@ function showDialog(elem, vm, tool) {
|
|||
attachAlt: '',
|
||||
uploadQueue: [], //当前上传的列表
|
||||
attachList: [], //附件管理列表
|
||||
switchTab: function(id) {
|
||||
switchTab(id) {
|
||||
this.tab = id
|
||||
if (id === 3) {
|
||||
this.attachList.clear()
|
||||
if (cache[tool].length) {
|
||||
this.attachList = cache[tool]
|
||||
} else {
|
||||
getAttach(vm, function(json) {
|
||||
if (json) {
|
||||
cache[tool] = json.data.list.map(function(it) {
|
||||
it.thumb =
|
||||
tool === 'image'
|
||||
? '<img src="' + it.url + '"/>'
|
||||
: '<em class="attach-icon"></em>'
|
||||
return it
|
||||
if (vm.props.getAttachList) {
|
||||
vm.props
|
||||
.getAttachList(tool)
|
||||
.then(list => {
|
||||
list.forEach(it => {
|
||||
let ext = it.name.slice(it.name.lastIndexOf('.'))
|
||||
it.isImage = /^\.(jpg|jpeg|png|gif|bmp|webp|ico)$/.test(ext)
|
||||
it.thumb = it.isImage
|
||||
? `<img src="${it.url}" />`
|
||||
: `<em class="do-icon-txt"></em>`
|
||||
})
|
||||
this.attachList = json.data.list
|
||||
}
|
||||
})
|
||||
return list
|
||||
})
|
||||
.then(list => {
|
||||
list = list.filter(it => {
|
||||
if (tool === 'image') {
|
||||
return it.isImage
|
||||
}
|
||||
return true
|
||||
})
|
||||
this.attachList = list
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -408,7 +415,6 @@ function showDialog(elem, vm, tool) {
|
|||
vm.insert(val)
|
||||
this.close()
|
||||
},
|
||||
|
||||
content: fixCont(vm, tool)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -65,16 +65,16 @@
|
|||
.red {color:#f30;}
|
||||
}
|
||||
|
||||
.manager {overflow:hidden;overflow-y:auto;width:100%;height:255px;padding:10px;
|
||||
|
||||
|
||||
|
||||
.manager {overflow:hidden;overflow-y:auto;width:100%;height:320px;padding:10px;}
|
||||
.manager .item {float:left;width:22%;height:130px;margin:10px 1.5%;padding:5px;}
|
||||
.manager .item:hover {background:#f7f7f7;}
|
||||
.manager .thumb {display:block;width:100%;height:100px;}
|
||||
.manager .name {overflow:hidden;height:20px;line-height:30px; text-align:center;}
|
||||
.manager img {width:100%;height:100%;}
|
||||
.manager .attach-icon {display:inline-block;width:100%;height:100px;text-align:center;font:50px/100px "ui font" !important;-webkit-font-smoothing: antialiased;-webkit-text-stroke-width: 0.2px;-moz-osx-font-smoothing: grayscale;}
|
||||
.item {float:left;width:22%;height:130px;margin:10px 1.5%;padding:5px;
|
||||
&:hover {background:#f7f7f7;}
|
||||
}
|
||||
.thumb {display:block;width:100%;height:100px;}
|
||||
.name {overflow:hidden;height:20px;line-height:30px; text-align:center;}
|
||||
img {width:100%;height:100%;}
|
||||
em {line-height:100px;font-size:50px;}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue