智慧园区前端大屏
shuishen
2024-11-07 3a1224b26d091fb6a2a08555054acb05592d357c
应急物资、救援队伍去除地图单页处理
4 files modified
81 ■■■■ changed files
src/hooks/initMap.js 15 ●●●● patch | view | raw | blame | history
src/store/router.js 14 ●●●● patch | view | raw | blame | history
src/views/layout/components/mainMenu.vue 8 ●●●●● patch | view | raw | blame | history
src/views/layout/index.vue 44 ●●●● patch | view | raw | blame | history
src/hooks/initMap.js
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 15:09:55
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-07 16:15:48
 * @LastEditTime: 2024-11-07 19:24:27
 * @FilePath: \bigScreen\src\hooks\initMap.js
 * @Description: 
 * 
@@ -11,7 +11,7 @@
let viewer = null
const { VITE_APP_BASE } = import.meta.env
import { useMap } from 'store/map'
import { nextTick } from 'vue'
import { nextTick, onMounted, onUnmounted } from 'vue'
export function readyViewer () {
  const Cesium = DC.getLib('Cesium')
@@ -43,7 +43,16 @@
    })
  }
  initMap()
  onMounted(() => {
    initMap()
  })
  onUnmounted(() => {
    viewer.destroy()
    viewer = null
    delete window.$viewer
    store.setLoadMap(false)
  })
  return {
src/store/router.js
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-11-06 10:46:45
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-06 10:56:14
 * @LastEditTime: 2024-11-07 18:58:32
 * @FilePath: \bigScreen\src\store\router.js
 * @Description: 
 * 
@@ -14,7 +14,8 @@
export const useRouterStore = defineStore('useRouterStore', {
  // 存储状态的地方,相当于 Vuex 的 state
  state: () => ({
    loadSub: false
    loadSub: false,
    loadSingle: false,
  }),
  // 相当于 Vuex 的 getters,用于计算状态
@@ -27,6 +28,10 @@
    setLoadSub (flag) {
      this.loadSub = flag
    },
    setLoadSingle (flag) {
      this.loadSingle = flag
    },
  },
  persist: {
@@ -37,6 +42,11 @@
        paths: ['loadSub'],
        storage: localStorage,
      },
      {
        key: 'loadSingle',
        paths: ['loadSingle'],
        storage: localStorage,
      },
    ]
  }
})
src/views/layout/components/mainMenu.vue
@@ -12,6 +12,8 @@
import { useRouter, useRoute } from 'vue-router'
import { Search } from '@element-plus/icons-vue'
import { getTime } from '@/utils/getTime.js'
import { useRouterStore } from 'store/router'
const store = useRouterStore()
let router = useRouter()
let currentUrl = ref('statistics')
@@ -49,6 +51,12 @@
  if (params.path) {
    if (router.currentRoute.value.path == params.path) return
    if (params.path == '/layout/supplies' || params.path == '/layout/rt') {
      store.setLoadSingle(true)
    } else {
      store.setLoadSingle(false)
    }
    router.push(params.path)
  } else {
    params.childrenFlag = !params.childrenFlag
src/views/layout/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:24
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-06 11:05:46
 * @LastEditTime: 2024-11-07 19:24:45
 * @FilePath: \bigScreen\src\views\layout\index.vue
 * @Description:
 *
@@ -10,11 +10,35 @@
-->
<template>
  <div class="wrapper">
    <map-container ref="MapContainer">
    <div v-if="showSinglePage" class="main-content" id="MainContent">
      <div class="w100 h100">
        <div class="main-header">
          <div class="title">吉水化工园区“一园一策一图”VR平台</div>
          <div class="login-out" @click="signOut">
            <img :src="loginOutBg" class="img" />
            <span>退出</span>
          </div>
        </div>
        <div class="main-container">
          <!-- 地图区域 -->
          <router-view></router-view>
        </div>
        <main-menu></main-menu>
      </div>
    </div>
    <map-container v-if="!showSinglePage" ref="MapContainer">
      <template #content>
        <div v-if="showContent" class="main-content" id="MainContent">
          <main-search></main-search>
          <main-tool></main-tool>
          <div v-if="showSubLayout" class="w100 h100">
            <router-view></router-view>
          </div>
          <div v-if="!showSubLayout" class="w100 h100">
            <div class="main-header">
@@ -32,10 +56,6 @@
            </div>
            <main-menu></main-menu>
          </div>
          <div v-if="showSubLayout" class="w100 h100">
            <router-view></router-view>
          </div>
        </div>
      </template>
@@ -60,20 +80,18 @@
const storeRouter = useRouterStore()
const showContent = ref(false)
const showSubLayout = ref(false)
const showSinglePage = ref(false)
// 监听createB的变化
watch(
  [
    () => store.loadMap,
    () => storeRouter.loadSub,
    () => storeRouter.loadSingle,
  ],
  ([newLoadMap, newLoadSub]) => {
    if (newLoadMap) {
      showContent.value = true
    }
    console.log(newLoadSub, 5555)
  ([newLoadMap, newLoadSub, newLoadSingle]) => {
    showContent.value = newLoadMap
    showSubLayout.value = newLoadSub
    showSinglePage.value = newLoadSingle
  },
  { immediate: true } // 设置immediate为true以便在组件挂载时立即检查createB的值
)