ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<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>