refactor(wish-tree): 参考 wishing-tree-pages 重写许愿树

- 使用精美许愿树 PNG 图片作为背景
- 许愿标签用 CSS 动画实现摇摆效果
- 添加萤火虫和花瓣氛围动画
- 预设树冠挂载点,标签位置更自然
- 深色主题 + 金色/红色/绿色标签
- 边缘暗角让树从中心发光
- 最近心愿横向滚动列表
This commit is contained in:
gouki
2026-08-08 16:49:57 +00:00
parent 0bd92a43bf
commit 81cfe76e2b
5 changed files with 488 additions and 799 deletions
+269 -52
View File
@@ -3,88 +3,252 @@
width: 100vw;
height: 100vh;
overflow: hidden;
background: linear-gradient(180deg, #0a0a1a 0%, #1a1a3a 50%, #0f2a4a 100%);
background: #0d0d1a;
}
/* WebGL Canvas */
.webgl-canvas {
/* 背景氛围 */
.ambiance {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1;
}
/* 顶部导航 */
.top-bar {
.firefly {
position: absolute;
border-radius: 50%;
background: #ffd700;
box-shadow: 0 0 8px #ffd700, 0 0 14px #ffd700;
animation: twinkle 3s ease-in-out infinite;
}
.petals {
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 100rpx 40rpx 30rpx;
display: flex;
justify-content: space-between;
align-items: flex-start;
z-index: 100;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1;
}
.top-bar .tree-info,
.top-bar .sensor-controls {
pointer-events: auto;
.petal {
position: absolute;
top: -20px;
border-radius: 50% 50% 50% 0;
background: rgba(255, 200, 200, 0.6);
animation: drift 12s linear infinite;
}
.tree-info {
/* 边缘暗角 */
.vignette {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(120% 90% at 50% 30%, transparent 40%, rgba(13, 13, 26, 0.9) 100%);
pointer-events: none;
z-index: 2;
}
/* 主内容 */
.main-content {
position: relative;
z-index: 10;
display: flex;
flex-direction: column;
gap: 8rpx;
}
.tree-name {
font-size: 40rpx;
color: #ffd700;
font-weight: bold;
text-shadow: 0 2rpx 10rpx rgba(255, 215, 0, 0.5);
}
.tree-desc {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.7);
}
/* 传感器控制 */
.sensor-controls {
display: flex;
gap: 16rpx;
}
.sensor-btn {
width: 80rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.1);
min-height: 100vh;
padding: 60rpx 40rpx 200rpx;
}
/* 头部 */
.header {
text-align: center;
margin-bottom: 20rpx;
}
.subtitle {
display: block;
font-size: 20rpx;
letter-spacing: 8rpx;
color: rgba(255, 215, 0, 0.8);
margin-bottom: 16rpx;
}
.title {
display: block;
font-size: 72rpx;
font-weight: bold;
color: #ffd700;
text-shadow: 0 4rpx 24rpx rgba(255, 215, 0, 0.4);
margin-bottom: 24rpx;
}
.description {
display: block;
font-size: 26rpx;
color: rgba(255, 255, 255, 0.7);
line-height: 1.6;
max-width: 500rpx;
margin: 0 auto 20rpx;
}
.wish-count {
display: block;
font-size: 24rpx;
color: rgba(255, 215, 0, 0.7);
}
.wish-count .count {
font-weight: bold;
color: #ffd700;
}
/* 许愿树容器 */
.tree-container {
position: relative;
width: 100%;
max-width: 700rpx;
aspect-ratio: 1;
margin: 0 auto;
}
.tree-image {
width: 100%;
height: 100%;
object-fit: contain;
}
/* 许愿标签 */
.wish-tag {
position: absolute;
z-index: 20;
transform: translateX(-50%);
display: flex;
flex-direction: column;
align-items: center;
}
.wish-tag.new {
animation: tag-drop 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.tag-sway {
display: flex;
flex-direction: column;
align-items: center;
transform-origin: top center;
animation: sway 4s ease-in-out infinite;
}
.tag-string {
width: 2rpx;
height: 40rpx;
}
.tag-knot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
border: 2rpx solid rgba(255, 255, 255, 0.2);
transition: all 0.3s;
margin-top: -2rpx;
}
.sensor-btn.active {
background: rgba(255, 215, 0, 0.3);
border-color: rgba(255, 215, 0, 0.6);
box-shadow: 0 0 30rpx rgba(255, 215, 0, 0.4);
.tag-content {
margin-top: 8rpx;
padding: 16rpx 20rpx;
border-radius: 12rpx;
min-width: 160rpx;
max-width: 200rpx;
backdrop-filter: blur(4px);
transition: transform 0.3s;
}
.sensor-icon {
font-size: 40rpx;
.wish-tag:active .tag-content {
transform: translateY(-4rpx) scale(1.05);
}
.tag-text {
display: block;
font-size: 20rpx;
font-weight: 500;
color: #2a2a3a;
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.tag-author {
display: block;
font-size: 16rpx;
color: #4a4a5a;
margin-top: 8rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 最近的心愿 */
.recent-section {
width: 100%;
margin-top: 40rpx;
}
.section-title {
display: block;
text-align: center;
font-size: 22rpx;
letter-spacing: 6rpx;
color: rgba(255, 255, 255, 0.5);
margin-bottom: 24rpx;
}
.recent-list {
display: flex;
gap: 20rpx;
padding-bottom: 20rpx;
white-space: nowrap;
}
.recent-item {
display: inline-flex;
flex-direction: column;
min-width: 280rpx;
padding: 24rpx;
background: rgba(255, 255, 255, 0.08);
border: 1rpx solid rgba(255, 255, 255, 0.1);
border-radius: 20rpx;
backdrop-filter: blur(8px);
}
.recent-text {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.9);
line-height: 1.5;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.recent-author {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.5);
margin-top: 12rpx;
}
/* 许愿按钮 */
.action-bar {
position: absolute;
bottom: 80rpx;
position: fixed;
bottom: 60rpx;
left: 50%;
transform: translateX(-50%);
z-index: 100;
@@ -314,3 +478,56 @@
border: none;
box-shadow: 0 8rpx 30rpx rgba(196, 30, 58, 0.4);
}
/* 动画 */
@keyframes sway {
0%, 100% {
transform: rotate(-3.5deg);
}
50% {
transform: rotate(3.5deg);
}
}
@keyframes twinkle {
0%, 100% {
opacity: 0.2;
transform: scale(0.7);
}
50% {
opacity: 1;
transform: scale(1.15);
}
}
@keyframes drift {
0% {
transform: translate3d(0, 0, 0) rotate(0deg);
opacity: 0;
}
10% {
opacity: 0.9;
}
90% {
opacity: 0.9;
}
100% {
transform: translate3d(-40px, 120vh, 0) rotate(360deg);
opacity: 0;
}
}
@keyframes tag-drop {
0% {
transform: translateY(-24px) rotate(-8deg);
opacity: 0;
}
60% {
transform: translateY(4px) rotate(3deg);
opacity: 1;
}
100% {
transform: translateY(0) rotate(0deg);
opacity: 1;
}
}