ny
22 小时以前 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script setup lang="ts">
import { computed } from 'vue';
 
import { useGlobSetting, useGo } from '@jnpf/hooks';
 
import { preferences, usePreferences } from '@vben/preferences';
import { useUserStore } from '@vben/stores';
 
import defaultLogo from '#/assets/images/jnpf.png';
import { useBaseStore } from '#/store';
import { getRealJnpfAppEnCode } from '#/utils/jnpf';
 
defineOptions({ name: 'JnpfLogo' });
 
const userStore = useUserStore();
const baseStore = useBaseStore();
const globSetting = useGlobSetting();
 
const go = useGo();
const { isHeaderNav, isMixedNav, isMobile, isSideMixedNav, isHeaderMixedNav, isHeaderSidebarNav, sidebarCollapsed } = usePreferences();
 
const getUserInfo: any = computed(() => userStore.getUserInfo || {});
const getSysConfig = computed(() => baseStore.sysConfigInfo);
const getIsChildApp = computed(() => {
  const appEnCode = getRealJnpfAppEnCode();
  return appEnCode && !['teamwork', 'workFlow'].includes(appEnCode);
});
const getCollapsed = computed(() => {
  if (isMobile.value && sidebarCollapsed.value) {
    return true;
  }
  if (isHeaderNav.value || isMixedNav.value || isHeaderSidebarNav.value) {
    return false;
  }
  return sidebarCollapsed.value || isSideMixedNav.value || isHeaderMixedNav.value;
});
const logoClass = computed(() => {
  const { collapsedShowTitle } = preferences.sidebar;
  const classes: string[] = [];
 
  if ((collapsedShowTitle && sidebarCollapsed.value && !isMixedNav.value) || getCollapsed.value) {
    classes.push('mx-auto');
  }
 
  if (isSideMixedNav.value) {
    classes.push('flex-center');
  }
 
  return classes.join(' ');
});
 
function clickLogo() {
  go(preferences.app.defaultHomePath);
}
</script>
 
<template>
  <div class="flex h-full items-center text-lg" @click="clickLogo">
    <div :class="logoClass" class="flex h-full cursor-pointer items-center gap-1 overflow-hidden px-[5px] text-lg leading-normal transition-all duration-500">
      <template v-if="getIsChildApp">
        <i class="jnpf-logo-icon" :class="getUserInfo?.systemIcon || ''"></i>
        <span v-if="!getCollapsed" class="truncate text-nowrap font-medium text-foreground">
          {{ getUserInfo.systemName }}
        </span>
      </template>
      <template v-else>
        <a-image class="jnpf-logo" :src="globSetting.apiURL + getSysConfig.logoIcon" :fallback="defaultLogo" :preview="false" v-if="getSysConfig?.logoIcon" />
        <img class="jnpf-logo" :src="defaultLogo" v-else />
        <span v-if="!getCollapsed" class="truncate text-nowrap font-medium text-foreground">
          {{ getSysConfig.title }}
        </span>
      </template>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.jnpf-logo-icon {
  display: block;
  font-size: 30px;
  text-align: center;
}
 
:deep(.ant-image),
.jnpf-logo {
  width: 40px;
  height: 40px;
 
  .jnpf-logo {
    width: 40px;
    height: 40px;
  }
}
</style>