1
0

index.html 31 KB

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