Repository navigation
perf(startup): 首屏静态页绘制后立即显示窗口,主界面按需加载 - #5
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
启动慢的主要原因不在 Go 端(
core.New本来就在 goroutine 里,数据库迁移只是 DDL),而在窗口显示的时机:StartHidden: true之后,窗口要等 React effect 发出frontend:ready才显示,而这个事件要等 583 kB 的主 JS(含 MainLayout、NoteEditor、react-markdown 等全部界面)下载、解析、执行完才会发。所以index.html里的静态启动页其实已经画好了,只是窗口一直是隐藏的。index.html:在#boot-splash后面加一段内联脚本,两帧requestAnimationFrame后立即调用window.runtime.EventsEmit('frontend:ready')(Wails 注入的ipc.js/runtime.js在<head>最前面,此时已经可用;还没准备好就每 16ms 重试一次)。React 端原来的 emit 保留作为兜底,showWindowOnce是幂等的。MainLayout改为lazy(() => import('./components/MainLayout'))按需加载,启动完成后在后台预取,解锁时不用再等下载。入口 chunk 从 582.72 kB 降到 220.10 kB,MainLayout 单独拆成 363.80 kB 的 chunk。waitForCoreReady轮询间隔 300ms → 50ms;IsUnlocked/GetVersion/GetDataDir改为Promise.all并发请求。验证:
npx tsc --noEmit、前端测试 130/130、vite build、go vet/go test ./internal/... .。没有在 Windows/macOS 实机上测启动耗时。Link to Devin session: https://app.devin.ai/sessions/d9ef026cb9244270a2d90f54f6d763a4
Open in Devin Desktop: https://app.devin.ai/desktop/session/d9ef026cb9244270a2d90f54f6d763a4?variant=devin
Requested by: @JackyZhang8