@@ -82,122 +82,69 @@ jobs:
82
82
mkdir -p gh-pages-deploy/benchmark-reports
83
83
cp -r worker-benchmark/benchmark-reports/* gh-pages-deploy/benchmark-reports/
84
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
85
+ # 创建索引页面 - 使用echo命令逐行添加内容而不是heredoc
86
+ echo '<!DOCTYPE html>' > gh-pages-deploy/benchmark-reports/index.html
87
+ echo '<html lang="zh-CN">' >> gh-pages-deploy/benchmark-reports/index.html
88
+ echo '<head>' >> gh-pages-deploy/benchmark-reports/index.html
89
+ echo ' <meta charset="UTF-8">' >> gh-pages-deploy/benchmark-reports/index.html
90
+ echo ' <meta name="viewport" content="width=device-width, initial-scale=1.0">' >> gh-pages-deploy/benchmark-reports/index.html
91
+ echo ' <title>Vue Styled Components 性能基准测试报告</title>' >> gh-pages-deploy/benchmark-reports/index.html
92
+ echo ' <style>' >> gh-pages-deploy/benchmark-reports/index.html
93
+ echo ' body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 1000px; margin: 0 auto; padding: 20px; line-height: 1.6; }' >> gh-pages-deploy/benchmark-reports/index.html
94
+ echo ' h1 { color: #2c3e50; }' >> gh-pages-deploy/benchmark-reports/index.html
95
+ echo ' .report-list { list-style: none; padding: 0; }' >> gh-pages-deploy/benchmark-reports/index.html
96
+ echo ' .report-item { margin-bottom: 10px; padding: 15px; border-radius: 8px; background-color: #f8f9fa; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }' >> gh-pages-deploy/benchmark-reports/index.html
97
+ echo ' .report-link { display: block; color: #3498db; font-weight: bold; text-decoration: none; }' >> gh-pages-deploy/benchmark-reports/index.html
98
+ echo ' .report-link:hover { text-decoration: underline; }' >> gh-pages-deploy/benchmark-reports/index.html
99
+ echo ' .report-date { color: #7f8c8d; font-size: 0.9em; margin-top: 5px; }' >> gh-pages-deploy/benchmark-reports/index.html
100
+ echo ' </style>' >> gh-pages-deploy/benchmark-reports/index.html
101
+ echo '</head>' >> gh-pages-deploy/benchmark-reports/index.html
102
+ echo '<body>' >> gh-pages-deploy/benchmark-reports/index.html
103
+ echo ' <h1>Vue Styled Components 性能基准测试报告</h1>' >> gh-pages-deploy/benchmark-reports/index.html
104
+ echo ' <p>此页面列出了所有可用的性能基准测试报告。点击链接查看详细报告。</p>' >> gh-pages-deploy/benchmark-reports/index.html
105
+ echo ' <ul class="report-list" id="reportList">' >> gh-pages-deploy/benchmark-reports/index.html
106
+ echo ' <li>正在加载报告列表...</li>' >> gh-pages-deploy/benchmark-reports/index.html
107
+ echo ' </ul>' >> gh-pages-deploy/benchmark-reports/index.html
108
+ echo ' <script>' >> gh-pages-deploy/benchmark-reports/index.html
109
+ echo ' async function loadReports() {' >> gh-pages-deploy/benchmark-reports/index.html
110
+ echo ' const reportList = document.getElementById("reportList");' >> gh-pages-deploy/benchmark-reports/index.html
111
+ echo ' reportList.innerHTML = "";' >> gh-pages-deploy/benchmark-reports/index.html
112
+ echo ' try {' >> gh-pages-deploy/benchmark-reports/index.html
113
+ echo ' const response = await fetch(".");' >> gh-pages-deploy/benchmark-reports/index.html
114
+ echo ' const text = await response.text();' >> gh-pages-deploy/benchmark-reports/index.html
115
+ echo ' const parser = new DOMParser();' >> gh-pages-deploy/benchmark-reports/index.html
116
+ echo ' const doc = parser.parseFromString(text, "text/html");' >> gh-pages-deploy/benchmark-reports/index.html
117
+ echo ' const links = Array.from(doc.querySelectorAll("a")).filter(a => a.href.endsWith(".html") && a.href !== "index.html");' >> gh-pages-deploy/benchmark-reports/index.html
118
+ echo ' links.sort((a, b) => b.href.localeCompare(a.href));' >> gh-pages-deploy/benchmark-reports/index.html
119
+ echo ' if (links.length === 0) {' >> gh-pages-deploy/benchmark-reports/index.html
120
+ echo ' reportList.innerHTML = "<li>暂无可用报告</li>";' >> gh-pages-deploy/benchmark-reports/index.html
121
+ echo ' return;' >> gh-pages-deploy/benchmark-reports/index.html
122
+ echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
123
+ echo ' links.forEach(link => {' >> gh-pages-deploy/benchmark-reports/index.html
124
+ echo ' const fileName = link.href.split("/").pop();' >> gh-pages-deploy/benchmark-reports/index.html
125
+ echo ' const dateMatch = fileName.match(/benchmark-report-(.*?)\.html/);' >> gh-pages-deploy/benchmark-reports/index.html
126
+ echo ' let dateStr = "";' >> gh-pages-deploy/benchmark-reports/index.html
127
+ echo ' if (dateMatch && dateMatch[1]) {' >> gh-pages-deploy/benchmark-reports/index.html
128
+ echo ' const timestamp = dateMatch[1].replace(/T/g, " ").replace(/-/g, ":");' >> gh-pages-deploy/benchmark-reports/index.html
129
+ echo ' try {' >> gh-pages-deploy/benchmark-reports/index.html
130
+ echo ' const date = new Date(timestamp);' >> gh-pages-deploy/benchmark-reports/index.html
131
+ echo ' dateStr = date.toLocaleString("zh-CN");' >> gh-pages-deploy/benchmark-reports/index.html
132
+ echo ' } catch(e) { dateStr = timestamp; }' >> gh-pages-deploy/benchmark-reports/index.html
133
+ echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
134
+ echo ' const li = document.createElement("li");' >> gh-pages-deploy/benchmark-reports/index.html
135
+ echo ' li.className = "report-item";' >> gh-pages-deploy/benchmark-reports/index.html
136
+ echo ' li.innerHTML = `<a href="${fileName}" class="report-link">性能测试报告 - ${dateStr || fileName}</a><div class="report-date">生成于: ${dateStr || "未知时间"}</div>`;' >> gh-pages-deploy/benchmark-reports/index.html
137
+ echo ' reportList.appendChild(li);' >> gh-pages-deploy/benchmark-reports/index.html
138
+ echo ' });' >> gh-pages-deploy/benchmark-reports/index.html
139
+ echo ' } catch (error) {' >> gh-pages-deploy/benchmark-reports/index.html
140
+ echo ' reportList.innerHTML = "<li>加载报告列表失败</li>";' >> gh-pages-deploy/benchmark-reports/index.html
141
+ echo ' console.error("加载报告列表失败:", error);' >> gh-pages-deploy/benchmark-reports/index.html
142
+ echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
143
+ echo ' }' >> gh-pages-deploy/benchmark-reports/index.html
144
+ echo ' document.addEventListener("DOMContentLoaded", loadReports);' >> gh-pages-deploy/benchmark-reports/index.html
145
+ echo ' </script>' >> gh-pages-deploy/benchmark-reports/index.html
146
+ echo '</body>' >> gh-pages-deploy/benchmark-reports/index.html
147
+ echo '</html>' >> gh-pages-deploy/benchmark-reports/index.html
201
148
202
149
- name : Deploy to GitHub Pages
203
150
uses : JamesIves/github-pages-deploy-action@v4
0 commit comments