-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYunFooter.vue
More file actions
188 lines (160 loc) · 5.26 KB
/
YunFooter.vue
File metadata and controls
188 lines (160 loc) · 5.26 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<template>
<footer
flex="~ col"
class="relative yun-footer va-footer px-4 py-4 pt-0 text-$va-c-text-light w-full mt-14"
bg="white dark:$va-c-bg-soft"
text="center sm"
>
<YunCloud v-if="themeConfig.footer.cloud?.enable" class="absolute top--10 left-0 right-0" />
<div v-if="themeConfig.footer.beian?.enable && themeConfig.footer.beian.icp" class="beian" m="y-2">
<a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener">
{{ themeConfig.footer.beian.icp }}
</a>
</div>
<div class="copyright flex justify-center items-center gap-2" p="1">
<span>
©
<template v-if="!isThisYear">
{{ themeConfig.footer.since }} -
</template>
{{ year }}
</span>
<a
v-if="themeConfig.footer.icon?.enable"
class="inline-flex"
:class="themeConfig.footer.icon.animated ? 'animate-pulse' : ''"
:href="footerIcon.url"
target="_blank"
:title="footerIcon.title"
>
<div :class="footerIcon.name" />
</a>
<span>{{ siteConfig.author.name }}</span>
</div>
<!-- 运营时间显示(自定义增强) -->
<div class="live-time" m="2">
<span class="live-time-prefix">{{ t('footer.live_time.prefix') }}</span>
<span class="live-time-content">
{{ liveTimeDisplay }}
</span>
<span class="live-time-suffix">{{ t('footer.live_time.suffix') }}</span>
</div>
<!-- 不蒜子统计(自定义增强) -->
<div class="busuanzi" m="2">
<span>{{ t('footer.statistics.total_views') }}:<span id="busuanzi_value_site_pv"></span></span>
<span class="mx-2">|</span>
<span>{{ t('footer.statistics.visitors') }}:<span id="busuanzi_value_site_uv"></span></span>
</div>
<div v-if="themeConfig.footer.powered" class="powered" m="2">
<span v-html="poweredHtml" />
<span mx-1>|</span>
<span>
<span>{{ t('footer.theme') }}</span>
<span mx-1>-</span>
<a :href="themeConfig.pkg.repository.url" :title="themeConfig.pkg.name" target="_blank">{{ capitalize(config.theme) }}</a>
<span class="ml-1 op-60">v{{ themeConfig.pkg.version }}</span>
</span>
</div>
<slot />
<div class="yun-footer-gradient" :style="gradientStyles" />
</footer>
</template>
<script lang="ts" setup>
import { useSiteConfig, useValaxyConfig, useValaxyDark, useThemeConfig } from 'valaxy'
import type { ThemeConfig } from 'valaxy-theme-yun'
import pkg from 'valaxy/package.json'
import { capitalize, computed, onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useScriptTag } from '@vueuse/core'
// background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
const { isDark } = useValaxyDark()
const gradientStyles = computed(() => {
if (isDark.value) {
return {
'--gradient-from': '0 0 0',
'--gradient-to': '0 0 0',
}
}
return {
'--gradient-from': '161 196 253',
'--gradient-to': '194 233 251',
}
})
const { t } = useI18n()
const config = useValaxyConfig()
const siteConfig = useSiteConfig()
const themeConfig = useThemeConfig<ThemeConfig>()
const year = new Date().getFullYear()
const isThisYear = computed(() => {
return year === themeConfig.value.footer.since
})
const poweredHtml = computed(() => t('footer.powered', [`<a href="${pkg.repository.url}" target="_blank" rel="noopener">Valaxy</a> <span class="op-60">v${pkg.version}</span>`]))
const footerIcon = computed(() => themeConfig.value.footer.icon || {
url: pkg.repository.url,
name: 'i-ri-cloud-line',
title: pkg.name,
})
// 运营时间相关代码
const liveTimeDisplay = ref('')
const startTime = '2021-07-08T00:00:00'
function updateLiveTime() {
const start = new Date(startTime)
const now = new Date()
const timeDiff = now.getTime() - start.getTime()
const msPerMinute = 60 * 1000
const msPerHour = 60 * msPerMinute
const msPerDay = 24 * msPerHour
const passDay = Math.floor(timeDiff / msPerDay)
const passHour = Math.floor((timeDiff % msPerDay) / msPerHour)
const passMinute = Math.floor((timeDiff % msPerHour) / msPerMinute)
const passSecond = Math.floor((timeDiff % msPerMinute) / 1000)
liveTimeDisplay.value = `${passDay} ${t('footer.live_time.days')} ${passHour} ${t('footer.live_time.hours')} ${passMinute} ${t('footer.live_time.minutes')} ${passSecond} ${t('footer.live_time.seconds')}`
}
onMounted(() => {
updateLiveTime()
setInterval(updateLiveTime, 1000)
})
useScriptTag('//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
</script>
<style lang="scss">
.yun-footer {
letter-spacing: 0.05rem;
line-height: 1.8;
}
.yun-footer-gradient {
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 300px;
z-index: 999;
pointer-events: none;
background: linear-gradient(to right,rgb(var(--gradient-from) / 0.2) 0,rgb(var(--gradient-to) / .2) 100%);
mask-image: linear-gradient(#fff0,#000 70%);
animation: fade-in 2s;
}
.live-time {
font-size: 0.875rem;
opacity: 0.8;
transition: opacity 0.3s;
&:hover {
opacity: 1;
}
&-prefix {
margin-right: 0.5rem;
}
&-suffix {
margin-left: 0.5rem;
opacity: 0.8;
}
}
.busuanzi {
font-size: 0.875rem;
opacity: 0.8;
transition: opacity 0.3s;
&:hover {
opacity: 1;
}
}
</style>