初步实现安装界面

This commit is contained in:
GoEdgeLab
2020-10-13 20:05:29 +08:00
parent fe432e9a8f
commit 2c9fffa4db
37 changed files with 1207 additions and 56 deletions

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil"
)
// API配置
type APIConfig struct {
RPC struct {
Endpoints []string `yaml:"endpoints"`
@@ -14,6 +15,7 @@ type APIConfig struct {
Secret string `yaml:"secret"`
}
// 加载API配置
func LoadAPIConfig() (*APIConfig, error) {
data, err := ioutil.ReadFile(Tea.ConfigFile("api.yaml"))
if err != nil {
@@ -28,3 +30,12 @@ func LoadAPIConfig() (*APIConfig, error) {
return config, nil
}
// 写入API配置
func (this *APIConfig) WriteFile(path string) error {
data, err := yaml.Marshal(this)
if err != nil {
return err
}
return ioutil.WriteFile(path, data, 0666)
}