mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			874 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			874 B
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
						|
 | 
						|
package configs
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"github.com/iwind/TeaGo/Tea"
 | 
						|
	"io/ioutil"
 | 
						|
)
 | 
						|
 | 
						|
var plusConfigFile = "plus.cache.json"
 | 
						|
 | 
						|
type PlusConfig struct {
 | 
						|
	IsPlus     bool     `json:"isPlus"`
 | 
						|
	Components []string `json:"components"`
 | 
						|
	DayTo      string   `json:"dayTo"`
 | 
						|
}
 | 
						|
 | 
						|
func ReadPlusConfig() *PlusConfig {
 | 
						|
	data, err := ioutil.ReadFile(Tea.ConfigFile(plusConfigFile))
 | 
						|
	if err != nil {
 | 
						|
		return &PlusConfig{IsPlus: false}
 | 
						|
	}
 | 
						|
	var config = &PlusConfig{IsPlus: false}
 | 
						|
	err = json.Unmarshal(data, config)
 | 
						|
	if err != nil {
 | 
						|
		return config
 | 
						|
	}
 | 
						|
	return config
 | 
						|
}
 | 
						|
 | 
						|
func WritePlusConfig(config *PlusConfig) error {
 | 
						|
	configJSON, err := json.Marshal(config)
 | 
						|
	if err != nil {
 | 
						|
		return err
 | 
						|
	}
 | 
						|
	err = ioutil.WriteFile(Tea.ConfigFile(plusConfigFile), configJSON, 0777)
 | 
						|
	if err != nil {
 | 
						|
		return err
 | 
						|
	}
 | 
						|
	return nil
 | 
						|
}
 |