| 72 | const resourceItem = resource[i]; |
| 73 | // 递归函数 |
| 74 | function recursive(obj: XmwInternational, serilKey = '') { |
| 75 | // 拼接对象名 |
| 76 | let pKey = serilKey; |
| 77 | pKey += pKey ? `.${obj[name]}` : obj[name]; |
| 78 | // 当前层级是否有数据,给 result 赋值 |
| 79 | if (obj[lang]) { |
| 80 | result[pKey] = obj[lang]; |
| 81 | } |
| 82 | // 判断是否有子级,有就递归遍历 |
| 83 | if (obj.children?.length && Array.isArray(obj.children)) { |
| 84 | for (let j = 0; j < obj.children.length; j++) { |
| 85 | const child = obj.children[j]; |
| 86 | recursive(child, pKey); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | // 循环执行 |
| 91 | recursive(resourceItem); |
| 92 | } |