setting.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. if (args === 'zhiHuiYun') {
  11. state.name = '综合智慧云'
  12. state.appid = '__UNI__36DE3A0'
  13. state.description = '综合智慧云APP,是一款助力于企业数字化的应用平台,帮助企业提升办公效率,实现组织数字化和业务数字化。'
  14. state.versionName = "2.1.9"
  15. state.versionCode = 19
  16. state.h5.title = '综合智慧云'
  17. } else if (args === 'xunJian') {
  18. state.name = '智能巡更'
  19. state.appid = '__UNI__BF1A1F0'
  20. state.description = '智能巡更app,是一款用于监督和记录巡逻人员按照预定路线和时间进行巡逻的系统。'
  21. state.versionName = "2.2.1"
  22. state.versionCode = 21
  23. state.h5.title = '智能巡更'
  24. } else if (args === 'huiYi') {
  25. state.name = '智能会议'
  26. state.appid = '__UNI__F3963F8'
  27. state.description = '智能会议APP,是一款集成了现代信息技术和智能化管理功能的移动应用程序,旨在提升会议体验和管理效率。'
  28. state.versionName = "2.0.1"
  29. state.versionCode = 1
  30. state.h5.title = '智能会议'
  31. }
  32. } else if ('./src/pages.json') {
  33. state.pages = [
  34. {
  35. "path": "pages/index",
  36. "style": {
  37. "navigationStyle": "custom",
  38. "navigationBarTitleText": "工作台",
  39. "app-plus": {
  40. "bounce": "none",
  41. "titleNView": false
  42. }
  43. }
  44. },
  45. {
  46. "path": "pages/login",
  47. "style": {
  48. "navigationBarTitleText": "登录",
  49. "navigationStyle": "custom",
  50. "navigationBarTextStyle": "black"
  51. }
  52. },
  53. {
  54. "path": "pages/register",
  55. "style": {
  56. "navigationBarTitleText": "注册",
  57. "navigationStyle": "custom",
  58. "navigationBarTextStyle": "black"
  59. }
  60. },
  61. {
  62. "path": "pages/serveConfigSelect",
  63. "style": {
  64. "navigationBarTitleText": "服务器配置",
  65. "navigationStyle": "custom",
  66. "navigationBarTextStyle": "black"
  67. }
  68. },
  69. {
  70. "path": "pages/serveConfig",
  71. "style": {
  72. "navigationBarTitleText": "服务器配置",
  73. "navigationStyle": "custom",
  74. "navigationBarTextStyle": "black"
  75. }
  76. },
  77. {
  78. "path": "pages/info",
  79. "style": {
  80. "navigationBarTitleText": "消息",
  81. "navigationStyle": "custom",
  82. "enablePullDownRefresh": false,
  83. "app-plus": {
  84. "bounce": "none",
  85. "titleNView": false
  86. }
  87. }
  88. },
  89. {
  90. "path": "pages/mine",
  91. "style": {
  92. "navigationBarTitleText": "我的",
  93. "navigationStyle": "custom",
  94. "app-plus": {
  95. "bounce": "none",
  96. "titleNView": false
  97. }
  98. }
  99. }
  100. ]
  101. }
  102. // 将修改后的对象转换回JSON字符串
  103. const updated = JSON.stringify(state, null, 4);
  104. // 写入新的配置到manifest.json
  105. fs.writeFile(file, updated, 'utf8', function (err) {
  106. if (err) throw err;
  107. console.log(file + ' updated successfully');
  108. });
  109. });
  110. })