Files
ruoyi-plus-vben5-h/apps/web-antd/src/layouts/basic.vue
dap 0934d7b785 chore: 迁移图标依赖从 @ant-design/icons-vue 到 @antdv-next/icons
移除对 @ant-design/icons-vue 的依赖,统一使用 @antdv-next/icons。
更新了 pnpm-workspace.yaml 中的包版本管理,并在多个 Vue 组件中修改了图标导入语句。
2026-01-28 09:59:05 +08:00

171 lines
4.3 KiB
Vue

<script lang="ts" setup>
import { computed, h, onMounted, watch } from 'vue';
import { useRouter } from 'vue-router';
import { AuthenticationLoginExpiredModal } from '@vben/common-ui';
import { VBEN_DOC_URL, VBEN_GITHUB_URL } from '@vben/constants';
import { useWatermark } from '@vben/hooks';
import { BookOpenText, CircleHelp, GiteeIcon } from '@vben/icons';
import {
BasicLayout,
LockScreen,
Notification,
UserDropdown,
} from '@vben/layouts';
import { preferences } from '@vben/preferences';
import { useAccessStore, useUserStore } from '@vben/stores';
import { openWindow } from '@vben/utils';
import { GithubOutlined, UserOutlined } from '@antdv-next/icons';
import { TenantToggle } from '#/components/tenant-toggle';
import { $t } from '#/locales';
import { resetRoutes } from '#/router';
import { useAuthStore, useNotifyStore } from '#/store';
import { useTenantStore } from '#/store/tenant';
import { useVersionUpdate } from '#/utils/check-update';
import LoginForm from '#/views/_core/authentication/login.vue';
const userStore = useUserStore();
const authStore = useAuthStore();
const accessStore = useAccessStore();
const router = useRouter();
const { destroyWatermark, updateWatermark } = useWatermark();
const tenantStore = useTenantStore();
const menus = computed(() => {
const defaultMenus = [
{
handler: () => {
openWindow(VBEN_DOC_URL, {
target: '_blank',
});
},
icon: BookOpenText,
text: $t('ui.widgets.document'),
},
{
handler: () => {
router.push('/profile');
},
icon: UserOutlined,
text: $t('ui.widgets.profile'),
},
{
handler: () => {
openWindow('https://gitee.com/dapppp/ruoyi-plus-vben5', {
target: '_blank',
});
},
icon: () => h(GiteeIcon, { class: 'text-red-800' }),
text: 'Gitee项目地址',
},
{
handler: () => {
openWindow(VBEN_GITHUB_URL, {
target: '_blank',
});
},
icon: GithubOutlined,
text: 'Vben官方地址',
},
{
handler: () => {
openWindow(`${VBEN_GITHUB_URL}/issues`, {
target: '_blank',
});
},
icon: CircleHelp,
text: $t('ui.widgets.qa'),
},
];
/**
* 租户选中状态 不显示个人中心
*/
if (tenantStore.checked) {
defaultMenus.splice(1, 1);
}
return defaultMenus;
});
const avatar = computed(() => {
return userStore.userInfo?.avatar || preferences.app.defaultAvatar;
});
async function handleLogout() {
/**
* 主动登出不需要带跳转地址
*/
await authStore.logout(false);
resetRoutes();
}
const notifyStore = useNotifyStore();
onMounted(() => notifyStore.startListeningMessage());
function handleViewAll() {
window.message.warning('暂未开放');
}
watch(
() => ({
enable: preferences.app.watermark,
content: preferences.app.watermarkContent,
}),
async ({ enable, content }) => {
if (enable) {
await updateWatermark({
content:
content ||
`${userStore.userInfo?.username} - ${userStore.userInfo?.realName}`,
});
} else {
destroyWatermark();
}
},
{
immediate: true,
},
);
// 检测版本更新
useVersionUpdate();
</script>
<template>
<BasicLayout @clear-preferences-and-logout="handleLogout">
<template #header-right-1>
<TenantToggle />
</template>
<template #user-dropdown>
<UserDropdown
:avatar
:menus
:text="userStore.userInfo?.realName"
:description="userStore.userInfo?.email || '未设置邮箱'"
:tag-text="userStore.userInfo?.username"
@logout="handleLogout"
/>
</template>
<template #notification>
<Notification
:dot="notifyStore.showDot"
:notifications="notifyStore.notifications"
@clear="notifyStore.clearAllMessage"
@make-all="notifyStore.setAllRead"
@read="notifyStore.setRead"
@view-all="handleViewAll"
/>
</template>
<template #extra>
<AuthenticationLoginExpiredModal
v-model:open="accessStore.loginExpired"
:avatar
>
<LoginForm />
</AuthenticationLoginExpiredModal>
</template>
<template #lock-screen>
<LockScreen :avatar @to-login="handleLogout" />
</template>
</BasicLayout>
</template>