Improve marketplace loading performance Fix https://github.com/siyuan-note/siyuan/issues/10973

This commit is contained in:
Daniel 2024-04-12 09:15:03 +08:00
parent 541483ed29
commit da59fa2afa
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
7 changed files with 49 additions and 0 deletions

View file

@ -51,6 +51,13 @@ func Icons() (icons []*Icon) {
repo := arg.(*StageRepo)
repoURL := repo.URL
if pkg, found := packageCache.Get(repoURL); found {
lock.Lock()
icons = append(icons, pkg.(*Icon))
lock.Unlock()
return
}
icon := &Icon{}
innerU := util.BazaarOSSServer + "/package/" + repoURL + "/icon.json"
innerResp, innerErr := httpclient.NewBrowserRequest().SetSuccessResult(icon).Get(innerU)
@ -91,6 +98,8 @@ func Icons() (icons []*Icon) {
lock.Lock()
icons = append(icons, icon)
lock.Unlock()
packageCache.SetDefault(repoURL, icon)
})
for _, repo := range stageIndex.Repos {
waitGroup.Add(1)