Skip to content

Commit cd17dc3

Browse files
authored
Merge pull request #114 from katagomo/main
更新页面样式
2 parents 7cc78d6 + 0297880 commit cd17dc3

File tree

5 files changed

+277
-97
lines changed

5 files changed

+277
-97
lines changed

api/source.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def redirect_to_welcome():
1717

1818

1919
@app.route('/acknowledgments')
20+
@app.route('/acknowledgments.html')
2021
def acknowledgments():
2122
return send_from_directory(src_path, 'acknowledgments.html')
2223

src/acknowledgments.html

+123-69
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>LrcAPI - 致谢名单</title>
6+
<title>致谢名单</title>
77
<link rel="stylesheet" href="/src/css/v50.css">
88
<style>
99
.barrage-container {
@@ -17,6 +17,19 @@
1717
overflow: hidden;
1818
}
1919

20+
.financial-status {
21+
opacity: 0;
22+
transform: translateY(20px);
23+
animation: fadeInUp 0.8s ease forwards;
24+
}
25+
26+
@keyframes fadeInUp {
27+
to {
28+
opacity: 1;
29+
transform: translateY(0);
30+
}
31+
}
32+
2033
.barrage-item {
2134
position: fixed;
2235
white-space: nowrap;
@@ -27,22 +40,16 @@
2740
transform: translateX(100vw);
2841
}
2942
</style>
43+
<script src="/src/js/site-config.js"></script>
44+
<script src="/src/js/common-elements.js"></script>
45+
<script>
46+
document.addEventListener('DOMContentLoaded', () => {
47+
document.title = `${siteConfig.site.name} - 致谢名单`;
48+
});
49+
</script>
3050
</head>
3151
<body>
32-
<header>
33-
<div class="logo-container">
34-
<img src="/src/img/LrcAPI-Text-Extra.png" alt="LrcAPI Logo" class="logo">
35-
<span class="project-name">LrcAPI</span>
36-
</div>
37-
<div class="github-link">
38-
<a href="https://github.com/hisatri/LrcAPI" class="github-button">
39-
<svg height="20" viewBox="0 0 16 16" width="20" class="github-icon">
40-
<path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
41-
</svg>
42-
GitHub
43-
</a>
44-
</div>
45-
</header>
52+
<header></header>
4653

4754
<div class="barrage-container" id="barrageContainer"></div>
4855

@@ -51,6 +58,14 @@ <h1>致谢名单</h1>
5158
<div class="acknowledgment-content">
5259
<p style="text-align: center">感谢所有支持 LrcAPI 项目发展的朋友们。LrcAPI 是一个完全免费的开源项目,它的发展离不开社区成员的支持。在此特别感谢以下支持者的慷慨赞助</p>
5360
<p class="subtitle" style="text-align: center">*排名不分先后。如果我们遗漏了您的名字,请您随时通过赞助渠道联系我们,我们将及时更新。</p>
61+
<div id="financialStatus" class="financial-status" style="text-align: center; margin-bottom: 30px;">
62+
<p style="color: #666; margin-bottom: 10px;">项目运营状况</p>
63+
<h1 id="financialAmount" style="font-weight: bold; display: inline-block; margin: 10px 0;"></h1>
64+
<p style="color: #666; font-size: 0.9em;">
65+
<span style="color: #2ecc71;">正值</span>代表项目有结余 |
66+
<span style="color: #e74c3c;">负值</span>代表项目需要赞助
67+
</p>
68+
</div>
5469
<div class="supporters-list">
5570
<div class="supporter-card">
5671
<h3>项目赞助者</h3>
@@ -62,9 +77,7 @@ <h3>项目赞助者</h3>
6277
</div>
6378
</main>
6479

65-
<footer>
66-
<p class="license-text">本项目基于 <a href="https://github.com/HisAtri/LrcApi/blob/main/LICENSE" target="_blank" style="color: gray; text-decoration: none;">GNU General Public License v3.0</a> 开源协议发布 | <a href="/">回到主页</a></p>
67-
</footer>
80+
<footer></footer>
6881

6982
<script>
7083
class BarrageSystem {
@@ -146,33 +159,6 @@ <h3>项目赞助者</h3>
146159
}
147160
}
148161

