diff --git a/resources/assets/src/components/mixins/setAsAvatar.js b/resources/assets/src/components/mixins/setAsAvatar.js new file mode 100644 index 00000000..1b13ae05 --- /dev/null +++ b/resources/assets/src/components/mixins/setAsAvatar.js @@ -0,0 +1,33 @@ +import toastr from 'toastr' +import { swal } from '../../js/notify' + +export default { + methods: { + async setAsAvatar() { + const { dismiss } = await swal({ + title: this.$t('user.setAvatar'), + text: this.$t('user.setAvatarNotice'), + type: 'question', + showCancelButton: true, + }) + if (dismiss) { + return + } + + const { errno, msg } = await this.$http.post( + '/user/profile/avatar', + { tid: this.tid } + ) + if (errno === 0) { + toastr.success(msg) + + $('[alt="User Image"]').each(function it() { + // eslint-disable-next-line no-invalid-this + $(this).prop('src', `${$(this).attr('src')}?${new Date().getTime()}`) + }) + } else { + toastr.warning(msg) + } + }, + }, +} diff --git a/resources/assets/src/components/skinlib/Show.vue b/resources/assets/src/components/skinlib/Show.vue index c73a2d0c..f6ce5a42 100644 --- a/resources/assets/src/components/skinlib/Show.vue +++ b/resources/assets/src/components/skinlib/Show.vue @@ -19,23 +19,26 @@ v-if="liked" v-t="'skinlib.apply'" :href="`${baseUrl}/user/closet?tid=${tid}`" - class="btn btn-success pull-right" - style="margin-left: 12px" + class="btn btn-success pull-right pulled-right-btn" /> +