仰望星辰工作室

starmusic-mobile

starmusic-mobile/ pages/splash/splash.vue 5.9 KB · 293 行 原始文件
1<template>
2 <view class="splash" :style="themeStyle" @click="goHome">
3 <!-- 自定义背景图(绘制在页面内容之下) -->
4 <view v-if="bgStyle" class="bg-image" :style="bgStyle" />
5 <!-- 背景装饰:漂浮音符 -->
6 <view class="deco deco-1" />
7 <view class="deco deco-2" />
8 <view class="deco deco-3" />
9
10 <!-- 主品牌区 -->
11 <view class="main">
12 <view class="logo logo-pop">
13 <lx-icon name="music" :size="96" color="theme" />
14 </view>
15 <text class="title title-up">star-music</text>
16 <text class="subtitle subtitle-up">基于 uniapp 的插件式音乐播放器</text>
17 </view>
18
19 <!-- 每日一句(中间偏下) -->
20 <view class="quote fade-in">
21 <view class="quote-line" />
22 <text class="quote-label">每日一句</text>
23 <view class="quote-line" />
24 <text class="quote-content">{{ quoteText }}</text>
25 <text v-if="quoteAuthor" class="quote-author">—— {{ quoteAuthor }}</text>
26 </view>
27
28 <!-- 底部信息 -->
29 <view class="footer">
30 <text class="version">v{{ version }}</text>
31 </view>
32 </view>
33</template>
34
35<script>
36import LxIcon from '../../components/lx-icon/lx-icon.vue'
37import { getAppVersion } from '../../common/update.js'
38
39/** 每日一句接口(古诗词·一言,原 gushi.ci 迁移后的官方域名) */
40const QUOTE_API = 'https://v1.jinrishici.com/all.json'
41/** 启动页停留时长(ms),保证每日一句有足够展示时间 */
42const SPLASH_DELAY = 2600
43/** 接口失败时的兜底句子 */
44const FALLBACK_QUOTE = { content: '长风破浪会有时,直挂云帆济沧海。', author: '李白' }
45
46export default {
47 components: { LxIcon },
48 data() {
49 return {
50 quoteText: '「古诗词·一言」加载中...',
51 quoteAuthor: '',
52 gone: false,
53 version: '1.3.7',
54 }
55 },
56 onLoad() {
57 this.version = getAppVersion()
58 this.loadQuote()
59 this._timer = setTimeout(() => this.goHome(), SPLASH_DELAY)
60 },
61 onUnload() {
62 if (this._timer) clearTimeout(this._timer)
63 },
64 methods: {
65 loadQuote() {
66 uni.request({
67 url: QUOTE_API,
68 method: 'GET',
69 timeout: 3000,
70 success: (res) => {
71 const d = res && res.data
72 if (d && d.content) {
73 this.quoteText = d.content
74 this.quoteAuthor = d.author || ''
75 } else {
76 this.applyFallback()
77 }
78 },
79 fail: () => {
80 this.applyFallback()
81 },
82 })
83 },
84 applyFallback() {
85 this.quoteText = FALLBACK_QUOTE.content
86 this.quoteAuthor = FALLBACK_QUOTE.author
87 },
88 goHome() {
89 if (this.gone) return
90 this.gone = true
91 if (this._timer) clearTimeout(this._timer)
92 uni.reLaunch({ url: '/pages/index/index' })
93 },
94 },
95}
96</script>
97
98<style lang="scss" scoped>
99.splash {
100 display: flex;
101 flex-direction: column;
102 align-items: center;
103 height: 100vh;
104 background: linear-gradient(180deg, #ffffff 0%, #eef9f4 100%);
105 overflow: hidden;
106}
107
108.main {
109 display: flex;
110 flex-direction: column;
111 align-items: center;
112 margin-top: 32vh;
113}
114
115.logo {
116 width: 168rpx;
117 height: 168rpx;
118 border-radius: 36rpx;
119 background: var(--card-bg, #fff);
120 display: flex;
121 align-items: center;
122 justify-content: center;
123 box-shadow: 0 12rpx 32rpx rgba(var(--theme-color-rgb, 49, 194, 124), 0.18);
124}
125
126.title {
127 margin-top: 32rpx;
128 font-size: 52rpx;
129 font-weight: 700;
130 color: #303133;
131 letter-spacing: 2rpx;
132}
133
134.subtitle {
135 margin-top: 12rpx;
136 font-size: 26rpx;
137 color: var(--text-muted, #909399);
138}
139
140/* 每日一句:中间偏下 */
141.quote {
142 display: flex;
143 flex-direction: column;
144 align-items: center;
145 margin-top: 18vh;
146 padding: 0 72rpx;
147 width: 100%;
148 box-sizing: border-box;
149}
150
151.quote-line {
152 width: 48rpx;
153 height: 4rpx;
154 border-radius: 2rpx;
155 background: var(--theme-color, #31c27c);
156 opacity: 0.6;
157}
158
159.quote-label {
160 margin: 16rpx 0 28rpx;
161 font-size: 26rpx;
162 color: var(--theme-color, #31c27c);
163 letter-spacing: 8rpx;
164}
165
166.quote-content {
167 font-size: 34rpx;
168 color: #303133;
169 line-height: 1.7;
170 text-align: center;
171}
172
173.quote-author {
174 margin-top: 20rpx;
175 font-size: 26rpx;
176 color: var(--text-muted, #909399);
177}
178
179.footer {
180 position: absolute;
181 bottom: 48rpx;
182 left: 0;
183 right: 0;
184 display: flex;
185 justify-content: center;
186}
187
188.version {
189 font-size: 24rpx;
190 color: var(--text-muted, #c0c4cc);
191}
192
193/* 每日一句淡入上移动画(App vue 页面基于 webview,支持 CSS animation) */
194@keyframes quoteFadeIn {
195 from {
196 opacity: 0;
197 transform: translateY(24rpx);
198 }
199 to {
200 opacity: 1;
201 transform: translateY(0);
202 }
203}
204
205.fade-in {
206 animation: quoteFadeIn 0.9s ease-out both;
207 animation-delay: 0.2s;
208}
209
210/* Logo 出场:缩放 + 淡入 + 弹性回弹 */
211@keyframes logoPop {
212 0% {
213 opacity: 0;
214 transform: scale(0.6);
215 }
216 60% {
217 opacity: 1;
218 transform: scale(1.08);
219 }
220 100% {
221 opacity: 1;
222 transform: scale(1);
223 }
224}
225
226.logo-pop {
227 animation: logoPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
228 animation-delay: 0.1s;
229}
230
231/* 标题上移淡入 */
232@keyframes riseUp {
233 from {
234 opacity: 0;
235 transform: translateY(24rpx);
236 }
237 to {
238 opacity: 1;
239 transform: translateY(0);
240 }
241}
242
243.title-up {
244 animation: riseUp 0.6s ease-out both;
245 animation-delay: 0.35s;
246}
247
248.subtitle-up {
249 animation: riseUp 0.6s ease-out both;
250 animation-delay: 0.5s;
251}
252
253/* 背景漂浮装饰 */
254.deco {
255 position: absolute;
256 border-radius: 50%;
257 background: rgba(var(--theme-color-rgb, 49, 194, 124), 0.08);
258 animation: floatDeco 6s ease-in-out infinite;
259}
260
261.deco-1 {
262 width: 200rpx;
263 height: 200rpx;
264 top: 12%;
265 left: -60rpx;
266}
267
268.deco-2 {
269 width: 120rpx;
270 height: 120rpx;
271 top: 30%;
272 right: 40rpx;
273 animation-delay: 1.5s;
274}
275
276.deco-3 {
277 width: 80rpx;
278 height: 80rpx;
279 top: 55%;
280 left: 12%;
281 animation-delay: 3s;
282}
283
284@keyframes floatDeco {
285 0%,
286 100% {
287 transform: translateY(0);
288 }
289 50% {
290 transform: translateY(-32rpx);
291 }
292}
293</style>