mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
fix examples bug
This commit is contained in:
parent
5e14b97c5a
commit
99758e1ef4
@ -31,16 +31,17 @@ func exportCharacter(path string) {
|
||||
fileName := filepath.Join(path, "api", "Character", "List")
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
|
||||
// export scenes
|
||||
// export characters
|
||||
var obj map[string]interface{}
|
||||
helper.FromJSON([]byte(result), &obj)
|
||||
array := obj["Data"].([]map[string]interface{})
|
||||
|
||||
for _, i := range array {
|
||||
id := i["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Character/Get?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Character/Character_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
if array, ok := obj["Data"].([]interface{}); ok {
|
||||
for _, i := range array {
|
||||
id := i.(map[string]interface{})["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Character/Get?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Character/Character_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
}
|
||||
}
|
||||
|
||||
// other apis
|
||||
|
||||
@ -31,16 +31,17 @@ func exportParticle(path string) {
|
||||
fileName := filepath.Join(path, "api", "Particle", "List")
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
|
||||
// export scenes
|
||||
// export particles
|
||||
var obj map[string]interface{}
|
||||
helper.FromJSON([]byte(result), &obj)
|
||||
array := obj["Data"].([]map[string]interface{})
|
||||
|
||||
for _, i := range array {
|
||||
id := i["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Particle/Get?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Particle/Particle_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
if array, ok := obj["Data"].([]interface{}); ok {
|
||||
for _, i := range array {
|
||||
id := i.(map[string]interface{})["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Particle/Get?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Particle/Particle_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
}
|
||||
}
|
||||
|
||||
// other apis
|
||||
|
||||
@ -34,13 +34,14 @@ func exportPrefab(path string) {
|
||||
// export scenes
|
||||
var obj map[string]interface{}
|
||||
helper.FromJSON([]byte(result), &obj)
|
||||
array := obj["Data"].([]map[string]interface{})
|
||||
|
||||
for _, i := range array {
|
||||
id := i["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Prefab/Get?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Prefab/Prefab_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
if array, ok := obj["Data"].([]interface{}); ok {
|
||||
for _, i := range array {
|
||||
id := i.(map[string]interface{})["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Prefab/Get?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Prefab/Prefab_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
}
|
||||
}
|
||||
|
||||
// other apis
|
||||
|
||||
@ -34,13 +34,14 @@ func exportScene(path string) {
|
||||
// export scenes
|
||||
var obj map[string]interface{}
|
||||
helper.FromJSON([]byte(result), &obj)
|
||||
array := obj["Data"].([]map[string]interface{})
|
||||
|
||||
for _, i := range array {
|
||||
id := i["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Scene/Load?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Scene/Scene_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
if array, ok := obj["Data"].([]interface{}); ok {
|
||||
for _, i := range array {
|
||||
id := i.(map[string]interface{})["ID"].(string)
|
||||
result, _ = helper.Get(fmt.Sprintf("http://%v/api/Scene/Load?ID=%v", port, id))
|
||||
fileName = fmt.Sprintf("%v/api/Scene/Scene_%v", path, id)
|
||||
ioutil.WriteFile(fileName, []byte(result), 0755)
|
||||
}
|
||||
}
|
||||
|
||||
// other apis
|
||||
|
||||
@ -47,18 +47,20 @@ func Run(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func copyStaticAssets(path string) error {
|
||||
list := []string{
|
||||
"favicon.ico",
|
||||
"index.html",
|
||||
"view.html",
|
||||
"assets",
|
||||
"build",
|
||||
"locales",
|
||||
"favicon.ico",
|
||||
"index.html",
|
||||
"manifest.json",
|
||||
"sw.js",
|
||||
"view.html",
|
||||
}
|
||||
|
||||
for _, i := range list {
|
||||
source := server.MapPath("/" + i)
|
||||
dest := filepath.Join(path, i)
|
||||
if stat, err := os.Stat(source); err != nil && stat.IsDir() {
|
||||
if stat, err := os.Stat(source); err == nil && stat.IsDir() {
|
||||
helper.CopyDirectory(source, dest)
|
||||
} else if err == nil {
|
||||
helper.CopyFile(source, dest)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user