mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 集市支持已安装的包单独显示 https://github.com/siyuan-note/siyuan/issues/5678
This commit is contained in:
parent
0f13f79ce4
commit
bb0995eb6b
5 changed files with 23 additions and 19 deletions
|
|
@ -96,7 +96,7 @@ func Icons() (icons []*Icon) {
|
||||||
|
|
||||||
func InstalledIcons() (ret []*Icon) {
|
func InstalledIcons() (ret []*Icon) {
|
||||||
ret = []*Icon{}
|
ret = []*Icon{}
|
||||||
dir, err := os.Open(filepath.Join(util.AppearancePath, "icons"))
|
dir, err := os.Open(util.IconsPath)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogWarnf("open icons folder failed: %s", err)
|
logging.LogWarnf("open icons folder failed: %s", err)
|
||||||
return
|
return
|
||||||
|
|
@ -137,14 +137,14 @@ func InstalledIcons() (ret []*Icon) {
|
||||||
icon.Size = iconDir.Size()
|
icon.Size = iconDir.Size()
|
||||||
icon.HSize = humanize.Bytes(uint64(icon.Size))
|
icon.HSize = humanize.Bytes(uint64(icon.Size))
|
||||||
icon.HUpdated = formatUpdated(icon.Updated)
|
icon.HUpdated = formatUpdated(icon.Updated)
|
||||||
readme, readErr := os.ReadFile(filepath.Join(util.AppearancePath, "icons", dirName, "README.md"))
|
readme, readErr := os.ReadFile(filepath.Join(util.IconsPath, dirName, "README.md"))
|
||||||
if nil != readErr {
|
if nil != readErr {
|
||||||
logging.LogWarnf("read install icon README.md failed: %s", readErr)
|
logging.LogWarnf("read install icon README.md failed: %s", readErr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
icon.README, _ = renderREADME(icon.URL, readme)
|
icon.README, _ = renderREADME(icon.URL, readme)
|
||||||
icon.Outdated = isOutdatedIcon(icon.URL, icon.Version, bazaarIcons)
|
icon.Outdated = isOutdatedIcon(icon, bazaarIcons)
|
||||||
ret = append(ret, icon)
|
ret = append(ret, icon)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ func WidgetJSON(widgetDirName string) (ret map[string]interface{}, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func IconJSON(iconDirName string) (ret map[string]interface{}, err error) {
|
func IconJSON(iconDirName string) (ret map[string]interface{}, err error) {
|
||||||
p := filepath.Join(util.AppearancePath, "icons", iconDirName, "icon.json")
|
p := filepath.Join(util.IconsPath, iconDirName, "icon.json")
|
||||||
if !gulu.File.IsExist(p) {
|
if !gulu.File.IsExist(p) {
|
||||||
err = os.ErrNotExist
|
err = os.ErrNotExist
|
||||||
return
|
return
|
||||||
|
|
@ -172,52 +172,56 @@ func getPkgIndex(pkgType string) (ret map[string]interface{}, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func isOutdatedTheme(fullURL, version string, bazaarThemes []*Theme) bool {
|
func isOutdatedTheme(theme *Theme, bazaarThemes []*Theme) bool {
|
||||||
if !strings.HasPrefix(fullURL, "https://github.com/") {
|
if !strings.HasPrefix(theme.URL, "https://github.com/") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range bazaarThemes {
|
for _, pkg := range bazaarThemes {
|
||||||
if fullURL == pkg.URL && version != pkg.Version {
|
if theme.URL == pkg.URL && theme.Version != pkg.Version {
|
||||||
|
theme.RepoHash = pkg.RepoHash
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isOutdatedIcon(fullURL, version string, bazaarIcons []*Icon) bool {
|
func isOutdatedIcon(icon *Icon, bazaarIcons []*Icon) bool {
|
||||||
if !strings.HasPrefix(fullURL, "https://github.com/") {
|
if !strings.HasPrefix(icon.URL, "https://github.com/") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range bazaarIcons {
|
for _, pkg := range bazaarIcons {
|
||||||
if fullURL == pkg.URL && version != pkg.Version {
|
if icon.URL == pkg.URL && icon.Version != pkg.Version {
|
||||||
|
icon.RepoHash = pkg.RepoHash
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isOutdatedWidget(fullURL, version string, bazaarWidgets []*Widget) bool {
|
func isOutdatedWidget(widget *Widget, bazaarWidgets []*Widget) bool {
|
||||||
if !strings.HasPrefix(fullURL, "https://github.com/") {
|
if !strings.HasPrefix(widget.URL, "https://github.com/") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range bazaarWidgets {
|
for _, pkg := range bazaarWidgets {
|
||||||
if fullURL == pkg.URL && version != pkg.Version {
|
if widget.URL == pkg.URL && widget.Version != pkg.Version {
|
||||||
|
widget.RepoHash = pkg.RepoHash
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isOutdatedTemplate(fullURL, version string, bazaarTemplates []*Template) bool {
|
func isOutdatedTemplate(template *Template, bazaarTemplates []*Template) bool {
|
||||||
if !strings.HasPrefix(fullURL, "https://github.com/") {
|
if !strings.HasPrefix(template.URL, "https://github.com/") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range bazaarTemplates {
|
for _, pkg := range bazaarTemplates {
|
||||||
if fullURL == pkg.URL && version != pkg.Version {
|
if template.URL == pkg.URL && template.Version != pkg.Version {
|
||||||
|
template.RepoHash = pkg.RepoHash
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ func InstalledTemplates() (ret []*Template) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
template.README, _ = renderREADME(template.URL, readme)
|
template.README, _ = renderREADME(template.URL, readme)
|
||||||
template.Outdated = isOutdatedTemplate(template.URL, template.Version, bazaarTemplates)
|
template.Outdated = isOutdatedTemplate(template, bazaarTemplates)
|
||||||
ret = append(ret, template)
|
ret = append(ret, template)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ func InstalledThemes() (ret []*Theme) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
theme.README, _ = renderREADME(theme.URL, readme)
|
theme.README, _ = renderREADME(theme.URL, readme)
|
||||||
theme.Outdated = isOutdatedTheme(theme.URL, theme.Version, bazaarThemes)
|
theme.Outdated = isOutdatedTheme(theme, bazaarThemes)
|
||||||
ret = append(ret, theme)
|
ret = append(ret, theme)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ func InstalledWidgets() (ret []*Widget) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
widget.README, _ = renderREADME(widget.URL, readme)
|
widget.README, _ = renderREADME(widget.URL, readme)
|
||||||
widget.Outdated = isOutdatedWidget(widget.URL, widget.Version, bazaarWidgets)
|
widget.Outdated = isOutdatedWidget(widget, bazaarWidgets)
|
||||||
ret = append(ret, widget)
|
ret = append(ret, widget)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue