<script lang="ts" setup>
|
import type { DropMenu } from '@jnpf/ui';
|
|
import { computed, unref } from 'vue';
|
|
import { Dropdown } from '@jnpf/ui';
|
import { openWindow } from '@jnpf/utils';
|
|
import { useUserStore } from '@vben/stores';
|
|
import { VbenIconButton } from '@vben-core/shadcn-ui';
|
|
import { Tooltip } from 'ant-design-vue';
|
|
import { $t } from '#/locales';
|
import { APP_BACKEND_PREFIX, APP_PREFIX } from '#/utils/constants';
|
import { getJnpfAppEnCode, getRealJnpfAppEnCode } from '#/utils/jnpf';
|
|
const userStore = useUserStore();
|
|
const getUserInfo: any = computed(() => userStore.getUserInfo || {});
|
const getIsBackend = computed(() => getJnpfAppEnCode() !== getRealJnpfAppEnCode());
|
const getMenuList = computed<DropMenu[]>(() => {
|
if (unref(getIsBackend)) return [{ event: 'toFrontend', text: '进入应用前台' }];
|
const menuList = [{ event: 'toMain', text: '进入控制台' }];
|
if (unref(getUserInfo)?.hasBackend) menuList.push({ event: 'toBackend', text: '进入应用后台' });
|
return menuList;
|
});
|
|
function handleMenuEvent(menu: DropMenu) {
|
let url = window.location.origin;
|
if (menu.event !== 'toMain') {
|
const appEnCode = getRealJnpfAppEnCode();
|
url = `${url}/${APP_PREFIX + (unref(getIsBackend) ? '' : APP_BACKEND_PREFIX) + appEnCode}`;
|
}
|
openWindow(url);
|
}
|
</script>
|
|
<template>
|
<Tooltip :mouse-enter-delay="0.5" :title="$t('layout.header.tooltipNotify')" placement="bottom" />
|
<Dropdown :drop-menu-list="getMenuList" :trigger="['hover']" placement="bottom" @menu-event="handleMenuEvent">
|
<VbenIconButton class="global-header-icon ml-[-4px] w-auto rounded-md !px-[6px]">
|
<i class="icon-ym icon-ym-nav-home text-[18px] text-foreground"></i>
|
</VbenIconButton>
|
</Dropdown>
|
</template>
|