Compare commits

..

2 Commits

Author SHA1 Message Date
ayflying
374fdac477 进行主机查找配置文件,最高5级目录 2025-05-14 16:22:07 +08:00
ayflying
595ababfde 更新路径拼接 2025-05-14 16:17:00 +08:00

View File

@@ -86,14 +86,19 @@ func (c *Cfg) GetFile(filename string, _pathStr ...string) (jsonObj *gjson.Json,
bytes = gres.GetContent(filePath) // 从打包资源中获取内容 bytes = gres.GetContent(filePath) // 从打包资源中获取内容
} }
//如果还是没有读取到配置,从当前目录返回上级读取 for range 5 {
if bytes == nil { //如果还是没有读取到配置,从当前目录返回上级读取
// 拼接完整的文件路径 if bytes == nil {
filePath = "../../" + pathStr + filename + ".json" // 上级拼接完整的文件路径
if gfile.IsFile(filePath) { filePath = "../" + filePath
bytes = gfile.GetBytes(filePath) // 读取物理文件内容 if gfile.IsFile(filePath) {
bytes = gfile.GetBytes(filePath) // 读取物理文件内容
//找到配置了,跳过
break
}
} }
} }
// 解析 JSON 内容并返回结果 // 解析 JSON 内容并返回结果
jsonObj, err = gjson.DecodeToJson(bytes) jsonObj, err = gjson.DecodeToJson(bytes)
return return