Agriculture-front-end/src/App.vue

50 lines
1.4 KiB
Vue
Raw Normal View History

2023-04-16 22:33:44 +08:00
<template>
2023-09-11 21:56:39 +08:00
<div class="center">
<Headers />
<navbar v-if="Route.path !== '/login'" @setLayout="setLayout" />
<router-view />
<settings ref="settingRef" />
</div>
2023-04-16 22:33:44 +08:00
</template>
<script setup>
import useSettingsStore from '@/store/modules/settings';
import { handleThemeStyle } from '@/utils/theme';
import VScaleScreen from 'v-scale-screen';
2023-04-23 09:41:12 +08:00
import Headers from '@/components/heades/index';
2023-09-11 21:56:39 +08:00
import { AppMain, Navbar, Settings, TagsView } from '@/layout/components';
2023-05-05 16:32:31 +08:00
import { useRoute } from 'vue-router';
2023-09-11 21:56:39 +08:00
import { getToken, setToken, removeToken } from '@/utils/auth';
2023-05-05 16:32:31 +08:00
const Route = useRoute();
2023-04-16 22:33:44 +08:00
onMounted(() => {
nextTick(() => {
// 初始化主题样式
handleThemeStyle(useSettingsStore().theme);
});
});
2023-05-05 16:32:31 +08:00
const settingRef = ref(null);
function setLayout() {
2023-09-11 21:56:39 +08:00
settingRef.value.openSetting();
2023-05-05 16:32:31 +08:00
}
2023-09-11 21:56:39 +08:00
var beginTime = 0; //执行onbeforeunload的开始时间
var differTime = 0; //时间差
window.onunload = function () {
differTime = new Date().getTime() - beginTime;
if (differTime >= 1200000) {
localStorage.clear();
removeToken();
} else {
console.log('浏览器刷新');
}
};
window.onbeforeunload = function () {
beginTime = new Date().getTime();
};
2023-04-16 22:33:44 +08:00
</script>
<style lang="scss" scoped>
.center {
width: 100%;
height: 100%;
}
</style>