setting.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. const fs = require('fs');
  2. const args = process.argv.slice(2)[0];
  3. const filesToModify = ['./src/manifest.json', './src/pages.json'];
  4. filesToModify.forEach((file) => {
  5. fs.readFile(file, 'utf8', function (err, data) {
  6. if (err) throw err;
  7. let cleanedData = data.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, '');// 使用正则表达式去除单行注释
  8. let state = JSON.parse(cleanedData);// 解析JSON数据
  9. if (file == './src/manifest.json') {
  10. var maps = state["app-plus"].distribute.sdkConfigs.maps
  11. var geolocation = state["app-plus"].distribute.sdkConfigs.geolocation
  12. var icons = state["app-plus"].distribute.icons
  13. var push = state["app-plus"].distribute.sdkConfigs.push
  14. if (args === 'huiYi') {
  15. state.name = '智能会议'
  16. state.appid = '__UNI__F3963F8'
  17. state.description = '智能会议APP,是一款集成了现代信息技术和智能化管理功能的移动应用程序,旨在提升会议体验和管理效率。'
  18. state.versionName = "1.0.3"
  19. state.versionCode = 3
  20. state.h5.title = '智能会议'
  21. maps.amap.name = "amapBOujshtbA"
  22. maps.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc"
  23. maps.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f"
  24. geolocation.amap.name = "amapBOujshtbA"
  25. geolocation.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc"
  26. geolocation.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f"
  27. geolocation.tencent.apikey_ios = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX"
  28. geolocation.tencent.apikey_android = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX"
  29. icons.android = {
  30. "hdpi": "unpackage/res/icons/72x72.png",
  31. "xhdpi": "unpackage/res/icons/96x96.png",
  32. "xxhdpi": "unpackage/res/icons/144x144.png",
  33. "xxxhdpi": "unpackage/res/icons/192x192.png"
  34. }
  35. icons.ios.appstore = "unpackage/res/icons/1024x1024.png"
  36. icons.ios.ipad = {
  37. "app": "unpackage/res/icons/76x76.png",
  38. "app@2x": "unpackage/res/icons/152x152.png",
  39. "notification": "unpackage/res/icons/20x20.png",
  40. "notification@2x": "unpackage/res/icons/40x40.png",
  41. "proapp@2x": "unpackage/res/icons/167x167.png",
  42. "settings": "unpackage/res/icons/29x29.png",
  43. "settings@2x": "unpackage/res/icons/58x58.png",
  44. "spotlight": "unpackage/res/icons/40x40.png",
  45. "spotlight@2x": "unpackage/res/icons/80x80.png"
  46. }
  47. icons.ios.iphone = {
  48. "app@2x": "unpackage/res/icons/120x120.png",
  49. "app@3x": "unpackage/res/icons/180x180.png",
  50. "notification@2x": "unpackage/res/icons/40x40.png",
  51. "notification@3x": "unpackage/res/icons/60x60.png",
  52. "settings@2x": "unpackage/res/icons/58x58.png",
  53. "settings@3x": "unpackage/res/icons/87x87.png",
  54. "spotlight@2x": "unpackage/res/icons/80x80.png",
  55. "spotlight@3x": "unpackage/res/icons/120x120.png"
  56. }
  57. push.unipush.icons.small = {
  58. "hdpi": "unpackage/res/push/36x36.png",
  59. "ldpi": "unpackage/res/push/18x18.png",
  60. "mdpi": "unpackage/res/push/24x24.png",
  61. "xhdpi": "unpackage/res/push/48x48.png",
  62. "xxhdpi": "unpackage/res/push/72x72.png"
  63. }
  64. } else if (args === 'menJin') {
  65. state.name = '智能门禁'
  66. state.appid = '__UNI__8D6E9FD'
  67. state.description = '智能门禁APP,是一款集成了现代信息技术和智能化管理功能的移动应用程序。'
  68. state.versionName = "1.0.1"
  69. state.versionCode = 2
  70. state.h5.title = '智能门禁'
  71. maps.amap.name = "amapBOujshtbA"
  72. maps.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc"
  73. maps.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f"
  74. geolocation.amap.name = "amapBOujshtbA"
  75. geolocation.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc"
  76. geolocation.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f"
  77. geolocation.tencent.apikey_ios = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX"
  78. geolocation.tencent.apikey_android = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX"
  79. icons.android = {
  80. "hdpi": "unpackage/res/icons/72x72.png",
  81. "xhdpi": "unpackage/res/icons/96x96.png",
  82. "xxhdpi": "unpackage/res/icons/144x144.png",
  83. "xxxhdpi": "unpackage/res/icons/192x192.png"
  84. }
  85. icons.ios.appstore = "unpackage/res/icons/1024x1024.png"
  86. icons.ios.ipad = {
  87. "app": "unpackage/res/icons/76x76.png",
  88. "app@2x": "unpackage/res/icons/152x152.png",
  89. "notification": "unpackage/res/icons/20x20.png",
  90. "notification@2x": "unpackage/res/icons/40x40.png",
  91. "proapp@2x": "unpackage/res/icons/167x167.png",
  92. "settings": "unpackage/res/icons/29x29.png",
  93. "settings@2x": "unpackage/res/icons/58x58.png",
  94. "spotlight": "unpackage/res/icons/40x40.png",
  95. "spotlight@2x": "unpackage/res/icons/80x80.png"
  96. }
  97. icons.ios.iphone = {
  98. "app@2x": "unpackage/res/icons/120x120.png",
  99. "app@3x": "unpackage/res/icons/180x180.png",
  100. "notification@2x": "unpackage/res/icons/40x40.png",
  101. "notification@3x": "unpackage/res/icons/60x60.png",
  102. "settings@2x": "unpackage/res/icons/58x58.png",
  103. "settings@3x": "unpackage/res/icons/87x87.png",
  104. "spotlight@2x": "unpackage/res/icons/80x80.png",
  105. "spotlight@3x": "unpackage/res/icons/120x120.png"
  106. }
  107. push.unipush.icons.small = {
  108. "hdpi": "unpackage/res/push/36x36.png",
  109. "ldpi": "unpackage/res/push/18x18.png",
  110. "mdpi": "unpackage/res/push/24x24.png",
  111. "xhdpi": "unpackage/res/push/48x48.png",
  112. "xxhdpi": "unpackage/res/push/72x72.png"
  113. }
  114. }
  115. } else if ('./src/pages.json') {
  116. state.pages.forEach((e, index) => {
  117. if (args === 'huiYi') {
  118. if (e.style.navigationBarTitleText === "人脸识别") {
  119. if (index != 0) {
  120. state.pages.splice(0, 1, ...state.pages.splice(index, 1, state.pages[0]))
  121. }
  122. }
  123. state.condition.list[0].path = "pages/face/index"
  124. } else if (args === 'menJin') {
  125. if (e.style.navigationBarTitleText === "门禁识别") {
  126. if (index != 0) {
  127. state.pages.splice(0, 1, ...state.pages.splice(index, 1, state.pages[0]))
  128. }
  129. }
  130. state.condition.list[0].path = "pages/door/index"
  131. }
  132. })
  133. }
  134. // 将修改后的对象转换回JSON字符串
  135. const updated = JSON.stringify(state, null, 4);
  136. // 写入新的配置到manifest.json
  137. fs.writeFile(file, updated, 'utf8', function (err) {
  138. if (err) throw err;
  139. console.log(file + ' updated successfully');
  140. });
  141. });
  142. })