feat: 全局获取userinfo、数据持久化、store处理
This commit is contained in:
24
src/App.vue
24
src/App.vue
@ -6,8 +6,26 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserStore } from '@/stores';
|
||||
import zhCN from '@arco-design/web-vue/es/locale/lang/zh-cn';
|
||||
const store = useUserStore();
|
||||
|
||||
const redTheme = {
|
||||
token: {
|
||||
colorPrimary: '#6d4cfe', // 主色
|
||||
colorLink: '#f5222d', // 链接色
|
||||
},
|
||||
};
|
||||
|
||||
const init = () => {
|
||||
const { isLogin, fetchUserInfo } = store;
|
||||
if (isLogin) {
|
||||
fetchUserInfo();
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
init();
|
||||
// 监听全局未处理错误
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
event.preventDefault();
|
||||
@ -15,10 +33,4 @@ onMounted(() => {
|
||||
console.error(`发现catch报错:${event.reason}`);
|
||||
});
|
||||
});
|
||||
const redTheme = {
|
||||
token: {
|
||||
colorPrimary: '#6d4cfe', // 主色
|
||||
colorLink: '#f5222d', // 链接色
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user