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

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