From 2286b0288155b62db23fce0805606437746b90fb Mon Sep 17 00:00:00 2001 From: click33 <2393584716@qq.com> Date: Sat, 25 Dec 2021 07:35:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sa-token-doc/doc/_sidebar.md | 2 +- sa-token-doc/doc/index.html | 50 ++------------- sa-token-doc/doc/lib/docsify-plugin.js | 78 +++++++++++++++++++++++ sa-token-doc/doc/lib/index.css | 10 +++ sa-token-doc/doc/more/common-questions.md | 2 + sa-token-doc/doc/more/link.md | 38 ++++++++--- sa-token-doc/doc/more/sa-token-donate.md | 1 + 7 files changed, 125 insertions(+), 56 deletions(-) create mode 100644 sa-token-doc/doc/lib/docsify-plugin.js diff --git a/sa-token-doc/doc/_sidebar.md b/sa-token-doc/doc/_sidebar.md index 3b9f3e56..f0419ef7 100644 --- a/sa-token-doc/doc/_sidebar.md +++ b/sa-token-doc/doc/_sidebar.md @@ -70,7 +70,7 @@ - **其它** - [更新日志](/more/update-log) - - [友情链接](/more/link) + - [框架生态](/more/link) - [推荐公众号](/more/tj-gzh) - [赞助 Sa-Token](/more/sa-token-donate) diff --git a/sa-token-doc/doc/index.html b/sa-token-doc/doc/index.html index bc9105e0..a8c65456 100644 --- a/sa-token-doc/doc/index.html +++ b/sa-token-doc/doc/index.html @@ -92,6 +92,8 @@ }, 1); + + diff --git a/sa-token-doc/doc/lib/docsify-plugin.js b/sa-token-doc/doc/lib/docsify-plugin.js new file mode 100644 index 00000000..a8aaea1c --- /dev/null +++ b/sa-token-doc/doc/lib/docsify-plugin.js @@ -0,0 +1,78 @@ +// 声明 docsify 插件 +var myDocsifyPlugin = function(hook, vm) { + + // 钩子函数:解析之前执行 + hook.beforeEach(function(content) { + try{ + // 功能 1,替换全局变量 + content = content.replace(/\$\{sa.top.version\}/g, window.saTokenTopVersion); + + // 添加 [toc] 标记 + content = content.replace(/\[\[toc\]\]/g, '
'); + + }catch(e){ + // + } + return content; + }); + + // 钩子函数:每次路由切换时,解析内容之后执行 + hook.afterEach(function(html) { + + // 功能 2,文章底部添加仓库地址 + var url = 'https://gitee.com/dromara/sa-token/tree/dev/sa-token-doc/doc/' + vm.route.file; + var url2 = 'https://github.com/dromara/sa-token/tree/dev/sa-token-doc/doc/' + vm.route.file; + var footer = [ + '







', + '' + ].join(''); + return html + footer; + }); + + // 每钩子函数:次路由切换时数据全部加载完成后调用,没有参数。 + hook.doneEach(function() { + + // 功能3,给代码盒子,添加行数样式 + $('pre code').each(function(){ + var lines = $(this).text().split('\n').length; + var $numbering = $('