Skip to content

Commit b7bf113

Browse files
committed
Test: Has the blockage been fixed?
1 parent ab308ce commit b7bf113

10 files changed

Lines changed: 297 additions & 65 deletions

File tree

api/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Vercel Serverless 函数入口
2+
import type { VercelRequest, VercelResponse } from '@vercel/node';
3+
import app from '../backend/server';
4+
5+
export default async function handler(req: VercelRequest, res: VercelResponse) {
6+
return app(req as any, res as any);
7+
}
8+

frontend/index.html

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,83 @@
66
<title>TesLongXiao の 主页</title>
77
<link rel="icon" type="image/svg+xml" href="/vite.svg">
88

9-
<!-- DNS 预解析 -->
10-
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
11-
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
12-
<link rel="dns-prefetch" href="https://code.iconify.design">
13-
14-
<!-- 预连接 -->
9+
<!-- 预连接关键域名 -->
1510
<link rel="preconnect" href="https://fonts.googleapis.com">
1611
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
12+
<link rel="dns-prefetch" href="https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com">
13+
<link rel="dns-prefetch" href="https://api.teslongxiao.cn">
14+
<link rel="dns-prefetch" href="https://cdn.xcnya.cn">
1715

18-
<!-- 关键字体预加载 -->
19-
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Archivo:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&family=Cinzel:wght@400;500;600;700&display=swap" as="style">
20-
<link href="https://fonts.googleapis.com/css2?family=Archivo:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&family=Cinzel:wght@400;500;600;700&display=swap" rel="stylesheet">
21-
22-
<!-- Iconify Icons - 异步加载 -->
23-
<script async src="https://code.iconify.design/iconify-icon/1.0.7/iconify-icon.min.js"></script>
24-
25-
<!-- 内联关键 CSS 防止闪烁 -->
16+
<!-- 关键 CSS 内联,避免外部请求 -->
2617
<style>
27-
* {
28-
margin: 0;
29-
padding: 0;
30-
box-sizing: border-box;
31-
}
32-
33-
body {
34-
margin: 0;
35-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
36-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
37-
sans-serif;
38-
-webkit-font-smoothing: antialiased;
39-
-moz-osx-font-smoothing: grayscale;
40-
background: #0a0e27;
41-
color: #fff;
42-
overflow-x: hidden;
43-
}
44-
45-
#app {
46-
min-height: 100vh;
18+
/* 使用系统字体作为后备,避免字体加载阻塞 */
19+
:root {
20+
--font-fallback: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
4721
}
22+
</style>
23+
24+
<!-- 字体异步加载 -->
25+
<script>
26+
console.log('[Index] HTML 开始解析')
4827

