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

7
src/views/user/Profile.vue

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