| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <template>
- <ul class="nav navbar-nav navbar-right">
- <li>
- <img :src="userImageSrc" class="user-profile-img" />
- </li>
- <li class="dropdown">
- <a
- href="#"
- class="dropdown-toggle"
- data-toggle="dropdown"
- role="button"
- aria-haspopup="true"
- aria-expanded="false"
- >
- {{ loginInfo != undefined ? loginInfo.userName : "" }}
- <span class="caret" />
- </a>
- <ul class="dropdown-menu">
- <li>
- <a @click="setUserParameters">{{
- $t("lang.top-nav-user-info.personalSettings")
- }}</a>
- </li>
- <li>
- <a @click="logout"><i class="fa fa-sign-out pull-right" />{{
- $t("lang.top-nav-user-info.cancellation")
- }}</a>
- </li>
- </ul>
- </li>
- </ul>
- </template>
- <script>
- import Common from '../common/Common.js';
- import AuthSettingResource from '../api/commom/AuthSettingResource.js';
- import store from '../store/index.js';
- export default {
- props: {
- loginInfo: {
- type: Object,
- default: function () {
- return null;
- },
- },
- },
- data: function () {
- this.Common = Common;
- return {};
- },
- computed: {
- userImageSrc: function () {
- if (this.loginInfo == null || this.loginInfo.userImageUrl == null) {
- return null;
- }
- return Common.getResourceUrl(
- 'image',
- 'com.leanwo.prodog.base.model.User',
- store.state.downloadStore.imageSrc,
- );
- },
- },
- mounted: function () {
- var _self = this;
- },
- methods: {
-
- setUserParameters: function () {
- this.$router.push('/desktop/userParameters');
- },
- logout: function () {
- Common.clearLocalStorage();
- //path为指定路径,直接删除该路径下的cookie
- // $.removeCookie('#accountId', { path: '/' });
- // $.removeCookie('token', { path: '/' });
- // bug fixed by jack
- // 清除掉/pcapp路径的cookie
- // $.removeCookie('#accountId', { path: '/pcapp' });
- // $.removeCookie('token', { path: '/pcapp' });
- this.$router.push('/login');
- // 这边存在问题,模块化以后,需要修复
- // AuthSettingResource.getAuthSettingDto().then(
- // successData => {
- // if (successData != null) {
- // var url =
- // 'http://jaccount.sjtu.edu.cn/oauth2/logout?client_id=' +
- // successData.jaccountClientId +
- // '&post_logout_redirect_uri=' +
- // Common.getRedirectUrl('#/login');
- // window.location.href = url;
- // } else {
- // this.$router.push('/login');
- // }
- // },
- // errorData => {
- // Common.processException(errorData);
- // },
- // );
- },
- },
- };
- </script>
- <style scoped>
- .user-profile-img {
- width: 29px;
- height: 29px;
- border-radius: 50%;
- margin-top: 10px;
- }
- </style>
|