49-
/* Loading 占位符 */
50-
.app-loading {
51-
position: fixed;
52-
top: 0;
53-
left: 0;
54-
width: 100vw;
55-
height: 100vh;
56-
background: linear-gradient(180deg, rgba(10, 14, 39, 1) 0%, rgba(26, 31, 58, 1) 50%, rgba(10, 14, 39, 1) 100%);
57-
display: flex;
58-
align-items: center;
59-
justify-content: center;
60-
z-index: 9999;
28+
// 延迟加载字体,避免阻塞渲染
29+
if ('requestIdleCallback' in window) {
30+
requestIdleCallback(function() {
31+
var link = document.createElement('link');
32+
link.rel = 'stylesheet';
33+
link.href = 'https://fonts.googleapis.com/css2?family=Archivo:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&family=Cinzel:wght@400;500;600;700&display=swap';
34+
document.head.appendChild(link);
35+
});
36+
} else {
37+
setTimeout(function() {
38+
var link = document.createElement('link');
39+
link.rel = 'stylesheet';
40+
link.href = 'https://fonts.googleapis.com/css2?family=Archivo:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&family=Cinzel:wght@400;500;600;700&display=swap';
41+
document.head.appendChild(link);
42+
}, 100);
6143
}
44+
</script>
45+
46+
<!-- Iconify 图标库 - 立即加载 -->
47+
<script src="https://code.iconify.design/iconify-icon/1.0.7/iconify-icon.min.js" defer></script>
48+
49+
<!-- 内联关键 CSS 防止闪烁 -->
50+
<style>
51+
*{margin:0;padding:0;box-sizing:border-box}
52+
body{margin:0;font-family:var(--font-fallback);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:#0a0e27;color:#fff;overflow-x:hidden}
53+
#app{min-height:100vh}
54+
.app-loading{position:fixed;top:0;left:0;width:100vw;height:100vh;background:linear-gradient(180deg,rgba(10,14,39,1) 0%,rgba(26,31,58,1) 50%,rgba(10,14,39,1) 100%);display:flex;align-items:center;justify-content:center;z-index:9999}
55+
.app-loading::after{content:'Loading...';font-size:2rem;color:rgba(202,215,255,0.9);animation:pulse 1.5s ease-in-out infinite}
56+
@keyframes pulse{0%,100%{opacity:0.5}50%{opacity:1}}
6257
</style>
6358
</head>
6459
<body>
6560
<div id="app">
6661
<!-- 初始加载占位符 -->
6762
<div class="app-loading"></div>
6863
</div>
64+
<script>
65+
console.log('[Index] 开始加载 main.js')
66+
console.time('[Index] main.js 加载时间')
67+
</script>
6968
<script type="module" src="/src/main.js"></script>
69+
<script>
70+
// 移除 loading 占位符
71+
window.addEventListener('load', function() {
72+
console.timeEnd('[Index] main.js 加载时间')
73+
console.log('[Index] 窗口完全加载')
74+
setTimeout(function() {
75+
var loading = document.querySelector('.app-loading');
76+
if (loading) {
77+
loading.style.transition = 'opacity 0.5s ease';
78+
loading.style.opacity = '0';
79+
setTimeout(function() {
80+
loading.remove();
81+
console.log('[Index] Loading 占位符已移除')
82+
}, 500);
83+
}
84+
}, 100);
85+
});
86+
</script>
7087
</body>
7188
</html>

frontend/public/music/playlist.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
"name": "pinKing",
55
"artist": "ChiliChill、陈Z-STUDIO",
66
"url": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/music/1.mp3",
7-
"cover": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/img/1.jpg"
7+
"cover": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/img/1.jpg?x-oss-process=image/resize,w_200,h_200/quality,q_80"
88
},
99
{
1010
"id": 2,
1111
"name": "不及",
1212
"artist": "蔡诗芸、陈Z-STUDIO、HOYO-MiX",
1313
"url": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/music/2.mp3",
14-
"cover": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/img/2.jpg"
14+
"cover": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/img/2.jpg?x-oss-process=image/resize,w_200,h_200/quality,q_80"
1515
},
1616
{
1717
"id": 3,
1818
"name": "Automaton Waltz",
1919
"artist": "PLUM",
2020
"url": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/music/3.mp3",
21-
"cover": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/img/3.jpg"
21+
"cover": "https://image-host-for-meta.oss-cn-hangzhou.aliyuncs.com/MusicPlayer/img/3.jpg?x-oss-process=image/resize,w_200,h_200/quality,q_80"
2222
}
2323
]

frontend/src/App.vue

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
<template>
22
<div id="app" class="relative min-h-screen">
3-
<router-view />
3+
<router-view v-slot="{ Component }">
4+
<transition name="fade" mode="out-in">
5+
<component :is="Component" />
6+
</transition>
7+
</router-view>
48
</div>
59
</template>
610

