chore
This commit is contained in:
@@ -8,14 +8,30 @@ function renderIcon(icon: Component): () => VNode {
|
||||
import { ChevronDown } from '@vicons/ionicons5';
|
||||
import { AlertFilled, AreaChartOutlined, FileTextFilled, HomeFilled, LogoutOutlined, VideoCameraFilled } from '@vicons/antd';
|
||||
import { NButton, NDropdown, NFlex, NIcon, NLayout, NLayoutContent, NLayoutFooter, NLayoutHeader, NLayoutSider, NMenu, NScrollbar, type DropdownOption, type MenuOption } from 'naive-ui';
|
||||
import { h, ref, type Component, type VNode } from 'vue';
|
||||
import { h, onBeforeMount, onBeforeUnmount, ref, type Component, type VNode } from 'vue';
|
||||
import { RouterLink, useRoute, useRouter } from 'vue-router';
|
||||
import { useStationListQuery } from '@/composables/query/use-station-list-query';
|
||||
import ThemeSwitch from '@/components/theme-switch.vue';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useStationListQuery } from '@/composables/query/use-station-list-query';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const { userInfo } = storeToRefs(userStore);
|
||||
|
||||
const stationStore = useStationStore();
|
||||
const { stationList } = storeToRefs(stationStore);
|
||||
|
||||
useStationListQuery();
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stationList.value = [];
|
||||
});
|
||||
|
||||
onBeforeMount(() => {
|
||||
userStore.userGetInfo().catch((err) => window.$message.error(err));
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -53,7 +69,6 @@ const dropdownOptions = ref<DropdownOption[]>([
|
||||
key: 'logout',
|
||||
icon: renderIcon(LogoutOutlined),
|
||||
onClick: async () => {
|
||||
const userStore = useUserStore();
|
||||
await userStore.userLogout();
|
||||
router.push('/login');
|
||||
},
|
||||
@@ -82,7 +97,7 @@ const selectDropdownOption = (key: string, option: DropdownOption) => {
|
||||
<NDropdown trigger="hover" show-arrow :options="dropdownOptions" @select="selectDropdownOption">
|
||||
<NButton secondary icon-placement="right" style="margin-right: 8px">
|
||||
<template #default>
|
||||
<span>你好</span>
|
||||
<span>你好,{{ userInfo?.nickName ?? '' }}</span>
|
||||
</template>
|
||||
<template #icon>
|
||||
<NIcon :component="ChevronDown" />
|
||||
|
||||
@@ -78,11 +78,11 @@ export const useUserStore = defineStore(
|
||||
};
|
||||
|
||||
const userGetInfo = async () => {
|
||||
const [err, userInfo] = await userClient.get<any>(`/api/oauth/anyone/getUserInfoById`);
|
||||
if (err || !userInfo) {
|
||||
const [err, info] = await userClient.get<any>(`/api/oauth/anyone/getUserInfoById`);
|
||||
if (err || !info) {
|
||||
throw err;
|
||||
}
|
||||
userInfo.value = userInfo;
|
||||
userInfo.value = info;
|
||||
};
|
||||
|
||||
const userGetResourceList = async () => {
|
||||
|
||||
Reference in New Issue
Block a user