添加CDN
Build and Publish / Run (push) Successful in 1m15s Details

This commit is contained in:
cxykevin 2024-08-31 18:11:29 +08:00
parent 1b70772b3c
commit 1091f3f9fc
13 changed files with 1636 additions and 0 deletions

21
theme/css/font.css Normal file
View File

@ -0,0 +1,21 @@
@font-face {
font-family: 'Noto Sans';
font-style: normal;
font-weight: 300;
src: local("NotoSansCJK-Medium") url('../font/noto.otf') format('otf');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 300;
src: local("SourceCodePro") url('../font/sourcecodepro.woff2') format('woff2');
}
body {
font-family: 'Noto Sans', sans-serif !important;
}
code {
font-family: 'Source Code Pro', 'Courier New', monospace !important;
}

9
theme/css/highlight.min.css vendored Normal file
View File

@ -0,0 +1,9 @@
/*!
Theme: Default
Description: Original highlight.js style
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
Maintainer: @highlightjs/core-team
Website: https://highlightjs.org/
License: see project LICENSE
Touched: 2021
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

22
theme/css/icons.css Normal file
View File

@ -0,0 +1,22 @@
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(../font/icons.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-smoothing: antialiased;
}

1
theme/css/mdui.css Normal file

File diff suppressed because one or more lines are too long

125
theme/css/page.css Normal file
View File

@ -0,0 +1,125 @@
ol,
li {
list-style: none;
font-size: 1em;
}
.part-title {
font-weight: bold;
font-size: 1.2em;
}
a {
position: relative;
text-decoration: none;
color: rgb(var(--mdui-color-primary));
}
a:after {
content: "";
position: absolute;
bottom: -2px;
left: 50%;
width: 0;
height: 2px;
transition: width 0.3s ease-in-out, left 0.3s ease-in-out;
background-color: rgb(var(--mdui-color-primary))
}
a:hover:after {
width: 100%;
left: 0;
}
h1 {
margin-top: 0px !important;
margin-bottom: 20px !important;
}
h2 {
margin-top: 30px !important;
margin-bottom: 15px !important;
}
.container {
min-height: 1rem !important;
}
.menu-link {
color: rgb(var(--mdui-color-on-surface));
}
.menu-link:after {
bottom: -2px;
left: 0;
width: 100%;
height: 2px;
background-color: rgb(var(--mdui-color-primary));
transition: width 0.2s ease-in-out, left 0.2s ease-in-out;
}
.menu-link:hover:after {
width: calc(100% - 20px);
left: 20px;
}
.topbar {
position: fixed !important;
top: 0px;
right: 0px;
left: 0px;
}
.mdui-prose {
margin-left: 50px;
margin-right: 50px;
max-width: 78%;
margin: auto;
left: 0;
right: 0;
}
.toc-drawer {
position: fixed !important;
margin-left: 0px !important;
margin-right: 0px !important;
}
.bottombar {
height: 10em !important;
margin-top: 2em !important;
margin-left: 2em !important;
margin-right: 2em !important;
display: flex !important;
}
.prevpage {
display: flex !important;
font-size: 1.2em !important;
margin-top: 10px !important;
margin-left: 4px !important;
}
.nextpage {
display: flex !important;
font-size: 1.2em !important;
margin-top: 10px !important;
margin-right: 4px !important;
}
hr {
margin-top: 16px !important;
margin-bottom: 16px !important;
}
@media (max-width: 641px) {
.hideonmobile {
display: none !important;
}
}
@media (min-width: 640px) {
.hideonmobile {
display: inline-flex !important;
}
}

BIN
theme/font/icons.woff2 Normal file

Binary file not shown.

BIN
theme/font/noto.otf Normal file

Binary file not shown.

Binary file not shown.

1213
theme/js/highlight.min.js vendored Normal file

File diff suppressed because one or more lines are too long

19
theme/js/mathjax.js Normal file

File diff suppressed because one or more lines are too long

22
theme/js/mdui.global.js Normal file

File diff suppressed because one or more lines are too long

110
theme/js/page.js Normal file
View File

@ -0,0 +1,110 @@
if (window.innerWidth > 640) { // 自动展开导航栏
document.getElementById("toc-drawer").setAttribute('open', true);
}
// 细节修复
function update_text() {
console.log(1)
// 修复 table
var tables = document.getElementsByTagName("table")
if (tables != undefined) {
for (let i = 0; i < tables.length; i++) {
tables[i].parentNode.classList.add('mdui-table');
}
}
// 修复 hr
var hrs = document.getElementsByTagName("hr")
if (hrs != undefined) {
for (let i = 0; i < hrs.length; i++) {
hrs[i].replaceWith(document.createElement("mdui-divider"));
}
}
}
function prevPage() {
var link = document.getElementById("helper_prevpage").href;
console.log("prev page:", link);
changePage(link);
}
function nextPage() {
var link = document.getElementById("helper_nextpage").href;
console.log("next page:", link);
changePage(link);
}
function setPage(url) { // 菜单跳转事件
if (url === "") {
return;
}
console.log("set page:", url);
changePage(url);
}
function changePage(url) {
// 加载图标
var nextbtn = document.getElementsByClassName("next—page")[0]
if (nextbtn != undefined) {
nextbtn.setAttribute("loading", "");
}
// 发送 XHR 动态更新
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState !== 4) return; // 加载失败
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
// 滚动到顶部
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
// 更新内容与翻页按钮
var old_tag = document.getElementsByClassName("mdui-prose")[0];
var old_topbar_tag = document.getElementsByClassName("navbtn")[0];
var old_navcard_tag = document.getElementsByClassName("navcard")[0];
var virtualtag = document.createElement('div');
virtualtag.insertAdjacentHTML('beforeend', xhr.responseText);
var title = virtualtag.getElementsByTagName("title")[0].innerText;
old_tag.innerHTML = virtualtag.getElementsByClassName("mdui-prose")[0].innerHTML;
old_topbar_tag.innerHTML = virtualtag.getElementsByClassName("navbtn")[0].innerHTML;
old_navcard_tag.innerHTML = virtualtag.getElementsByClassName("navcard")[0].innerHTML;
// 更新导航栏当前选择的内容
var elements = document.querySelectorAll('[active]');
elements.forEach(element => {
element.removeAttribute('active');
});
var elementshighliht = document.querySelectorAll('[search_link="' + url + '"]');
elementshighliht.forEach(element => {
element.setAttribute('active', "true");
});
// 清除临时标签
virtualtag.remove();
// 添加历史记录
history.pushState({ page: title }, title, url);
// 刷新高亮
hljs.highlightAll();
// 修复内容
update_text();
}
};
// 发送 XHR
xhr.open('GET', url, true);
xhr.send(null);
}
// 当回到上一页时
window.addEventListener('popstate', function (event) {
console.log('pop state:', window.location.protocol + "//" + window.location.host + location.pathname);
changePage(window.location.protocol + "//" + window.location.host + location.pathname);
});
update_text();

94
theme/js/tocrender.js Normal file
View File

@ -0,0 +1,94 @@
// 获取当前 toc 内容
var toc_obj = document.getElementById("helperframe").getElementsByTagName("ol")[0]
// html 转目录树
function createTree(elements) {
let result = [];
last = 0
elements.childNodes.forEach(element => {
// 有子元素并且不是大标题
if (element.childNodes.length > 0 && (!element.classList.contains("part-title"))) {
let a = element.childNodes[0]
let link = a.tagName === 'A' ? a.href : '' // 获取链接,没有的就是目录
if (link == '') { // 目录
if (a.tagName === 'DIV') { // 目录不可点击
result.push({
link: "#",
text: a.textContent,
child: [],
avtive: false
})
} else { // 目录可点击
result[result.length - 1].child = createTree(element.getElementsByTagName("ol")[0])
}
} else { // 文章
result.push({
link: link,
text: a.innerText,
child: [],
active: element.childNodes[0].classList.contains("active") // 当前选中的
})
}
} else if (element.classList.contains("part-title")) { // 大标题
result.push({
link: "",
text: `<h3 style="margin-top: 0px;margin-bottom:0;margin-left:0rem;"><strong>` + element.textContent + "</strong></h3>",
child: [],
active: false
})
}
});
return result
}
// 目录结构树生成新html的dfs部分
function loadTreeItem(treeitem, v) {
var active_str = treeitem.active ? "active" : "" // 是否是当前文章
if (treeitem.child.length > 0) { // 目录
// 添加头部模板
var i_str = `<mdui-collapse-item value=item"` + v.toString() + `">
<mdui-list-item rounded slot="header" search_link="` + treeitem.link + `" ` + active_str + `><a href="javascript:void(0);" onclick="setPage('` + treeitem.link + `')" class="menu-link">` + treeitem.text + `</a><mdui-icon slot="end-icon" name="keyboard_arrow_down"></mdui-icon></mdui-list-item>
<div style="margin-left: 1rem">
<mdui-list-item rounded>
<mdui-collapse>`
var i = 0
treeitem.child.forEach(element => { // 拼接每级目录
i_str = i_str + loadTreeItem(element, i)
i++
})
// 添加尾部模板
i_str = i_str + `</mdui-collapse>
</mdui-list-item>
</div>
</mdui-collapse-item>`
return i_str
} else { // 文章
disabled = treeitem.link === '#' ? "disabled" : ""
return `<mdui-collapse-item><mdui-list-item rounded search_link="` + treeitem.link + `" ` + active_str + ` slot="header" ` + disabled + ` href="javascript:void(0);" onclick="setPage('` + treeitem.link + `')">` + treeitem.text + `</mdui-list-item></mdui-collapse-item>`
}
}
// 目录结构树生成新html
function getResult(obj) {
var get_tree = createTree(obj)
var n_str = `<mdui-list><mdui-collapse>`
var i = 0
get_tree.forEach(element => {
n_str = n_str + loadTreeItem(element, i)
i++
})
n_str = n_str + `</mdui-collapse></mdui-list>`
return n_str
}
// 插入内容
document.getElementById("toc-drawer").insertAdjacentHTML('beforeend', getResult(toc_obj));
// 移除 toc
document.getElementById("helperframe").remove()
// 终端内容
console.info(" _____ __ __ ___ _______ __ \n / ___// /___ ______/ /_ __/ | ________ ____ _/ ____/ | / / \n \\__ \\/ __/ / / / __ / / / / /| | / ___/ _ \\/ __ `/ / / |/ / \n ___/ / /_/ /_/ / /_/ / /_/ / ___ |/ / / __/ /_/ / /___/ /| / \n/____/\\__/\\__,_/\\__,_/\\__, /_/ |_/_/ \\___/\\__,_/\\____/_/ |_/ \n /____/ \n欢迎来到 Study Area CN! \nstudy-area.org.cn \n")
console.info("本站使用mdbook生成gitea action自动构建 \n恭喜你发现了彩蛋")
console.info("欢迎参与我们的开源项目! https://git.hmtsai.cn/study-area-cn/study-area-cn")
console.info("=====================================")