@@ -48,6 +48,167 @@ jobs:
4848 NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
4949 run : pnpm release
5050
51+ deploy-benchmark-report :
52+ needs : release
53+ runs-on : ubuntu-latest
54+ permissions :
55+ contents : write
56+ pages : write
57+ steps :
58+ - name : Checkout
59+ uses : actions/checkout@v4
60+ with :
61+ fetch-depth : 0
62+
63+ - name : Using pnpm
64+ uses : pnpm/action-setup@v3
65+ with :
66+ version : 9.3.0
67+
68+ - name : Setup Node
69+ uses : actions/setup-node@v4
70+ with :
71+ node-version : 20
72+ cache : pnpm
73+
74+ - name : Install dependencies
75+ run : pnpm install
76+
77+ - name : Run benchmark tests
78+ run : pnpm benchmark:worker
79+
80+ - name : Create Reports Directory
81+ run : |
82+ mkdir -p gh-pages-deploy/benchmark-reports
83+ cp -r benchmark-reports/* gh-pages-deploy/benchmark-reports/
84+
85+ # 创建索引页面
86+ cat > gh-pages-deploy/benchmark-reports/index.html << EOF
87+ <!DOCTYPE html>
88+ <html lang="zh-CN">
89+ <head>
90+ <meta charset="UTF-8">
91+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
92+ <title>Vue Styled Components 性能基准测试报告</title>
93+ <style>
94+ body {
95+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
96+ max-width: 1000px;
97+ margin: 0 auto;
98+ padding: 20px;
99+ line-height: 1.6;
100+ }
101+ h1 { color: #2c3e50; }
102+ .report-list {
103+ list-style: none;
104+ padding: 0;
105+ }
106+ .report-item {
107+ margin-bottom: 10px;
108+ padding: 15px;
109+ border-radius: 8px;
110+ background-color: #f8f9fa;
111+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
112+ }
113+ .report-link {
114+ display: block;
115+ color: #3498db;
116+ font-weight: bold;
117+ text-decoration: none;
118+ }
119+ .report-link:hover {
120+ text-decoration: underline;
121+ }
122+ .report-date {
123+ color: #7f8c8d;
124+ font-size: 0.9em;
125+ margin-top: 5px;
126+ }
127+ </style>
128+ </head>
129+ <body>
130+ <h1>Vue Styled Components 性能基准测试报告</h1>
131+ <p>此页面列出了所有可用的性能基准测试报告。点击链接查看详细报告。</p>
132+
133+ <ul class="report-list" id="reportList">
134+ <!-- 报告列表将通过JavaScript动态生成 -->
135+ <li>正在加载报告列表...</li>
136+ </ul>
137+
138+ <script>
139+ // 动态加载并显示报告列表
140+ async function loadReports() {
141+ const reportList = document.getElementById('reportList');
142+ reportList.innerHTML = '';
143+
144+ try {
145+ // 获取当前目录下的HTML文件列表
146+ const response = await fetch('.');
147+ const text = await response.text();
148+ const parser = new DOMParser();
149+ const doc = parser.parseFromString(text, 'text/html');
150+ const links = Array.from(doc.querySelectorAll('a'))
151+ .filter(a => a.href.endsWith('.html') && a.href !== 'index.html');
152+
153+ // 按修改日期排序(最新的在前)
154+ links.sort((a, b) => {
155+ return b.href.localeCompare(a.href);
156+ });
157+
158+ if (links.length === 0) {
159+ reportList.innerHTML = '<li>暂无可用报告</li>';
160+ return;
161+ }
162+
163+ // 创建报告列表
164+ links.forEach(link => {
165+ const fileName = link.href.split('/').pop();
166+ // 从文件名中提取时间戳
167+ const dateMatch = fileName.match(/benchmark-report-(.*?)\.html/);
168+ let dateStr = '';
169+
170+ if (dateMatch && dateMatch[1]) {
171+ // 将时间戳转换为更友好的格式
172+ const timestamp = dateMatch[1].replace(/T/g, ' ').replace(/-/g, ':');
173+ try {
174+ const date = new Date(timestamp);
175+ dateStr = date.toLocaleString('zh-CN');
176+ } catch(e) {
177+ dateStr = timestamp;
178+ }
179+ }
180+
181+ const li = document.createElement('li');
182+ li.className = 'report-item';
183+ li.innerHTML = `
184+ <a href="${fileName}" class="report-link">性能测试报告 - ${dateStr || fileName}</a>
185+ <div class="report-date">生成于: ${dateStr || '未知时间'}</div>
186+ `;
187+ reportList.appendChild(li);
188+ });
189+ } catch (error) {
190+ reportList.innerHTML = '<li>加载报告列表失败</li>';
191+ console.error('加载报告列表失败:', error);
192+ }
193+ }
194+
195+ // 页面加载后执行
196+ document.addEventListener('DOMContentLoaded', loadReports);
197+ </script>
198+ </body>
199+ </html>
200+ EOF
201+
202+ - name : Deploy to GitHub Pages
203+ uses : JamesIves/github-pages-deploy-action@v4
204+ with :
205+ folder : gh-pages-deploy
206+ target-folder : benchmark-reports
207+ clean : false
208+ clean-exclude : |
209+ !benchmark-reports/**/*
210+ token : ${{ secrets.GITHUB_TOKEN }}
211+
51212 sync-beta :
52213 runs-on : ubuntu-latest
53214 needs : release
0 commit comments