Skip to content

Commit b48d42d

Browse files
committed
feat: announcement bar
1 parent dc3c795 commit b48d42d

File tree

8 files changed

+214
-26
lines changed

8 files changed

+214
-26
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
**注意:请确保您 Fork 的仓库为最新,可通过自己仓库页面的【Sync fork】更新后再提交 PR!旧版仓库的合并会带来很多麻烦,感谢您的支持!**
1818

19-
QQ交流群:596520944
19+
QQ交流群:[596520944](https://qm.qq.com/q/EBKhjsGRbM)
2020

21-
~~喵呜,网站运营仍需经费,可以赏点钱吗?~~[爱发电](https://afdian.com/a/MCiSEE)
21+
<small>喵呜,网站运营仍需经费,可以赏点钱吗?</small> [爱发电](https://afdian.com/a/MCiSEE)
2222

2323
## 贡献教程
2424

THANKS.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77

88
诚心感谢所有贡献以及支持我们的个人/组织/项目等。
99

10+
感谢[籽岷](https://space.bilibili.com/686127)叔的宣传与支持。
11+
1012
排名不分先后。
1113

1214

1315
## 发电感谢
1416

1517
| 人员 | 捐献 |
1618
|-----------------------------------------------------|-----|
17-
| GitHub: [baiyuncode](https://github.com/baiyuncode) | 服务器 |
19+
| GitHub: [baiyun1123](https://github.com/baiyun1123) | 服务器 |
1820

1921

2022
## 依赖/引用的项目
@@ -84,6 +86,8 @@
8486

8587
Thank you to all the people/organizations/projects that have contributed or supported us.
8688

89+
Thank Uncle [Zi Min](https://space.bilibili.com/686127) for publicity and support.
90+
8791
The list is in no particular order.
8892

8993

assets/dark.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ a.button.important:hover {
5353
text-decoration-color: var(--apple-color-white);
5454
}
5555

56+
.announcement-bar {
57+
background-color: rgba(0, 0, 0, 0.2);
58+
}
59+
5660
hr {
5761
background-color: #cfc9c2;
5862
height: 1px;
@@ -303,7 +307,7 @@ details+hr {
303307
background-color: rgba(255, 255, 255, 0.3);
304308
}
305309

306-
text, h1, h2, h3, h4, h5, h6, p, input {
310+
text, h1, h2, h3, h4, h5, h6, p, input, .announcement-bar {
307311
color: var(--apple-color-white);
308312
}
309313

assets/lib/literary.css

+16-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ mdui-slider {
1313
writing-mode: lr;
1414
}
1515

16+
.announcement-bar {
17+
left: 0;
18+
width: 2vw;
19+
height: 100%;
20+
line-height: 2vw;
21+
z-index: 1000;
22+
}
23+
1624
.article img {
1725
max-width: 90px;
1826
}
@@ -93,4 +101,11 @@ mdui-tooltip {
93101
footer {
94102
position: relative;
95103
z-index: -1;
96-
}
104+
}
105+
106+
@keyframes announcement {
107+
0% { left: 4vh; opacity: 0; }
108+
15% { left: 0; opacity: 1; }
109+
75% { left: 0; opacity: 1; }
110+
100% { left: -2.5vh; opacity: 0; }
111+
}

assets/main.css

+42-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,36 @@ div[id]>*:first-child {
117117
white-space: nowrap;
118118
}
119119

120+
.announcement-bar {
121+
position: fixed;
122+
top: 0;
123+
width: 100%;
124+
height: max(4vh, max-content);
125+
background-color: rgba(214, 213, 218, 0.2);
126+
line-height: 4vh;
127+
text-align: center;
128+
margin: auto;
129+
font-size: 14px;
130+
z-index: 0;
131+
overflow: hidden;
132+
}
133+
134+
.announcement-bar ul {
135+
list-style: none;
136+
}
137+
138+
.announcement-bar li {
139+
position: relative;
140+
}
141+
142+
.announcement-bar li.announcement-1 {
143+
animation: announcement 5s ease-out forwards;
144+
}
145+
146+
.announcement-bar li:not(.announcement-1) {
147+
display: none;
148+
}
149+
120150
.apf:hover {
121151
transform: scale(1.05) rotate(-1deg);
122152
transition: transform 0.5s;
@@ -196,7 +226,7 @@ div[id]>*:first-child {
196226
}
197227

198228
.article h3 {
199-
margin: 16px 0;
229+
margin: 0.5em 0;
200230
}
201231

202232
.article h3:first-child {
@@ -407,6 +437,10 @@ summary::before {
407437
transform: rotate(90deg);
408438
}
409439

440+
summary.noicon::before {
441+
display: none;
442+
}
443+
410444
details {
411445
max-height: 1em;
412446
transition: max-height 2s;
@@ -462,6 +496,13 @@ a.button img {
462496
}
463497

464498

499+
@keyframes announcement {
500+
0% { top: 4vh; opacity: 0; }
501+
15% { top: 0; opacity: 1; }
502+
75% { top: 0; opacity: 1; }
503+
100% { top: -2.5vh; opacity: 0; }
504+
}
505+
465506
@keyframes h-shake {
466507
10%, 90% { transform: translate3d(-1px, 0, 0); }
467508
20%, 80% { transform: translate3d(+2px, 0, 0); }

index.html

+58-15
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@
5454

5555
<body class="page-body">
5656
<div class="background"></div>
57+
<div class="announcement-bar">
58+
<ul>
59+
<li al="announcement.1"></li>
60+
<li>
61+
<small>
62+
<text al="announcement.2"></text>
63+
<a href="https://afdian.com/a/MCiSEE" target="_blank" al="afdian"></a>
64+
</small>
65+
</li>
66+
<li>
67+
<text class="inline" al="introduction.2"></text>
68+
<svg id="star" aria-hidden="true" height="16" viewBox="0 0 16 16" width="16" data-view-component="true"
69+
fill="currentColor" class="octicon octicon-star d-inline-block mr-2">
70+
<path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path>
71+
</svg>
72+
</li>
73+
</ul>
74+
</div>
5775
<sidebar id="目录">
5876
<info al="content"></info>
5977
<dl>
@@ -207,15 +225,15 @@ <h2 class="page-title" al="config"></h2>
207225
<input type="checkbox" onclick="" disabled>
208226
<text al="debugMode">debugMode</text>
209227
</label>
210-
<label>
228+
<label id="gitHubProxy">
211229
<input class="github-proxy" type="checkbox" checked>
212230
<text al="GitHubProxy"></text>
213231
</label>
214-
<label>
232+
<label id="searchableDirect">
215233
<input class="searchable-direct" type="checkbox" checked>
216234
<text al="searchableDirect"></text>
217235
</label>
218-
<label style="display: flex; align-items: center;">
236+
<label id="searchablePromptLength" style="display: flex; align-items: center;">
219237
<text al="searchablePromptLength"></text>
220238
<mdui-slider class="inline-block searchable-prompt-length" name="searchable-prompt-length"
221239
value="10" min="0" max="30"></mdui-slider>
@@ -249,20 +267,45 @@ <h2 al="ellipsis"></h2>
249267
<h2 al="statistics"></h2>
250268
<hr>
251269
<div class="article">
252-
<h3 al="visitorCount"></h3>
253-
<p style="text-align: center;">
254-
<img src="https://visitor-badge.laobi.icu/badge?page_id=teaSummer.MCiSEE" alt="Visitor Count">
255-
</p>
270+
<h3 class="inline-block" al="visitorCount"></h3>
271+
<div id="访问计数" class="inline">
272+
<a class="to-unfold" href="#访问计数-展开" style="display: none;" al="unfold"></a>
273+
<a class="to-fold" href="#访问计数-收起" al="fold"></a>
274+
<details style="text-align: center;" open>
275+
<summary class="noicon"></summary>
276+
<img src="https://visitor-badge.laobi.icu/badge?page_id=teaSummer.MCiSEE" alt="Visitor Count">
277+
</details>
278+
</div>
256279

257-
<h3 al="contributors"></h3>
258-
<p style="text-align: center;">
259-
<img src="https://contrib.rocks/image?repo=teaSummer/MCiSEE" alt="Contributors">
260-
</p>
280+
<!-- <h3 class="inline-block" al="thankDonation"></h3>
281+
<div id="发电感谢" class="inline">
282+
<a class="to-unfold" href="#发电感谢-展开" al="unfold"></a>
283+
<a class="to-fold" href="#发电感谢-收起" style="display: none;" al="fold"></a>
284+
<details style="text-align: center;">
285+
<summary class="noicon"></summary>
286+
<img src="https://visitor-badge.laobi.icu/badge?page_id=teaSummer.MCiSEE" alt="Visitor Count">
287+
</details>
288+
</div> -->
261289

262-
<h3 al="starsOverTime"></h3>
263-
<p style="text-align: center;">
264-
<img src="https://starchart.cc/teaSummer/MCiSEE.svg?variant=adaptive" alt="Stars Over Time">
265-
</p>
290+
<h3 class="inline-block" al="contributors"></h3>
291+
<div id="贡献者" class="inline">
292+
<a class="to-unfold" href="#贡献者-展开" al="unfold"></a>
293+
<a class="to-fold" href="#贡献者-收起" style="display: none;" al="fold"></a>
294+
<details style="text-align: center;">
295+
<summary class="noicon"></summary>
296+
<img src="https://contrib.rocks/image?repo=teaSummer/MCiSEE" alt="Contributors">
297+
</details>
298+
</div>
299+
300+
<h3 class="inline-block" al="starsOverTime"></h3>
301+
<div id="GitHub星星历史图" class="inline">
302+
<a class="to-unfold" href="#GitHub星星历史图-展开" al="unfold"></a>
303+
<a class="to-fold" href="#GitHub星星历史图-收起" style="display: none;" al="fold"></a>
304+
<details style="text-align: center;">
305+
<summary class="noicon"></summary>
306+
<img src="https://starchart.cc/teaSummer/MCiSEE.svg?variant=adaptive" alt="Stars Over Time">
307+
</details>
308+
</div>
266309
</div>
267310
<hr>
268311
<p class="ICP" al="ICP"></p>

scripts/init.js

+83-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ let searchKeyword = '', searchableAbbr = '';
33

44
let hShake;
55
let notificationCount = '';
6-
const checkDate = (date = new Date()) => (date.getDate() == 1 && date.getMonth() + 1 == 4) ? true : false;
76

87
const downloadMirrorUrl = 'https://ghfast.top/<T>';
98
const fIconUrl = 'https://www.faviconextractor.com/favicon/<T>?larger=true';
109
const ghRepoMirrorUrl = '';
1110

11+
const checkDate = (date = new Date()) => (date.getDate() == 1 && date.getMonth() + 1 == 4) ? true : false;
1212
const fIconGet = ((url, p) => '<img src="' + (p ? p : fIconUrl.replace('<T>', url.replace(/https?:\/\//, '').replace(/\/.*/, ''))) + '" width="16" height="16" loading="lazy"/> ')
1313
const downloadSVG = '<span class="svg right"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M320 336h76c55 0 100-21.21 100-75.6s-53-73.47-96-75.6C391.11 99.74 329 48 256 48c-69 0-113.44 45.79-128 91.2-60 5.7-112 35.88-112 98.4S70 336 136 336h56M192 400.1l64 63.9 64-63.9M256 224v224.03" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="56"></path></svg></span>';
1414
const downloadMirror = ((url) => $('.github-proxy').is(':checked') && String(url).startsWith('https://github.com/') ? downloadMirrorUrl.replace('<T>', url) : url); // 针对中国大陆地区 | for Chinese Mainland
@@ -39,7 +39,7 @@ let goingapf = false;
3939
al.current(languages, {url: true, yaml: true});
4040
const i18n = ((callback = () => {}) => {
4141
if (isapf) {
42-
const apflang = navigator.language.startsWith('zh') ? 'lzh' : 'en-UD';
42+
const apflang = al.getUserLang().startsWith('zh-') ? 'lzh' : 'en-UD';
4343
if (!goingapf) {
4444
al.current(languages, {url: true, yaml: true}, apflang, () => {
4545
goingapf = true;
@@ -67,6 +67,23 @@ const i18n = ((callback = () => {}) => {
6767
});
6868

6969

70+
// 公告栏
71+
const announcement_init = (() => {
72+
$('.announcement-bar li').removeAttr('class').each((i, e) => $(e).addClass(`announcement-${i + 1}`));
73+
});
74+
const announcement_switch = (() => {
75+
setInterval(function() {
76+
for (let i = 1;; ++i) {
77+
if ($(`.announcement-${i}`).length) {
78+
let z = i - 1;
79+
if (z < 1) z = $(`.announcement-bar li`).length + 1;
80+
$(`.announcement-${i}`).removeClass(`announcement-${i}`).addClass(`announcement-${z}`);
81+
} else break;
82+
}
83+
}, 5000);
84+
});
85+
86+
7087
// 不记录历史滚动位置
7188
if (history.scrollRestoration) {
7289
history.scrollRestoration = 'manual';
@@ -76,7 +93,7 @@ if (history.scrollRestoration) {
7693
// 读取 JSON5 文件
7794
const read = ((file, isPath = false) => {
7895
return JSON5.parse($.ajax({
79-
url: isPath? file: `data/${file}.json5`,
96+
url: isPath ? file : `data/${file}.json5`,
8097
dataType: 'json',
8198
async: false
8299
}).responseText);
@@ -103,8 +120,8 @@ const hashChanged = (() => {
103120
// 自动展开/收起:<details> 元素
104121
try {
105122
// 通过检测哈希属性
106-
if (hash == '#全部展开') toggleDetails('pre', true);
107-
if (hash == '#全部收起') toggleDetails('pre', false);
123+
if (hash == '#全部展开') toggleDetails('pre, footer', true);
124+
if (hash == '#全部收起') toggleDetails('pre, footer', false);
108125
if (hash.endsWith('-展开')) {
109126
toggleDetails(slicedHash, true);
110127
location.hash = slicedHash;
@@ -143,3 +160,64 @@ const forum = read('forum');
143160
const cfg = read("scripts/cfg/apf.cfg.json5", true);
144161
let isapf = checkDate() || cfg.testMode;
145162
import("./apf.js").then(apf => (globalThis.apf = apf, apf.main()));
163+
164+
// 版本
165+
const getVersion = ((content, type) => {
166+
const s = '| ' + type + ' = ';
167+
if (content.indexOf(s) == -1) return '';
168+
return content.split(s)[1].split('\n')[0].replace(/^ *= */, '');
169+
});
170+
$.ajax({
171+
url: 'https://zh.minecraft.wiki/index.php?title=Template:Version&action=raw', // Chinese Minecraft Wiki, CC BY-NC-SA 3.0
172+
async: true,
173+
success: (r => {
174+
const result = r.split('-->')[1].split('}}\n}}')[0].trim();
175+
const version = {
176+
java: getVersion(result, 'java'),
177+
javaSnap: getVersion(result, 'java-snap'),
178+
bedrock: getVersion(result, 'bedrock'),
179+
bedrockBeta: getVersion(result, 'bedrock-beta')
180+
};
181+
let w = 'minecraft.wiki'
182+
const l = al.getUserLang().split('-')[0];
183+
const wiki = {cs: {},
184+
de: {java: '$', javaSnap: '$', bedrock: 'Bedrock_Edition_$', bedrockBeta: 'Bedrock_Edition_beta_$'},
185+
en: {java: 'Java_Edition_$', javaSnap: 'Java_Edition_$', bedrock: 'Bedrock_Edition_$', bedrockBeta: 'Bedrock_Edition_beta_$'},
186+
el: {},
187+
es: {java: 'Java_Edition_$', javaSnap: 'Java_Edition_$', bedrock: 'Bedrock_Edition_$', bedrockBeta: 'Bedrock_Edition_beta_$'},
188+
fr: {java: 'Édition_Java_$', javaSnap: 'Édition_Java_$', bedrock: 'Édition_Bedrock_$', bedrockBeta: 'Édition_Bedrock_bêta_$'},
189+
hu: {},
190+
id: {},
191+
it: {java: 'Java_Edition_$', javaSnap: 'Java_Edition_$', bedrock: 'Bedrock_Edition_$', bedrockBeta: 'Bedrock_Edition_beta_$'},
192+
ja: {java: 'Java_Edition_$', javaSnap: 'Java_Edition_$', bedrock: 'Bedrock_Edition_$', bedrockBeta: 'Bedrock_Edition_beta_$'},
193+
ko: {java: 'Java_Edition_$', javaSnap: 'Java_Edition_$', bedrock: 'Bedrock_Edition_$', bedrockBeta: 'Bedrock_Edition_베타_$'},
194+
lzh: {},
195+
nl: {java: '$', javaSnap: '$', bedrock: 'Bedrockeditie_$', bedrockBeta: 'Bedrockeditie_$'},
196+
pl: {},
197+
pt: {java: 'Edição_Java_$', javaSnap: 'Edição_Java_$', bedrock: 'Edição_Bedrock_$', bedrockBeta: 'Edição_Bedrock_beta_$'},
198+
ru: {java: '$_(Java_Edition)', javaSnap: '$_(Java_Edition)', bedrock: '$_(Bedrock_Edition)', bedrockBeta: 'Beta_$_(Bedrock_Edition)'},
199+
th: {java: 'รุ่น_Java_$', javaSnap: 'รุ่น_Java_$', bedrock: 'รุ่น_Bedrock_$', bedrockBeta: 'รุ่น_Bedrock_beta_$'},
200+
tr: {},
201+
uk: {java: '$_(Java_Edition)', javaSnap: '$_(Java_Edition)', bedrock: '$_(Bedrock_Edition)', bedrockBeta: 'Beta_$_(Bedrock_Edition)'},
202+
zh: {java: 'Java版$', javaSnap: '$', bedrock: '基岩版$', bedrockBeta: '基岩版$'},
203+
}
204+
if (Object.keys(wiki).indexOf(l) != -1 && l != 'en') w = l + '.minecraft.wiki';
205+
else l = 'en';
206+
w = 'href="https://' + w + '/w/';
207+
const q = ((v) => {
208+
if (!wiki[l] || !wiki[l][v]) return '';
209+
return w + wiki[l][v].replace('$', version[v]) + '"';
210+
});
211+
if (version.javaSnap) {
212+
version.javaSnap = `&nbsp;&nbsp;<text al="news.development"></text><a ${q('javaSnap')} target="_blank">${version.javaSnap}</a>`;
213+
}
214+
if (version.bedrockBeta) {
215+
version.bedrockBeta = `&nbsp;&nbsp;<text al="news.beta"></text><a ${q('bedrockBeta')} target="_blank">${version.bedrockBeta}</a>`;
216+
}
217+
version.java = `<text al="news.release"></text><a ${q('java')} target="_blank">${version.java}</a>${version.javaSnap}`;
218+
version.bedrock = `<text al="news.release"></text><a ${q('bedrock')} target="_blank">${version.bedrock}</a>${version.bedrockBeta}`;
219+
const news = `<li><text al="news.java"></text>${version.java}</li><li><text al="news.bedrock"></text>${version.bedrock}</li>`;
220+
$('.announcement-bar li:nth-child(2)').after(news);
221+
i18n(announcement_init);
222+
})
223+
});

0 commit comments

Comments
 (0)