1
0

index.html 30 KB

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