Browse Source

feat: 优化标注登录显示

jinx 2 years ago
parent
commit
2119f7245d
2 changed files with 10 additions and 5 deletions
  1. 7 4
      src/components/header/index.vue
  2. 3 1
      src/pages/Viewer.vue

+ 7 - 4
src/components/header/index.vue

@@ -49,7 +49,7 @@
     <CopyLink v-if="showLink" @close="showLink = false" @done="done" />
 </template>
 <script setup>
-import { ref, defineProps, onMounted, watchEffect } from 'vue'
+import { ref, defineProps, onMounted, watchEffect, inject } from 'vue'
 import { http } from '@/utils/request'
 import browser from '@/utils/browser'
 import Toast from '@/components/dialog/Toast'
@@ -64,7 +64,7 @@ const props = defineProps({
     showAdjust: Boolean,
 })
 const emits = defineEmits(['update', 'getUserId'])
-
+const isLogin = inject('isLogin')
 const user = ref(null)
 const points = ref({ p1: null, p2: null })
 const showLink = ref(false)
@@ -78,7 +78,8 @@ const done = () => {
 }
 const getUser = info => {
     user.value = info
-    emits('getUserId', localStorage.getItem('userId'))
+    isLogin.value = true
+    // emits('getUserId', localStorage.getItem('userId'))
 }
 const openLink = () => {
     showLink.value = true
@@ -129,6 +130,7 @@ const getUserInfo = () => {
                     nickName: response.data.nickName,
                 }
                 localStorage.setItem('userId', response.data.id)
+                isLogin.value = true
             } else {
                 if (response.code == 4008) {
                     // 未登录
@@ -149,7 +151,8 @@ const onLogout = () => [
                 localStorage.removeItem('password')
                 localStorage.removeItem('userId')
                 user.value = null
-                emits('getUserId', null)
+                // emits('getUserId', null)
+                isLogin.value = false
             }
         })
         .catch(() => {}),

+ 3 - 1
src/pages/Viewer.vue

@@ -70,7 +70,7 @@
                 </div>
             </div>
             <div class="model" v-show="showWidget && !showAdjust">
-                <div v-if="userId" class="file" :class="{ active: fileChecked, disable: fileDisable }" v-show="!fscChecked && !showBim">
+                <div v-if="isLogin" class="file" :class="{ active: fileChecked, disable: fileDisable }" v-show="!fscChecked && !showBim">
                     <div @click="onFileChecked">
                         <i class="iconfont icon-note1"></i>
                         <span>{{ $t('home.tag') }}</span>
@@ -118,9 +118,11 @@ const isDev = process.env.VUE_APP_TEST == 1
 const tags = ref([])
 const notify = ref(null)
 const isEdit = ref(false)
+const isLogin = ref(false)
 provide('tags', tags)
 provide('notify', notify)
 provide('isEdit', isEdit)
+provide('isLogin', isLogin)
 const userId = ref(localStorage.getItem('userId') || null)
 
 const getUserId = id => {