(schema: unknown, self: any, options: IParseOptions = {})
| 317 | } |
| 318 | |
| 319 | export function parseData(schema: unknown, self: any, options: IParseOptions = {}): any { |
| 320 | if (isJSExpression(schema)) { |
| 321 | return parseExpression({ |
| 322 | str: schema, |
| 323 | self, |
| 324 | thisRequired: options.thisRequiredInJSE, |
| 325 | logScope: options.logScope, |
| 326 | }); |
| 327 | } else if (isI18nData(schema)) { |
| 328 | return parseI18n(schema, self); |
| 329 | } else if (typeof schema === 'string') { |
| 330 | return schema.trim(); |
| 331 | } else if (Array.isArray(schema)) { |
| 332 | return schema.map((item) => parseData(item, self, options)); |
| 333 | } else if (typeof schema === 'function') { |
| 334 | return schema.bind(self); |
| 335 | } else if (typeof schema === 'object') { |
| 336 | // 对于undefined及null直接返回 |
| 337 | if (!schema) { |
| 338 | return schema; |
| 339 | } |
| 340 | const res: any = {}; |
| 341 | forEach(schema, (val: any, key: string) => { |
| 342 | if (key.startsWith('__')) { |
| 343 | return; |
| 344 | } |
| 345 | res[key] = parseData(val, self, options); |
| 346 | }); |
| 347 | return res; |
| 348 | } |
| 349 | return schema; |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * process params for using in a url query |
searching dependent graphs…