<template>
    <div class="center">
        <Headers />
        <navbar v-if="Route.path !== '/login'" @setLayout="setLayout" />
        <router-view />
        <settings ref="settingRef" />
    </div>
</template>

<script setup>
import useSettingsStore from '@/store/modules/settings';
import { handleThemeStyle } from '@/utils/theme';
import VScaleScreen from 'v-scale-screen';
import Headers from '@/components/heades/index';
import { AppMain, Navbar, Settings, TagsView } from '@/layout/components';
import { useRoute } from 'vue-router';
import { getToken, setToken, removeToken } from '@/utils/auth';
const Route = useRoute();
onMounted(() => {
    nextTick(() => {
        // 初始化主题样式
        handleThemeStyle(useSettingsStore().theme);
    });
});
const settingRef = ref(null);
function setLayout() {
    settingRef.value.openSetting();
}
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();
};
</script>
<style lang="scss" scoped>
.center {
    width: 100%;
    height: 100%;
}
</style>
