配置导出工具优化及示例

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 {
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)
}
}
@ -51,7 +51,7 @@ func (slf *ConfigExport) ExportServer(prefix, outputDir string) {
if len(prefix) > 0 {
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)
}
}

View File

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

View File

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

View File

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

View File

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