🎨 Improve marketplace loading https://github.com/siyuan-note/siyuan/issues/11179
This commit is contained in:
parent
479370b9f5
commit
bc22aa0c35
7 changed files with 66 additions and 21 deletions
|
@ -530,8 +530,10 @@ export const bazaar = {
|
|||
<div class="ft__on-surface ft__smaller" style="line-height: 20px;">${window.siyuan.languages.currentVer}<br>v${data.version}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<div class="ft__on-surface ft__smaller" style="line-height: 20px;">${dataObj.downloaded ? window.siyuan.languages.installDate : window.siyuan.languages.releaseDate}<br>${dataObj.downloaded ? data.hInstallDate : data.hUpdated}</div>
|
||||
<div class="fn__hr${dataObj.downloaded?"fn__none":""}"></div>
|
||||
<div class="ft__on-surface ft__smaller${dataObj.downloaded?"fn__none":""}" style="line-height: 20px;">${window.siyuan.languages.pkgSize}<br>${data.hSize}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<div class="ft__on-surface ft__smaller" style="line-height: 20px;">${dataObj.downloaded ? window.siyuan.languages.installSize : window.siyuan.languages.pkgSize}<br>${dataObj.downloaded ? data.hInstallSize : data.hSize}</div>
|
||||
<div class="ft__on-surface ft__smaller" style="line-height: 20px;">${window.siyuan.languages.installSize}<br>${data.hInstallSize}</div>
|
||||
<div class="fn__hr--b"></div>
|
||||
<div class="fn__hr--b"></div>
|
||||
<div${(data.installed || dataObj.downloaded) ? ' class="fn__none"' : ""}>
|
||||
|
|
|
@ -89,6 +89,9 @@ func Icons() (icons []*Icon) {
|
|||
icon.OpenIssues = repo.OpenIssues
|
||||
icon.Size = repo.Size
|
||||
icon.HSize = humanize.BytesCustomCeil(uint64(icon.Size), 2)
|
||||
icon.InstallSize = repo.InstallSize
|
||||
icon.HInstallSize = humanize.BytesCustomCeil(uint64(icon.InstallSize), 2)
|
||||
packageInstallSizeCache.SetDefault(icon.RepoURL, icon.InstallSize)
|
||||
icon.HUpdated = formatUpdated(icon.Updated)
|
||||
pkg := bazaarIndex[strings.Split(repoURL, "@")[0]]
|
||||
if nil != pkg {
|
||||
|
@ -156,9 +159,14 @@ func InstalledIcons() (ret []*Icon) {
|
|||
continue
|
||||
}
|
||||
icon.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
installSize, _ := util.SizeOfDirectory(installPath)
|
||||
icon.InstallSize = installSize
|
||||
icon.HInstallSize = humanize.BytesCustomCeil(uint64(installSize), 2)
|
||||
if installSize, ok := packageInstallSizeCache.Get(icon.RepoURL); ok {
|
||||
icon.InstallSize = installSize.(int64)
|
||||
} else {
|
||||
is, _ := util.SizeOfDirectory(installPath)
|
||||
icon.InstallSize = is
|
||||
packageInstallSizeCache.SetDefault(icon.RepoURL, is)
|
||||
}
|
||||
icon.HInstallSize = humanize.BytesCustomCeil(uint64(icon.InstallSize), 2)
|
||||
readmeFilename := getPreferredReadme(icon.Readme)
|
||||
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
|
||||
if nil != readErr {
|
||||
|
|
|
@ -121,11 +121,12 @@ type StagePackage struct {
|
|||
}
|
||||
|
||||
type StageRepo struct {
|
||||
URL string `json:"url"`
|
||||
Updated string `json:"updated"`
|
||||
Stars int `json:"stars"`
|
||||
OpenIssues int `json:"openIssues"`
|
||||
Size int64 `json:"size"`
|
||||
URL string `json:"url"`
|
||||
Updated string `json:"updated"`
|
||||
Stars int `json:"stars"`
|
||||
OpenIssues int `json:"openIssues"`
|
||||
Size int64 `json:"size"`
|
||||
InstallSize int64 `json:"installSize"`
|
||||
|
||||
Package *StagePackage `json:"package"`
|
||||
}
|
||||
|
@ -703,3 +704,5 @@ func disallowDisplayBazaarPackage(pkg *Package) bool {
|
|||
}
|
||||
|
||||
var packageCache = gcache.New(6*time.Hour, 30*time.Minute) // [repoURL]*Package
|
||||
|
||||
var packageInstallSizeCache = gcache.New(48*time.Hour, 6*time.Hour) // [repoURL]*int64
|
||||
|
|
|
@ -94,6 +94,9 @@ func Plugins(frontend string) (plugins []*Plugin) {
|
|||
plugin.OpenIssues = repo.OpenIssues
|
||||
plugin.Size = repo.Size
|
||||
plugin.HSize = humanize.BytesCustomCeil(uint64(plugin.Size), 2)
|
||||
plugin.InstallSize = repo.InstallSize
|
||||
plugin.HInstallSize = humanize.BytesCustomCeil(uint64(plugin.InstallSize), 2)
|
||||
packageInstallSizeCache.SetDefault(plugin.RepoURL, plugin.InstallSize)
|
||||
plugin.HUpdated = formatUpdated(plugin.Updated)
|
||||
pkg := bazaarIndex[strings.Split(repoURL, "@")[0]]
|
||||
if nil != pkg {
|
||||
|
@ -194,9 +197,14 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
|
|||
continue
|
||||
}
|
||||
plugin.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
installSize, _ := util.SizeOfDirectory(installPath)
|
||||
plugin.InstallSize = installSize
|
||||
plugin.HInstallSize = humanize.BytesCustomCeil(uint64(installSize), 2)
|
||||
if installSize, ok := packageInstallSizeCache.Get(plugin.RepoURL); ok {
|
||||
plugin.InstallSize = installSize.(int64)
|
||||
} else {
|
||||
is, _ := util.SizeOfDirectory(installPath)
|
||||
plugin.InstallSize = is
|
||||
packageInstallSizeCache.SetDefault(plugin.RepoURL, is)
|
||||
}
|
||||
plugin.HInstallSize = humanize.BytesCustomCeil(uint64(plugin.InstallSize), 2)
|
||||
readmeFilename := getPreferredReadme(plugin.Readme)
|
||||
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
|
||||
if nil != readErr {
|
||||
|
|
|
@ -90,6 +90,9 @@ func Templates() (templates []*Template) {
|
|||
template.OpenIssues = repo.OpenIssues
|
||||
template.Size = repo.Size
|
||||
template.HSize = humanize.BytesCustomCeil(uint64(template.Size), 2)
|
||||
template.InstallSize = repo.InstallSize
|
||||
template.HInstallSize = humanize.BytesCustomCeil(uint64(template.InstallSize), 2)
|
||||
packageInstallSizeCache.SetDefault(template.RepoURL, template.InstallSize)
|
||||
template.HUpdated = formatUpdated(template.Updated)
|
||||
pkg := bazaarIndex[strings.Split(repoURL, "@")[0]]
|
||||
if nil != pkg {
|
||||
|
@ -157,9 +160,14 @@ func InstalledTemplates() (ret []*Template) {
|
|||
continue
|
||||
}
|
||||
template.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
installSize, _ := util.SizeOfDirectory(installPath)
|
||||
template.InstallSize = installSize
|
||||
template.HInstallSize = humanize.BytesCustomCeil(uint64(installSize), 2)
|
||||
if installSize, ok := packageInstallSizeCache.Get(template.RepoURL); ok {
|
||||
template.InstallSize = installSize.(int64)
|
||||
} else {
|
||||
is, _ := util.SizeOfDirectory(installPath)
|
||||
template.InstallSize = is
|
||||
packageInstallSizeCache.SetDefault(template.RepoURL, is)
|
||||
}
|
||||
template.HInstallSize = humanize.BytesCustomCeil(uint64(template.InstallSize), 2)
|
||||
readmeFilename := getPreferredReadme(template.Readme)
|
||||
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
|
||||
if nil != readErr {
|
||||
|
|
|
@ -91,6 +91,9 @@ func Themes() (ret []*Theme) {
|
|||
theme.OpenIssues = repo.OpenIssues
|
||||
theme.Size = repo.Size
|
||||
theme.HSize = humanize.BytesCustomCeil(uint64(theme.Size), 2)
|
||||
theme.InstallSize = repo.InstallSize
|
||||
theme.HInstallSize = humanize.BytesCustomCeil(uint64(theme.InstallSize), 2)
|
||||
packageInstallSizeCache.SetDefault(theme.RepoURL, theme.InstallSize)
|
||||
theme.HUpdated = formatUpdated(theme.Updated)
|
||||
pkg := bazaarIndex[strings.Split(repoURL, "@")[0]]
|
||||
if nil != pkg {
|
||||
|
@ -158,9 +161,14 @@ func InstalledThemes() (ret []*Theme) {
|
|||
continue
|
||||
}
|
||||
theme.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
installSize, _ := util.SizeOfDirectory(installPath)
|
||||
theme.InstallSize = installSize
|
||||
theme.HInstallSize = humanize.BytesCustomCeil(uint64(installSize), 2)
|
||||
if installSize, ok := packageInstallSizeCache.Get(theme.RepoURL); ok {
|
||||
theme.InstallSize = installSize.(int64)
|
||||
} else {
|
||||
is, _ := util.SizeOfDirectory(installPath)
|
||||
theme.InstallSize = is
|
||||
packageInstallSizeCache.SetDefault(theme.RepoURL, is)
|
||||
}
|
||||
theme.HInstallSize = humanize.BytesCustomCeil(uint64(theme.InstallSize), 2)
|
||||
readmeFilename := getPreferredReadme(theme.Readme)
|
||||
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
|
||||
if nil != readErr {
|
||||
|
|
|
@ -90,6 +90,9 @@ func Widgets() (widgets []*Widget) {
|
|||
widget.OpenIssues = repo.OpenIssues
|
||||
widget.Size = repo.Size
|
||||
widget.HSize = humanize.BytesCustomCeil(uint64(widget.Size), 2)
|
||||
widget.InstallSize = repo.InstallSize
|
||||
widget.HInstallSize = humanize.BytesCustomCeil(uint64(widget.InstallSize), 2)
|
||||
packageInstallSizeCache.SetDefault(widget.RepoURL, widget.InstallSize)
|
||||
widget.HUpdated = formatUpdated(widget.Updated)
|
||||
pkg := bazaarIndex[strings.Split(repoURL, "@")[0]]
|
||||
if nil != pkg {
|
||||
|
@ -155,9 +158,14 @@ func InstalledWidgets() (ret []*Widget) {
|
|||
continue
|
||||
}
|
||||
widget.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
installSize, _ := util.SizeOfDirectory(installPath)
|
||||
widget.InstallSize = installSize
|
||||
widget.HInstallSize = humanize.BytesCustomCeil(uint64(installSize), 2)
|
||||
if installSize, ok := packageInstallSizeCache.Get(widget.RepoURL); ok {
|
||||
widget.InstallSize = installSize.(int64)
|
||||
} else {
|
||||
is, _ := util.SizeOfDirectory(installPath)
|
||||
widget.InstallSize = is
|
||||
packageInstallSizeCache.SetDefault(widget.RepoURL, is)
|
||||
}
|
||||
widget.HInstallSize = humanize.BytesCustomCeil(uint64(widget.InstallSize), 2)
|
||||
readmeFilename := getPreferredReadme(widget.Readme)
|
||||
readme, readErr := os.ReadFile(filepath.Join(installPath, readmeFilename))
|
||||
if nil != readErr {
|
||||
|
|
Loading…
Add table
Reference in a new issue