diff --git a/demo/advanced.yaml b/demo/advanced.yaml index 7a22ece6ace0715301d0130bc1104bda5044a82e..20172a6e71cfde8a5b4eb3a97b69a2ef2ec5b8db 100644 --- a/demo/advanced.yaml +++ b/demo/advanced.yaml @@ -43,7 +43,7 @@ fields: use: large{3} - field: field_use_yaml - range: 9-7,test/nested1.yaml{5} + range: 测试,测,9-7,test/nested1.yaml{5} # rand: true prefix: "***" postfix: "***\t" diff --git a/demo/test/test.yaml b/demo/test/test.yaml new file mode 100644 index 0000000000000000000000000000000000000000..abde8ff91492ece5bbd168da420e660832f4a85e --- /dev/null +++ b/demo/test/test.yaml @@ -0,0 +1,15 @@ +title: 测试文件 +desc: +author: zentao +version: 1.0 + +fields: + - field: test1 + from: base.name.letters.v1.yaml + use: letters + postfix: "\t" + + - field: test2 + from: base.name.numbers.v1.yaml + use: numbers + postfix: "\t" \ No newline at end of file diff --git a/res/en/messages.json b/res/en/messages.json index e17f89d8e2e22bc13569e08c89266db2fb8e972f..658d8d60d8d3e73b6fe168942b7d44f297df7c26 100644 --- a/res/en/messages.json +++ b/res/en/messages.json @@ -71,6 +71,10 @@ "id": "fail_to_parse_ranges", "translation": "%s is not ResRanges format, try to parse as ResInsts." }, + { + "id": "fail_to_find_res", + "translation": "Fail to load resource from %s." + }, { "id": "generate_records", diff --git a/res/zh/messages.json b/res/zh/messages.json index 98a7f1f5c0dc4bbc89b8ad21b80284ddfd1cb87c..75d7ebd4576f8133aadfe0baeebecdb35e9b71f8 100644 --- a/res/zh/messages.json +++ b/res/zh/messages.json @@ -66,6 +66,10 @@ "id": "fail_to_parse_ranges", "translation": "%s不是ResRanges格式,尝试解析为ResInsts对象。" }, + { + "id": "fail_to_find_res", + "translation": "加载资源%s失败." + }, { "id": "generate_records", diff --git a/src/utils/file/file.go b/src/utils/file/file.go index 75fedc222f0ccfef7d506c38a34da9765d9a242c..7c5758c50cfb71cbdbbf88ff885bb2ef3a9f814e 100644 --- a/src/utils/file/file.go +++ b/src/utils/file/file.go @@ -4,7 +4,9 @@ import ( "github.com/easysoft/zendata/res" commonUtils "github.com/easysoft/zendata/src/utils/common" constant "github.com/easysoft/zendata/src/utils/const" + i118Utils "github.com/easysoft/zendata/src/utils/i118" "github.com/easysoft/zendata/src/utils/vari" + "github.com/fatih/color" "io/ioutil" "os" "os/exec" @@ -188,14 +190,15 @@ func ConvertResYamlPath(from string) (ret string) { } file := strings.Join(arr[i:], ".") + relatPath := "" if dir != "" { - ret = dir + constant.PthSep + file + relatPath = dir + constant.PthSep + file } else { - ret = file + relatPath = file } - realPth1 := vari.WorkDir + constant.ResDirYaml + constant.PthSep + ret - realPth2 := vari.WorkDir + constant.ResDirUsers + constant.PthSep + ret + realPth1 := vari.WorkDir + constant.ResDirYaml + constant.PthSep + relatPath + realPth2 := vari.WorkDir + constant.ResDirUsers + constant.PthSep + relatPath if FileExist(realPth1) { ret = realPth1 break @@ -205,6 +208,10 @@ func ConvertResYamlPath(from string) (ret string) { } } + if ret == "" { + color.New(color.FgCyan).Fprintf(color.Output, i118Utils.I118Prt.Sprintf("fail_to_find_res", from) + "\n") + } + return } @@ -224,13 +231,14 @@ func convertResExcelPath(from string) (ret, sheet string) { } file := strings.Join(arr[i:], ".") + ".xlsx" + relatPath := "" if dir != "" { - ret = dir + constant.PthSep + file + relatPath = dir + constant.PthSep + file } else { - ret = file + relatPath = file } - realPth := vari.WorkDir + constant.ResDirData + constant.PthSep + ret + realPth := vari.WorkDir + constant.ResDirData + constant.PthSep + relatPath if FileExist(realPth) { if index == 1 { sheet = from[strings.LastIndex(from, ".")+1:] @@ -241,5 +249,9 @@ func convertResExcelPath(from string) (ret, sheet string) { } } + if ret == "" { + color.New(color.FgCyan).Fprintf(color.Output, i118Utils.I118Prt.Sprintf("fail_to_find_res", from) + "\n") + } + return } \ No newline at end of file diff --git a/yaml/base/name/numbers.v1.yaml b/yaml/base/name/numbers.v1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9001f4c399ca7e00a406d9bcbb8460cb39ea3bec --- /dev/null +++ b/yaml/base/name/numbers.v1.yaml @@ -0,0 +1,46 @@ +title: 数字账号 +desc: +author: zentao +version: 1.0 + +field: account_numbers +instances: + - instance: 1_number + note: 单个数字 + prefix: + fields: + - field: part1 + range: 0-9 + + - instance: 2_numbers + note: 两个数字 + prefix: + fields: + - field: part1 + range: 0-9 + loop: 2 + + - instance: 3_numbers + note: 三个数字 + prefix: + fields: + - field: part1 + range: 0-9 + loop: 3 + + - instance: 4_numbers + note: 四个数字 + prefix: + fields: + - field: part1 + range: 0-9 + loop: 4 + + - instance: numbers + note: 多个数字 + prefix: + fields: + - field: part1 + range: 0-9 + loop: 5-100 + rand: true \ No newline at end of file