This commit is contained in:
Liang Ding 2022-09-03 23:54:26 +08:00
parent fcfbab3652
commit 9bc71a9f2c
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
15 changed files with 49 additions and 38 deletions

View file

@ -124,6 +124,8 @@ func InstalledIcons() (ret []*Icon) {
continue
}
installPath := filepath.Join(util.IconsPath, dirName)
icon := &Icon{}
icon.Installed = true
icon.Name = iconConf["name"].(string)
@ -134,10 +136,11 @@ func InstalledIcons() (ret []*Icon) {
icon.PreviewURL = "/appearance/icons/" + dirName + "/preview.png"
icon.PreviewURLThumb = "/appearance/icons/" + dirName + "/preview.png"
icon.Updated = iconDir.ModTime().Format("2006-01-02 15:04:05")
icon.Size = iconDir.Size()
icon.HSize = humanize.Bytes(uint64(icon.Size))
icon.HUpdated = formatUpdated(icon.Updated)
readme, readErr := os.ReadFile(filepath.Join(util.IconsPath, dirName, "README.md"))
installSize, _ := util.SizeOfDirectory(installPath)
icon.InstallSize = installSize
icon.HInstallSize = humanize.Bytes(uint64(installSize))
readme, readErr := os.ReadFile(filepath.Join(installPath, "README.md"))
if nil != readErr {
logging.LogWarnf("read install icon README.md failed: %s", readErr)
continue

View file

@ -50,16 +50,18 @@ type Package struct {
README string `json:"readme"`
Installed bool `json:"installed"`
Outdated bool `json:"outdated"`
Current bool `json:"current"`
Updated string `json:"updated"`
Stars int `json:"stars"`
OpenIssues int `json:"openIssues"`
Size int64 `json:"size"`
HSize string `json:"hSize"`
HUpdated string `json:"hUpdated"`
Downloads int `json:"downloads"`
Installed bool `json:"installed"`
Outdated bool `json:"outdated"`
Current bool `json:"current"`
Updated string `json:"updated"`
Stars int `json:"stars"`
OpenIssues int `json:"openIssues"`
Size int64 `json:"size"`
HSize string `json:"hSize"`
InstallSize int64 `json:"installSize"`
HInstallSize string `json:"hInstallSize"`
HUpdated string `json:"hUpdated"`
Downloads int `json:"downloads"`
}
func WidgetJSON(widgetDirName string) (ret map[string]interface{}, err error) {

View file

@ -124,6 +124,8 @@ func InstalledTemplates() (ret []*Template) {
continue
}
installPath := filepath.Join(util.DataDir, "templates", dirName)
template := &Template{}
template.Installed = true
template.Name = templateConf["name"].(string)
@ -134,10 +136,11 @@ func InstalledTemplates() (ret []*Template) {
template.PreviewURL = "/templates/" + dirName + "/preview.png"
template.PreviewURLThumb = "/templates/" + dirName + "/preview.png"
template.Updated = templateDir.ModTime().Format("2006-01-02 15:04:05")
template.Size = templateDir.Size()
template.HSize = humanize.Bytes(uint64(template.Size))
template.HUpdated = formatUpdated(template.Updated)
readme, readErr := os.ReadFile(filepath.Join(util.DataDir, "templates", dirName, "README.md"))
installSize, _ := util.SizeOfDirectory(installPath)
template.InstallSize = installSize
template.HInstallSize = humanize.Bytes(uint64(installSize))
readme, readErr := os.ReadFile(filepath.Join(installPath, "README.md"))
if nil != readErr {
logging.LogWarnf("read install template README.md failed: %s", readErr)
continue

View file

@ -126,6 +126,8 @@ func InstalledThemes() (ret []*Theme) {
continue
}
installPath := filepath.Join(util.ThemesPath, dirName)
theme := &Theme{}
theme.Installed = true
theme.Name = themeConf["name"].(string)
@ -137,10 +139,11 @@ func InstalledThemes() (ret []*Theme) {
theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png"
theme.PreviewURLThumb = "/appearance/themes/" + dirName + "/preview.png"
theme.Updated = themeDir.ModTime().Format("2006-01-02 15:04:05")
theme.Size = themeDir.Size()
theme.HSize = humanize.Bytes(uint64(theme.Size))
theme.HUpdated = formatUpdated(theme.Updated)
readme, readErr := os.ReadFile(filepath.Join(util.ThemesPath, dirName, "README.md"))
installSize, _ := util.SizeOfDirectory(installPath)
theme.InstallSize = installSize
theme.HInstallSize = humanize.Bytes(uint64(installSize))
readme, readErr := os.ReadFile(filepath.Join(installPath, "README.md"))
if nil != readErr {
logging.LogWarnf("read install theme README.md failed: %s", readErr)
continue

View file

@ -122,6 +122,8 @@ func InstalledWidgets() (ret []*Widget) {
continue
}
installPath := filepath.Join(util.DataDir, "widgets", dirName)
widget := &Widget{}
widget.Installed = true
widget.Name = widgetConf["name"].(string)
@ -132,10 +134,11 @@ func InstalledWidgets() (ret []*Widget) {
widget.PreviewURL = "/widgets/" + dirName + "/preview.png"
widget.PreviewURLThumb = "/widgets/" + dirName + "/preview.png"
widget.Updated = widgetDir.ModTime().Format("2006-01-02 15:04:05")
widget.Size = widgetDir.Size()
widget.HSize = humanize.Bytes(uint64(widget.Size))
widget.HUpdated = formatUpdated(widget.Updated)
readme, readErr := os.ReadFile(filepath.Join(util.DataDir, "widgets", dirName, "README.md"))
installSize, _ := util.SizeOfDirectory(installPath)
widget.InstallSize = installSize
widget.HInstallSize = humanize.Bytes(uint64(installSize))
readme, readErr := os.ReadFile(filepath.Join(installPath, "README.md"))
if nil != readErr {
logging.LogWarnf("read install widget README.md failed: %s", readErr)
continue