top-nav-user-info.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <ul class="nav navbar-nav navbar-right">
  3. <li>
  4. <img :src="userImageSrc" class="user-profile-img" />
  5. </li>
  6. <li class="dropdown">
  7. <a
  8. href="#"
  9. class="dropdown-toggle"
  10. data-toggle="dropdown"
  11. role="button"
  12. aria-haspopup="true"
  13. aria-expanded="false"
  14. >
  15. {{ loginInfo != undefined ? loginInfo.userName : "" }}
  16. <span class="caret" />
  17. </a>
  18. <ul class="dropdown-menu">
  19. <li>
  20. <a @click="setUserParameters">{{
  21. $t("lang.top-nav-user-info.personalSettings")
  22. }}</a>
  23. </li>
  24. <li>
  25. <a @click="logout"><i class="fa fa-sign-out pull-right" />{{
  26. $t("lang.top-nav-user-info.cancellation")
  27. }}</a>
  28. </li>
  29. </ul>
  30. </li>
  31. </ul>
  32. </template>
  33. <script>
  34. import Common from '../common/Common.js';
  35. import AuthSettingResource from '../api/commom/AuthSettingResource.js';
  36. import store from '../store/index.js';
  37. export default {
  38. props: {
  39. loginInfo: {
  40. type: Object,
  41. default: function () {
  42. return null;
  43. },
  44. },
  45. },
  46. data: function () {
  47. this.Common = Common;
  48. return {};
  49. },
  50. computed: {
  51. userImageSrc: function () {
  52. if (this.loginInfo == null || this.loginInfo.userImageUrl == null) {
  53. return null;
  54. }
  55. return Common.getResourceUrl(
  56. 'image',
  57. 'com.leanwo.prodog.base.model.User',
  58. store.state.downloadStore.imageSrc,
  59. );
  60. },
  61. },
  62. mounted: function () {
  63. var _self = this;
  64. },
  65. methods: {
  66. setUserParameters: function () {
  67. this.$router.push('/desktop/userParameters');
  68. },
  69. logout: function () {
  70. Common.clearLocalStorage();
  71. //path为指定路径,直接删除该路径下的cookie
  72. // $.removeCookie('#accountId', { path: '/' });
  73. // $.removeCookie('token', { path: '/' });
  74. // bug fixed by jack
  75. // 清除掉/pcapp路径的cookie
  76. // $.removeCookie('#accountId', { path: '/pcapp' });
  77. // $.removeCookie('token', { path: '/pcapp' });
  78. this.$router.push('/login');
  79. // 这边存在问题,模块化以后,需要修复
  80. // AuthSettingResource.getAuthSettingDto().then(
  81. // successData => {
  82. // if (successData != null) {
  83. // var url =
  84. // 'http://jaccount.sjtu.edu.cn/oauth2/logout?client_id=' +
  85. // successData.jaccountClientId +
  86. // '&post_logout_redirect_uri=' +
  87. // Common.getRedirectUrl('#/login');
  88. // window.location.href = url;
  89. // } else {
  90. // this.$router.push('/login');
  91. // }
  92. // },
  93. // errorData => {
  94. // Common.processException(errorData);
  95. // },
  96. // );
  97. },
  98. },
  99. };
  100. </script>
  101. <style scoped>
  102. .user-profile-img {
  103. width: 29px;
  104. height: 29px;
  105. border-radius: 50%;
  106. margin-top: 10px;
  107. }
  108. </style>