This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

优化layer组件的回收,避免在极端场景下的异常;更新meditor附件管理机制

old
宇天 2018-05-19 13:15:48 +08:00
parent fead12b0d2
commit 99b95e67e1
3 changed files with 42 additions and 31 deletions

View File

@ -58,11 +58,16 @@ const close = function(id) {
layerDom[id][1].classList.add('shift') layerDom[id][1].classList.add('shift')
layerDom[id][0].style.opacity = '' layerDom[id][0].style.opacity = ''
layerDom[id][1].style.opacity = 0 layerDom[id][1].style.opacity = 0
setTimeout(_ => { setTimeout(
document.body.removeChild(layerDom[id][0]) (_ => {
delete layerDom[id] return function() {
delete Anot.vmodels[id] document.body.removeChild(layerDom[_][0])
}, 200) delete layerDom[_]
delete Anot.vmodels[_]
}
})(id),
200
)
} catch (err) {} } catch (err) {}
} }
document.body.style.overflow = '' document.body.style.overflow = ''

View File

@ -209,7 +209,7 @@ const fixCont = function(vm, tool) {
</ul> </ul>
</div> </div>
<ul class="manager" :visible="tab === 3"> <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> <span class="thumb" :html="el.thumb"></span>
<p class="name" :attr-title="el.name" :text="el.name"></p> <p class="name" :attr-title="el.name" :text="el.name"></p>
</li> </li>
@ -359,25 +359,32 @@ function showDialog(elem, vm, tool) {
attachAlt: '', attachAlt: '',
uploadQueue: [], //当前上传的列表 uploadQueue: [], //当前上传的列表
attachList: [], //附件管理列表 attachList: [], //附件管理列表
switchTab: function(id) { switchTab(id) {
this.tab = id this.tab = id
if (id === 3) { if (id === 3) {
this.attachList.clear() this.attachList.clear()
if (cache[tool].length) { if (vm.props.getAttachList) {
this.attachList = cache[tool] vm.props
} else { .getAttachList(tool)
getAttach(vm, function(json) { .then(list => {
if (json) { list.forEach(it => {
cache[tool] = json.data.list.map(function(it) { let ext = it.name.slice(it.name.lastIndexOf('.'))
it.thumb = it.isImage = /^\.(jpg|jpeg|png|gif|bmp|webp|ico)$/.test(ext)
tool === 'image' it.thumb = it.isImage
? '<img src="' + it.url + '"/>' ? `<img src="${it.url}" />`
: '<em class="attach-icon">&#xe73e;</em>' : `<em class="do-icon-txt"></em>`
return it
}) })
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) vm.insert(val)
this.close() this.close()
}, },
content: fixCont(vm, tool) content: fixCont(vm, tool)
}) })
} }

View File

@ -65,16 +65,16 @@
.red {color:#f30;} .red {color:#f30;}
} }
.manager {overflow:hidden;overflow-y:auto;width:100%;height:255px;padding:10px;
.item {float:left;width:22%;height:130px;margin:10px 1.5%;padding:5px;
&:hover {background:#f7f7f7;}
.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;} .thumb {display:block;width:100%;height:100px;}
.manager .item:hover {background:#f7f7f7;} .name {overflow:hidden;height:20px;line-height:30px; text-align:center;}
.manager .thumb {display:block;width:100%;height:100px;} img {width:100%;height:100%;}
.manager .name {overflow:hidden;height:20px;line-height:30px; text-align:center;} em {line-height:100px;font-size:50px;}
.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;}
} }
} }