|
@@ -27,6 +27,8 @@ export const dialogResizeImg = {
|
|
|
const dragDom: any = document.querySelector('.' + binding.value)
|
|
|
const dialogHeaderEl = dragDom.querySelector('.el-dialog__header')
|
|
|
const img = dragDom.querySelector('.small-img')
|
|
|
+ let imgError = false
|
|
|
+ const resizeEl = document.createElement('div')
|
|
|
|
|
|
if (!img.src) {
|
|
|
dragDom.style.width = minWidth + 'px'
|
|
@@ -50,6 +52,9 @@ export const dialogResizeImg = {
|
|
|
}
|
|
|
img.onerror = function () {
|
|
|
dragDom.style.width = minWidth + 'px'
|
|
|
+ dragDom.style.height = minWidth + 'px'
|
|
|
+ imgError = true
|
|
|
+ resizeEl.style.display = 'none'
|
|
|
}
|
|
|
|
|
|
// console.log('img', getComputedStyle(img).width)
|
|
@@ -60,7 +65,7 @@ export const dialogResizeImg = {
|
|
|
// dragDom.style.overflow = 'auto'
|
|
|
dragDom.style.background = '#fff'
|
|
|
|
|
|
- if (keyboardPositions) {
|
|
|
+ if (keyboardPositions && !!img.src) {
|
|
|
dragDom.style.left = JSON.parse(keyboardPositions).left || 0
|
|
|
dragDom.style.top = JSON.parse(keyboardPositions).top || 0
|
|
|
}
|
|
@@ -130,16 +135,20 @@ export const dialogResizeImg = {
|
|
|
document.onmousemove = null
|
|
|
document.onmouseup = null
|
|
|
console.log('dragDom.style.left:', dragDom.style.left, dragDom.style.top)
|
|
|
- localStorage.setItem(
|
|
|
- localKeyMap.positions[bValue],
|
|
|
- JSON.stringify({
|
|
|
- left: dragDom.style.left || 0,
|
|
|
- top: dragDom.style.top || 0,
|
|
|
- })
|
|
|
- )
|
|
|
+ if (!imgError) {
|
|
|
+ localStorage.setItem(
|
|
|
+ localKeyMap.positions[bValue],
|
|
|
+ JSON.stringify({
|
|
|
+ left: dragDom.style.left || 0,
|
|
|
+ top: dragDom.style.top || 0,
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- dialogHeaderEl.onmousedown = moveDown
|
|
|
+ if (!!img.src) {
|
|
|
+ dialogHeaderEl.onmousedown = moveDown
|
|
|
+ }
|
|
|
// const bodyHeight = 'auto'
|
|
|
|
|
|
// function setMaxMin() {
|
|
@@ -193,7 +202,6 @@ export const dialogResizeImg = {
|
|
|
// 双击头部效果
|
|
|
// dialogHeaderEl.ondblclick = setMaxMin
|
|
|
// 拉伸
|
|
|
- const resizeEl = document.createElement('div')
|
|
|
dragDom.appendChild(resizeEl)
|
|
|
// 在弹窗右下角加上一个10-10px的控制块
|
|
|
resizeEl.style.cursor = 'se-resize'
|
|
@@ -265,13 +273,16 @@ export const dialogResizeImg = {
|
|
|
document.onmouseup = function (e) {
|
|
|
document.onmousemove = null
|
|
|
document.onmouseup = null
|
|
|
- localStorage.setItem(
|
|
|
- localKeyMap.resize[bValue],
|
|
|
- JSON.stringify({
|
|
|
- width: dragDom.style.width || 'auto',
|
|
|
- height: dragDom.style.height || 'auto',
|
|
|
- })
|
|
|
- )
|
|
|
+ if (!imgError) {
|
|
|
+ localStorage.setItem(
|
|
|
+ localKeyMap.resize[bValue],
|
|
|
+ JSON.stringify({
|
|
|
+ width: dragDom.style.width || 'auto',
|
|
|
+ height: dragDom.style.height || 'auto',
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
el.dispatchEvent(resizeEvent)
|
|
|
}
|
|
|
}
|