File tree Expand file tree Collapse file tree 1 file changed +29
-7
lines changed Expand file tree Collapse file tree 1 file changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -112,19 +112,28 @@ export default {
112
112
data () {
113
113
return {
114
114
openMessageId: {},
115
- hoverMessageId: null
115
+ hoverMessageId: null ,
116
+ imageLoading: false
117
+ }
118
+ },
119
+
120
+ watch: {
121
+ message: {
122
+ immediate: true ,
123
+ handler () {
124
+ this .checkImgLoad ()
125
+ }
116
126
}
117
127
},
118
128
119
129
computed: {
120
130
isImage () {
121
- if (! this .message .file ) return
122
- const imageTypes = [' png' , ' jpg' ]
123
- const { type } = this .message .file
124
- return imageTypes .some (t => type .includes (t))
131
+ return this .checkImageFile ()
125
132
},
126
133
isImageLoading () {
127
- return this .message .file .url .indexOf (' blob:http' ) !== - 1
134
+ return (
135
+ this .message .file .url .indexOf (' blob:http' ) !== - 1 || this .imageLoading
136
+ )
128
137
},
129
138
isEditable () {
130
139
return this .canEditMessage ()
@@ -174,6 +183,19 @@ export default {
174
183
},
175
184
openFile ({ url }) {
176
185
window .open (url, ' _blank' )
186
+ },
187
+ checkImageFile () {
188
+ if (! this .message .file ) return
189
+ const imageTypes = [' png' , ' jpg' ]
190
+ const { type } = this .message .file
191
+ return imageTypes .some (t => type .includes (t))
192
+ },
193
+ checkImgLoad () {
194
+ if (! this .checkImageFile ()) return
195
+ this .imageLoading = true
196
+ const image = new Image ()
197
+ image .src = this .message .file .url
198
+ image .addEventListener (' load' , () => (this .imageLoading = false ))
177
199
}
178
200
}
179
201
}
@@ -282,7 +304,7 @@ export default {
282
304
}
283
305
284
306
.image-loading {
285
- filter : blur (5 px );
307
+ filter : blur (3 px );
286
308
}
287
309
288
310
@keyframes slide-up {
You can’t perform that action at this time.
0 commit comments