index.html 27 KB

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