Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaotoday committed Jul 23, 2018
1 parent fb1dd28 commit 87fc177
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/Uploader/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:on-exceeded-size="handleMaxSize"
:before-upload="handleBeforeUpload"
:headers="headers"
action="//localhost:3002/apis/v1/files">
:action="`${consts.API_URL}/files`">
<Button type="ghost" icon="ios-cloud-upload-outline">上传文件</Button>
</Upload>
<Modal title="查看图片" v-model="visible">
Expand All @@ -32,11 +32,14 @@
</div>
</template>
<script>
import consts from '@/utils/consts'
import helpers from '@/utils/helpers/base'
import restHelpers from '@/utils/helpers/restHelpers'
export default {
data () {
return {
consts,
defaultList: [],
imgURL: '',
visible: false,
Expand Down Expand Up @@ -68,8 +71,8 @@
this.$emit('on-change', null)
},
handleSuccess (res, file) {
file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar'
file.name = ''
file.url = helpers.getImageURL(res.data)
file.name = res.data.title
if (this.uploadList.length > 1) {
this._remove(this.uploadList[0])
Expand Down
10 changes: 10 additions & 0 deletions src/utils/helpers/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import consts from '@/utils/consts'

export default {
/**
* 获取图片地址
*/
getImageURL (data) {
return `${consts.BASE_URL}/files/${data.dir}/${data.uuid}.${data.ext}`
}
}

0 comments on commit 87fc177

Please sign in to comment.