Skip to content

加快Render - #491

Merged
CodFrm merged 2 commits into
scriptscat:mainfrom
cyfung1031:patch_speed
Jul 5, 2025
Merged

CodFrm merged 2 commits into
scriptscat:mainfrom
cyfung1031:patch_speed

Conversation

@cyfung1031

Copy link
Copy Markdown
Collaborator
  • package.json 版本更新
  • pages/popup/... 代碼優化
  • 無用X-UA-Compatible移除,修正<!DOCTYPE html>
  • loggerCore的debug start加 requestIdleCallback
  • randomString 代碼優化
  • calculateMd5: 原生 crypto API 來計算 MD5

@cyfung1031

Copy link
Copy Markdown
Collaborator Author

相關issue: #265

@CodFrm
CodFrm requested a review from Copilot July 5, 2025 13:02
Comment thread src/pages/offscreen.html Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR accelerates rendering by deferring non-critical tasks, optimizes utility functions, updates HTML templates, and bumps several dependencies to newer versions.

  • Defer loggerCore.debug calls using requestIdleCallback in popup and options pages
  • Optimize randomString, implement native crypto-based MD5 with fallback, and clean up HTML/doctypes
  • Memoize component lists in the popup, refine CSS specificity, and update package versions

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/pkg/utils/utils.ts Optimized randomString, added native crypto MD5 with fallback
src/pages/template.html Fixed <!DOCTYPE html>, removed obsolete X-UA-Compatible
src/pages/sandbox.html Fixed <!DOCTYPE html>, removed obsolete X-UA-Compatible
src/pages/offscreen.html Fixed <!DOCTYPE html>, enhanced iframe sandbox attributes
src/pages/popup/main.tsx Deferred non-critical logging via requestIdleCallback
src/pages/options/main.tsx Deferred non-critical logging via requestIdleCallback
src/pages/popup/index.css Scoped .arco-collapse selector, removed !important
src/pages/popup/App.tsx Added useMemo, simplified URL effect, cleaned up handlers
package.json Bumped React, tools, and devDependencies versions
Comments suppressed due to low confidence (2)

src/pages/popup/App.tsx:104

  • [nitpick] The variable name bUserScriptsAvailable uses Hungarian notation; consider renaming it to userScriptsAvailable or isUserScriptsAvailableFlag for clarity.
  const bUserScriptsAvailable = isUserScriptsAvailable();

src/pages/popup/index.css:13

  • [nitpick] Using the [class] attribute selector may unintentionally limit rule application; ensure this specificity is intended and consider a clearer selector to improve maintainability.
.arco-collapse[class] {

Comment thread src/pages/offscreen.html Resolved
Comment thread src/pkg/utils/utils.ts Resolved
Comment thread src/pages/popup/main.tsx Resolved
Comment thread src/pages/options/main.tsx Resolved
@CodFrm
CodFrm merged commit 1b266be into scriptscat:main Jul 5, 2025
@cyfung1031

Copy link
Copy Markdown
Collaborator Author

@CodFrm 有空的話看一看 vitest 升上 3.x.x 版本有沒有問題吧

https://cn.vitest.dev/guide/migration

我看過好像不用改代碼。不肯定

@cyfung1031

Copy link
Copy Markdown
Collaborator Author

剛發現 calculateMd5 的新代碼是錯誤的
下一次PR修回來

@CodFrm

CodFrm commented Jul 7, 2025 •

Copy link
Copy Markdown
Member

@cyfung1031 我升级了vitest到最新版本了,并修改了calculateMd5 bbc2550

@cyfung1031
cyfung1031 deleted the patch_speed branch July 8, 2025 14:40
@CodFrm

CodFrm commented Jul 13, 2025 •

Copy link
Copy Markdown
Member

@cyfung1031 我刚刚在Windows环境上跑,才发现无法使用vitest了 https://github.com/scriptscat/scriptcat/actions/runs/16246287627


奇怪,ci通过了,我再看看我本地的环境


我更新了我本地的node(22.6.0)到最新可以了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants