index.html 31 KB

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