feat: 全局获取userinfo、数据持久化、store处理

This commit is contained in:
renxiaodong
2025-06-23 22:03:57 -04:00
parent 55198613a8
commit 59dac3bb13
10 changed files with 104 additions and 75 deletions

View File

@ -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>