Documentation
¶
Index ¶
- func GetBazaarPackageREADME(ctx context.Context, repoURL, repoHash, pkgType string) (ret string)
- func GetBazaarPackagesMap(pkgType, frontend string) map[string]*Package
- func GetCurrentBackend() string
- func GetPreferredLocaleString(m LocaleStrings, fallback string) string
- func InstallPackage(repoURL, repoHash, installPath, systemID, pkgType, packageName string) error
- func IsIncompatibleKernelPlugin(plugin *Package) bool
- func IsIncompatiblePlugin(plugin *Package, frontend string) bool
- func IsTargetSupported(platforms []string, target string) bool
- func ParseInstalledPlugin(name, frontend string) (found bool, version, displayName string, ...)
- func ReadInstalledPackageDirs(basePath string) ([]os.DirEntry, error)
- func RemovePackageInfo(pkgType, pkgName string)
- func SetInstalledPackageMetadata(pkg *Package, installPath, baseURLPath, pkgType, frontend string, ...) bool
- func UninstallPackage(installPath string) (err error)
- type BazaarInfo
- type Funding
- type LocaleStrings
- type Package
- type PackageInfo
- type StageBazaarResult
- type StageIndex
- type StageRepo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBazaarPackageREADME ¶
GetBazaarPackageREADME 获取集市包的在线 README。
func GetBazaarPackagesMap ¶
GetBazaarPackagesMap 返回按包名索引的在线集市包映射(plugins 类型需要传递 frontend 参数)。
func GetCurrentBackend ¶
func GetCurrentBackend() string
func GetPreferredLocaleString ¶
func GetPreferredLocaleString(m LocaleStrings, fallback string) string
GetPreferredLocaleString 从 LocaleStrings 中按当前语种取值,无则回退 default、en、en_US(历史命名兼容),再回退 fallback。
func InstallPackage ¶
InstallPackage 安装集市包
func IsIncompatibleKernelPlugin ¶
IsIncompatibleKernelPlugin 判断内核插件是否与当前环境不兼容
func IsIncompatiblePlugin ¶
IsIncompatiblePlugin 判断插件是否与当前环境不兼容
func IsTargetSupported ¶
IsTargetSupported 检查 platforms 中是否包含 target 或 "all"
func ParseInstalledPlugin ¶
func ReadInstalledPackageDirs ¶
ReadInstalledPackageDirs 读取本地集市包的目录列表
func RemovePackageInfo ¶
func RemovePackageInfo(pkgType, pkgName string)
RemovePackageInfo 删除集市包的持久化信息
func SetInstalledPackageMetadata ¶
func SetInstalledPackageMetadata(pkg *Package, installPath, baseURLPath, pkgType, frontend string, bazaarPackagesMap map[string]*Package) bool
SetInstalledPackageMetadata 设置本地集市包的通用元数据
func UninstallPackage ¶
UninstallPackage 卸载集市包
Types ¶
type BazaarInfo ¶
type BazaarInfo struct {
Packages map[string]map[string]*PackageInfo `json:"packages"`
}
BazaarInfo 集市的持久化信息
type LocaleStrings ¶
LocaleStrings 表示按语种 key 的字符串表,key 为语种如 "default"、"en_US"、"zh_CN" 等
type Package ¶
type Package struct {
Author string `json:"author"`
URL string `json:"url"`
Version string `json:"version"`
MinAppVersion string `json:"minAppVersion"`
DisabledInPublish bool `json:"disabledInPublish"`
Kernels []string `json:"kernels"`
Backends []string `json:"backends"`
Frontends []string `json:"frontends"`
DisplayName LocaleStrings `json:"displayName"`
Description LocaleStrings `json:"description"`
Readme LocaleStrings `json:"readme"`
Funding *Funding `json:"funding"`
Keywords []string `json:"keywords"`
PreferredFunding string `json:"preferredFunding"`
PreferredName string `json:"preferredName"`
PreferredDesc string `json:"preferredDesc"`
PreferredReadme string `json:"preferredReadme"`
Name string `json:"name"` // 包名,不一定是仓库名
RepoURL string `json:"repoURL"` // 形式为 https://github.com/owner/repo
RepoHash string `json:"repoHash"`
PreviewURL string `json:"previewURL"`
IconURL string `json:"iconURL"`
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"`
HInstallDate string `json:"hInstallDate"`
HUpdated string `json:"hUpdated"`
Downloads int `json:"downloads"`
DisallowInstall bool `json:"disallowInstall"`
DisallowUpdate bool `json:"disallowUpdate"`
UpdateRequiredMinAppVer string `json:"updateRequiredMinAppVer,omitempty"` // 升级目标要求的最小应用版本
// 专用字段,nil 时不序列化
InstalledIncompatible *bool `json:"installedIncompatible,omitempty"` // Plugin:本地已安装版本是否不兼容
BazaarIncompatible *bool `json:"bazaarIncompatible,omitempty"` // Plugin:在线集市版本是否不兼容
Enabled *bool `json:"enabled,omitempty"` // Plugin:是否启用
Modes *[]string `json:"modes,omitempty"` // Theme:支持的模式列表
}
Package 描述了集市包元数据和传递给前端的其他信息。
- 集市包新增元数据字段需要同步修改 bazaar 的工作流,参考 https://github.com/siyuan-note/bazaar/commit/aa36d0003139c52d8e767c6e18a635be006323e2
func FilterPackages ¶
FilterPackages 按关键词过滤集市包列表
func GetBazaarPackages ¶
GetBazaarPackages 返回指定类型的在线集市包列表(plugins 类型需要传递 frontend 参数)。
func ParsePackageJSON ¶
ParsePackageJSON 解析集市包 JSON 文件
type PackageInfo ¶
type PackageInfo struct {
InstallTime int64 `json:"installTime"` // 安装时间戳(毫秒)
}
PackageInfo 集市包的持久化信息
type StageBazaarResult ¶
type StageBazaarResult struct {
StageIndex *StageIndex // stage 索引
BazaarStats map[string]*bazaarStats // 统计信息
Online bool // online 状态
StageErr error // stage 错误
}
type StageIndex ¶
type StageIndex struct {
Repos []*StageRepo `json:"repos"`
// contains filtered or unexported fields
}
type StageRepo ¶
type StageRepo struct {
URL string `json:"url"` // owner/repo@hash 形式
Updated string `json:"updated"`
Stars int `json:"stars"`
OpenIssues int `json:"openIssues"`
Size int64 `json:"size"`
InstallSize int64 `json:"installSize"`
// Package 与 stage/*.json 内嵌的完整 package 一致,可直接用于构建列表
Package *Package `json:"package"`
}