Skip to content

Commit 87fc177

Browse files
committed
优化
1 parent fb1dd28 commit 87fc177

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/components/Uploader/index.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:on-exceeded-size="handleMaxSize"
1212
:before-upload="handleBeforeUpload"
1313
:headers="headers"
14-
action="//localhost:3002/apis/v1/files">
14+
:action="`${consts.API_URL}/files`">
1515
<Button type="ghost" icon="ios-cloud-upload-outline">上传文件</Button>
1616
</Upload>
1717
<Modal title="查看图片" v-model="visible">
@@ -32,11 +32,14 @@
3232
</div>
3333
</template>
3434
<script>
35+
import consts from '@/utils/consts'
36+
import helpers from '@/utils/helpers/base'
3537
import restHelpers from '@/utils/helpers/restHelpers'
3638
3739
export default {
3840
data () {
3941
return {
42+
consts,
4043
defaultList: [],
4144
imgURL: '',
4245
visible: false,
@@ -68,8 +71,8 @@
6871
this.$emit('on-change', null)
6972
},
7073
handleSuccess (res, file) {
71-
file.url = 'https://o5wwk8baw.qnssl.com/7eb99afb9d5f317c912f08b5212fd69a/avatar'
72-
file.name = ''
74+
file.url = helpers.getImageURL(res.data)
75+
file.name = res.data.title
7376
7477
if (this.uploadList.length > 1) {
7578
this._remove(this.uploadList[0])

src/utils/helpers/base.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import consts from '@/utils/consts'
2+
3+
export default {
4+
/**
5+
* 获取图片地址
6+
*/
7+
getImageURL (data) {
8+
return `${consts.BASE_URL}/files/${data.dir}/${data.uuid}.${data.ext}`
9+
}
10+
}

0 commit comments

Comments
 (0)