Browse Source

feat: 标注登录显示

jinx 2 years ago
parent
commit
75f26357e0
2 changed files with 18 additions and 4 deletions
  1. 7 2
      src/components/header/index.vue
  2. 11 2
      src/pages/Viewer.vue

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

@@ -44,7 +44,7 @@
     </footer>
     <Toast v-if="showCopyDone" :content="t('common.copySuccess')" />
     <Toast v-if="showTips" :content="showTips" :close="() => (showTips = null)" />
-    <Login v-if="showLogin" @close="showLogin = false" @user="info => (user = info)" />
+    <Login v-if="showLogin" @close="showLogin = false" @user="getUser" />
     <Loading v-if="showLoading" />
     <CopyLink v-if="showLink" @close="showLink = false" @done="done" />
 </template>
@@ -63,7 +63,7 @@ const props = defineProps({
     project: Object,
     showAdjust: Boolean,
 })
-const emits = defineEmits(['update'])
+const emits = defineEmits(['update', 'getUserId'])
 
 const user = ref(null)
 const points = ref({ p1: null, p2: null })
@@ -76,6 +76,10 @@ const done = () => {
     showCopyDone.value = true
     showLink.value = false
 }
+const getUser = info => {
+    user.value = info
+    emits('getUserId', localStorage.getItem('userId'))
+}
 const openLink = () => {
     showLink.value = true
     showCopyDone.value = false
@@ -145,6 +149,7 @@ const onLogout = () => [
                 localStorage.removeItem('password')
                 localStorage.removeItem('userId')
                 user.value = null
+                emits('getUserId', null)
             }
         })
         .catch(() => {}),

+ 11 - 2
src/pages/Viewer.vue

@@ -1,5 +1,5 @@
 <template>
-    <AppHeader v-show="!fscChecked" :project="project" :show-adjust="showAdjust" @update="onPointsUpdate" />
+    <AppHeader v-show="!fscChecked" :project="project" @getUserId="getUserId" :show-adjust="showAdjust" @update="onPointsUpdate" />
     <article>
         <main>
             <div class="split">
@@ -70,7 +70,7 @@
                 </div>
             </div>
             <div class="model" v-show="showWidget && !showAdjust">
-                <div class="file" :class="{ active: fileChecked, disable: fileDisable }" v-show="!fscChecked && !showBim">
+                <div v-if="userId" 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>
@@ -121,6 +121,11 @@ const isEdit = ref(false)
 provide('tags', tags)
 provide('notify', notify)
 provide('isEdit', isEdit)
+const userId = ref(localStorage.getItem('userId') || null)
+
+const getUserId = id => {
+    userId.value = id
+}
 
 // 是否BIM模式
 const showBim = ref(browser.urlHasValue('bim'))
@@ -535,6 +540,10 @@ const onP2Click = type => {
 }
 
 onMounted(() => {
+    window.addEventListener('setItem', e => {
+        console.error('88888', e)
+    })
+
     const num = browser.valueFromUrl('m') || ''
     const projectId = browser.valueFromUrl('projectId') || 1
     http.get(`smart-site/project/info?projectId=${projectId}&sceneOrder=asc`)