export-table-pulgin-csharp 1.1.85 → 1.1.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,7 @@
1
- import { HandleSheetParams, PluginBase } from "export-table-lib";
1
+ import { HandleSheetParams, Field, PluginBase, FieldType } from "export-table-lib";
2
+ export declare function TryConvValue(value: any, t: FieldType, f: Field): any;
3
+ export declare function ConvValue(value: any, t: FieldType, f: Field): any;
4
+ export declare function ConvValue2Literal(value: any, t: FieldType, f: Field): string;
2
5
  export declare function export_stuff(paras: HandleSheetParams): string | null;
3
6
  export declare class ExportPlugin extends PluginBase {
4
7
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAA0B,MAAM,kBAAkB,CAAA;AAK1H,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAqVpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
1
+ {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAAE,KAAK,EAAwB,UAAU,EAA0B,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGrI,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,GAAG,CAMpE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,GAAG,CAwCjE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAuD5E;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+RpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
@@ -23,9 +23,146 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ExportPlugin = exports.export_stuff = void 0;
26
+ exports.ExportPlugin = exports.export_stuff = exports.ConvValue2Literal = exports.ConvValue = exports.TryConvValue = void 0;
27
27
  const export_table_lib_1 = require("export-table-lib");
28
28
  const fs = __importStar(require("fs-extra"));
29
+ function TryConvValue(value, t, f) {
30
+ try {
31
+ return ConvValue(value, t, f);
32
+ }
33
+ catch (ex) {
34
+ return null;
35
+ }
36
+ }
37
+ exports.TryConvValue = TryConvValue;
38
+ function ConvValue(value, t, f) {
39
+ if (t == "object") {
40
+ return JSON.parse(value);
41
+ }
42
+ else if (t == "object[]") {
43
+ return JSON.parse(value);
44
+ }
45
+ else if (t == "number" || t == "int" || t == "long") {
46
+ return JSON.parse(value);
47
+ }
48
+ else if (t == "number[]") {
49
+ return JSON.parse(value);
50
+ }
51
+ else if (t == "int[]") {
52
+ return JSON.parse(value);
53
+ }
54
+ else if (t == "long[]") {
55
+ return JSON.parse(value);
56
+ }
57
+ else if (t == "uid") {
58
+ return JSON.parse(value);
59
+ }
60
+ else if (t == "bool") {
61
+ try {
62
+ return !!JSON.parse(value);
63
+ }
64
+ catch (ex) {
65
+ console.log(ex);
66
+ return false;
67
+ }
68
+ }
69
+ else if (t == "bool[]") {
70
+ return JSON.parse(value);
71
+ }
72
+ else if (t == "string") {
73
+ return value;
74
+ }
75
+ else if (t == "string[]") {
76
+ return JSON.parse(value);
77
+ }
78
+ else if (t == "fk") {
79
+ return value;
80
+ }
81
+ else if (t == "fk[]") {
82
+ return value;
83
+ }
84
+ else if (t == "any") {
85
+ console.log(f);
86
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
87
+ }
88
+ else if (t == "key") {
89
+ return JSON.parse(t);
90
+ }
91
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`);
92
+ }
93
+ exports.ConvValue = ConvValue;
94
+ function ConvValue2Literal(value, t, f) {
95
+ if (t == "object") {
96
+ //throw new Error("invalid type <object>")
97
+ let convert = [];
98
+ for (let k in value) {
99
+ convert.push(`{"${k}","${value[k].toString()}"}`);
100
+ }
101
+ ;
102
+ return `new Dictionary<string,string>(${convert.length}){${convert}}`;
103
+ }
104
+ else if (t == "object[]") {
105
+ let values = value;
106
+ //throw new Error("invalid type <object[]>")
107
+ return `new List<Dictionary<string,string>>(){${values.map((val) => {
108
+ let convert = [];
109
+ for (let k in val) {
110
+ convert.push(`{"${k}","${val[k].toString()}"}`);
111
+ }
112
+ ;
113
+ return `new Dictionary<string,string>(${convert.length}){${convert}}`;
114
+ })}}`;
115
+ }
116
+ else if (t == "number" || t == "int" || t == "long") {
117
+ return `${value}`;
118
+ }
119
+ else if (t == "number[]") {
120
+ let values = value;
121
+ return `new double[]{${values.join(", ")}}`;
122
+ }
123
+ else if (t == "int[]") {
124
+ let values = value;
125
+ return `new int[]{${values.join(", ")}}`;
126
+ }
127
+ else if (t == "long[]") {
128
+ let values = value;
129
+ return `new long[]{${values.join(", ")}}`;
130
+ }
131
+ else if (t == "uid") {
132
+ return `${value}`;
133
+ }
134
+ else if (t == "bool") {
135
+ return `${value}`;
136
+ }
137
+ else if (t == "bool[]") {
138
+ let values = value;
139
+ return `new bool[]{${values.join(", ")}}`;
140
+ }
141
+ else if (t == "string") {
142
+ // return `"${value}"`
143
+ return JSON.stringify(value);
144
+ }
145
+ else if (t == "string[]") {
146
+ let values = value;
147
+ return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`;
148
+ }
149
+ else if (t == "fk") {
150
+ return `${value}`;
151
+ }
152
+ else if (t == "fk[]") {
153
+ let values = value;
154
+ return `new int[]{${values.join(", ")}}`;
155
+ }
156
+ else if (t == "any") {
157
+ console.log(f);
158
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
159
+ }
160
+ else if (t == "key") {
161
+ return `${value}`;
162
+ }
163
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`);
164
+ }
165
+ exports.ConvValue2Literal = ConvValue2Literal;
29
166
  var isSkipExportDefaults0 = process.argv.findIndex(v => v == "--SkipDefaults") >= 0;
30
167
  function export_stuff(paras) {
31
168
  let { datas, fields, inject, name, objects, packagename, tables, xxtea, exportNamespace, moreOptions, } = paras;
@@ -112,76 +249,7 @@ function export_stuff(paras) {
112
249
  return tables.find(a => a.name == field.fkTableName).fields.find(a => a.name == field.fkFieldName).type;
113
250
  };
114
251
  const genValue = (value, f) => {
115
- let t = f.type;
116
- if (t == "object") {
117
- //throw new Error("invalid type <object>")
118
- let convert = [];
119
- for (let k in value) {
120
- convert.push(`{"${k}","${value[k].toString()}"}`);
121
- }
122
- ;
123
- return `new Dictionary<string,string>(${convert.length}){${convert}}`;
124
- }
125
- else if (t == "object[]") {
126
- let values = value;
127
- //throw new Error("invalid type <object[]>")
128
- return `new List<Dictionary<string,string>>(){${values.map((val) => {
129
- let convert = [];
130
- for (let k in val) {
131
- convert.push(`{"${k}","${val[k].toString()}"}`);
132
- }
133
- ;
134
- return `new Dictionary<string,string>(${convert.length}){${convert}}`;
135
- })}}`;
136
- }
137
- else if (t == "number" || t == "int" || t == "long") {
138
- return `${value}`;
139
- }
140
- else if (t == "number[]") {
141
- let values = value;
142
- return `new double[]{${values.join(", ")}}`;
143
- }
144
- else if (t == "int[]") {
145
- let values = value;
146
- return `new int[]{${values.join(", ")}}`;
147
- }
148
- else if (t == "long[]") {
149
- let values = value;
150
- return `new long[]{${values.join(", ")}}`;
151
- }
152
- else if (t == "uid") {
153
- return `${value}`;
154
- }
155
- else if (t == "bool") {
156
- return `${value}`;
157
- }
158
- else if (t == "bool[]") {
159
- let values = value;
160
- return `new bool[]{${values.join(", ")}}`;
161
- }
162
- else if (t == "string") {
163
- // return `"${value}"`
164
- return JSON.stringify(value);
165
- }
166
- else if (t == "string[]") {
167
- let values = value;
168
- return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`;
169
- }
170
- else if (t == "fk") {
171
- return `${value}`;
172
- }
173
- else if (t == "fk[]") {
174
- let values = value;
175
- return `new int[]{${values.join(", ")}}`;
176
- }
177
- else if (t == "any") {
178
- console.log(f);
179
- throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
180
- }
181
- else if (t == "key") {
182
- return `${value}`;
183
- }
184
- throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`);
252
+ return ConvValue2Literal(value, f.type, f);
185
253
  };
186
254
  const getTitle = (v) => {
187
255
  return v.describe.split("\n")[0];
@@ -230,11 +298,11 @@ ${(0, export_table_lib_1.foreach)(getDescripts(f), line => ` /// ${line}`)}
230
298
  /// </summary>
231
299
  public ${getFieldType(f)} ${convMemberName(f.name)};
232
300
 
233
- ${(0, export_table_lib_1.iff)(f.rawType == "@(int,string)[]", () => `
301
+ ${(0, export_table_lib_1.iff)(f.rawType.startsWith("@"), () => `
234
302
  /// <summary>
235
303
  ${(0, export_table_lib_1.foreach)(getDescripts(f), line => ` /// ${line}`)}
236
304
  /// </summary>
237
- public (int,string)[] ${convMemberName(f.name)}Obj;`)}`)}
305
+ public ${f.rawType.substring(1).replaceAll(/(?<=[^\w])(number)(?=[^\w]|$)/g, "double").replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool")} ${convMemberName(f.name)}Obj;`)}`)}
238
306
 
239
307
  ${(0, export_table_lib_1.cmm)( /**生成get字段 */)}
240
308
  #region get字段
@@ -1 +1 @@
1
- {"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAMxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA8EnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFzE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAY;IAE1B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAmC3C"}
1
+ {"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAOxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAiFnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFzE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAY;IAE1B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAmC3C"}
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ExportUJsonPlugin = exports.exportUJsonLoader = exports.exportUJson = void 0;
27
27
  const export_table_lib_1 = require("export-table-lib");
28
28
  const fs = __importStar(require("fs-extra"));
29
+ const ExportCSPlugin_1 = require("./ExportCSPlugin");
29
30
  var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0;
30
31
  let firstLetterUpper = export_table_lib_1.makeFirstLetterUpper;
31
32
  function exportUJson(paras) {
@@ -43,7 +44,8 @@ function exportUJson(paras) {
43
44
  let key = f.name;
44
45
  var newKey = convMemberName(key);
45
46
  newObj[newKey] = obj[key];
46
- if (f.rawType == "@(int,string)[]") {
47
+ let m = f.rawType.match(/\@\((\w+),(\w+)\)\[\]/);
48
+ if (m != null) {
47
49
  // [{"Item1":99,"Item2":"klwjefl"}]
48
50
  let content = obj[key];
49
51
  let index = 0;
@@ -52,6 +54,7 @@ function exportUJson(paras) {
52
54
  while (0 <= index && index < content.length) {
53
55
  index2 = content.indexOf("|", index);
54
56
  let numStr = content.substring(index, index2);
57
+ let t1 = m[1];
55
58
  index = content.indexOf(";;", index2);
56
59
  let posEnd = index;
57
60
  if (index == -1) {
@@ -61,10 +64,11 @@ function exportUJson(paras) {
61
64
  index += 2;
62
65
  }
63
66
  let ssStr = content.substring(index2 + 1, posEnd);
64
- // console.log(`parseinfo: ${index2}, ${index}, ${numStr}, ${ssStr}`)
67
+ let t2 = m[2];
68
+ console.log(`parseinfo: ${index2}, ${index}, ${numStr}, ${ssStr}, ${t1}, ${t2}`);
65
69
  objs.push({
66
- Item1: parseFloat(numStr),
67
- Item2: ssStr,
70
+ Item1: (0, ExportCSPlugin_1.TryConvValue)(numStr, t1, f),
71
+ Item2: (0, ExportCSPlugin_1.TryConvValue)(ssStr, t2, f),
68
72
  });
69
73
  }
70
74
  newObj[newKey + "Obj"] = objs;
@@ -199,7 +203,7 @@ class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
199
203
  }
200
204
  handleBatch(paras) {
201
205
  let { moreOptions, tables, exportNamespace, } = paras;
202
- let isSkipIndexLoader = !!moreOptions.SkipIndexLoader ?? false;
206
+ let isSkipIndexLoader = !!moreOptions?.SkipIndexLoader ?? false;
203
207
  if (isSkipIndexLoader0) {
204
208
  isSkipIndexLoader = true;
205
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.1.85",
3
+ "version": "1.1.87",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -1,7 +1,114 @@
1
1
 
2
- import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, iff } from "export-table-lib"
2
+ import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, iff, FieldType } from "export-table-lib"
3
3
  import * as fs from "fs-extra"
4
4
 
5
+ export function TryConvValue(value: any, t: FieldType, f: Field): any {
6
+ try {
7
+ return ConvValue(value, t, f)
8
+ } catch (ex) {
9
+ return null
10
+ }
11
+ }
12
+
13
+ export function ConvValue(value: any, t: FieldType, f: Field): any {
14
+ if (t == "object") {
15
+ return JSON.parse(value)
16
+ } else if (t == "object[]") {
17
+ return JSON.parse(value)
18
+ } else if (t == "number" || t == "int" || t == "long") {
19
+ return JSON.parse(value)
20
+ } else if (t == "number[]") {
21
+ return JSON.parse(value)
22
+ } else if (t == "int[]") {
23
+ return JSON.parse(value)
24
+ } else if (t == "long[]") {
25
+ return JSON.parse(value)
26
+ } else if (t == "uid") {
27
+ return JSON.parse(value)
28
+ } else if (t == "bool") {
29
+ try {
30
+ return !!JSON.parse(value)
31
+ } catch (ex) {
32
+ console.log(ex)
33
+ return false
34
+ }
35
+ } else if (t == "bool[]") {
36
+ return JSON.parse(value)
37
+ } else if (t == "string") {
38
+ return value
39
+ } else if (t == "string[]") {
40
+ return JSON.parse(value)
41
+ } else if (t == "fk") {
42
+ return value
43
+ } else if (t == "fk[]") {
44
+ return value
45
+ } else if (t == "any") {
46
+ console.log(f)
47
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
48
+ } else if (t == "key") {
49
+ return JSON.parse(t)
50
+ }
51
+
52
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
53
+ }
54
+
55
+ export function ConvValue2Literal(value: any, t: FieldType, f: Field): string {
56
+ if (t == "object") {
57
+ //throw new Error("invalid type <object>")
58
+ let convert: string[] = [];
59
+ for (let k in value) {
60
+ convert.push(`{"${k}","${(value as any)[k].toString()}"}`);
61
+ };
62
+ return `new Dictionary<string,string>(${convert.length}){${convert}}`;
63
+ } else if (t == "object[]") {
64
+ let values = value as object[];
65
+ //throw new Error("invalid type <object[]>")
66
+ return `new List<Dictionary<string,string>>(){${values.map((val) => {
67
+ let convert: string[] = [];
68
+ for (let k in val) {
69
+ convert.push(`{"${k}","${(val as any)[k].toString()}"}`);
70
+ };
71
+ return `new Dictionary<string,string>(${convert.length}){${convert}}`;
72
+ })}}`
73
+ } else if (t == "number" || t == "int" || t == "long") {
74
+ return `${value}`
75
+ } else if (t == "number[]") {
76
+ let values = value as number[]
77
+ return `new double[]{${values.join(", ")}}`
78
+ } else if (t == "int[]") {
79
+ let values = value as number[]
80
+ return `new int[]{${values.join(", ")}}`
81
+ } else if (t == "long[]") {
82
+ let values = value as number[]
83
+ return `new long[]{${values.join(", ")}}`
84
+ } else if (t == "uid") {
85
+ return `${value}`
86
+ } else if (t == "bool") {
87
+ return `${value}`
88
+ } else if (t == "bool[]") {
89
+ let values = value as boolean[]
90
+ return `new bool[]{${values.join(", ")}}`
91
+ } else if (t == "string") {
92
+ // return `"${value}"`
93
+ return JSON.stringify(value)
94
+ } else if (t == "string[]") {
95
+ let values = value as string[]
96
+ return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`
97
+ } else if (t == "fk") {
98
+ return `${value}`
99
+ } else if (t == "fk[]") {
100
+ let values = value as number[]
101
+ return `new int[]{${values.join(", ")}}`
102
+ } else if (t == "any") {
103
+ console.log(f)
104
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
105
+ } else if (t == "key") {
106
+ return `${value}`
107
+ }
108
+
109
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
110
+ }
111
+
5
112
  var isSkipExportDefaults0 = process.argv.findIndex(v => v == "--SkipDefaults") >= 0
6
113
 
7
114
  export function export_stuff(paras: HandleSheetParams): string | null {
@@ -89,61 +196,7 @@ export function export_stuff(paras: HandleSheetParams): string | null {
89
196
  }
90
197
 
91
198
  const genValue = (value: any, f: Field): string => {
92
- let t = f.type
93
- if (t == "object") {
94
- //throw new Error("invalid type <object>")
95
- let convert: string[] = [];
96
- for (let k in value) {
97
- convert.push(`{"${k}","${(value as any)[k].toString()}"}`);
98
- };
99
- return `new Dictionary<string,string>(${convert.length}){${convert}}`;
100
- } else if (t == "object[]") {
101
- let values = value as object[];
102
- //throw new Error("invalid type <object[]>")
103
- return `new List<Dictionary<string,string>>(){${values.map((val) => {
104
- let convert: string[] = [];
105
- for (let k in val) {
106
- convert.push(`{"${k}","${(val as any)[k].toString()}"}`);
107
- };
108
- return `new Dictionary<string,string>(${convert.length}){${convert}}`;
109
- })}}`
110
- } else if (t == "number" || t == "int" || t == "long") {
111
- return `${value}`
112
- } else if (t == "number[]") {
113
- let values = value as number[]
114
- return `new double[]{${values.join(", ")}}`
115
- } else if (t == "int[]") {
116
- let values = value as number[]
117
- return `new int[]{${values.join(", ")}}`
118
- } else if (t == "long[]") {
119
- let values = value as number[]
120
- return `new long[]{${values.join(", ")}}`
121
- } else if (t == "uid") {
122
- return `${value}`
123
- } else if (t == "bool") {
124
- return `${value}`
125
- } else if (t == "bool[]") {
126
- let values = value as boolean[]
127
- return `new bool[]{${values.join(", ")}}`
128
- } else if (t == "string") {
129
- // return `"${value}"`
130
- return JSON.stringify(value)
131
- } else if (t == "string[]") {
132
- let values = value as string[]
133
- return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`
134
- } else if (t == "fk") {
135
- return `${value}`
136
- } else if (t == "fk[]") {
137
- let values = value as number[]
138
- return `new int[]{${values.join(", ")}}`
139
- } else if (t == "any") {
140
- console.log(f)
141
- throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`)
142
- } else if (t == "key") {
143
- return `${value}`
144
- }
145
-
146
- throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`)
199
+ return ConvValue2Literal(value, f.type, f)
147
200
  }
148
201
 
149
202
  const getTitle = (v: Field) => {
@@ -203,13 +256,13 @@ ${foreach(getDescripts(f), line =>
203
256
  /// </summary>
204
257
  public ${getFieldType(f)} ${convMemberName(f.name)};
205
258
 
206
- ${iff(f.rawType == "@(int,string)[]", () => `
259
+ ${iff(f.rawType.startsWith("@"), () => `
207
260
  /// <summary>
208
261
  ${foreach(getDescripts(f), line =>
209
262
  ` /// ${line}`
210
263
  )}
211
264
  /// </summary>
212
- public (int,string)[] ${convMemberName(f.name)}Obj;`)}`
265
+ public ${f.rawType.substring(1).replaceAll(/(?<=[^\w])(number)(?=[^\w]|$)/g, "double").replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool")} ${convMemberName(f.name)}Obj;`)}`
213
266
  )}
214
267
 
215
268
  ${cmm(/**生成get字段 */)}
@@ -1,6 +1,7 @@
1
1
 
2
2
  import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper } from "export-table-lib"
3
3
  import * as fs from "fs-extra"
4
+ import { TryConvValue } from "./ExportCSPlugin";
4
5
 
5
6
  var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0
6
7
 
@@ -29,7 +30,8 @@ export function exportUJson(paras: HandleSheetParams): string | null {
29
30
  var newKey = convMemberName(key);
30
31
  newObj[newKey] = obj[key];
31
32
 
32
- if (f.rawType == "@(int,string)[]") {
33
+ let m = f.rawType.match(/\@\((\w+),(\w+)\)\[\]/)
34
+ if (m != null) {
33
35
  // [{"Item1":99,"Item2":"klwjefl"}]
34
36
  let content = obj[key] as string;
35
37
  let index = 0;
@@ -38,6 +40,7 @@ export function exportUJson(paras: HandleSheetParams): string | null {
38
40
  while (0 <= index && index < content.length) {
39
41
  index2 = content.indexOf("|", index)
40
42
  let numStr = content.substring(index, index2)
43
+ let t1 = m[1]
41
44
  index = content.indexOf(";;", index2)
42
45
  let posEnd = index
43
46
  if (index == -1) {
@@ -46,10 +49,11 @@ export function exportUJson(paras: HandleSheetParams): string | null {
46
49
  index += 2
47
50
  }
48
51
  let ssStr = content.substring(index2 + 1, posEnd)
49
- // console.log(`parseinfo: ${index2}, ${index}, ${numStr}, ${ssStr}`)
52
+ let t2 = m[2]
53
+ console.log(`parseinfo: ${index2}, ${index}, ${numStr}, ${ssStr}, ${t1}, ${t2}`)
50
54
  objs.push({
51
- Item1: parseFloat(numStr),
52
- Item2: ssStr,
55
+ Item1: TryConvValue(numStr, t1 as any, f),
56
+ Item2: TryConvValue(ssStr, t2 as any, f),
53
57
  })
54
58
  }
55
59
  newObj[newKey + "Obj"] = objs
@@ -204,7 +208,7 @@ export class ExportUJsonPlugin extends PluginBase {
204
208
  tables,
205
209
  exportNamespace,
206
210
  } = paras
207
- let isSkipIndexLoader = !!moreOptions.SkipIndexLoader ?? false
211
+ let isSkipIndexLoader = !!moreOptions?.SkipIndexLoader ?? false
208
212
  if (isSkipIndexLoader0) {
209
213
  isSkipIndexLoader = true
210
214
  }