mapping.js 1.3 KB

1234567891011121314151617181920212223242526272829303132
  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. if (!data[0]) return []
  11. return data.map((item) => {
  12. const code = item.code || item.productCode
  13. if (code && Object.prototype.hasOwnProperty.call(nameMapping, code)) {
  14. if (item.name) item.name = nameMapping[code]
  15. if (item.productName) item.productName = nameMapping[code]
  16. }
  17. const codes = item.codes || item.productCodes
  18. if (codes) {
  19. const multipleCodes = codes.split(',')
  20. const multipleNames = multipleCodes.map((code) => nameMapping[code])
  21. if (multipleNames.length > 0) {
  22. if (item.names) item.names = multipleNames.join(',')
  23. if (item.productNames) item.productNames = multipleNames.join(',')
  24. }
  25. }
  26. return item
  27. })
  28. }
  29. export { productListNameMapping }