Browse Source

Support select gravatar.

pull/34/head
ruibaby 5 years ago
parent
commit
ed5af44840
  1. 16
      src/views/attachment/components/AttachmentSelectDrawer.vue
  2. 7
      src/views/user/Profile.vue

16
src/views/attachment/components/AttachmentSelectDrawer.vue

@ -47,8 +47,14 @@
@change="handlePaginationChange"
></a-pagination>
</div>
<a-divider class="divider-transparent"/>
<a-divider class="divider-transparent" />
<div class="bottom-control">
<a-button
type="dashed"
style="marginRight: 8px"
v-if="isChooseAvatar"
@click="handleSelectGravatar"
>使用 Gravatar</a-button>
<a-button
@click="handleShowUploadModal"
type="primary"
@ -103,6 +109,11 @@ export default {
type: String,
required: false,
default: '选择附件'
},
isChooseAvatar: {
type: Boolean,
required: false,
default: false
}
},
data() {
@ -150,6 +161,9 @@ export default {
handleSelectAttachment(item) {
this.$emit('listenToSelect', item)
},
handleSelectGravatar() {
this.$emit('listenToSelectGravatar')
},
handlePaginationChange(page, pageSize) {
this.pagination.page = page
this.pagination.size = pageSize

7
src/views/user/Profile.vue

@ -138,7 +138,9 @@
<AttachmentSelectDrawer
v-model="attachmentDrawerVisible"
@listenToSelect="handleSelectAvatar"
@listenToSelectGravatar="handleSelectGravatar"
title="选择头像"
isChooseAvatar
/>
</div>
</template>
@ -149,6 +151,7 @@ import userApi from '@/api/user'
import adminApi from '@/api/admin'
import optionApi from '@/api/option'
import { mapMutations } from 'vuex'
import MD5 from 'md5.js'
export default {
components: {
@ -217,6 +220,10 @@ export default {
handleSelectAvatar(data) {
this.user.avatar = data.path
this.attachmentDrawerVisible = false
},
handleSelectGravatar() {
this.user.avatar = '//cn.gravatar.com/avatar/' + new MD5().update(this.user.email).digest('hex') + '&d=mm'
this.attachmentDrawerVisible = false
}
}
}

Loading…
Cancel
Save