- 新增多个源文件和目录,包括 app.rc、assets、build 脚本等 - 实现了与 MirrorChyan API 交互的客户端逻辑 - 添加了版本检查、更新检测和下载 URL 生成等功能 - 嵌入了配置模板和资源文件系统 - 提供了完整的构建和发布流程
35 lines
698 B
Go
35 lines
698 B
Go
package assets
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
)
|
|
|
|
//go:embed config_template.yaml
|
|
var EmbeddedAssets embed.FS
|
|
|
|
// GetConfigTemplate returns the embedded config template
|
|
func GetConfigTemplate() ([]byte, error) {
|
|
return EmbeddedAssets.ReadFile("config_template.yaml")
|
|
}
|
|
|
|
// GetAssetFS returns the embedded filesystem
|
|
func GetAssetFS() fs.FS {
|
|
return EmbeddedAssets
|
|
}
|
|
|
|
// ListAssets returns a list of all embedded assets
|
|
func ListAssets() ([]string, error) {
|
|
var assets []string
|
|
err := fs.WalkDir(EmbeddedAssets, ".", func(path string, d fs.DirEntry, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if !d.IsDir() {
|
|
assets = append(assets, path)
|
|
}
|
|
return nil
|
|
})
|
|
return assets, err
|
|
}
|