index.html 26 KB

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