提交 | 用户 | 时间
|
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' |
|
5 |
|
|
6 |
defineOptions({ name: 'Logo' }) |
|
7 |
|
|
8 |
const { getPrefixCls } = useDesign() |
|
9 |
|
|
10 |
const prefixCls = getPrefixCls('logo') |
|
11 |
|
|
12 |
const appStore = useAppStore() |
|
13 |
|
|
14 |
const show = ref(true) |
|
15 |
|
|
16 |
const title = computed(() => appStore.getTitle) |
|
17 |
|
|
18 |
const layout = computed(() => appStore.getLayout) |
|
19 |
|
|
20 |
const collapse = computed(() => appStore.getCollapse) |
|
21 |
|
|
22 |
onMounted(() => { |
|
23 |
if (unref(collapse)) show.value = false |
|
24 |
}) |
|
25 |
|
|
26 |
watch( |
|
27 |
() => collapse.value, |
|
28 |
(collapse: boolean) => { |
|
29 |
if (unref(layout) === 'topLeft' || unref(layout) === 'cutMenu') { |
|
30 |
show.value = true |
|
31 |
return |
|
32 |
} |
|
33 |
if (!collapse) { |
|
34 |
setTimeout(() => { |
|
35 |
show.value = !collapse |
|
36 |
}, 400) |
|
37 |
} else { |
|
38 |
show.value = !collapse |
|
39 |
} |
|
40 |
} |
|
41 |
) |
|
42 |
|
|
43 |
watch( |
|
44 |
() => layout.value, |
|
45 |
(layout) => { |
|
46 |
if (layout === 'top' || layout === 'cutMenu') { |
|
47 |
show.value = true |
|
48 |
} else { |
|
49 |
if (unref(collapse)) { |
|
50 |
show.value = false |
|
51 |
} else { |
|
52 |
show.value = true |
|
53 |
} |
|
54 |
} |
|
55 |
} |
|
56 |
) |
|
57 |
</script> |
|
58 |
|
|
59 |
<template> |
|
60 |
<div> |
|
61 |
<router-link |
|
62 |
:class="[ |
|
63 |
prefixCls, |
|
64 |
layout !== 'classic' ? `${prefixCls}__Top` : '', |
|
65 |
'flex !h-[var(--logo-height)] items-center cursor-pointer pl-8px relative decoration-none overflow-hidden' |
|
66 |
]" |
|
67 |
to="/" |
|
68 |
> |
|
69 |
<img |
|
70 |
class="h-[calc(var(--logo-height)-10px)] w-[calc(var(--logo-height)-10px)]" |
|
71 |
src="@/assets/imgs/logo.png" |
|
72 |
/> |
|
73 |
<div |
|
74 |
v-if="show" |
|
75 |
:class="[ |
|
76 |
'ml-10px text-16px font-700', |
|
77 |
{ |
|
78 |
'text-[var(--logo-title-text-color)]': layout === 'classic', |
|
79 |
'text-[var(--top-header-text-color)]': |
|
80 |
layout === 'topLeft' || layout === 'top' || layout === 'cutMenu' |
|
81 |
} |
|
82 |
]" |
|
83 |
> |
|
84 |
{{ title }} |
|
85 |
</div> |
|
86 |
</router-link> |
|
87 |
</div> |
|
88 |
</template> |