1
0

index.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. <!doctype html>
  2. <html>
  3. <markdown-html version="1.10.1" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
  4. license="CC BY-SA 4.0 International"></markdown-html>
  5. <head>
  6. <meta charset="utf-8">
  7. <meta name="description" content="HTML read markdown">
  8. <meta name="keywords" content="markdown, html, renderer, low-dependency, one-click deployment">
  9. <meta name="author" content="PJ568">
  10. <meta name="viewport" content="width=256, initial-scale=1">
  11. <script defer src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/marked/4.0.2/marked.min.js"
  12. type="text/javascript"></script>
  13. <script src="https://lib.baomitu.com/pjax/0.2.8/pjax.min.js" type="text/javascript"></script>
  14. <script src="https://lib.baomitu.com/translate.js/3.7.2/translate.js" type="text/javascript"></script>
  15. <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/Darkmode.js/1.5.7/darkmode-js.min.js"
  16. type="text/javascript"></script>
  17. <script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/11.5.0/mermaid.min.js" type="text/javascript"></script>
  18. <script>
  19. // 使用 IIFE 包裹以避免全局变量污染
  20. (function () {
  21. const about = `
  22. # 关于
  23. ## MARKDOWN.HTML
  24. 旨在提供低依赖、一键部署的 Markdown 网页渲染方案。
  25. 详情请访问 [GitHub](https://github.com/PJ-568/MARKDOWN.HTML) 或 [Gitee](https://gitee.com/PJ-568/MARKDOWN.HTML) 仓库。
  26. `;
  27. // 加载动画相关
  28. var loadingState = {
  29. countLoading: 0
  30. };
  31. Object.defineProperty(loadingState, 'countLoading', {
  32. get: function () {
  33. return this._countLoading;
  34. },
  35. set: function (newValue) {
  36. if (newValue < 0) {
  37. newValue = 0;
  38. }
  39. const loadingBar = document.querySelector('.loading-bar');
  40. const progress = document.querySelector('.loading-bar .progress');
  41. if (this.countLoading === 0 && newValue > 0) {
  42. var loadingBarWidth = 20;
  43. var MAX_LOADING_WIDTH = 95;
  44. loadingBar.classList.add('loading');
  45. progress.style.width = loadingBarWidth + '%';
  46. clearInterval(timer);
  47. timer = setInterval(function () {
  48. loadingBarWidth += 3;
  49. if (loadingBarWidth > MAX_LOADING_WIDTH) {
  50. loadingBarWidth = MAX_LOADING_WIDTH;
  51. }
  52. progress.style.width = loadingBarWidth + '%';
  53. }, 500);
  54. } else if (this.countLoading > 0 && newValue === 0) {
  55. clearInterval(timer);
  56. progress.style.width = '100%';
  57. loadingBar.classList.remove('loading');
  58. setTimeout(function () {
  59. progress.style.width = 0;
  60. }, 400);
  61. }
  62. this._countLoading = newValue;
  63. }
  64. });
  65. loadingState.countLoading = 0;
  66. function startLoad() {
  67. loadingState.countLoading = loadingState.countLoading + 1;
  68. }
  69. function endLoad() {
  70. loadingState.countLoading = loadingState.countLoading - 1;
  71. }
  72. var timer = null;
  73. // 文档解析功能相关
  74. var notExistIndexPage = null; // 是否不存在索引页
  75. async function getPValue() {
  76. return await decodeMDPath(window.location.href);
  77. }
  78. // PJAX 相关
  79. let PJAX;
  80. // 深色模式相关
  81. let darkmode;
  82. // 自定义 PJAX 相关
  83. const existPushState = (history && history.pushState);
  84. var level = 1; // 当前页面的层级
  85. var lastLevel = 0;
  86. // 初始化 PJAX
  87. function initPJAX() {
  88. try {
  89. const Pjax = window.Pjax || function () {
  90. console.warn('Pjax 不存在?');
  91. };
  92. PJAX = new Pjax({
  93. selectors: [
  94. 'head title',
  95. '.markdown-body',
  96. '.pjax-reload'
  97. ],
  98. switches: {
  99. ".markdown-body": Pjax.switches.sideBySide
  100. },
  101. switchesOptions: {
  102. ".markdown-body": {
  103. classNames: {
  104. remove: "Animated Animated-remove Animated--reverse Animate--fast Animate--noDelay",
  105. add: "Animated",
  106. backward: "Animate--slideInRight",
  107. forward: "Animate--slideInLeft"
  108. }
  109. }
  110. },
  111. cacheBust: false
  112. });
  113. } catch (e) {
  114. console.error('PJAX 初始化出错:' + e);
  115. }
  116. }
  117. // translate-js 翻译系统
  118. //// 初始化翻译系统
  119. function initTranslate() {
  120. try {
  121. translate.service.use('client.edge');
  122. translate.request.listener.start();
  123. translate.setAutoDiscriminateLocalLanguage();
  124. translate.language.setUrlParamControl();
  125. translate.ignore.class.push('notTranslate');
  126. translate.execute();
  127. } catch (e) {
  128. console.error('翻译系统出错:' + e);
  129. }
  130. }
  131. // Darkmode.js 深色模式
  132. function initDarkmode() {
  133. try {
  134. const Darkmode = window.Darkmode || function () {
  135. console.warn('Darkmode.js 不存在?');
  136. };
  137. darkmode = new Darkmode();
  138. } catch (e) {
  139. console.error('初始化 Darkmode.js 出错:' + e);
  140. }
  141. }
  142. //// 检查并提示翻译
  143. function infoTranslate() {
  144. try {
  145. const currentLang = translate.language.getCurrent();
  146. const originalLang = translate.language.getLocal();
  147. if (currentLang !== originalLang) {
  148. const translateInfo = document.querySelectorAll('.translate-info');
  149. if (translateInfo) {
  150. translateInfo.forEach(function (item) {
  151. item.remove();
  152. })
  153. }
  154. // 获取 .markdown-body 元素
  155. var bq = document.createElement('blockquote');
  156. bq.classList.add('translate-info');
  157. var infoBody = document.createElement('p');
  158. infoBody.innerText = '当前页面已翻译。您可以:';
  159. var msgBody = document.createElement('p');
  160. var switchButton = document.createElement('a');
  161. switchButton.classList.add('translate-switch');
  162. switchButton.href = 'javascript:;';
  163. switchButton.title = '切换到原语言';
  164. switchButton.innerText = '切换到文章原本的语言';
  165. bq.appendChild(infoBody);
  166. bq.appendChild(switchButton);
  167. const mainElement = document.querySelector('.markdown-body .content');
  168. mainElement.insertBefore(bq, mainElement.children[1]);
  169. }
  170. } catch (e) {
  171. console.error('检查并提示翻译出错:' + e);
  172. }
  173. }
  174. //// 刷新翻译
  175. function refreshTranslate() {
  176. try {
  177. translate.selectLanguageTag.refreshRender();
  178. } catch (e) {
  179. console.error('刷新翻译出错:' + e);
  180. }
  181. }
  182. // 获取文件所在目录
  183. function getDirectory(path) {
  184. path = new URL(path, 'http://example.com').pathname;
  185. const lastSlashIndex = path.lastIndexOf('/');
  186. return path.substring(0, lastSlashIndex + 1);
  187. }
  188. // 获取 markdown.html 当前所加载的 md 文件的所在路径
  189. function getPath() {
  190. return getDirectory(window.location.href);
  191. }
  192. // 将 ?p= 后面的值转换为绝对路径
  193. /*
  194. 输出的值是 /path/to/file.md
  195. 当其为 null 时,根据是否存在 index.md 文件来决定返回的值
  196. */
  197. async function decodeMDPath(path) {
  198. const url = new URL(path);
  199. const params = new URLSearchParams(url.search);
  200. path = formatMDPath(params.get('p'));
  201. return path;
  202. }
  203. // 格式化路径
  204. /*
  205. 如果 mdPath 为 null,则返回 null,如果 mdPath 是路径,则返回该路径下 /index.md
  206. return: 返回格式化后的文件路径,一定是绝对路径,或者 null
  207. */
  208. function formatMDPath(mdPath) {
  209. if (mdPath) {
  210. if (isRelativePath(mdPath)) {
  211. mdPath = getPath() + mdPath;
  212. }
  213. mdPath = new URL(mdPath, 'http://example.com').pathname;
  214. if (!mdPath.endsWith('.md')) {
  215. if (!mdPath.endsWith('/')) {
  216. mdPath += '/';
  217. }
  218. mdPath += 'index.md';
  219. }
  220. }
  221. return mdPath;
  222. }
  223. // 判断路径是否为相对路径
  224. const isRelativePath = (path) => !path.startsWith('/');
  225. // 处理错误
  226. function updateContent(article, title = null, mdPath = null) {
  227. try {
  228. document.querySelector('.markdown-body').innerHTML = `<div class="old-content Animated Animated-remove Animated--reverse Animate--fast Animate--noDelay Animate--slideInLeft">${document.querySelector('.markdown-body .content').innerHTML}</div><div class="content Animated Animate--slideInRight">${article}</div>`;
  229. firstH1 = document.querySelector('.markdown-body .content h1');
  230. document.title = title ? title : (firstH1 ? firstH1.textContent : mdPath);
  231. } catch (error) {
  232. throw error;
  233. }
  234. }
  235. // 等待动画结束
  236. function waitForAnimationsEnd(parentElement, selector, animationNames) {
  237. return new Promise(resolve => {
  238. var completedCount = 0;
  239. const elements = parentElement.querySelectorAll(selector);
  240. const totalElements = elements.length;
  241. const handleAnimationEnd = function (event) {
  242. if (animationNames.includes(event.animationName) && Array.from(elements).includes(event.target)) {
  243. completedCount++;
  244. if (completedCount === totalElements) {
  245. parentElement.removeEventListener('animationend', handleAnimationEnd);
  246. resolve();
  247. }
  248. }
  249. };
  250. parentElement.addEventListener('animationend', handleAnimationEnd);
  251. });
  252. }
  253. // 处理错误
  254. function handleError(mdPath, errorMessage) {
  255. updateContent(`<h1>加载失败</h1><p>加载文档<code>${mdPath}</code>时出错:<code>${errorMessage}</code>。您可以尝试<a class="refresh-btn" href="">重新加载</a>或<a class="back-btn">返回</a>。</p>`, '加载失败');
  256. customPushState(window.location.origin + window.location.pathname + '?p=error.md');
  257. waitForAnimationsEnd(document.querySelector('.markdown-body'), '.content, .old-content', ['Animation-slideInRight', 'Animation-slideInLeft']).then(() => {
  258. customPushState(window.location.origin + window.location.pathname + (mdPath ? ('?p=' + mdPath) : ''));
  259. });
  260. endLoad();
  261. }
  262. // 更新页面的 markdown 内容
  263. /*
  264. mdPath: 要加载的 markdown 文件路径,最好是带主机名的绝对路径(要用于 fetch())
  265. response: fetch() 的返回值,用于防止二次访问
  266. */
  267. const showMarkdown = async (mdPath, response = null) => {
  268. if (mdPath === null) {
  269. var path = null;
  270. const currentPath = getPath();
  271. // 如果存在 index.md 文件,则返回 index.md,否则返回 README.md
  272. if (notExistIndexPage) {
  273. path = currentPath + 'README.md';
  274. } else if (notExistIndexPage === false) {
  275. path = currentPath + 'index.md';
  276. } else {
  277. response = await fetch(getPath() + 'index.md');
  278. if (response.ok && response.headers.get('content-type').startsWith('text/markdown')) {
  279. notExistIndexPage = false;
  280. path = currentPath + 'index.md';
  281. } else {
  282. response = null;
  283. notExistIndexPage = true;
  284. path = currentPath + 'README.md';
  285. }
  286. }
  287. } else if (mdPath.endsWith('about.md')) {
  288. // 特殊处理 about.md
  289. response = await fetch(mdPath);
  290. if (response.ok && response.headers.get('content-type').startsWith('text/markdown')) {
  291. var r_text = await response.text();
  292. const content = about + await r_text.replace(/^# .*/m, '');
  293. response = {
  294. ok: true,
  295. status: 200,
  296. statusText: '自生成。',
  297. text: async () => {
  298. return content;
  299. }
  300. };
  301. } else {
  302. response = {
  303. ok: true,
  304. status: 200,
  305. statusText: '自生成。',
  306. text: async () => {
  307. return about + '*无更多详细信息*';
  308. }
  309. };
  310. }
  311. }
  312. try {
  313. updateContent(await getMarkdown((mdPath ? mdPath : path), response))
  314. document.querySelector('html').classList.add('loaded'); //// 防止缓存的页面被自定义 PJAX 中覆写的处理响应的函数捕获
  315. waitForAnimationsEnd(document.querySelector('.markdown-body'), '.content, .old-content', ['Animation-slideInRight', 'Animation-slideInLeft']).then(async () => {
  316. await showMarkdownEnded();
  317. customPushState(window.location.origin + window.location.pathname + (mdPath ? ('?p=' + mdPath) : ''));
  318. });
  319. } catch (error) {
  320. handleError((mdPath ? mdPath : path), error)
  321. }
  322. }
  323. // 读取并解析指定文件
  324. const getMarkdown = async (mdPath, response = null) => {
  325. // 生成目录
  326. function generateOutline(doc) {
  327. const headings = Array.from(doc.querySelectorAll('h1, h2, h3, h4, h5, h6'));
  328. if (headings.length === 0) return '<i>无目录</i>';
  329. var outline = '<ul>';
  330. var stack = [];
  331. headings.forEach(heading => {
  332. const level = parseInt(heading.tagName.charAt(1));
  333. const id = heading.textContent.toLowerCase()
  334. .replace(/ /g, '-') // 将空格替换为连字符
  335. .replace(/[^\w\u4e00-\u9fa5-]/g, ''); // 保留字母、数字、下划线、中文字符和连字符
  336. // 设置 id 属性以便链接跳转
  337. heading.setAttribute('id', id);
  338. while (stack.length > 0 && stack[stack.length - 1].level >= level) {
  339. stack.pop();
  340. outline += '</ul></li>';
  341. }
  342. if (stack.length === 0 || stack[stack.length - 1].level < level) {
  343. outline += '<li><ul>';
  344. } else {
  345. outline += '</li><li>';
  346. }
  347. outline += `<a href="#${id}">${heading.textContent}</a>`;
  348. stack.push({ level: level });
  349. });
  350. while (stack.length > 0) {
  351. outline += '</ul></li>';
  352. stack.pop();
  353. }
  354. outline += '</ul>';
  355. return outline;
  356. }
  357. if (!response) {
  358. response = await fetch(mdPath);
  359. if (!response.ok && response.headers.get('content-type').startsWith('text/markdown')) {
  360. throw new Error('请求失败:' + mdPath + ',' + response.headers.get('content-type') + ',' + response.status + ',' + response.statusText);
  361. }
  362. }
  363. var content = marked.parse(await response.text());
  364. if (content === '') {
  365. content = '<i>空文件</i>';
  366. }
  367. content = `<details class="outline"><summary>${decodeURIComponent(mdPath)}</summary></details><hr>${content}`;
  368. const parser = new DOMParser();
  369. const doc = parser.parseFromString(content, 'text/html');
  370. const outline = generateOutline(doc);
  371. doc.querySelector('.outline').innerHTML += outline;
  372. const links = doc.querySelectorAll('a[href$=".md"]');
  373. const pValue = await getPValue()
  374. links.forEach(link => {
  375. var href = link.getAttribute('href');
  376. /*
  377. 如果 href 是相对路径,则在其前加上当前读取的文档的绝对路径;
  378. 如果不存在当前读取的文档(默认读取的 index.md 或 README.md),
  379. 则在其前加上 markdown.html 的绝对路径。
  380. */
  381. if (isRelativePath(href)) {
  382. if (pValue) {
  383. href = getDirectory(mdPath) + href;
  384. } else {
  385. href = getPath() + href;
  386. }
  387. const absoluteHref = new URL(href, 'http://example.com').pathname;
  388. link.setAttribute('href', `${window.location.pathname}?p=${absoluteHref}`);
  389. } else if (href.startsWith('/')) {
  390. link.setAttribute('href', `${window.location.pathname}?p=${href}`);
  391. }
  392. });
  393. return doc.body.innerHTML;
  394. };
  395. // 初始化自定义 PJAX 响应
  396. function initCustomPJAXResponse() {
  397. // 覆写 PJAX 处理响应的函数,在内容插入页面之前实现 markdown 的渲染
  398. PJAX._handleResponse = PJAX.handleResponse;
  399. PJAX.handleResponse = async function (responseText, request, href, options) {
  400. if (request.responseText.startsWith('<!doctype html><html><markdown-html') || request.responseText.startsWith(`<!doctype html>
  401. <html>
  402. <markdown-html`)) {
  403. await showMarkdown(await decodeMDPath(href));
  404. } else {
  405. PJAX._handleResponse(responseText, request, href, options);
  406. }
  407. }
  408. }
  409. // 初始化自定义 PJAX 事件监听器
  410. function initCustomPJAXEventListener() {
  411. // 监听自定义链接的点击事件
  412. if (existPushState) {
  413. document.querySelector('.markdown-body').addEventListener('click', async function (event) {
  414. const link = event.target.closest('a[href$=".md"]');
  415. if (link) {
  416. try {
  417. event.preventDefault();
  418. startLoad();
  419. await showMarkdown(await decodeMDPath(link.href));
  420. } catch (e) {
  421. console.error('自定义 PJAX 出错:' + e);
  422. }
  423. }
  424. });
  425. }
  426. }
  427. // 自定义推送状态
  428. function customPushState(url = window.location.href) {
  429. if (existPushState) {
  430. if (level > lastLevel) {
  431. history.pushState({ url: url, title: document.title, uid: level }, null, url);
  432. lastLevel = level++;
  433. } else {
  434. lastLevel = level - 1;
  435. }
  436. }
  437. }
  438. // 初始化内容
  439. const initContent = async () => {
  440. try {
  441. await showMarkdown(await getPValue());
  442. } catch (error) {
  443. handleError(await getPValue(), '初始化内容时出错:' + error);
  444. }
  445. };
  446. // 初始化返回首页按钮
  447. function initHomeBtn() {
  448. const homeBtn = document.querySelector('.to-home');
  449. homeBtn.href = window.location.pathname;
  450. }
  451. // 初始化返回首页按钮
  452. function initAboutBtn() {
  453. const aboutBtn = document.querySelector('.about-btn');
  454. aboutBtn.href = `?p=${getDirectory(window.location.pathname)}about.md`;
  455. }
  456. // 初始化
  457. function initialize() {
  458. initDarkmode(); //// 初始化深色模式
  459. initHomeBtn(); //// 初始化返回首页按钮
  460. initAboutBtn(); //// 初始化关于按钮
  461. initContent(); //// 初始化内容
  462. initTranslate(); //// 初始化页面翻译
  463. initPJAX(); //// 初始化 PJAX
  464. initCustomPJAXResponse(); //// 初始化自定义 PJAX 响应
  465. initCustomPJAXEventListener(); //// 初始化自定义 PJAX 事件监听器
  466. }
  467. // 触发器
  468. //// 网页加载完毕后触发初始化
  469. window.addEventListener('DOMContentLoaded', () => initialize());
  470. //// 翻译执行完成后触发
  471. translate.listener.renderTaskFinish = function (_task) {
  472. endLoad();
  473. }
  474. //// PJAX 开始时执行的函数
  475. document.addEventListener('pjax:send', function () {
  476. startLoad();
  477. });
  478. //// 监听 PJAX 完成后,重新加载
  479. document.addEventListener('pjax:complete', async function () {
  480. await showMarkdown(await getPValue());
  481. initCustomPJAXEventListener(); //// 重新初始化自定义 PJAX 事件监听器
  482. });
  483. //// 监听 animationend 事件
  484. document.addEventListener('animationend', function handleAnimationEnd(event) {
  485. if (event.animationName === 'Animation-slideInRight') {
  486. const element = document.querySelector('.markdown-body .content');
  487. element.classList.remove('Animated');
  488. element.classList.remove('Animate--slideInRight');
  489. } else if (event.animationName === 'Animation-slideInLeft') {
  490. document.querySelector('.markdown-body .old-content').remove();
  491. }
  492. });
  493. //// 点击事件委托
  494. document.addEventListener('click', function (event) {
  495. const imgOrSvg = event.target.closest('.content img, .content svg');
  496. if (imgOrSvg) {
  497. const url = imgOrSvg.getAttribute('src') || imgOrSvg.getAttribute('xlink:href');
  498. if (url) {
  499. window.open(url, '_blank');
  500. event.preventDefault();
  501. return;
  502. } else {
  503. const newWindow = window.open('', '_blank');
  504. newWindow.document.write(imgOrSvg.outerHTML);
  505. newWindow.document.close();
  506. event.preventDefault();
  507. return;
  508. }
  509. }
  510. if (event.target.closest('.back-btn')) {
  511. window.history.back();
  512. } else if (event.target.closest('.refresh-btn')) {
  513. window.location.reload();
  514. } else if (event.target.closest('.dark-btn')) {
  515. darkmode.toggle();
  516. } else if (event.target.closest('.translate-switch')) {
  517. translate.changeLanguage(translate.language.getLocal());
  518. } else if (event.target.closest('a[href^="#"]')) {
  519. // 目录平滑移动
  520. const href = event.target.getAttribute('href');
  521. if (href !== '#') {
  522. event.preventDefault();
  523. const targetElement = document.querySelector(href);
  524. if (targetElement) {
  525. targetElement.scrollIntoView({
  526. behavior: 'smooth'
  527. });
  528. } else {
  529. console.error(`ID 为 ${targetId} 的元素不存在。`);
  530. }
  531. }
  532. }
  533. });
  534. //// 文档内容加载完毕时触发
  535. async function showMarkdownEnded() {
  536. refreshTranslate();
  537. infoTranslate(); //// 检查并提示翻译
  538. await mermaid.init({ noteMargin: 10 }, '.language-mermaid'); //// 初始化 mermaid
  539. translate.execute(); //// 手动触发翻译,但是理论上 translate-js 会监听页面变化
  540. endLoad();
  541. window.scrollTo({
  542. top: 0,
  543. behavior: 'smooth'
  544. });
  545. }
  546. //// 浏览器返回时触发
  547. window.onpopstate = function (event) {
  548. if (level > 1) {
  549. --level;
  550. }
  551. };
  552. })();
  553. </script>
  554. <title>加载中</title>
  555. <style>
  556. /* 全局 */
  557. * {
  558. font-family: 'Exo', sans-serif;
  559. text-decoration: none;
  560. }
  561. :root {
  562. background-color: #e6e6e6;
  563. }
  564. ::selection {
  565. background-color: #DCEDC8;
  566. }
  567. body {
  568. margin: 0;
  569. }
  570. a {
  571. color: #66BB6A;
  572. cursor: pointer;
  573. text-decoration: none;
  574. }
  575. a:hover {
  576. color: #2E7D32;
  577. }
  578. /* 背景 */
  579. .background {
  580. position: fixed;
  581. left: 0;
  582. top: 0;
  583. height: 100%;
  584. width: 100%;
  585. z-index: -1;
  586. background-color: #e6e6e6;
  587. }
  588. /* 导航栏 */
  589. nav {
  590. position: fixed;
  591. top: 0;
  592. right: 0;
  593. width: min-content;
  594. background-color: #616161;
  595. display: flex;
  596. justify-content: space-between;
  597. align-items: center;
  598. z-index: 1;
  599. }
  600. nav a {
  601. color: #FAFAFA;
  602. padding: .3rem;
  603. transition:
  604. color .2s,
  605. background-color .2s;
  606. }
  607. nav a:hover {
  608. color: #FFF;
  609. background-color: #212121;
  610. }
  611. /* 动画 */
  612. .Animated {
  613. animation-fill-mode: both;
  614. animation-duration: 1s;
  615. }
  616. .Animated-remove {
  617. position: absolute;
  618. }
  619. .Animated--reverse {
  620. animation-direction: reverse
  621. }
  622. .Animate--fast {
  623. animation-duration: .5s
  624. }
  625. .Animate--noDelay {
  626. animation-delay: 0s !important;
  627. }
  628. .Animate--slideInRight {
  629. animation-name: Animation-slideInRight
  630. }
  631. @keyframes Animation-slideInRight {
  632. 0% {
  633. transform: translateX(200%);
  634. }
  635. 100% {
  636. transform: translateX(0);
  637. }
  638. }
  639. .Animate--slideInLeft {
  640. animation-name: Animation-slideInLeft
  641. }
  642. @keyframes Animation-slideInLeft {
  643. 0% {
  644. transform: translateX(-100%);
  645. }
  646. 100% {
  647. transform: translateX(0);
  648. }
  649. }
  650. /* 主要内容 */
  651. .markdown-body {
  652. position: relative;
  653. margin: 3rem auto;
  654. width: 100%;
  655. max-width: 950px;
  656. min-height: 300px;
  657. background-color: #FAFAFA;
  658. color: #212121;
  659. box-sizing: border-box;
  660. overflow-x: hidden;
  661. box-shadow: 0 2px 6px rgba(100, 100, 100, .3);
  662. }
  663. .markdown-body .content,
  664. .markdown-body .old-content {
  665. margin: 2rem;
  666. }
  667. .markdown-body img,
  668. .markdown-body video,
  669. .markdown-body iframe,
  670. .markdown-body object,
  671. .markdown-body embed,
  672. .markdown-body svg,
  673. .markdown-body canvas,
  674. .markdown-body audio {
  675. max-width: 100%;
  676. }
  677. /* Markdown 样式 */
  678. .markdown-body a {
  679. transition:
  680. color .2s,
  681. background-color .2s;
  682. }
  683. .markdown-body a:hover {
  684. background-color: rgba(255, 255, 255, 0.1);
  685. }
  686. .markdown-body ul,
  687. .markdown-body ol {
  688. padding-left: 2rem;
  689. }
  690. .markdown-body pre {
  691. background-color: rgba(0, 0, 0, 0.05);
  692. padding: .4rem;
  693. border-radius: .1rem;
  694. overflow-y: scroll;
  695. }
  696. .markdown-body code {
  697. font-family: "cousine nerd font mono", monospace;
  698. background-color: rgba(0, 0, 0, 0.05);
  699. font-size: small;
  700. padding: .2rem;
  701. border-radius: .1rem;
  702. }
  703. .markdown-body pre code {
  704. background-color: unset;
  705. font-size: unset;
  706. padding: unset;
  707. border-radius: unset;
  708. }
  709. .markdown-body blockquote {
  710. background-color: rgba(0, 0, 0, 0.05);
  711. font-size: small;
  712. padding: .4rem;
  713. margin: .5rem 2rem;
  714. border-left: 5px solid rgba(0, 0, 0, 0.1);
  715. }
  716. .markdown-body details {
  717. border: 1px solid rgba(0, 0, 0, 0.1);
  718. border-radius: .1rem;
  719. }
  720. .markdown-body summary {
  721. font-size: small;
  722. cursor: pointer;
  723. background-color: rgba(0, 0, 0, 0.05);
  724. padding: .4rem;
  725. font-weight: bold;
  726. }
  727. .markdown-body details a {
  728. margin-left: -2rem;
  729. }
  730. .markdown-body table {
  731. border-spacing: 0;
  732. border-radius: .1rem;
  733. width: 100%;
  734. border-collapse: separate;
  735. border: .1rem solid rgba(0, 0, 0, 0.05);
  736. }
  737. .markdown-body table td,
  738. .markdown-body table th {
  739. border-right: .1rem solid rgba(0, 0, 0, 0.05);
  740. }
  741. .markdown-body table td,
  742. .markdown-body table th {
  743. border-top: .1rem solid rgba(0, 0, 0, 0.05);
  744. }
  745. .markdown-body table td:last-child,
  746. .markdown-body th:last-child {
  747. border-right-color: transparent;
  748. }
  749. .markdown-body table thead tr:first-child>* {
  750. border-top: .1rem solid transparent;
  751. }
  752. /* 加载进度条 */
  753. .loading-bar {
  754. position: fixed;
  755. top: 0;
  756. left: 0;
  757. z-index: 2;
  758. opacity: 0;
  759. transition: opacity .4s linear;
  760. .progress {
  761. position: fixed;
  762. top: 0;
  763. left: 0;
  764. width: 0;
  765. height: 4px;
  766. background-color: #2E7D32;
  767. box-shadow: 0 0 10px rgba(102, 187, 106, .7);
  768. }
  769. &.loading {
  770. opacity: 1;
  771. transition: none;
  772. .progress {
  773. transition: width .4s ease;
  774. }
  775. }
  776. }
  777. /* 翻译按钮相关 */
  778. .translateSelectLanguage {
  779. background-color: #616161;
  780. color: inherit;
  781. z-index: 3;
  782. width: 17%;
  783. height: 100%;
  784. opacity: 0;
  785. cursor: pointer;
  786. position: absolute;
  787. top: 0;
  788. left: 50%;
  789. }
  790. /* 深色模式相关 */
  791. .darkmode--activated .markdown-body img,
  792. .darkmode--activated .markdown-body svg {
  793. isolation: isolate;
  794. mix-blend-mode: difference
  795. }
  796. .darkmode-layer,
  797. .darkmode-toggle {
  798. z-index: 3
  799. }
  800. /* 小屏响应式优化 */
  801. @media only screen and (max-width: 950px) {
  802. html,
  803. body,
  804. .markdown-body {
  805. height: 100%;
  806. }
  807. .markdown-body {
  808. overflow-y: scroll;
  809. min-width: 256px;
  810. top: 0;
  811. margin: 0 0;
  812. }
  813. }
  814. </style>
  815. </head>
  816. <body>
  817. <!-- 导航栏 -->
  818. <nav>
  819. <a title="返回" class="back-btn">
  820. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
  821. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  822. class="icon icon-tabler icons-tabler-outline icon-tabler-arrow-back">
  823. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  824. <path d="M9 11l-4 4l4 4m-4 -4h11a4 4 0 0 0 0 -8h-1" />
  825. </svg>
  826. </a>
  827. <a title="刷新" class="refresh-btn" href="">
  828. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
  829. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  830. class="icon icon-tabler icons-tabler-outline icon-tabler-refresh">
  831. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  832. <path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4" />
  833. <path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4" />
  834. </svg>
  835. </a>
  836. <a title="主页" class="to-home">
  837. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
  838. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  839. class="icon icon-tabler icons-tabler-outline icon-tabler-home">
  840. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  841. <path d="M5 12l-2 0l9 -9l9 9l-2 0" />
  842. <path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
  843. <path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
  844. </svg>
  845. </a>
  846. <a title="更改语言" id="translate">
  847. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
  848. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  849. class="icon icon-tabler icons-tabler-outline icon-tabler-language">
  850. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  851. <path d="M4 5h7" />
  852. <path d="M9 3v2c0 4.418 -2.239 8 -5 8" />
  853. <path d="M5 9c0 2.144 2.952 3.908 6.7 4" />
  854. <path d="M12 20l4 -9l4 9" />
  855. <path d="M19.1 18h-6.2" />
  856. </svg>
  857. </a>
  858. <a title="切换显示模式" class="dark-btn" href="javascript:;">
  859. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
  860. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  861. class="icon icon-tabler icons-tabler-outline icon-tabler-brightness">
  862. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  863. <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />
  864. <path d="M12 3l0 18" />
  865. <path d="M12 9l4.65 -4.65" />
  866. <path d="M12 14.3l7.37 -7.37" />
  867. <path d="M12 19.6l8.85 -8.85" />
  868. </svg>
  869. </a>
  870. <a title="关于" class="about-btn">
  871. <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
  872. stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  873. class="icon icon-tabler icons-tabler-outline icon-tabler-info-circle">
  874. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  875. <path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" />
  876. <path d="M12 9h.01" />
  877. <path d="M11 12h1v4h1" />
  878. </svg>
  879. </a>
  880. </nav>
  881. <!-- 内容主体 -->
  882. <div class="markdown-body">
  883. <div class="content">
  884. <h1>加载中……</h1>
  885. <p>请稍等。</p>
  886. </div>
  887. </div>
  888. <!-- 加载动画 -->
  889. <div class="loading-bar">
  890. <div class="progress"></div>
  891. </div>
  892. <div class="background"></div>
  893. <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-y/instant.page/5.1.0/instantpage.min.js"
  894. type="text/javascript"></script>
  895. </body>
  896. </html>