瀏覽代碼

feat: 修改提示

rindy 2 年之前
父節點
當前提交
064587f368
共有 1 個文件被更改,包括 36 次插入14 次删除
  1. 36 14
      src/components/header/index.vue

+ 36 - 14
src/components/header/index.vue

@@ -11,7 +11,13 @@
         <div class="user">
             <ul>
                 <li>
-                    <i @click="showLink=true;showCopyDone=false" class="iconfont icon-share"></i>
+                    <i
+                        @click="
+                            showLink = true
+                            showCopyDone = false
+                        "
+                        class="iconfont icon-share"
+                    ></i>
                 </li>
                 <li><em></em></li>
                 <li v-if="user" class="uinfo" @click="showDrop = true">
@@ -32,13 +38,21 @@
         <h4>为场景设置关联位置</h4>
         <div>请选择位置,确认左右视图中的场景在同一位置后,单击右侧按钮将其设为关联位置。</div>
         <div class="points">
-            <button @click="onSetP1" :class="{ active: points.p1 }">设为P1</button>
-            <button @click="onSetP2" :class="{ active: points.p2 }">设为P2</button>
+            <button @click="onSetP1" :class="{ active: points.p1 }">{{ points.p1 ? '重设P1' : '设为P1' }}</button>
+            <button @click="onSetP2" :class="{ active: points.p2 }">{{ points.p2 ? '重设P2' : '设为P2' }}</button>
         </div>
     </footer>
-    <Toast v-if="showCopyDone"  content="复制成功" />
+    <Toast v-if="showCopyDone" content="复制成功" />
+    <Toast v-if="showTips" :content="showTips" :close="() => (showTips = null)" />
     <Login v-if="showLogin" @close="showLogin = false" @user="info => (user = info)" />
-    <CopyLink v-if="showLink" @close="showLink=false" @done="showCopyDone=true;showLink=false" />
+    <CopyLink
+        v-if="showLink"
+        @close="showLink = false"
+        @done="
+            showCopyDone = true
+            showLink = false
+        "
+    />
 </template>
 <script setup>
 import { ref, defineProps, onMounted, watchEffect } from 'vue'
@@ -60,6 +74,7 @@ const points = ref({ p1: null, p2: null })
 const showLink = ref(false)
 const showLogin = ref(false)
 const showCopyDone = ref(false)
+const showTips = ref(null)
 
 const getCurPosInfo = () => {
     let app = sync.sourceInst
@@ -75,14 +90,18 @@ const getCurPosInfo = () => {
 }
 
 const onSetP1 = () => {
+    if (points.value.p1) {
+        showTips.value = '关联位置已更新'
+    }
     points.value.p1 = getCurPosInfo()
-    console.log(points.value.p1)
-    emits('update', 'p1',points.value.p1)
+    emits('update', 'p1', points.value.p1)
 }
 const onSetP2 = () => {
+    if (points.value.p2) {
+        showTips.value = '关联位置已更新'
+    }
     points.value.p2 = getCurPosInfo()
-    console.log(points.value.p2)
-    emits('update', 'p2',points.value.p2)
+    emits('update', 'p2', points.value.p2)
 }
 
 const getUserInfo = () => {
@@ -125,15 +144,18 @@ const onSubmit = () => {
     })
         .then(response => {
             if (response.success) {
-                window.location.href = window.location.href.replace('&adjust', '&split')
-            } else if(response.code == 4008) {
+                showTips.value = 'BIM同步成功'
+                setTimeout(() => {
+                    window.location.href = window.location.href.replace('&adjust', '&split')
+                }, 4000)
+            } else if (response.code == 4008) {
                 showLogin.value = true
             } else {
-                alert(response.message)
+                showTips.value = response.message
             }
         })
         .catch(() => {
-            alert('链接服务器失败')
+            showTips.value = '连接服务器失败'
         })
 }
 
@@ -226,7 +248,7 @@ footer {
     }
     i {
         font-size: 18px;
-        cursor:pointer;
+        cursor: pointer;
     }
     em {
         margin: 0 20px;