Commit 3faf04c4 by User

登录角色名称修改

parent 2190a231
<!doctype html>
<html lang="zh-cmn-Hans">
<head>
<meta name="buildTime" content="2025-04-25 15:49:09">
<meta name="buildTime" content="2025-04-25 17:56:27">
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="light dark" />
<title>VueDashboard</title>
<script type="module" crossorigin src="/Content/VueDashboardUi/VueDashboard1/assets/index-CrvCiZyA.js"></script>
<script type="module" crossorigin src="/Content/VueDashboardUi/VueDashboard1/assets/index-CsI39EZy.js"></script>
<link rel="stylesheet" crossorigin href="/Content/VueDashboardUi/VueDashboard1/assets/index-DhhgO4aJ.css">
</head>
<body>
......
<script setup lang="ts">
import { computed } from 'vue';
import type { VNode } from 'vue';
import type { DropdownOption } from 'naive-ui';
import type { RouteKey } from '@elegant-router/types';
import { useAuthStore } from '@/store/modules/auth';
import { $t } from '@/locales';
import { useRouterPush } from '@/hooks/common/router';
import { useSvgIcon } from '@/hooks/common/icon';
import { $t } from '@/locales';
defineOptions({
name: 'UserAvatar'
......@@ -14,59 +15,40 @@ const authStore = useAuthStore();
const { routerPushByKey, toLogin } = useRouterPush();
const { SvgIconVNode } = useSvgIcon();
// 计算属性获取认证状态
const isAuthenticated = computed(() => {
const globalConfig = (window as any).uiGlobalConfig;
return globalConfig?.IsAuthenticated ?? false;
});
function loginOrRegister() {
toLogin();
}
type DropdownKey = 'logout';
type DropdownOption =
| {
key: DropdownKey;
label: string;
icon?: () => VNode;
}
| {
type: 'divider';
key: string;
};
const options = computed(() => {
const opts: DropdownOption[] = [
const options = computed<DropdownOption[]>(() => [
// {
// label: $t('common.userCenter'),
// key: 'user_center',
// icon: SvgIconVNode({ icon: 'carbon:user-avatar', fontSize: 18 })
// },
{
label: $t('common.logout'),
key: 'logout',
icon: SvgIconVNode({ icon: 'ph:sign-out', fontSize: 18 })
icon: SvgIconVNode({ icon: 'carbon:logout', fontSize: 18 })
}
];
]);
return opts;
});
function logout() {
window.$dialog?.info({
title: $t('common.tip'),
content: $t('common.logoutConfirm'),
positiveText: $t('common.confirm'),
negativeText: $t('common.cancel'),
onPositiveClick: () => {
authStore.resetStore();
}
});
}
function handleDropdown(key: DropdownKey) {
function handleDropdown(key: string) {
if (key === 'logout') {
logout();
} else {
// If your other options are jumps from other routes, they will be directly supported here
routerPushByKey(key);
authStore.resetStore();
} else if (key === 'user_center') {
routerPushByKey(key as RouteKey);
}
}
</script>
<template>
<NButton v-if="!authStore.isLogin" quaternary @click="loginOrRegister">
<NButton v-if="!isAuthenticated" quaternary @click="loginOrRegister">
{{ $t('page.login.common.loginOrRegister') }}
</NButton>
<NDropdown v-else placement="bottom" trigger="click" :options="options" @select="handleDropdown">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment