diff options
| author | mayx <mayx@outlook.com> | 2026-05-23 10:06:55 +0000 |
|---|---|---|
| committer | mayx <mayx@outlook.com> | 2026-05-23 10:06:55 +0000 |
| commit | 481df19596b14612a5b1bc358d9514c8d4b490bb (patch) | |
| tree | 125869a62f96c41edd8a0e7f6892ac7abb8e6edd /assets/js/pjax.js | |
| parent | 1a529143a833b22fb2e2600498f6703c2edd9a84 (diff) | |
- /_layouts/default.html
- /_data/proxylist.yml
- /assets/js/main.js
- /assets/js/pjax.js
- /assets/js/main_new.js
Diffstat (limited to 'assets/js/pjax.js')
| -rw-r--r-- | assets/js/pjax.js | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/assets/js/pjax.js b/assets/js/pjax.js index 9e832ad..324087a 100644 --- a/assets/js/pjax.js +++ b/assets/js/pjax.js @@ -16,25 +16,6 @@ // ========== 各组件重初始化 ========== - /** 访问量统计 */ - function reinitVisitors() { - if (typeof BlogAPI === 'undefined') return; - var apiBase = BlogAPI; - if ($('.visitors').length === 1) { - var $visitor = $('.visitors:first'); - $.get(apiBase + '/count_click_add?id=' + $visitor.attr('id'), function (data) { - $visitor.text(Number(data)); - }); - } else if ($('.visitors-index').length > 0) { - $('.visitors-index').each(function () { - var $elem = $(this); - $.get(apiBase + '/count_click?id=' + $elem.attr('id'), function (data) { - $elem.text(Number(data)); - }); - }); - } - } - /** AI 摘要(post.html 内联脚本,pjax 后由 executeScripts 触发) */ function reinitAISummary() { if (typeof ai_gen === 'function' && $('#ai-output').length) { @@ -42,23 +23,6 @@ } } - /** 代码块复制按钮 */ - function reinitCopyButtons() { - $('.copy').remove(); - $('div.highlight').each(function () { - var $block = $(this); - var $btn = $('<button>', { class: 'copy', type: 'button', text: '📋' }); - $block.append($btn); - $btn.on('click', function () { - var code = $btn.siblings('pre').find('code').text().trim(); - navigator.clipboard.writeText(code) - .then(function () { $btn.text('✅'); }) - .catch(function () { $btn.text('❌'); }) - .finally(function () { setTimeout(function () { $btn.text('📋'); }, 1500); }); - }); - }); - } - /** 关键词高亮 */ function reinitHighlight() { var keyword = new URLSearchParams(window.location.search).get('kw'); @@ -158,8 +122,8 @@ /** 每次 pjax 完成后执行所有重初始化 */ function onPjaxComplete() { - reinitVisitors(); - reinitCopyButtons(); + initVisitors(); + initCopyButtons(); reinitHighlight(); reinitAISummary(); reinitLive2d(); @@ -206,8 +170,6 @@ newScript.remove(); }); }); - // 首次加载初始化 - reinitCopyButtons(); }); })(jQuery);
\ No newline at end of file |
