| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <template>
- <div class="avue-contail" :class="{'avue--collapse':isCollapse}">
- <div class="avue-header">
- <!-- 顶部导航栏 -->
- <top ref="top" />
- </div>
- <div class="avue-layout" style="background-color: #042352;">
- <!-- 左侧导航栏 -->
- <div v-show="menuIndex != 0" style="background-color: #16488B;"
- class="animate__animated avue-left animate__faster"
- :class="menuIndex == 0 ? 'animate__fadeOutLeftBig' : 'animate__fadeInLeftBig'">
- <sidebar />
- </div>
- <div class="avue-main" :style="menuIndex == 0 ?'left: 0;width: 100%;height: calc(100vh - 10rem);':''">
- <!-- 顶部标签卡 -->
- <div v-show="menuIndex != 0" class="animate__animated animate__faster"
- :class="menuIndex == 0 ? 'animate__fadeOutLeftBig' : 'animate__fadeInLeftBig'">
- <tags />
- <transition name="fade-scale">
- <search class="avue-view" v-show="isSearch"></search>
- </transition>
- </div>
- <!-- 主体视图层 -->
- <div class="animate__animated animate__fadeInUpBig" style="height:100%;overflow-y:auto;overflow-x:hidden;"
- :style="menuIndex == 0 ?'height: calc(100vh - 10rem);':''" id="avue-view" v-show="!isSearch">
- <keep-alive>
- <router-view class="avue-view" v-if="$route.meta.keepAlive" />
- </keep-alive>
- <router-view class="avue-view" v-if="!$route.meta.keepAlive" />
- </div>
- </div>
- </div>
- <!-- <div class="avue-shade" @click="showCollapse"></div> -->
- <!-- 园区事件 -->
- <my-dialog ref="myDialog"></my-dialog>
- <!-- 视频播放 -->
- <devicePlayer ref="devicePlayer"></devicePlayer>
- </div>
- </template>
- <script>
- import {
- mapGetters
- } from "vuex";
- import tags from "./tags";
- import search from "./search";
- import top from "./top/";
- import sidebar from "./sidebar/";
- import admin from "@/util/admin";
- import devicePlayer from "@/components/scene/wvp/devicePlayer.vue";
- import myDialog from "@/components/dialog/my-dialog.vue"
- import {
- validatenull
- } from "@/util/validate";
- import {
- calcDate
- } from "@/util/date.js";
- import {
- getStore
- } from "@/util/store.js";
- export default {
- components: {
- top,
- tags,
- search,
- sidebar,
- myDialog,
- devicePlayer
- },
- name: "index",
- provide() {
- return {
- index: this
- };
- },
- data() {
- return {
- slot:'',
- incidentdetail: {},
- menuShow: false,
- //搜索控制
- isSearch: false,
- //刷新token锁
- refreshLock: false,
- //刷新token的时间
- refreshTime: ""
- };
- },
- created() {
- //实时检测刷新token
- this.refreshToken();
- },
- mounted() {
- this.init();
- },
- computed: mapGetters(["isMenu", "menuIndex", "isLock", "isCollapse", "website", "menu"]),
- props: [],
- methods: {
- showCollapse() {
- this.$store.commit("SET_COLLAPSE");
- },
- // 初始化
- init() {
- this.$store.commit("SET_SCREEN", admin.getScreen());
- window.onresize = () => {
- setTimeout(() => {
- this.$store.commit("SET_SCREEN", admin.getScreen());
- }, 0);
- };
- this.$store.dispatch("FlowRoutes").then(() => {});
- },
- //打开菜单
- openMenu(item = {}) {
- this.$store.dispatch("GetMenu", item.id).then(data => {
- if (data.length !== 0) {
- this.$router.$avueRouter.formatRoutes(data, true);
- }
- if (!this.validatenull(item) && item.name != '首页') {
- //当点击顶部菜单后默认打开第一个菜单
- let itemActive = {},
- childItemActive = 0;
- if (item.path) {
- itemActive = item;
- } else {
- if (this.menu[childItemActive].length === 0) {
- itemActive = this.menu[childItemActive];
- } else {
- itemActive = this.menu[childItemActive].children[childItemActive];
- }
- }
- this.$store.commit('SET_MENU_ID', item);
- let path = {
- name: (itemActive.label || itemActive.name),
- src: itemActive.path
- };
- if (item.name === '全景园区') {
- path = {
- path: "全景园区",
- src: "/dashboard/panoramapark"
- }
- } else if (item.name === '智能运营中心') {
- path = {
- path: "智能运营中心",
- src: "/dashboard/smartoperationcenter"
- }
- } else if (item.name === '智能安防') {
- path = {
- path: "智能安防",
- src: "/dashboard/smartsecurity"
- }
- } else if (item.name === '一脸通') {
- path = {
- path: "一脸通",
- src: "/dashboard/onefaceaccess"
- }
- } else if (item.name === '停车管理') {
- path = {
- path: "停车管理",
- src: "/dashboard/parkingmng"
- }
- } else if (item.name === '能耗管理') {
- path = {
- path: "能耗管理",
- src: "/dashboard/energymng"
- }
- } else if (item.name === '环境管理') {
- path = {
- path: "环境管理",
- src: "/dashboard/environmentmng"
- }
- } else if (item.name === '消防管理') {
- path = {
- path: "消防管理",
- src: "/dashboard/firemng"
- }
- } else if (item.name === '红色园区') {
- path = {
- path: "红色园区",
- src: "/dashboard/redpark"
- }
- }
- this.$router.push({
- path: this.$router.$avueRouter.getPath(path)
- });
- // let itemActive = {},
- // childItemActive = 0;
- // if (item.path) {
- // itemActive = item;
- // } else {
- // if (this.menu[childItemActive].length === 0) {
- // itemActive = this.menu[childItemActive];
- // } else {
- // itemActive = this.menu[childItemActive].children[childItemActive];
- // }
- // }
- // this.$store.commit('SET_MENU_ID', item);
- // this.$router.push({
- // path: this.$router.$avueRouter.getPath({
- // name: (itemActive.label || itemActive.name),
- // src: itemActive.path
- // }, itemActive.meta)
- // });
- }
- });
- },
- // 定时检测token
- refreshToken() {
- this.refreshTime = setInterval(() => {
- const token = getStore({
- name: "token",
- debug: true
- }) || {};
- const date = calcDate(token.datetime, new Date().getTime());
- if (validatenull(date)) return;
- if (date.seconds >= this.website.tokenTime && !this.refreshLock) {
- this.refreshLock = true;
- this.$store
- .dispatch("refreshToken")
- .then(() => {
- this.refreshLock = false;
- })
- .catch(() => {
- this.refreshLock = false;
- });
- }
- }, 10000);
- }
- }
- };
- </script>
|