123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <header v-if="showAdjust">
- <div v-if="project">{{ project.projectName }}</div>
- </header>
- <header v-else>
- <div v-if="project">{{ project.projectName }}</div>
- <div class="user">
- <ul>
- <li>
- <i class="iconfont icon-share"></i>
- </li>
- <li><em></em></li>
- <li v-if="user" class="uinfo" @click="showDrop = true">
- <img :src="user.head + '&x-oss-process=image/resize,m_fill,w_64,h_64/quality,q_70'" alt="" />
- <div class="menu">
- <ul>
- <li><a href="">个人信息</a></li>
- <li class="split"></li>
- <li><span>退出登录</span></li>
- </ul>
- </div>
- </li>
- <li v-else class="login" @click="showLogin = true"><span>登录</span></li>
- </ul>
- </div>
- <Login v-if="showLogin" @close="showLogin = false" @user="info => (user = info)" />
- </header>
- </template>
- <script setup>
- import { ref, defineProps, onMounted } from 'vue'
- import { http } from '@/utils/request'
- import browser from '@/utils/browser'
- import Login from './Login'
- const props = defineProps({
- project: Object,
- })
- const user = ref(null)
- const showLogin = ref(false)
- const showAdjust = ref(browser.urlHasValue('adjust'))
- const getUserInfo = () => {
- http.post(`smart-site/getUserInfo`)
- .then(response => {
- if (response.success) {
- user.value = {
- head: response.data.head,
- nickName: response.data.nickName,
- }
- } else {
- if (response.code == 4008) {
- // 未登录
- }
- }
- })
- .catch(() => {})
- }
- onMounted(() => {
- if (localStorage.getItem('token')) {
- getUserInfo()
- }
- })
- </script>
- <style lang="scss" scoped>
- ul,
- li {
- margin: 0;
- padding: 0;
- list-style: none;
- }
- header {
- position: relative;
- height: 60px;
- background-color: #1a1b1d;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 16px;
- }
- .user {
- position: absolute;
- top: 0;
- right: 20px;
- bottom: 0;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 14px;
- ul {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- i {
- font-size: 18px;
- }
- em {
- margin: 0 20px;
- display: inline-block;
- width: 1px;
- height: 16px;
- vertical-align: -2px;
- background-color: rgba(255, 255, 255, 0.16);
- }
- .login {
- cursor: pointer;
- color: rgba(0, 118, 246, 1);
- }
- .uinfo {
- position: relative;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 40px;
- height: 40px;
- font-size: 14px;
- &::after {
- content: '';
- position: absolute;
- right: 3px;
- bottom: 4px;
- width: 0;
- height: 0;
- border-color: rgba(255, 255, 255, 0.6) transparent;
- border-width: 0 0 5px 5px;
- border-style: solid;
- }
- &:hover{
- .menu{
- display: block;
- }
- }
- img {
- width: 32px;
- height: 32px;
- border-radius: 50%;
- background-size: cover;
- border: none;
- outline: none;
- overflow: hidden;
- cursor: pointer;
- }
- .menu {
- display: none;
- position: absolute;
- top: 40px;
- right: 0;
- z-index: 2000;
- a {
- color: #fff;
- text-decoration: none;
- }
- ul {
- background-color: #343535;
- width: 128px;
- flex-direction: column;
- border-radius: 4px;
- box-shadow: 0 0 4px #333;
- padding: 0 10px;
- margin-top: 15px
- }
- li {
- height: 45px;
- line-height: 45px;
- text-align: center;
- }
- }
- }
- }
- </style>
|