-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
230 lines (200 loc) · 7.23 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RSS 阅读器</title>
<link rel="icon" type="image/png" href="/favicon.png">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
<link href="https://cdn.staticfile.net/twitter-bootstrap/5.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.staticfile.net/twitter-bootstrap/5.1.1/js/bootstrap.bundle.min.js"></script>
<style>
/* 全局样式 */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
color: #333;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
overflow: hidden;
position: relative; /* 使右下角文本定位相对 */
}
/* 容器样式 */
.container {
max-width: 600px;
width: 90%;
background: #fff;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0,0,0,0.15);
padding: 30px;
text-align: center;
overflow-y: auto; /* 允许上下滚动 */
max-height: 90vh; /* 限制容器的最大高度 */
animation: fadeIn 1s ease;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
h2 {
color: #333;
margin-bottom: 20px;
font-size: 1.8em;
font-weight: bold;
}
/* 输入框和按钮 */
#rss-url, button {
width: 100%;
padding: 12px;
font-size: 1em;
margin: 8px 0;
border-radius: 8px;
border: 1px solid #ddd;
box-sizing: border-box;
}
#rss-url:focus {
outline: none;
border-color: #2575fc;
}
button {
background: #6a11cb;
color: #fff;
border: none;
cursor: pointer;
transition: background 0.3s;
}
button:hover {
background: #2575fc;
}
/* RSS 订阅条目样式 */
.feed-item {
padding: 20px;
margin-top: 15px;
background: #f8f9fd;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
transition: transform 0.3s;
}
.feed-item:hover {
transform: translateY(-5px);
box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.feed-item h3 {
font-size: 1.2em;
margin: 0;
color: #2575fc;
}
.feed-item a {
text-decoration: none;
color: inherit;
}
.feed-item a:hover {
color: #6a11cb;
}
.feed-item p {
color: #555;
font-size: 0.9em;
margin: 8px 0;
}
/* 加载动画 */
#feed p {
animation: fadeIn 0.5s ease;
font-size: 1.1em;
}
/* 响应式 */
@media (max-width: 768px) {
.container {
padding: 20px;
}
h2 {
font-size: 1.5em;
}
}
a {
text-decoration: none;
padding: 5px;
transition: all 0.3s ease; /* 添加过渡效果 */
}
/* 鼠标悬停时改变样式 */
a:hover {
background-color: lightgray;
text-decoration: underline;
}
/* 点击时反色 */
a:active {
color: white;
background-color: blue;
}
/* 右下角文本样式 */
.footer-text {
position: absolute;
right: 20px;
bottom: 20px;
color: white;
font-size: 1em;
padding: 5px 10px;
border-radius: 5px;
}
</style>
<script>
// 当页面加载完成后执行此函数
window.onload = function() {
// 获取输入框元素
var input = document.getElementById('rss-url');
// 设置输入框的值
input.value = 'https://blog.mcenahle.com/feed'; /* 清除URL,以阻止自动输入 */
};
</script>
</head>
<body>
<div class="container">
<h2><i class="bi bi-rss"></i> RSS 阅读器</h2>
<input type="text" id="rss-url" placeholder="输入 RSS 订阅链接">
<button onclick="fetchRSS()"><b><i class="bi bi-arrow-return-right"></i> 获取 RSS</b></button>
<p><a href="https://open-source.mcenahle.org/" target="_blank"> 本项目开源链接:https://open-source.mcenahle.org/</a> <i class="bi bi-box-arrow-up-right"></i></p>
<div id="feed"></div>
</div>
<!-- 右下角的文字 -->
<div class="footer-text"><b>RSS 阅读器 - rss.mcenahle.org</b></div>
<script>
async function fetchRSS() {
const rssUrl = document.getElementById('rss-url').value;
const feedContainer = document.getElementById('feed');
feedContainer.innerHTML = '<p><i class="bi bi-hourglass-split"></i> 加载中...</p>';
try {
const response = await fetch(`https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(rssUrl)}`);
const data = await response.json();
if (data.status !== 'ok') {
feedContainer.innerHTML = '<p><i class="bi bi-exclamation-triangle"></i> 无法获取 RSS 源,请检查链接,或者输入是否正确。</p>';
return;
}
feedContainer.innerHTML = '';
data.items.slice(0, 3).forEach(item => {
const feedItem = document.createElement('div');
feedItem.classList.add('feed-item');
// 限制描述长度
const truncatedDescription = item.description.length > 50
? item.description.slice(0, 50) + '...'
: item.description;
feedItem.innerHTML = `
<h3><a href="${item.link}" target="_blank"><b>${item.title}</b></a> <i class="bi bi-box-arrow-up-right"></i></h3>
<p>发布时间:${new Date(item.pubDate).toLocaleDateString()}</p>
<p>${truncatedDescription}</p>
`;
feedContainer.appendChild(feedItem);
});
// 添加获取更多链接
const moreLink = document.createElement('p');
moreLink.innerHTML = `<br> 若要获取其他 RSS 资源,请转到 <a href="${data.feed.link}" target="_blank"><b>${data.feed.title}</b></a> <i class="bi bi-box-arrow-up-right"></i>。`;
feedContainer.appendChild(moreLink);
} catch (error) {
feedContainer.innerHTML = `<p>加载失败: ${error.message}</p>`;
}
}
</script>
</body>
</html>