配置导出工具优化及示例

This commit is contained in:
kercylan98 2023-05-19 14:09:36 +08:00
parent 3f36a3cddc
commit 746eb7cacd
7 changed files with 74 additions and 60 deletions

View File

@ -0,0 +1,4 @@
{
"Finish": "StartFinish",
"Addr": ":9999"
}

View File

@ -0,0 +1,10 @@
{
"1": {
"Id": 1,
"Text": "Hello"
},
"2": {
"Id": 2,
"Text": "World"
}
}

View File

@ -39,7 +39,7 @@ func (slf *ConfigExport) ExportClient(prefix, outputDir string) {
if len(prefix) > 0 { if len(prefix) > 0 {
config.Prefix = fmt.Sprintf("%s.", prefix) config.Prefix = fmt.Sprintf("%s.", prefix)
} }
if err := file.WriterFile(filepath.Join(outputDir, fmt.Sprintf("%s%s.json", prefix, config.Name)), config.JsonClient()); err != nil { if err := file.WriterFile(filepath.Join(outputDir, fmt.Sprintf("%s%s.json", config.Prefix, config.Name)), config.JsonClient()); err != nil {
panic(err) panic(err)
} }
} }
@ -51,7 +51,7 @@ func (slf *ConfigExport) ExportServer(prefix, outputDir string) {
if len(prefix) > 0 { if len(prefix) > 0 {
config.Prefix = fmt.Sprintf("%s.", prefix) config.Prefix = fmt.Sprintf("%s.", prefix)
} }
if err := file.WriterFile(filepath.Join(outputDir, fmt.Sprintf("%s%s.json", prefix, config.Name)), config.JsonServer()); err != nil { if err := file.WriterFile(filepath.Join(outputDir, fmt.Sprintf("%s%s.json", config.Prefix, config.Name)), config.JsonServer()); err != nil {
panic(err) panic(err)
} }
} }

View File

@ -1,18 +1,18 @@
{ {
"Other": {
"1": {
"id": 2,
"name": "刘备"
},
"0": {
"id": 1,
"name": "张飞"
}
},
"Id": 1, "Id": 1,
"Count": "a", "Count": "a",
"Award": { "Award": {
"0": "asd", "0": "asd",
"1": "12" "1": "12"
},
"Other": {
"0": {
"id": 1,
"name": "张飞"
},
"1": {
"id": 2,
"name": "刘备"
}
} }
} }

View File

@ -1,38 +1,38 @@
{ {
"1": { "1": {
"b": { "b": {
"Other": {
"1": {
"id": 2,
"name": "刘备"
},
"0": {
"name": "张飞",
"id": 1
}
},
"Id": 1, "Id": 1,
"Count": "b", "Count": "b",
"Award": { "Award": {
"0": "asd", "0": "asd",
"1": "12" "1": "12"
},
"Other": {
"0": {
"id": 1,
"name": "张飞"
},
"1": {
"id": 2,
"name": "刘备"
}
} }
} }
}, },
"2": { "2": {
"c": { "c": {
"Award": { "Award": {
"1": "12", "0": "asd",
"0": "asd" "1": "12"
}, },
"Other": { "Other": {
"0": { "0": {
"name": "张飞", "id": 1,
"id": 1 "name": "张飞"
}, },
"1": { "1": {
"id": 2, "name": "刘备",
"name": "刘备" "id": 2
} }
}, },
"Id": 2, "Id": 2,
@ -51,8 +51,8 @@
"name": "张飞" "name": "张飞"
}, },
"1": { "1": {
"name": "刘备", "id": 2,
"id": 2 "name": "刘备"
} }
} }
} }

View File

@ -1,4 +1,14 @@
{ {
"Other": {
"0": {
"id": 1,
"name": "张飞"
},
"1": {
"id": 2,
"name": "刘备"
}
},
"Id": 1, "Id": 1,
"Count": "a", "Count": "a",
"Info": { "Info": {
@ -11,15 +21,5 @@
"count": 100 "count": 100
} }
} }
},
"Other": {
"0": {
"id": 1,
"name": "张飞"
},
"1": {
"id": 2,
"name": "刘备"
}
} }
} }

View File

@ -1,35 +1,33 @@
{ {
"1": { "2": {
"b": { "c": {
"Count": "b",
"Info": { "Info": {
"id": 1,
"name": "小明",
"info": { "info": {
"lv": 1, "lv": 1,
"exp": { "exp": {
"mux": 10, "mux": 10,
"count": 100 "count": 100
} }
}, }
"id": 1,
"name": "小明"
}, },
"Other": { "Other": {
"0": { "0": {
"name": "张飞", "id": 1,
"id": 1 "name": "张飞"
}, },
"1": { "1": {
"id": 2, "id": 2,
"name": "刘备" "name": "刘备"
} }
}, },
"Id": 1
}
},
"2": {
"c": {
"Id": 2, "Id": 2,
"Count": "c", "Count": "c"
},
"d": {
"Id": 2,
"Count": "d",
"Info": { "Info": {
"id": 1, "id": 1,
"name": "小明", "name": "小明",
@ -51,11 +49,14 @@
"name": "刘备" "name": "刘备"
} }
} }
}, }
"d": { },
"Id": 2, "1": {
"Count": "d", "b": {
"Id": 1,
"Count": "b",
"Info": { "Info": {
"id": 1,
"name": "小明", "name": "小明",
"info": { "info": {
"lv": 1, "lv": 1,
@ -63,8 +64,7 @@
"mux": 10, "mux": 10,
"count": 100 "count": 100
} }
}, }
"id": 1
}, },
"Other": { "Other": {
"0": { "0": {