Files
fe-manage/src/App.vue
2023-02-04 01:49:52 +08:00

208 lines
4.8 KiB
Vue

<template>
<div id="container" v-if="!isLogin">
<nav-top/>
<div style="display: flex">
<nav-left/>
<div style="flex: 1; display: flex; flex-direction: column; width: 0">
<open-pages/>
<bread-crumb/>
<main>
<a-config-provider :locale="zhCN">
<router-view/>
</a-config-provider>
</main>
</div>
</div>
</div>
<div id="container" v-if="isLogin">
<router-view/>
</div>
</template>
<script setup>
import {ref, onMounted} from "vue";
import {useStore, createStore} from "vuex";
import NavLeft from "@/components/NavLeft";
import NavTop from "@/components/NavTop";
import OpenPages from "@/components/OpenPages";
import BreadCrumb from "@/components/BreadCrumb";
import zhCN from "ant-design-vue/es/locale/zh_CN";
import * as api1 from "@/api/index1";
import * as api2 from "@/api/index";
const store = useStore();
const isLogin = ref(false);
console.log("版本2.1.6------------");
// 监听关闭浏览器
let time1 = ref(0);
let time2 = ref(0);
onMounted(() => {
init()
window.addEventListener('beforeunload', e => beforeunloadHandler(e));
window.addEventListener('unload', e => unloadHandler(e));
})
//添加监听事件
function beforeunloadHandler() {
time1.value = new Date().getTime();
}
function init() {
getUserInfo();
initDict("faceclassPic");
initDict("faceclassClass");
initDict("faceclassScene");
initDict("projectLevel");
initDict("projectSys");
initDict("pathmapPic");
initDict("projectClass");
initDict("projectPic");
initDict("sysType");
getMemberInfo();
}
function unloadHandler() {
time2.value = new Date().getTime() - time1.value;
if (time2.value <= 5) {
store.replaceState(createStore({state: {openpages: null}}).state);
localStorage.removeItem("openpages");
}
}
async function getMemberInfo() {
const list = localStorage.getItem("memberInitInfo");
if (list) {
store.commit("SET_MEMBER_INFO", JSON.parse(list));
return;
}
const memberInitInfo = await api1
.getMemberInfo({keyWord: "", pageNo: 1, pageSize: 10})
.then((res) => res.data.data.rows);
store.commit("SET_MEMBER_INFO", memberInitInfo);
localStorage.setItem("memberInitInfo", JSON.stringify(memberInitInfo));
}
async function getUserInfo() {
const userInfo = await api2.userInfo();
store.commit("SET_USER", userInfo.data.data);
}
async function initDict(key, localStory = false) {
let list;
if (localStory) {
list = localStorage.getItem(key);
if (list) {
store.commit("SET_DICT", {key, data: JSON.parse(list)});
return;
}
}
list = await getDictList(key);
localStory && localStorage.setItem(key, JSON.stringify(list));
store.commit("SET_DICT", {key, data: list});
}
const getDictList = (param) => api1.getDictTree({setCode: param,}).then((res) => res.data.data);
</script>
<style lang="scss">
#app {
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
Microsoft YaHei, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
height: 100%;
}
.ant-table-wrapper {
.ant-table-content {
.ant-table-thead th {
background-color: #eff4fc !important;
text-align: center !important;
}
}
.ant-table-tbody > tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) > td {
background: #f6f9fd;
}
}
.ant-btn-link {
padding: 0 !important;
}
#container {
margin: 0;
display: flex;
flex-direction: column;
width: 100%;
min-width: 1000px;
min-height: 100%;
background-color: rgba(245, 247, 250, 1);
main {
height: 0;
flex: 1 1 auto;
// flex-shrink: 0;
display: flex;
overflow-y: auto;
// display: flex;
// flex: 1 1 auto;
width: calc(100% - 40px);
// margin-bottom: 20px;
margin: 0px 20px 20px 20px;
box-sizing: border-box;
background: #ffffff;
box-shadow: 0px 1px 35px 0px rgba(118, 136, 166, 0.07);
}
.cus-btn {
width: 100%;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16px;
border: 1px solid #4ea6ff;
border-radius: 8px;
background: #4ea6ff;
cursor: pointer;
color: #fff;
}
.white {
background: #fff;
color: #4ea6ff;
}
.cus-input {
height: 40px;
border-radius: 8px;
}
.cus-select {
height: 40px;
border-radius: 8px;
}
// @media screen and (max-width: 1366px) {
// .cmMain {
// width: 750px;
// }
// }
// @media screen and (min-width: 1367px) and (max-width: 1680px) {
// .cmMain {
// width: 1010px;
// }
// }
// @media screen and (min-width: 1681px) and (max-width: 1920px) {
// .cmMain {
// width: 1270px;
// }
// }
// @media screen and (min-width: 1921px) {
// .cmMain {
// width: 1270px;
// }
// }
}
</style>