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