// 声明 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/' + vm.route.file; var url2 = 'https://github.com/dromara/sa-token/tree/dev/sa-token-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 = $('