mapping.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // 产品名映射
  2. function productListNameMapping (data) {
  3. const nameMapping = {
  4. 'com.brother.pdfreaderpro.mac.product_1': 'PDF Reader Pro for Mac',
  5. 'com.brother.pdfreaderpro.windows.product_1': 'PDF Reader Pro for Windows',
  6. 'com.brother.pdfreaderpro.mac.product_3': 'PDF Reader Pro for Mac (With PDF to Office Pack)',
  7. 'com.brother.pdfreaderpro.windows.product_3': 'PDF Reader Pro for Windows (With PDF to Office Pack)',
  8. 'com.brother.pdfreaderpro.cross.platform.product_3': 'PDF Reader Pro Cross-Platform (With PDF to Office Pack)'
  9. }
  10. return data.map((item) => {
  11. const code = item.code || item.productCode
  12. if (code && Object.prototype.hasOwnProperty.call(nameMapping, code)) {
  13. if (item.name) item.name = nameMapping[code]
  14. if (item.productName) item.productName = nameMapping[code]
  15. }
  16. const codes = item.codes || item.productCodes
  17. if (codes) {
  18. const multipleCodes = codes.split(',')
  19. const multipleNames = multipleCodes.map((code) => nameMapping[code])
  20. if (multipleNames.length > 0) {
  21. if (item.names) item.names = multipleNames.join(',')
  22. if (item.productNames) item.productNames = multipleNames.join(',')
  23. }
  24. }
  25. return item
  26. })
  27. }
  28. export { productListNameMapping }