链接图片加载
This commit is contained in:
@@ -127,7 +127,6 @@
|
||||
class="upload-demo"
|
||||
:action="uploadUrl"
|
||||
:show-file-list="false"
|
||||
:limit="1"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeAvatarUpload"
|
||||
>
|
||||
@@ -331,11 +330,11 @@ export default {
|
||||
const index = file.name.lastIndexOf('.')
|
||||
const ext = file.name.substr(index + 1)
|
||||
const isJPG = (file.type === 'image/jpeg' || file.type === 'image/png');
|
||||
const isType = (ext === 'jpeg' || ext === 'jpg' || ext === 'png')
|
||||
const isType = (ext === 'jpg' || ext === 'png')
|
||||
const isLt2M = file.size / 1024 / 1024 < 2;
|
||||
|
||||
if (!isJPG || !isType) {
|
||||
this.$message.error('上传头像图片只能是 .jpg、.jpeg、.png 格式!');
|
||||
this.$message.error('上传头像图片只能是 .jpg、.png 格式!');
|
||||
}
|
||||
if (!isLt2M) {
|
||||
this.$message.error('上传头像图片大小不能超过 2MB!');
|
||||
@@ -445,12 +444,16 @@ export default {
|
||||
_this: this,
|
||||
loading: 'Loading'
|
||||
}, res => {
|
||||
this.Loading = true
|
||||
this.linkList = res.data
|
||||
res.data.forEach(item => {
|
||||
if (item.type === 1) {
|
||||
this.linkListFirst.push(item)
|
||||
}
|
||||
})
|
||||
if (this.linkListFirst.length === 0) {
|
||||
this.Loading = false
|
||||
}
|
||||
this.linkListFirst.forEach(item => {
|
||||
if (item.icon !== '') {
|
||||
let imgId = {
|
||||
@@ -466,6 +469,7 @@ export default {
|
||||
)
|
||||
item.icon = src
|
||||
})
|
||||
this.Loading = false
|
||||
}
|
||||
})
|
||||
this.initSortable()
|
||||
|
||||
@@ -127,7 +127,6 @@
|
||||
class="avatar-uploader"
|
||||
:action="uploadUrl"
|
||||
:show-file-list="false"
|
||||
:limit="1"
|
||||
:on-success="handleAvatarSuccess"
|
||||
:before-upload="beforeAvatarUpload">
|
||||
<img v-if="imageUrl" :src="imageUrl" class="avatar">
|
||||
@@ -443,12 +442,16 @@ export default {
|
||||
_this: this,
|
||||
loading: 'Loading'
|
||||
}, res => {
|
||||
this.Loading = true
|
||||
this.linkList = res.data
|
||||
res.data.forEach(item => {
|
||||
if (item.type === 2) {
|
||||
this.linkListSecond.push(item)
|
||||
}
|
||||
})
|
||||
if (this.linkListSecond.length === 0) {
|
||||
this.Loading = false
|
||||
}
|
||||
this.linkListSecond.forEach(item => {
|
||||
if (item.icon !== '') {
|
||||
let imgId = {
|
||||
@@ -456,16 +459,15 @@ export default {
|
||||
}
|
||||
// 图片转base64
|
||||
getImg(imgId).then(res => {
|
||||
if (res.ok) {
|
||||
const src =
|
||||
"data:image/png;base64," +
|
||||
btoa(
|
||||
new Uint8Array(res).reduce(
|
||||
(data, byte) => data + String.fromCharCode(byte), "")
|
||||
)
|
||||
item.icon = src
|
||||
}
|
||||
const src =
|
||||
"data:image/png;base64," +
|
||||
btoa(
|
||||
new Uint8Array(res).reduce(
|
||||
(data, byte) => data + String.fromCharCode(byte), "")
|
||||
)
|
||||
item.icon = src
|
||||
})
|
||||
this.Loading = false
|
||||
}
|
||||
})
|
||||
this.initSortable()
|
||||
|
||||
Reference in New Issue
Block a user