1
0

index.html 26 KB

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