149-
// 初始化弹幕系统
150-
const barrageSystem = new BarrageSystem();
151-
// 消息数据,在这里添加需要显示的弹幕
152-
const messages = [
153-
"项目越来越好!",
154-
"加油!继续努力!",
155-
"很棒的项目!",
156-
"支持开源!",
157-
"希望项目能一直维护下去",
158-
"太赞了!",
159-
"非常实用的API",
160-
"非常好的项目,爱来自LinuxDo",
161-
"我是Mio,请你吃疯狂星期四",
162-
"Good Job!",
163-
"感谢开发LRCAPI",
164-
"真好用",
165-
"完美,好东西!",
166-
"很棒!继续加油"
167-
];
168-
// 定期发送弹幕,使用可变的时间间隔
169-
function sendRandomMessage() {
170-
const msg = messages[Math.floor(Math.random() * messages.length)];
171-
barrageSystem.addMessage(msg);
172-
// 在此处调整弹幕发送频率(当前为0.5-2秒)
173-
setTimeout(sendRandomMessage, 500 + Math.random() * 1500);
174-
}
175-
sendRandomMessage();
176162
// 定义支持者卡片组件
177163
class SupporterCard extends HTMLElement {
178164
constructor() {
@@ -190,30 +176,98 @@ <h3>项目赞助者</h3>
190176
}
191177

192178
customElements.define('supporter-card', SupporterCard);
193-
// 支持者数据,在这里添加需要显示的支持者和赞助金额
194-
const supporters = [
195-
{ name: 'XinLoong', amount: 10.00 },
196-
{ name: '木羽', amount: 5.00 },
197-
{ name: '依然不懂', amount: 5.00 },
198-
{ name: '扑克', amount: 20.00 },
199-
{ name: '未知', amount: 10.00 },
200-
{ name: 'yule', amount: 10.00 },
201-
{ name: 'Erikaze', amount: 90.00 },
202-
{ name: 'hikaru', amount: 10.00 },
203-
{ name: 'KawaKaze', amount: 6.66 },
204-
{ name: 'Mio', amount: 50.00 },
205-
{ name: '呜噜噜', amount: 50.00 }
206-
];
207-
const supportersGrid = document.getElementById('supportersGrid');
208-
supporters.forEach(supporter => {
209-
const li = document.createElement('li');
210-
li.className = 'supporter-box';
211-
212-
const card = document.createElement('supporter-card');
213-
card.supporter = supporter;
214-
215-
li.appendChild(card);
216-
supportersGrid.appendChild(li);
179+
180+
// 模块控制器
181+
class ModuleController {
182+
constructor(config) {
183+
this.config = config;
184+
this.init();
185+
}
186+
187+
init() {
188+
// 初始化财务状况显示
189+
if (this.config.financial.enabled) {
190+
this.initFinancial();
191+
} else {
192+
document.getElementById('financialStatus').style.display = 'none';
193+
}
194+
195+
// 初始化弹幕系统
196+
if (this.config.barrage.enabled) {
197+
this.initBarrage();
198+
} else {
199+
document.getElementById('barrageContainer').style.display = 'none';
200+
}
201+
202+
// 初始化支持者列表
203+
if (this.config.supporters.enabled) {
204+
this.initSupporters();
205+
} else {
206+
document.querySelector('.supporters-list').style.display = 'none';
207+
}
208+
}
209+
210+
initFinancial() {
211+
const financial = this.config.financial;
212+
const element = document.getElementById('financialAmount');
213+
const startValue = 0;
214+
const endValue = financial.amount;
215+
const duration = financial.duration;
216+
const currency = financial.currency;
217+
218+
// 设置颜色
219+
element.style.color = endValue >= 0 ? '#2ecc71' : '#e74c3c';
220+
221+
// 使用 CSS cubic-bezier 实现动画效果
222+
const startTime = performance.now();
223+
224+
function update(currentTime) {
225+
const elapsed = currentTime - startTime;
226+
const progress = Math.min(elapsed / duration, 1);
227+
228+
// 使用缓动函数使动画更自然
229+
const easeProgress = progress < 0.5
230+
? 4 * progress * progress * progress
231+
: 1 - Math.pow(-2 * progress + 2, 3) / 2;
232+
233+
const currentValue = startValue + (endValue - startValue) * easeProgress;
234+
element.textContent = `${currency}${currentValue.toFixed(2)}`;
235+
236+
if (progress < 1) {
237+
requestAnimationFrame(update);
238+
}
239+
}
240+
241+
requestAnimationFrame(update);
242+
}
243+
244+
initBarrage() {
245+
const barrageSystem = new BarrageSystem();
246+
const sendRandomMessage = () => {
247+
const messages = this.config.barrage.messages;
248+
const msg = messages[Math.floor(Math.random() * messages.length)];
249+
barrageSystem.addMessage(msg);
250+
setTimeout(sendRandomMessage, 500 + Math.random() * 1500);
251+
};
252+
sendRandomMessage();
253+
}
254+
255+
initSupporters() {
256+
const supportersGrid = document.getElementById('supportersGrid');
257+
this.config.supporters.data.forEach(supporter => {
258+
const li = document.createElement('li');
259+
li.className = 'supporter-box';
260+
const card = document.createElement('supporter-card');
261+
card.supporter = supporter;
262+
li.appendChild(card);
263+
supportersGrid.appendChild(li);
264+
});
265+
}
266+
}
267+
268+
// 初始化模块控制器
269+
document.addEventListener('DOMContentLoaded', () => {
270+
new ModuleController(siteConfig.acknowledgments);
217271
});
218272
</script>
219273
</body>

src/index.html

+11-28
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
<!DOCTYPE html>
22
<html lang="zh">
3-
<!--
4-
本目录为项目 LrcAPI 的一部分
5-
本目录及其相关联的前端界面代码采用 Apache License 2.0 许可证开源
6-
项目源代码地址:https://github.com/HisAtri/DonateMe
7-
8-
注意:本目录是原 GPL-3.0 项目的一个组件,但经原作者明确声明,
9-
本目录及其相关联的前端界面代码采用 Apache License 2.0 许可证单独授权,不受GPL-3.0协议限制。
10-
其余项目代码仍然遵循 GNU GPL-3.0 许可证。
11-
*“本目录”仅包含css/html/js,不包含本项目的Logo图片等资源
12-
-->
133
<head>
144
<meta charset="UTF-8">
155
<meta name="viewport" content="width=device-width, initial-scale=1.0">
16-
<title>LrcAPI - 支持我们</title>
6+
<title>支持我们</title>
177
<link rel="stylesheet" href="/src/css/v50.css">
8+
<script src="/src/js/site-config.js"></script>
9+
<script src="/src/js/common-elements.js"></script>
10+
<script>
11+
document.addEventListener('DOMContentLoaded', () => {
12+
document.title = `${siteConfig.site.name} - 支持我们`;
13+
});
14+
</script>
1815
</head>
1916
<body>
20-
<header>
21-
<div class="logo-container">
22-
<img src="/src/img/LrcAPI-Text-Extra.png" alt="LrcAPI Logo" class="logo">
23-
<span class="project-name">LrcAPI</span>
24-
</div>
25-
<div class="github-link">
26-
<a href="https://github.com/hisatri/LrcAPI" class="github-button">
27-
<svg height="20" viewBox="0 0 16 16" width="20" class="github-icon">
28-
<path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
29-
</svg>
30-
GitHub
31-
</a>
32-
</div>
33-
</header>
17+
<header></header>
3418

3519
<main>
3620
<h1>支持我们的开源项目</h1>
@@ -69,8 +53,7 @@ <h3>合作伙伴支持</h3>
6953
</div>
7054
</div>
7155
</main>
72-
<footer>
73-
<p class="license-text">本项目基于 <a href="https://github.com/HisAtri/LrcApi/blob/main/LICENSE" target="_blank" style="color: gray; text-decoration: none;">GNU General Public License v3.0</a> 开源协议发布 | <a href="/acknowledgments">致谢名单</a></p>
74-
</footer>
56+
57+
<footer></footer>
7558
</body>
7659
</html>

src/js/common-elements.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
class CommonElements {
2+
constructor(config) {
3+
this.config = config;
4+
}
5+
6+
// 渲染页头
7+
renderHeader() {
8+
const header = document.createElement('header');
9+
header.innerHTML = `
10+
<div class="logo-container" style="cursor: pointer">
11+
<img src="${this.config.site.logo}" alt="${this.config.site.name} Logo" class="logo">
12+
<span class="project-name">${this.config.site.name}</span>
13+
</div>
14+
<div class="github-link">
15+
<a href="${this.config.site.github}" class="github-button">
16+
<svg height="20" viewBox="0 0 16 16" width="20" class="github-icon">
17+
<path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
18+
</svg>
19+
GitHub
20+
</a>
21+
</div>
22+
`;
23+
24+
// 添加点击事件监听器
25+
const logoContainer = header.querySelector('.logo-container');
26+
logoContainer.addEventListener('click', () => {
27+
window.location.href = '/';
28+
});
29+
30+
return header;
31+
}
32+
33+
// 渲染页脚
34+
renderFooter() {
35+
const footer = document.createElement('footer');
36+
const footerLinks = this.config.navigation
37+
.filter(item => item.showInFooter)
38+
.map(item => `<a href="${item.url}">${item.text}</a>`)
39+
.join(' | ');
40+
41+
footer.innerHTML = `
42+
<p class="license-text">
43+
本项目基于 <a href="${this.config.site.license.url}" target="_blank" style="color: gray; text-decoration: none;">
44+
${this.config.site.license.name}
45+
</a> 开源协议发布 | ${footerLinks}
46+
</p>
47+
`;
48+
return footer;
49+
}
50+
51+
// 初始化页面公共元素
52+
init() {
53+
// 替换页头
54+
const existingHeader = document.querySelector('header');
55+
if (existingHeader) {
56+
existingHeader.replaceWith(this.renderHeader());
57+
}
58+
59+
// 替换页脚
60+
const existingFooter = document.querySelector('footer');
61+
if (existingFooter) {
62+
existingFooter.replaceWith(this.renderFooter());
63+
}
64+
}
65+
}
66+
67+
// 当DOM加载完成后初始化
68+
document.addEventListener('DOMContentLoaded', () => {
69+
const commonElements = new CommonElements(siteConfig);
70+
commonElements.init();
71+
});

0 commit comments

Comments
 (0)