711
<script setup>
8-
import { onMounted } from 'vue'
12+
import { onMounted, onBeforeMount } from 'vue'
13+
14+
console.log('[App] App.vue 组件开始初始化')
15+
16+
onBeforeMount(() => {
17+
console.log('[App] App.vue onBeforeMount')
18+
})
919
1020
onMounted(() => {
21+
console.log('[App] App.vue onMounted')
1122
// 页面加载动画
1223
document.body.style.opacity = '0'
1324
setTimeout(() => {
1425
document.body.style.transition = 'opacity 1s ease'
1526
document.body.style.opacity = '1'
27+
console.log('[App] 页面淡入动画完成')
1628
}, 100)
1729
})
1830
</script>
@@ -21,5 +33,15 @@ onMounted(() => {
2133
#app {
2234
font-family: 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
2335
}
36+
37+
.fade-enter-active,
38+
.fade-leave-active {
39+
transition: opacity 0.3s ease;
40+
}
41+
42+
.fade-enter-from,
43+
.fade-leave-to {
44+
opacity: 0;
45+
}
2446
</style>
2547

frontend/src/components/cards/LinkCard.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
:src="link.icon"
1313
:alt="link.name"
1414
class="w-full h-full rounded-full object-cover border-2 border-white/10"
15+
loading="lazy"
16+
decoding="async"
17+
width="64"
18+
height="64"
1519
@error="handleImageError"
1620
/>
1721
<Icon v-else :icon="link.icon || 'ri:link'" width="48" height="48" />

frontend/src/main.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
console.log('[Main] 开始加载应用...')
2+
console.time('[Main] 总加载时间')
3+
14
import { createApp } from 'vue'
25
import { createRouter, createWebHistory } from 'vue-router'
36
import App from './App.vue'
47
import './assets/main.css'
8+
import { logPerformance, logResourceTiming } from './utils/performance'
9+
10+
console.log('[Main] Vue 和样式已导入')
11+
12+
// 启动性能监控
13+
logPerformance()
14+
logResourceTiming()
515

616
// 路由配置
717
const router = createRouter({
@@ -10,7 +20,15 @@ const router = createRouter({
1020
{
1121
path: '/',
1222
name: 'Home',
13-
component: () => import('./views/Home.vue')
23+
component: () => {
24+
console.log('[Router] 开始加载 Home.vue...')
25+
console.time('[Router] Home.vue 加载时间')
26+
return import('./views/Home.vue').then(module => {
27+
console.timeEnd('[Router] Home.vue 加载时间')
28+
console.log('[Router] Home.vue 加载完成')
29+
return module
30+
})
31+
}
1432
}
1533
],
1634
scrollBehavior(to, from, savedPosition) {
@@ -24,7 +42,15 @@ const router = createRouter({
2442
}
2543
})
2644

45+
console.log('[Main] 路由配置完成')
46+
2747
const app = createApp(App)
48+
console.log('[Main] App 实例创建完成')
49+
2850
app.use(router)
51+
console.log('[Main] 路由已注册')
52+
2953
app.mount('#app')
54+
console.log('[Main] App 已挂载到 DOM')
55+
console.timeEnd('[Main] 总加载时间')
3056

frontend/src/utils/performance.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// 性能监控工具
2+
export function logPerformance() {
3+
if (typeof window === 'undefined') return
4+
5+
window.addEventListener('load', () => {
6+
setTimeout(() => {
7+
const perfData = window.performance.timing
8+
const pageLoadTime = perfData.loadEventEnd - perfData.navigationStart
9+
const connectTime = perfData.responseEnd - perfData.requestStart
10+
const renderTime = perfData.domComplete - perfData.domLoading
11+
const domReadyTime = perfData.domContentLoadedEventEnd - perfData.navigationStart
12+
13+
console.group(' 性能指标')
14+
console.log(`页面总加载时间: ${pageLoadTime}ms`)
15+
console.log(`服务器连接时间: ${connectTime}ms`)
16+
console.log(`DOM 渲染时间: ${renderTime}ms`)
17+
console.log(`DOM Ready 时间: ${domReadyTime}ms`)
18+
console.groupEnd()
19+
20+
// 检测慢加载
21+
if (pageLoadTime > 3000) {
22+
console.warn('⚠️ 页面加载较慢,超过 3 秒')
23+
}
24+
if (connectTime > 1000) {
25+
console.warn('⚠️ 服务器响应较慢,超过 1 秒')
26+
}
27+
}, 0)
28+
})
29+
}
30+
31+
// 监控资源加载
32+
export function logResourceTiming() {
33+
if (typeof window === 'undefined') return
34+
35+
window.addEventListener('load', () => {
36+
setTimeout(() => {
37+
const resources = window.performance.getEntriesByType('resource')
38+
39+
console.group('📦 资源加载详情')
40+
41+
// 按类型分组
42+
const grouped = {}
43+
resources.forEach(resource => {
44+
const type = resource.initiatorType
45+
if (!grouped[type]) grouped[type] = []
46+
grouped[type].push({
47+
name: resource.name.split('/').pop(),
48+
duration: Math.round(resource.duration),
49+
size: resource.transferSize
50+
})
51+
})
52+
53+
Object.keys(grouped).forEach(type => {
54+
const items = grouped[type]
55+
const totalTime = items.reduce((sum, item) => sum + item.duration, 0)
56+
const totalSize = items.reduce((sum, item) => sum + (item.size || 0), 0)
57+
58+
console.log(`${type}: ${items.length} 个文件, ${totalTime}ms, ${(totalSize / 1024).toFixed(2)}KB`)
59+
60+
// 显示最慢的资源
61+
const slowest = items.sort((a, b) => b.duration - a.duration).slice(0, 3)
62+
slowest.forEach(item => {
63+
if (item.duration > 500) {
64+
console.warn(` ⚠️ ${item.name}: ${item.duration}ms`)
65+
}
66+
})
67+
})
68+
69+
console.groupEnd()
70+
}, 0)
71+
})
72+
}
73+

0 commit comments

Comments
 (0)