|
@@ -16,37 +16,11 @@
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
import { SvgIcon } from '@/components/common';
|
|
import { SvgIcon } from '@/components/common';
|
|
- import { computed } from 'vue';
|
|
|
|
- import { useDialog } from 'naive-ui';
|
|
|
|
import { routesConst } from '@/router';
|
|
import { routesConst } from '@/router';
|
|
import { useRouter } from 'vue-router';
|
|
import { useRouter } from 'vue-router';
|
|
- import { useUserStore } from '@/store';
|
|
|
|
- import defaultAvatar from '@/assets/avatar.jpg';
|
|
|
|
|
|
+ import Profile from '@/layout/Profile.vue';
|
|
|
|
|
|
- const dialog = useDialog();
|
|
|
|
- const userStore = useUserStore();
|
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
- const user = computed(() => userStore.user);
|
|
|
|
-
|
|
|
|
- async function onLogout() {
|
|
|
|
- dialog.warning({
|
|
|
|
- title: '提示',
|
|
|
|
- content: '你确定注销当前账户吗',
|
|
|
|
- positiveText: '注销',
|
|
|
|
- negativeText: '取消',
|
|
|
|
- onPositiveClick: async () => {
|
|
|
|
- await userStore.logout();
|
|
|
|
- userStore.changeIsLogin();
|
|
|
|
- },
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- async function onLogin() {
|
|
|
|
- userStore.changeIsLogin();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function onProfile() {
|
|
|
|
- router.push({ name: 'Profile' });
|
|
|
|
- }
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -82,48 +56,7 @@
|
|
<div class="p-2 flex flex-col justify-center items-center gap-2 pb-3 bottom-0">
|
|
<div class="p-2 flex flex-col justify-center items-center gap-2 pb-3 bottom-0">
|
|
<n-divider class="!my-0 !py-0" />
|
|
<n-divider class="!my-0 !py-0" />
|
|
|
|
|
|
- <template v-if="user == null">
|
|
|
|
- <n-avatar class="cursor-pointer !text-black" round>
|
|
|
|
- <SvgIcon class="text-2xl" icon="solar:user-broken" />
|
|
|
|
- </n-avatar>
|
|
|
|
- <n-button
|
|
|
|
- block
|
|
|
|
- class="!rounded-lg !py-4"
|
|
|
|
- secondary
|
|
|
|
- size="small"
|
|
|
|
- type="success"
|
|
|
|
- @click="onLogin()"
|
|
|
|
- >
|
|
|
|
- <span class="text-center w-full">登录系统</span>
|
|
|
|
- </n-button>
|
|
|
|
- </template>
|
|
|
|
- <div v-else class="flex w-full flex-col gap-3 mb-2 px-2">
|
|
|
|
- <div class="flex gap-2 items-center px-2">
|
|
|
|
- <n-avatar
|
|
|
|
- :fallback-src="defaultAvatar"
|
|
|
|
- :src="user.avatar ?? '/avatar.jpg'"
|
|
|
|
- class="cursor-pointer w-[30px]"
|
|
|
|
- round
|
|
|
|
- />
|
|
|
|
- <n-ellipsis style="max-width: 85px">
|
|
|
|
- {{ user.username }}
|
|
|
|
- </n-ellipsis>
|
|
|
|
- </div>
|
|
|
|
-
|
|
|
|
- <n-button class="!rounded-lg" size="small" tertiary type="info" @click="onProfile()">
|
|
|
|
- <div class="w-full text-center flex justify-center items-center gap-2">
|
|
|
|
- <SvgIcon class="text-lg" icon="iconamoon:profile" />
|
|
|
|
- <span>个人中心</span>
|
|
|
|
- </div>
|
|
|
|
- </n-button>
|
|
|
|
-
|
|
|
|
- <n-button class="!rounded-lg" secondary size="small" type="warning" @click="onLogout()">
|
|
|
|
- <div class="w-full text-center flex justify-center items-center gap-2">
|
|
|
|
- <SvgIcon class="text-lg" icon="material-symbols:logout" />
|
|
|
|
- <span>注销账户</span>
|
|
|
|
- </div>
|
|
|
|
- </n-button>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <Profile />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|