优化代码

This commit is contained in:
刘祥超
2022-08-04 11:51:34 +08:00
parent 529b7041e7
commit dad8802fb0
15 changed files with 52 additions and 58 deletions

View File

@@ -6,7 +6,7 @@ import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/Tea"
"io/ioutil"
"os"
)
type HideTipAction struct {
@@ -23,7 +23,7 @@ func (this *HideTipAction) RunPost(params struct {
// 保存到文件
tipJSON, err := json.Marshal(tipKeyMap)
if err == nil {
_ = ioutil.WriteFile(Tea.ConfigFile(tipConfigFile), tipJSON, 0666)
_ = os.WriteFile(Tea.ConfigFile(tipConfigFile), tipJSON, 0666)
}
this.Success()

View File

@@ -7,7 +7,7 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo"
"github.com/iwind/TeaGo/Tea"
"io/ioutil"
"os"
"sync"
)
@@ -18,7 +18,7 @@ var tipConfigFile = "tip.cache.json"
func init() {
TeaGo.BeforeStart(func(server *TeaGo.Server) {
// 从配置文件中加载已关闭的tips
data, err := ioutil.ReadFile(Tea.ConfigFile(tipConfigFile))
data, err := os.ReadFile(Tea.ConfigFile(tipConfigFile))
if err == nil {
var m = map[string]bool{}
err = json.Unmarshal(data, &m)