Files
lingji-work-fe/src/App.vue
2025-08-07 18:05:27 +08:00

56 lines
1.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<a-config-provider :locale="zhCN" size="small" :theme="redTheme">
<router-view v-if="$route.path === '/login' || ['ExploreList', 'ExploreDetail'].includes($route.name)" />
<LayoutBasic v-else />
</a-config-provider>
</template>
<script setup>
import { useUserStore } from '@/stores';
import { getUserEnterpriseInfo } from '@/utils/user';
import { useSidebarStore } from '@/stores/modules/side-bar';
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
const userStore = useUserStore();
const sidebarStore = useSidebarStore();
const redTheme = {
token: {
colorPrimary: '#6d4cfe', // 主色
colorLink: '#f5222d', // 链接色
},
};
const init = async () => {
const { isLogin, getUserInfo } = userStore;
if (isLogin) {
await getUserInfo(); // 初始化用户信息
await getUserEnterpriseInfo();
sidebarStore.startUnreadInfoPolling();
} else {
sidebarStore.stopUnreadInfoPolling();
}
};
onMounted(() => {
init();
// 监听全局未处理错误
window.addEventListener('unhandledrejection', (event) => {
event.preventDefault();
console.log(event);
console.error(`发现catch报错${event.reason}`);
});
});
onUnmounted(() => {
sideBarStore.stopUnreadInfoPolling();
});
</script>
<style lang="scss">
@import './styles/index.scss';
</style>