const fs = require('fs'); const args = process.argv.slice(2)[0]; const filesToModify = ['./src/manifest.json', './src/pages.json']; filesToModify.forEach((file) => { fs.readFile(file, 'utf8', function (err, data) { if (err) throw err; let cleanedData = data.replace(/\/\/.*|\/\*[\s\S]*?\*\//g, '');// 使用正则表达式去除单行注释 let state = JSON.parse(cleanedData);// 解析JSON数据 if (file == './src/manifest.json') { var maps = state["app-plus"].distribute.sdkConfigs.maps var geolocation = state["app-plus"].distribute.sdkConfigs.geolocation if (args === 'zhiHuiYun') { state.name = '综合智慧云' state.appid = '__UNI__36DE3A0' state.description = '综合智慧云APP,是一款助力于企业数字化的应用平台,帮助企业提升办公效率,实现组织数字化和业务数字化。' state.versionName = "2.2.4" state.versionCode = 24 state.h5.title = '综合智慧云' maps.amap.name = "amapBOujshtbA" maps.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc" maps.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f" geolocation.amap.name = "amapBOujshtbA" geolocation.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc" geolocation.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f" geolocation.tencent.apikey_ios = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" geolocation.tencent.apikey_android = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" } else if (args === 'xunJian') { state.name = '智能巡更' state.appid = '__UNI__BF1A1F0' state.description = '智能巡更app,是一款用于监督和记录巡逻人员按照预定路线和时间进行巡逻的系统。' state.versionName = "2.2.7" state.versionCode = 27 state.h5.title = '智能巡更' maps.amap.name = "amap_15575941817CWPEQVCyc" maps.amap.appkey_ios = "4da4abbd317d0b083d6c25dd9b509eed" maps.amap.appkey_android = "63bef5d715bfa5433189e7b65516dfa5" geolocation.amap.name = "amap_15575941817CWPEQVCyc" geolocation.amap.appkey_ios = "4da4abbd317d0b083d6c25dd9b509eed" geolocation.amap.appkey_android = "63bef5d715bfa5433189e7b65516dfa5" geolocation.tencent.apikey_ios = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" geolocation.tencent.apikey_android = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" } else if (args === 'huiYi') { state.name = '智能会议' state.appid = '__UNI__F3963F8' state.description = '智能会议APP,是一款集成了现代信息技术和智能化管理功能的移动应用程序,旨在提升会议体验和管理效率。' state.versionName = "2.0.5" state.versionCode = 1 state.h5.title = '智能会议' maps.amap.name = "amapBOujshtbA" maps.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc" maps.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f" geolocation.amap.name = "amapBOujshtbA" geolocation.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc" geolocation.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f" geolocation.tencent.apikey_ios = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" geolocation.tencent.apikey_android = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" } else if (args === 'menJin') { state.name = '智能门禁' state.appid = '__UNI__8D6E9FD' state.description = '智能门禁APP,是一款集成了现代信息技术和智能化管理功能的移动应用程序。' state.versionName = "1.0.0" state.versionCode = 1 state.h5.title = '智能门禁' maps.amap.name = "amapBOujshtbA" maps.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc" maps.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f" geolocation.amap.name = "amapBOujshtbA" geolocation.amap.appkey_ios = "fb35d03fbb17cbf7a8743a522da3c7fc" geolocation.amap.appkey_android = "ffc71dfd4e576596027f8f45a1b8fb2f" geolocation.tencent.apikey_ios = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" geolocation.tencent.apikey_android = "EGOBZ-74ZET-ST7XS-VYICT-RBLHZ-KLFEX" } } else if ('./src/pages.json') { state.pages.forEach((e, index) => { if (args === 'zhiHuiYun') { if (e.style.navigationBarTitleText === "工作台") { if (index != 0) { state.pages.splice(0, 1, ...state.pages.splice(index, 1, state.pages[0])) } } state.condition.list[0].path = "pages/login" } else if (args === 'xunJian') { if (e.style.navigationBarTitleText === "工作台") { if (index != 0) { state.pages.splice(0, 1, ...state.pages.splice(index, 1, state.pages[0])) } } state.condition.list[0].path = "pages/login" } else if (args === 'huiYi') { if (e.style.navigationBarTitleText === "人脸识别") { if (index != 0) { state.pages.splice(0, 1, ...state.pages.splice(index, 1, state.pages[0])) } } state.condition.list[0].path = "pages/face/index" } else if (args === 'menJin') { if (e.style.navigationBarTitleText === "门禁识别") { if (index != 0) { state.pages.splice(0, 1, ...state.pages.splice(index, 1, state.pages[0])) } } state.condition.list[0].path = "pages/door/index" } }) } // 将修改后的对象转换回JSON字符串 const updated = JSON.stringify(state, null, 4); // 写入新的配置到manifest.json fs.writeFile(file, updated, 'utf8', function (err) { if (err) throw err; console.log(file + ' updated successfully'); }); }); })