Commit 7d501f37c9667bc797f6198bafddd96689b08a7b
1 parent
2e6cd487
image-gallery: update previewURL to url
Showing
4 changed files
with
26 additions
and
10 deletions
front-end/h5/src/components/core/support/image-gallery/components/image-item.js
front-end/h5/src/components/core/support/image-gallery/gallery.js
| ... | ... | @@ -50,7 +50,7 @@ export default { |
| 50 | 50 | }, |
| 51 | 51 | handleSelectImage (item) { |
| 52 | 52 | this.handleClose() |
| 53 | - this.$emit('change', item.previewURL) | |
| 53 | + this.$emit('change', item.url) | |
| 54 | 54 | }, |
| 55 | 55 | renderContent () { |
| 56 | 56 | switch (this.activeTab) { |
| ... | ... | @@ -79,12 +79,12 @@ export default { |
| 79 | 79 | <div class="default-activator cursor-pointer "><img src={this.value} width="50%" style={{ margin: 'auto' }} /></div> |
| 80 | 80 | <div class="flex-space-between" style="margin-top: 8px;"> |
| 81 | 81 | <a-button size="small">更换</a-button> |
| 82 | - <a-button size="small" onClick={e => { | |
| 82 | + {/* <a-button size="small" onClick={e => { | |
| 83 | 83 | e.stopPropagation() |
| 84 | - }}>裁剪</a-button> | |
| 84 | + }}>裁剪</a-button> */} | |
| 85 | 85 | <a-button size="small" onClick={(e) => { |
| 86 | 86 | e.stopPropagation() |
| 87 | - this.handleSelectImage({ previewURL: '' }) | |
| 87 | + this.handleSelectImage({ url: '' }) | |
| 88 | 88 | }}>移除</a-button> |
| 89 | 89 | </div> |
| 90 | 90 | </div> | ... | ... |
front-end/h5/src/components/core/support/image-gallery/tabs/personal.js
| ... | ... | @@ -11,7 +11,7 @@ export default { |
| 11 | 11 | methods: { |
| 12 | 12 | uploadSuccess ({ file, fileList }) { |
| 13 | 13 | const response = file.response.length && file.response[0] |
| 14 | - this.items = [{ name: response.name, previewURL: response.url.replace('http://localhost:1337', '') }, ...this.cachedItems] | |
| 14 | + this.items = [{ name: response.name, url: response.url.replace('http://localhost:1337', '') }, ...this.cachedItems] | |
| 15 | 15 | }, |
| 16 | 16 | beforeUpload (file) { |
| 17 | 17 | this.items.unshift({ |
| ... | ... | @@ -51,10 +51,16 @@ export default { |
| 51 | 51 | mounted () { |
| 52 | 52 | // demo code |
| 53 | 53 | axios |
| 54 | - .get('https://pixabay.com/api/?key=12120348-2ad26e4cc05d9bc068097ab3b&q=yellow+flowers&image_type=photo&pretty=true') | |
| 54 | + .get('/upload/files', { | |
| 55 | + params: { | |
| 56 | + '_limit': 10, | |
| 57 | + '_start': 0, | |
| 58 | + mime: 'image/png' | |
| 59 | + } | |
| 60 | + }) | |
| 55 | 61 | .then(res => { |
| 56 | - this.items = res.data.hits | |
| 57 | - this.cachedItems = res.data.hits.slice(0) | |
| 62 | + this.items = res.data | |
| 63 | + this.cachedItems = [] | |
| 58 | 64 | }) |
| 59 | 65 | } |
| 60 | 66 | } | ... | ... |
front-end/h5/src/components/core/support/image-gallery/tabs/pixabay.js
| 1 | +/* | |
| 2 | + * @Author: ly525 | |
| 3 | + * @Date: 2019-12-01 18:11:50 | |
| 4 | + * @LastEditors: ly525 | |
| 5 | + * @LastEditTime: 2020-01-13 00:48:13 | |
| 6 | + * @FilePath: /luban-h5/front-end/h5/src/components/core/support/image-gallery/tabs/pixabay.js | |
| 7 | + * @Github: https://github.com/ly525/luban-h5 | |
| 8 | + * @Description: Do not edit | |
| 9 | + * @Copyright 2018 - 2019 luban-h5. All Rights Reserved | |
| 10 | + */ | |
| 1 | 11 | import axios from 'axios' |
| 2 | 12 | import ImageItem from '../components/image-item.js' |
| 3 | 13 | |
| ... | ... | @@ -23,7 +33,7 @@ export default { |
| 23 | 33 | axios |
| 24 | 34 | .get('https://pixabay.com/api/', { params: this.options }) |
| 25 | 35 | .then(res => { |
| 26 | - this.items = res.data.hits | |
| 36 | + this.items = res.data.hits.map(item => ({ ...item, url: item.previewURL })) | |
| 27 | 37 | }) |
| 28 | 38 | } |
| 29 | 39 | }, | ... | ... |