Skip to content

Commit 79c7b79

Browse files
committed
feat: 添加路由配置和导航功能,优化页面跳转逻辑
1 parent da85774 commit 79c7b79

12 files changed

Lines changed: 209 additions & 311 deletions

src/components/BlessingBar.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import { computed, ref } from 'vue';
33
import { useFetch } from '@vueuse/core';
4+
import { ROUTES } from '../config/routes';
5+
import { goTo } from '../utils/navigation';
46
57
const floorNumber = 444012
68
@@ -32,7 +34,7 @@ const interval = setInterval(() => {
3234
}, 10)
3335
3436
function toHole() {
35-
window.location.href = "/anniversary/2025/hole"
37+
goTo(ROUTES.anniversary2025.hole)
3638
}
3739
3840
@@ -62,4 +64,4 @@ function toHole() {
6264
.move {
6365
transform: translateX(v-bind(positionString));
6466
}
65-
</style>
67+
</style>

src/config/routes.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const ROUTES = {
2+
anniversary2025: {
3+
base: '/anniversary/2025',
4+
webMobile: '/anniversary/2025/web-mobile/index.html',
5+
webDesktop: '/anniversary/2025/web-desktop/index.html',
6+
hole: '/anniversary/2025/hole',
7+
gallery: '/anniversary/2025/gallery',
8+
},
9+
anniversary2026: {
10+
base: '/anniversary/2026',
11+
webMobile: '/anniversary/2026/web-mobile/index.html',
12+
webDesktop: '/anniversary/2026/web-desktop/index.html',
13+
gallery: '/anniversary/2026/gallery',
14+
letter: '/anniversary/2026/letter',
15+
},
16+
} as const

src/utils/navigation.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export function goTo(url: string): void {
2+
window.location.href = url
3+
}
4+
5+
export function goBack(): void {
6+
window.history.back()
7+
}
8+
9+
export function goToResponsivePage(mobileUrl: string, desktopUrl: string): void {
10+
const isMobile = !window.matchMedia('(min-width: 768px)').matches
11+
window.location.href = isMobile ? mobileUrl : desktopUrl
12+
}

src/views/Anniversary2026View.vue

Lines changed: 15 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script setup lang="ts">
22
import { onMounted, ref } from 'vue'
33
import { galleryItems } from './anniversary2026GalleryData'
4+
import { letterGreeting2026, letterParagraphs2026, letterSignature2026, letterTitle2026 } from './anniversary2026LetterData'
5+
import { ROUTES } from '../config/routes'
6+
import { goToResponsivePage } from '../utils/navigation'
47
58
// --- Tab state ---
69
const activeTab = ref('game')
@@ -12,11 +15,7 @@ const tabs = [
1215
1316
// --- Game ---
1417
function playGame() {
15-
if (!window.matchMedia('(min-width: 768px)').matches) {
16-
window.location.href = '/anniversary/2026/web-mobile/index.html'
17-
} else {
18-
window.location.href = '/anniversary/2026/web-desktop/index.html'
19-
}
18+
goToResponsivePage(ROUTES.anniversary2026.webMobile, ROUTES.anniversary2026.webDesktop)
2019
}
2120
2221
// --- Survey ---
@@ -139,24 +138,12 @@ onMounted(() => {
139138
<section v-if="activeTab === 'letter'" class="ann-panel panel-letter">
140139
<div class="letter-paper">
141140
<div class="letter-header-deco"></div>
142-
<h2 class="letter-title">致茶友们的一封信</h2>
141+
<h2 class="letter-title">{{ letterTitle2026 }}</h2>
143142
<div class="letter-body">
144-
<p class="letter-greeting">各位亲爱的茶友:</p>
145-
<p>2021 年 4 月 15 日,在复旦园和煦的春风中,一只旦挞猫猫悄悄在校园的某个角落里破壳而出,并用代码为复旦大学的各位茶友搭建起一个小小的交流空间。转眼间,在各位茶友的陪伴下,这只可爱的猫猫迎来了五岁生日。</p>
146-
<p>五年来,猫猫迎来了五万余位作客的茶友;人声鼎沸中,五百余万条消息在茶楼里留下回响。对于每一位造访的茶友来说,茶楼或许都有着属于自己的独特意义。</p>
147-
<p>或许,你是茶楼的常客,每天造访已经成为习惯;或许,你心血来潮时会来听听最新校园奇谭。</p>
148-
<p>或许,你最爱翻阅猫猫钦点的「#旦挞精选」;或许,你最关心的是茶楼顶上的公告栏。</p>
149-
<p>或许,你热爱在茶楼激扬文字,是名副其实的「大水怪」;或许,你在默默潜水时注视着浪花有所感慨。</p>
150-
<p>或许,茶楼是你茶余饭后的快乐来源;或许,茶楼是你深夜 emo 时的温暖港湾。</p>
151-
<p>或许,茶楼是你分享生活智慧的闪耀平台;或许,茶楼是你手足无措时的智囊团。</p>
152-
<p>或许,茶楼是你碰撞思维火花的试炼场;或许,茶楼是你寻找同好的朋友圈。</p>
153-
<p>无论茶楼对大家来说意味着什么,旦挞猫猫都会感到非常欣慰!猫猫喜欢看到茶楼里热闹的样子,喜欢身边有熟客的陪伴,喜欢重逢阔别已久的面孔,也喜欢看到大家脸上的笑容!每当看到温馨和谐的茶楼,猫猫都会忍不住幸福地发眯起眼睛,发出咕噜咕噜的声音!(当然,猫猫最喜欢的是遵守规则、维护茶楼友好氛围的好孩子,对于不遵守规则的坏孩子猫猫也是不会客气的!)</p>
154-
<p>茶楼的今天离不开各位茶友的踊跃参与,也离不开各位猫猫的饲养员——旦挞团队的辛勤付出。如今,旦挞团队已经有了 70 位成员。对于旦挞团队的各位成员来说,为各位茶友提供更好的服务是我们一直以来的追求。我们喜欢看到大家在 GitHub 仓库中点亮的星星,喜欢看到维护时大家表达的支持和鼓励;喜欢看到大家对猫猫表情包、红包封面、文创物料、推送文案的夸夸和热情,喜欢看到各个社团的联动申请;喜欢看到大家对卖萌的管理员表达的善意,也喜欢看到大家在站务区、QQ 群和邮件里对团队工作提出的真诚建议。如果你也希望成为一名饲养员,那么我们非常欢迎你的加入!</p>
155-
<p>感谢各位茶友一直以来的支持,希望大家都能够常来坐坐,在茶楼收获更多快乐~猫猫会一直在茶楼里摇着尾巴等待你!</p>
143+
<p class="letter-greeting">{{ letterGreeting2026 }}</p>
144+
<p v-for="paragraph in letterParagraphs2026" :key="paragraph">{{ paragraph }}</p>
156145
<div class="letter-sig">
157-
<p>旦挞团队</p>
158-
<p>旦挞猫猫(爪印代)</p>
159-
<p>2026 年 4 月 15 日</p>
146+
<p v-for="item in letterSignature2026" :key="item">{{ item }}</p>
160147
</div>
161148
</div>
162149
</div>
@@ -205,6 +192,9 @@ onMounted(() => {
205192
</style>
206193

207194
<style scoped>
195+
@import './galleryShared.css';
196+
@import './lightboxShared.css';
197+
208198
/* ===== FOUNDATIONS ===== */
209199
.ann-root {
210200
--c-blossom: #e8a0b4;
@@ -216,6 +206,10 @@ onMounted(() => {
216206
--c-leaf: #8fb88c;
217207
--c-leaf-pale: #ddecd8;
218208
--c-cream: #fdf8f4;
209+
--gallery-accent: var(--c-blossom);
210+
--gallery-accent-strong: var(--c-blossom-deep);
211+
--gallery-accent-bg: var(--c-blossom-wash);
212+
--gallery-text: var(--c-ink-light);
219213
220214
position: relative;
221215
min-height: 100vh;
@@ -490,129 +484,6 @@ onMounted(() => {
490484
font-size: 0.9rem;
491485
}
492486
493-
/* ===== GALLERY PANEL ===== */
494-
.gallery-cats {
495-
display: flex;
496-
justify-content: center;
497-
gap: 0.5rem;
498-
margin-bottom: 1.5rem;
499-
flex-wrap: wrap;
500-
}
501-
502-
.gallery-cat-btn {
503-
padding: 0.4rem 1.2rem;
504-
border: 1px solid var(--c-blossom);
505-
background: transparent;
506-
color: var(--c-blossom-deep);
507-
border-radius: 999px;
508-
font-family: 'ZCOOL XiaoWei', serif;
509-
font-size: 0.9rem;
510-
cursor: pointer;
511-
transition: all 0.25s ease;
512-
letter-spacing: 0.06em;
513-
}
514-
515-
.gallery-cat-btn:hover {
516-
background: var(--c-blossom-wash);
517-
}
518-
519-
.gallery-cat-btn.active {
520-
background: var(--c-blossom-deep);
521-
color: white;
522-
border-color: var(--c-blossom-deep);
523-
}
524-
525-
.gallery-grid {
526-
display: grid;
527-
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
528-
gap: 1rem;
529-
}
530-
531-
.gallery-cell {
532-
display: flex;
533-
flex-direction: column;
534-
align-items: center;
535-
cursor: pointer;
536-
transition: transform 0.25s ease;
537-
}
538-
539-
.gallery-cell:hover {
540-
transform: scale(1.04);
541-
}
542-
543-
.gallery-cell img {
544-
width: 100%;
545-
border-radius: 0.75rem;
546-
background: white;
547-
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
548-
border: 1px solid rgba(232, 160, 180, 0.12);
549-
}
550-
551-
.gallery-cell-name {
552-
font-size: 0.8rem;
553-
color: var(--c-ink-light);
554-
margin-top: 0.4rem;
555-
letter-spacing: 0.04em;
556-
}
557-
558-
.gallery-credit {
559-
text-align: center;
560-
font-size: 0.78rem;
561-
color: var(--c-ink-light);
562-
margin-top: 1.5rem;
563-
opacity: 0.6;
564-
}
565-
566-
/* ===== LIGHTBOX ===== */
567-
.lightbox {
568-
position: fixed;
569-
inset: 0;
570-
z-index: 9999;
571-
background: rgba(0, 0, 0, 0.7);
572-
backdrop-filter: blur(4px);
573-
display: flex;
574-
align-items: center;
575-
justify-content: center;
576-
animation: lb-in 0.2s ease;
577-
cursor: pointer;
578-
}
579-
580-
@keyframes lb-in {
581-
from { opacity: 0; }
582-
to { opacity: 1; }
583-
}
584-
585-
.lightbox-img {
586-
max-width: 90vw;
587-
max-height: 85vh;
588-
border-radius: 0.75rem;
589-
box-shadow: 0 16px 64px rgba(0, 0, 0, 0.3);
590-
cursor: default;
591-
}
592-
593-
.lightbox-close {
594-
position: absolute;
595-
top: 1.5rem;
596-
right: 1.5rem;
597-
width: 2.5rem;
598-
height: 2.5rem;
599-
border: none;
600-
background: rgba(255, 255, 255, 0.15);
601-
color: white;
602-
font-size: 1.5rem;
603-
border-radius: 50%;
604-
cursor: pointer;
605-
display: flex;
606-
align-items: center;
607-
justify-content: center;
608-
backdrop-filter: blur(8px);
609-
transition: background 0.2s;
610-
}
611-
612-
.lightbox-close:hover {
613-
background: rgba(255, 255, 255, 0.3);
614-
}
615-
616487
/* ===== MOBILE ===== */
617488
@media (max-width: 640px) {
618489
.ann-header {
@@ -648,11 +519,6 @@ onMounted(() => {
648519
font-size: 1.25rem;
649520
}
650521
651-
.gallery-grid {
652-
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
653-
gap: 0.75rem;
654-
}
655-
656522
.home-cards {
657523
grid-template-columns: 1fr;
658524
max-width: 320px;

src/views/CelebrationView.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<script setup lang="ts">
22
import { ref, onMounted, watch } from 'vue';
33
import BlessingBar from '../components/BlessingBar.vue';
4+
import { ROUTES } from '../config/routes';
5+
import { goTo, goToResponsivePage } from '../utils/navigation';
46
57
function gamePage() {
6-
if (!window.matchMedia("(min-width: 768px)").matches) {
7-
window.location.href = "/anniversary/2025/web-mobile/index.html"
8-
} else {
9-
window.location.href = "/anniversary/2025/web-desktop/index.html"
10-
}
8+
goToResponsivePage(ROUTES.anniversary2025.webMobile, ROUTES.anniversary2025.webDesktop)
119
}
1210
1311
function holePage() {
14-
window.location.href = "/anniversary/2025/hole"
12+
goTo(ROUTES.anniversary2025.hole)
1513
}
1614
1715
function recruitPage() {
@@ -23,7 +21,7 @@ function officialAccountPage() {
2321
}
2422
2523
function galleryPage() {
26-
window.location.href = "/anniversary/2025/gallery"
24+
goTo(ROUTES.anniversary2025.gallery)
2725
}
2826
2927
const src = ref("")
@@ -74,4 +72,4 @@ function imgLoad() {
7472
</div>
7573
</template>
7674

77-
<style scoped></style>
75+
<style scoped></style>

src/views/GalleryView.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script setup>
2-
function goBack() {
3-
window.history.back()
4-
}
2+
import { goBack } from '../utils/navigation'
53
</script>
64

75
<template>

0 commit comments

Comments
 (0)