mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
🎨 Improve the fallback logic for fetching README in the marketplace (#16551)
* 加载已下载插件列表时,如果插件指定 README 文件不存在,则回退到 README.md https://github.com/siyuan-note/siyuan/issues/14636#issuecomment-3035905944 * 加载已下载插件列表时,如果插件指定 README 文件不存在,则回退到 README.md https://github.com/siyuan-note/siyuan/issues/14636#issuecomment-3035905944 * 提取公共函数 * 获取首选 Readme Name Desc 时优先回退到指定的默认值 * 兼容赞助链接 * 在线获取 README 时最后回退到 README.md
This commit is contained in:
parent
d11ed21f06
commit
058ade01c7
6 changed files with 108 additions and 78 deletions
|
|
@ -169,9 +169,9 @@ func InstalledIcons() (ret []*Icon) {
|
|||
icon.PreferredFunding = getPreferredFunding(icon.Funding)
|
||||
icon.PreferredName = GetPreferredName(icon.Package)
|
||||
icon.PreferredDesc = getPreferredDesc(icon.Description)
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "README.md"))
|
||||
info, statErr := os.Stat(filepath.Join(installPath, "icon.json"))
|
||||
if nil != statErr {
|
||||
logging.LogWarnf("stat install theme README.md failed: %s", statErr)
|
||||
logging.LogWarnf("stat install icon.json failed: %s", statErr)
|
||||
continue
|
||||
}
|
||||
icon.HInstallDate = info.ModTime().Format("2006-01-02")
|
||||
|
|
@ -183,14 +183,7 @@ func InstalledIcons() (ret []*Icon) {
|
|||
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 {
|
||||
logging.LogWarnf("read installed README.md failed: %s", readErr)
|
||||
continue
|
||||
}
|
||||
|
||||
icon.PreferredReadme, _ = renderLocalREADME("/appearance/icons/"+dirName+"/", readme)
|
||||
icon.PreferredReadme = loadInstalledReadme(installPath, "/appearance/icons/"+dirName+"/", icon.Readme)
|
||||
icon.Outdated = isOutdatedIcon(icon, bazaarIcons)
|
||||
ret = append(ret, icon)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue