













5.6.0
Full Changelog: 5.5.5...5.6.0
knocket.pug,在聊天配置中新增 knocket 選項scriptCache / cssCache),避免重複加載相同資源rafThrottle 工具函數,基於 requestAnimationFrame 實現節流sanitizeString),防範 XSS 注入IntersectionObserver 取代原本的 throttle + 遍歷方式,大幅減少滾動事件計算量btf.throttle 改為 btf.rafThrottle,與瀏覽器渲染幀率同步resize 事件處理加入 rafThrottle 節流scrollToDest 平滑滾動改用 easeOutQuart 緩動曲線,取代原本的線性插值rightsideScrollPercent 的 goUpElement / scrollPercentElement 改為閉包緩存,避免每次滾動都查詢 DOMoverflowPaddingR 的 page-header / menus 元素改為閉包緩存document.getElementById 查詢結果緩存到 sidebarFnadjustMenu 的 classList.toggle 包裹在 requestAnimationFrame 中forPostFn 改為接收 $article 參數,內部所有函數(addHighlightTool、addPhotoFigcaption、runLightbox、scrollFnToDo、addTableWrap、clickFnOfTagHide、tabsFn)統一使用傳入的 $article 查詢,避免重複 document.getElementById('article-container')tabsFn 改為事件委託,將點擊監聽綁在 $article 上而非每個 .tabs 元素clickFnOfTagHide 改為事件委託,綁在 $article 上而非逐個 .hide-button 綁定getActualHeight 改用 cloneNode(true) + 隱藏插入測量,取代原本遍歷父節點修改 style 的方式indexOf 改為 Map.has / Map.get,O(1) 查找getMaps),避免不必要的計算tw_cn.js 的 translateButtonObject 改為 let,支持 pjax 後重新查詢AbortController 管理事件監聽生命週期,避免重複綁定;wheel 事件加入 stopPropagation 防止穿透滾動;getBoundingClientRect 加入 dirty flag 緩存;DOM 更新改為 requestAnimationFrame 批次處理;deltaMode 正規化處理跨瀏覽器差異revokeObjectURL 超時從 30 秒縮短為 5 秒ui/lazy 模組實現延遲渲染,移除原本的 renderActions.findScript hacktypesetClear + typesetPromise,取代 texResetrandom_cover.js 的 resolvePostAsset 提取為獨立函數,減少重複邏輯page.js 的 getVersion 改為直接引用模組頂部 require 的 themeVersion,避免每次呼叫都重複讀取 package.jsoninject_head_js.js 的 darkmode 判斷邏輯修復了 start > end(跨午夜)的時段判斷錯誤translateButtonObject 改為 let 並在 translateInitialization 中重新查詢)script[data-pjax] 替換失敗的問題(加入 item.parentNode 存在性檢查)responseURL 可能為 undefined 的問題,加入空值檢查handleThemeChange 中 themeChange 可能不是物件的問題(加入 typeof fn !== 'function' 檢查)scrollFn 中 checkDocumentHeight() 在初始化時過早 return 導致滾動事件未綁定的問題svg.style.touchAction = 'none' + wheel 事件 preventDefault + stopPropagation)__mermaidGestureBound 移除改用 __mermaidAbortController)gallery.js 的 IMAGE_REGEX 在多次呼叫時 lastIndex 未重置的 bugflink.js 和 button.js 缺少 HTML escape 導致的 XSS 風險hide.js 的 parseArgs 缺少 trim 導致參數帶有前導空格series.js 模組級可變狀態 groups 在多次 build 時累積過期資料(加入 before_generate 清理)score.js 重複實現 escapeHTML,改用 hexo-util 的 escapeHTML + 額外處理 {}getArchiveLength.js 中 monthly 模式下 year 計數未累加的問題(year 計數改為始終執行)getArchiveLength.js 中 key 選取邏輯,daily 模式下也能正確取得月份計數related_post.js 中 postDesc 被提前計算的問題,改為在渲染時才取值page.js 中 shuoshuoFN 時區轉換的變數作用域問題page.js 中 cloudTags 多餘的 colorClass 變數和 classpage.js 中 findArchivesTitle 遞迴時 m[key] 可能不是字串的問題main.js 的 fetchUrl 在 HTTP 失敗時靜默返回空數組的問題,改為 throw 錯誤main.js 的 runJustifiedGallery 在 limit / firstLimit 為非法值時的邊界處理main.js 的 addJustifiedGallery 在 data 非陣列時的錯誤處理main.js 的 sanitizeString 從只替換 " 改為替換 &、"、'、<、> 五種字符main.js 的 forPostFn 在 hbe-container 存在時跳過初始化main.js 的 gallery 空數據時顯示載入動畫的問題Math.pow(1.001, delta)),操作更平滑minW/maxW/minH/maxHopenSvgInNewTab 移除了不再需要的 typeof svg === 'string' 分支lazyMargin 設為 200pxadjustMenu 的 hideMenuIndex 改為先宣告再賦值scrollFn 的 isChatBtn 改為 typeof window.chatBtn !== 'undefined'scrollFn 的 innerHeight 改為每次滾動時動態計算 window.innerHeight + 56knocket.pug template and config optionscriptCache / cssCache) to prevent duplicate loadsrafThrottle utility function based on requestAnimationFramesanitizeString) to prevent XSS injectionIntersectionObserver instead of throttle + iteration, significantly reducing scroll event computationbtf.throttle to btf.rafThrottle, syncing with browser render frame raterafThrottle to resize event handlerscrollToDest smooth scrolling from linear interpolation to easeOutQuart easinggoUpElement / scrollPercentElement in closure for rightsideScrollPercent, avoiding DOM queries on every scrollpage-header / menus elements in closure for overflowPaddingRdocument.getElementById results in sidebarFn for hamburger menu toggleadjustMenu's classList.toggle in requestAnimationFrameforPostFn to accept $article parameter; all internal functions (addHighlightTool, addPhotoFigcaption, runLightbox, scrollFnToDo, addTableWrap, clickFnOfTagHide, tabsFn) use the passed $article instead of repeated document.getElementById('article-container')tabsFn to event delegation, binding click listener on $article instead of each .tabs elementclickFnOfTagHide to event delegation, binding on $article instead of individual .hide-button elementsgetActualHeight to use cloneNode(true) + hidden insertion measurement instead of traversing parent nodes and modifying stylesindexOf to Map.has / Map.get for O(1) lookupsgetMaps) to avoid unnecessary computationtranslateButtonObject in tw_cn.js to let, supporting re-query after pjaxAbortController for event listener lifecycle management to prevent duplicate bindings; add stopPropagation to wheel events to prevent scroll pass-through; cache getBoundingClientRect with dirty flag; batch DOM updates via requestAnimationFrame; normalize deltaMode for cross-browser compatibilityrevokeObjectURL timeout from 30s to 5sui/lazy module for deferred rendering, removing the renderActions.findScript hacktypesetClear + typesetPromise instead of texResetresolvePostAsset as independent function in random_cover.js to reduce duplicationgetVersion in page.js to reference themeVersion from module-level require, avoiding repeated package.json readsinject_head_js.js for cross-midnight scenarios (start > end)translateButtonObject changed to let and re-queried in translateInitialization)script[data-pjax] replacement failure after pjax completion (add item.parentNode existence check)responseURL potentially being undefined in pjax error handling, add null checkshandleThemeChange crash when themeChange is not an object (add typeof fn !== 'function' check)scrollFn where checkDocumentHeight() returning early prevented scroll event bindingsvg.style.touchAction = 'none' + preventDefault + stopPropagation on wheel events)__mermaidGestureBound flag with __mermaidAbortController cleanup)gallery.js IMAGE_REGEX lastIndex not resetting on repeated callsflink.js and button.js due to missing HTML escapinghide.js parseArgs missing trim, causing parameters to have leading spacesseries.js module-level mutable groups state accumulating stale data across builds (add before_generate cleanup)score.js duplicating escapeHTML implementation, switch to hexo-util's escapeHTML with additional {} handlinggetArchiveLength.js year count not accumulating in monthly modegetArchiveLength.js key selection logic so daily mode correctly retrieves month countsrelated_post.js computing postDesc prematurely; defer to render timepage.js timezone variable scope issue in shuoshuoFNpage.js cloudTags removing redundant colorClass variable and classpage.js findArchivesTitle recursion where m[key] might not be a stringmain.js fetchUrl silently returning empty array on HTTP failure; now throws errormain.js runJustifiedGallery edge case handling when limit / firstLimit are invalid valuesmain.js addJustifiedGallery error handling when data is not an arraymain.js sanitizeString from only replacing " to replacing &, ", ', <, > charactersmain.js forPostFn skipping initialization when hbe-container existsmain.js gallery showing loading animation when data is emptyMath.pow(1.001, delta)) for smoother operationminW/maxW/minH/maxHtypeof svg === 'string' branch in Mermaid openSvgInNewTablazyMargin to 200pxadjustMenu hideMenuIndex from inline to pre-declaredscrollFn isChatBtn to typeof window.chatBtn !== 'undefined'scrollFn innerHeight to dynamically compute window.innerHeight + 56 on each scroll此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。