zhgdlarge/src/App.vue
2024-04-01 18:54:18 +08:00

81 lines
2.3 KiB
Vue

<template>
<el-config-provider :locale="i18nLocale" v-if="isRouterAlive" :button="config" :size="assemblySize">
<router-view></router-view>
</el-config-provider>
</template>
<script setup lang="ts">
import { ref, reactive, computed, nextTick, provide, onMounted } from "vue";
import { GlobalStore } from "@/stores";
import { getBrowserLang } from "@/utils/util";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn";
import en from "element-plus/es/locale/lang/en";
const isRouterAlive = ref(true);
const reload = () => {
isRouterAlive.value = false;
nextTick(() => {
isRouterAlive.value = true;
});
};
provide("reload", reload);
const globalStore = GlobalStore();
// 配置element按钮文字中间是否有空格
const config = reactive({
autoInsertSpace: false
});
// element 语言配置
const i18nLocale = computed(() => {
if (globalStore.language && globalStore.language == "zh") return zhCn;
if (globalStore.language == "en") return en;
return getBrowserLang() == "zh" ? zhCn : en;
});
// 配置全局组件大小
const assemblySize = computed(() => globalStore.assemblySize);
onMounted(() => {
// window.onload = function () {
// if (!window.sessionStorage["login"]) {
// // 关闭浏览器时清空
// //window.localStorage.removeItem("userInfo"); 或者写这俩
// //window.localStorage.removeItem("token");
// console.log("关闭浏览器清空");
// return
// globalStore.setToken("");
// globalStore.setUserInfo("");
// }
// };
// window.onunload = function () {
// window.sessionStorage["login"] = true;
// };
// window.onbeforeunload = function () {
// window.sessionStorage["login"] = true;
// };
// 监听 beforeunload 事件
// window.addEventListener("beforeunload", function () {
// if (window.performance.navigation.type === window.performance.navigation.TYPE_RELOAD) {
// // 如果是刷新页面操作,不清除 token
// return;
// }
// // globalStore.setToken("");
// // globalStore.setUserInfo("");
// });
});
</script>
<style lang="scss">
// 地图的搜索层级功能 去掉或者加上scope就会导致地图搜索失效
.amap-sug-result {
z-index: 2999 !important;
.auto-item {
padding-left: 8px;
padding-right: 8px;
font-size: 14px;
color: #666;
}
}
</style>