index.html 31 KB

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