提交 | 用户 | 时间
|
820397
|
1 |
<script lang="ts" setup> |
H |
2 |
import { computed, onMounted, ref, unref, watch } from 'vue' |
|
3 |
import { useAppStore } from '@/store/modules/app' |
|
4 |
import { useDesign } from '@/hooks/web/useDesign' |
39248b
|
5 |
import * as authUtil from "@/utils/auth"; |
820397
|
6 |
|
H |
7 |
defineOptions({ name: 'Logo' }) |
|
8 |
|
|
9 |
const { getPrefixCls } = useDesign() |
|
10 |
|
|
11 |
const prefixCls = getPrefixCls('logo') |
|
12 |
|
|
13 |
const appStore = useAppStore() |
|
14 |
|
|
15 |
const show = ref(true) |
|
16 |
|
39248b
|
17 |
const homePath = ref('/index') |
H |
18 |
|
820397
|
19 |
const title = computed(() => appStore.getTitle) |
H |
20 |
|
|
21 |
const layout = computed(() => appStore.getLayout) |
|
22 |
|
|
23 |
const collapse = computed(() => appStore.getCollapse) |
39248b
|
24 |
|
H |
25 |
let tenantId = authUtil.getTenantId() |
|
26 |
console.log(tenantId) |
|
27 |
if (tenantId && tenantId === 1) { |
|
28 |
homePath.value = '/index' |
|
29 |
} else { |
|
30 |
homePath.value = '/home2' |
|
31 |
} |
|
32 |
console.log(homePath.value) |
820397
|
33 |
|
H |
34 |
onMounted(() => { |
|
35 |
if (unref(collapse)) show.value = false |
|
36 |
}) |
|
37 |
|
|
38 |
watch( |
|
39 |
() => collapse.value, |
|
40 |
(collapse: boolean) => { |
|
41 |
if (unref(layout) === 'topLeft' || unref(layout) === 'cutMenu') { |
|
42 |
show.value = true |
|
43 |
return |
|
44 |
} |
|
45 |
if (!collapse) { |
|
46 |
setTimeout(() => { |
|
47 |
show.value = !collapse |
|
48 |
}, 400) |
|
49 |
} else { |
|
50 |
show.value = !collapse |
|
51 |
} |
|
52 |
} |
|
53 |
) |
|
54 |
|
|
55 |
watch( |
|
56 |
() => layout.value, |
|
57 |
(layout) => { |
|
58 |
if (layout === 'top' || layout === 'cutMenu') { |
|
59 |
show.value = true |
|
60 |
} else { |
|
61 |
if (unref(collapse)) { |
|
62 |
show.value = false |
|
63 |
} else { |
|
64 |
show.value = true |
|
65 |
} |
|
66 |
} |
|
67 |
} |
|
68 |
) |
|
69 |
</script> |
|
70 |
|
|
71 |
<template> |
|
72 |
<div> |
|
73 |
<router-link |
|
74 |
:class="[ |
|
75 |
prefixCls, |
|
76 |
layout !== 'classic' ? `${prefixCls}__Top` : '', |
|
77 |
'flex !h-[var(--logo-height)] items-center cursor-pointer pl-8px relative decoration-none overflow-hidden' |
|
78 |
]" |
39248b
|
79 |
:to="homePath" |
820397
|
80 |
> |
H |
81 |
<img |
|
82 |
class="h-[calc(var(--logo-height)-10px)] w-[calc(var(--logo-height)-10px)]" |
|
83 |
src="@/assets/imgs/logo.png" |
|
84 |
/> |
|
85 |
<div |
|
86 |
v-if="show" |
|
87 |
:class="[ |
|
88 |
'ml-10px text-16px font-700', |
|
89 |
{ |
|
90 |
'text-[var(--logo-title-text-color)]': layout === 'classic', |
|
91 |
'text-[var(--top-header-text-color)]': |
|
92 |
layout === 'topLeft' || layout === 'top' || layout === 'cutMenu' |
|
93 |
} |
|
94 |
]" |
|
95 |
> |
|
96 |
{{ title }} |
|
97 |
</div> |
|
98 |
</router-link> |
|
99 |
</div> |
|
100 |
</template> |