UserTools.vue 1017 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template lang="html">
  2. <div id="user-tools">
  3. <h4
  4. class="mdi mdi-account"
  5. >{{ mail }}</h4>
  6. <a href="/admin/content/materials"
  7. v-if="isAdmin"
  8. class="mdi mdi-settings"
  9. title="admin"
  10. ></a>
  11. <a href="/user/logout"
  12. @click.prevent="onLogout()"
  13. class="mdi mdi-logout"
  14. title="logout"
  15. ></a>
  16. </div>
  17. </template>
  18. <script>
  19. import { mapState, mapActions } from 'vuex'
  20. export default {
  21. // data () {
  22. // return {
  23. // mail: "Hello User!"
  24. // }
  25. // },
  26. computed: {
  27. ...mapState({
  28. mail: state => state.User.mail,
  29. isAdmin: state => state.User.isAdmin
  30. })
  31. },
  32. methods: {
  33. ...mapActions({
  34. userLogout: 'User/userLogout'
  35. }),
  36. onLogout () {
  37. console.log('UserTools onLogout');
  38. this.userLogout()
  39. }
  40. }
  41. }
  42. </script>
  43. <style lang="css" scoped>
  44. #user-tools{
  45. margin-right:0.5em;
  46. padding-right:0.5em;
  47. border-right:1px solid #222;
  48. }
  49. h4{
  50. margin:0;
  51. display:inline-block;
  52. font-size:inherited;
  53. }
  54. </style>