Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@


VUE_APP_BASE_URL = 'http://dev.lin.colorful3.com/'
VUE_APP_BASE_URL = ''http://koa.lin.colorful3.com/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"fastscan": "^1.0.4",
"good-storage": "^1.1.0",
"js-cookie": "^2.2.0",
"lodash": "^4.17.11",
"lodash": "^4.17.14",
"moment": "^2.24.0",
"photoswipe": "^4.1.2",
"screenfull": "^4.2.0",
Expand Down
19 changes: 13 additions & 6 deletions src/components/base/preview/preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<script>
// photoswipe接口文档 http://photoswipe.com/documentation/api.html

import { Loading } from 'element-ui'
import 'photoswipe/dist/photoswipe.css'
import 'photoswipe/dist/default-skin/default-skin.css'
import PhotoSwipe from 'photoswipe/dist/photoswipe'
Expand Down Expand Up @@ -124,6 +125,7 @@ export default {
options = Object.assign(defaultOptions, options, {
index: imageIndex,
})
const loadingInstance = Loading.service()
const galleryElement = this.$refs.myGallery
this.radom = createId();
let pswpElement = this.$refs.pswpWrap
Expand All @@ -144,6 +146,7 @@ export default {
}
this.gallery = new PhotoSwipe(pswpElement, PhotoSwipeUIDefault, items, photoSwipeOptions)
this.gallery.init()
loadingInstance.close()
// Gallery starts closing
this.gallery.listen('close', () => {
if (this.gallery) {
Expand Down Expand Up @@ -211,19 +214,23 @@ export default {
}
return items
},
destroy() {
// 销毁
if (this.gallery) {
this.gallery.close();
this.gallery = null
}
},
},
beforeDestroy() {
// 销毁
if (this.gallery) {
this.gallery.close();
this.gallery = null
}
this.destroy()
},
}
</script>

<style lang="css" scoped>
<style lang="scss" scoped>
.my-gallery {
opacity: 0;
display: none;
}
</style>
7 changes: 7 additions & 0 deletions src/components/layout/AppMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
<script>
export default {
name: 'AppMain',
watch: {
$route() {
if (this.$previewInstance) {
this.$previewInstance.destroy()
}
},
},
}
</script>

Expand Down
38 changes: 26 additions & 12 deletions src/lin/plugins/preview/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
import Vue from 'vue'
import Preview from '@/components/base/preview/preview'


const previewImage = {}
previewImage.install = (Vue, options = {}) => { // eslint-disable-line
const PreviewConstructor = Vue.extend(Preview)

let instance = null

// eslint-disable-next-line func-names
PreviewConstructor.prototype.close = function () {
this.data = []
this.options = {}
this.imageIndex = 0
}

const getInstance = () => {
if (!instance) {
instance = new PreviewConstructor()
}
return instance
}

Vue.prototype.$imagePreview = (opts = {}) => { // eslint-disable-line
const elem = document.createElement('div')
let instance = new PreviewConstructor()
instance.$mount(elem)
instance.data = opts.images || []
instance.imageIndex = opts.index || 0
instance.options = opts.defaultOpt || {}
document.body.appendChild(instance.$el)
instance.$on('close', () => {
instance.close()
document.body.removeChild(instance.$el)
instance.$destroy()
instance = null
})
if (!instance) {
let myInstance = getInstance()
Vue.prototype.$previewInstance = myInstance // eslint-disable-line
myInstance.$mount(elem)
myInstance.data = opts.images || []
myInstance.imageIndex = opts.index || 0
myInstance.options = opts.defaultOpt || {}
document.body.appendChild(myInstance.$el)
myInstance.$on('close', () => {
myInstance.close()
document.body.removeChild(myInstance.$el)
myInstance.$destroy()
myInstance = null
instance = null
})
}
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/plugins/custom/views/Gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div
class="img-box"
@click="preview(index)"
v-for="(url, index) in urls"
v-for="(url, index) in thumbs"
:key="index">
<el-image
class="thumb-item-img"
Expand Down Expand Up @@ -35,8 +35,13 @@ export default {
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/gallery3.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/gallery4.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/gallery5.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/gallery6.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/gallery7.jpg',
],
thumbs: [
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/thumb/gallery1.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/thumb/gallery2.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/thumb/gallery3.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/thumb/gallery4.jpg',
'https://consumerminiaclprd01.blob.core.chinacloudapi.cn/miniappbackground/sfgmember/lin/gallery/thumb/gallery5.jpg',
],
}
},
Expand Down