Browse Source

fix: post list showing the number of post in the tags (#650)

master
恪晨 2 years ago committed by GitHub
parent
commit
84c88825a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      package.json
  2. 5
      src/components/Post/PostTag.vue
  3. 40
      src/views/user/Profile.vue

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "halo-admin", "name": "halo-admin",
"version": "1.6.0-SNAPSHOT", "version": "1.6.0",
"author": "halo-dev", "author": "halo-dev",
"description": "Halo admin client.", "description": "Halo admin client.",
"repository": { "repository": {

5
src/components/Post/PostTag.vue

@ -1,5 +1,8 @@
<template> <template>
<a-tag :color="tag.color" :style="{ color: labelColor }"> {{ tag.name }}({{ tag.postCount }})</a-tag> <a-tag :color="tag.color" :style="{ color: labelColor }">
{{ tag.name }}
<span v-if="tag.postCount !== undefined">({{ tag.postCount }})</span>
</a-tag>
</template> </template>
<script> <script>
import { isHex, isLight } from '@/utils/colorUtil' import { isHex, isLight } from '@/utils/colorUtil'

40
src/views/user/Profile.vue

@ -255,7 +255,16 @@
</a-form> </a-form>
<template #footer> <template #footer>
<a-button type="primary" @click="handleUpdateAvatar">确定</a-button> <ReactiveButton
:errored="updateAvatarForm.errored"
:loading="updateAvatarForm.saving"
erroredText="保存失败"
loadedText="保存成功"
text="保存"
type="primary"
@callback="handleUpdateAvatarCallback"
@click="handleUpdateAvatar"
></ReactiveButton>
<a-button @click="updateAvatarForm.visible = false">关闭</a-button> <a-button @click="updateAvatarForm.visible = false">关闭</a-button>
</template> </template>
</a-modal> </a-modal>
@ -521,20 +530,27 @@ export default {
}) })
}, },
async handleUpdateAvatar() { async handleUpdateAvatar() {
const { updateAvatarData } = await apiClient.user.getProfile() const { data: userToUpdate } = await apiClient.user.getProfile()
updateAvatarData.avatar = this.updateAvatarForm.avatar userToUpdate.avatar = this.updateAvatarForm.avatar
this.updateAvatarForm.saving = true
apiClient.user apiClient.user
.updateProfile(updateAvatarData) .updateProfile(userToUpdate)
.then(response => {
this.$message.success('更新头像成功!')
this.updateAvatarForm.visible = false
this.userForm.model.avatar = response.data.avatar
this.setUser(Object.assign({}, this.userForm.model))
})
.catch(() => { .catch(() => {
this.$message.error('更新头像失败!') this.updateAvatarForm.saveErrored = true
this.updateAvatarForm.visible = true
}) })
.finally(() => {
setTimeout(() => {
this.updateAvatarForm.saving = false
}, 400)
this.handleLoadStatistics()
})
},
handleUpdateAvatarCallback() {
if (this.updateAvatarForm.saveErrored) {
this.updateAvatarForm.saveErrored = false
return
}
this.updateAvatarForm.visible = false
} }
} }
} }

Loading…
Cancel
Save