main.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. // Modules to control application life and create native browser window
  2. const {app, ipcMain, BrowserWindow, session} = require('electron')
  3. const path = require('path')
  4. const fs = require('fs')
  5. const iconv = require('iconv-lite');
  6. const request = require('request');
  7. const download = require('download');
  8. // 读取配置文件
  9. let enterURL = 'https://demos.run/debuger/index.html'
  10. let webConfig = {
  11. width: 376,
  12. height: 667,
  13. webPreferences: {
  14. webSecurity: false,
  15. contextIsolation: true,
  16. nodeIntegration: false,
  17. allowRunningInsecureContent: true, // 允许不安全内容
  18. plugins: true,
  19. scrollBounce: true,
  20. preload: path.join(__dirname, "preload.js")
  21. },
  22. autoHideMenuBar: true
  23. // 无边框
  24. // frame: false,
  25. // 全屏
  26. // fullscreen: true
  27. }
  28. // 判断是否有特殊配置文件
  29. console.log(__dirname + "\\config.json")
  30. if (fs.existsSync("./config.json")) {
  31. let configStr = fs.readFileSync('./config.json', 'utf-8')
  32. // 特殊符号表示运行目录
  33. configStr = configStr.replaceAll('<dir>', __dirname.replaceAll('\\', '/').replace('/resources/app.asar', ''))
  34. webConfig = JSON.parse(configStr)
  35. enterURL = webConfig.enterURL
  36. }
  37. console.log(webConfig)
  38. const codeMap = {"fc":"[re]","ep":"[Af]","rj":"[M_]","sp":"[sW]","ws":"[Pj]","mb":"[^~]","ww":"[Dp]","wh":"[ZH]","ph":"[b+]","hk":"[3b]","mc":"[%)]","fm":"[$4]","nm":"[T!]","ei":"[J3]","pd":"[(A]","ef":"[%t]","xf":"[n_]","na":"[W6]","mr":"[dn]","km":"[b*]","aw":"[#*]","sj":"[~6]","ry":"[t#]","sd":"[$R]","eh":"[!!]","wp":"[TE]","fy":"[s6]","ex":"[EE]","ce":"[PS]","xr":"[~z]","cj":"[xh]","am":"[(G]","kw":"[Nr]","hj":"[p@]","ia":"[jO]","mp":"[75]","py":"[6C]","hc":"[46]","sk":"[(8]","hp":"[SB]","my":"[pq]","wk":"[Xd]","bk":"[Q^]","ak":"[)J]","cw":"[ai]","ym":"[Te]","yh":"[Cd]","xb":"[R5]","yy":"[#H]","nt":"[4)]","bc":"[#J]","fe":"[2+]","ni":"[f@]","bb":"[!k]","jc":"[$Q]","an":"[m$]","ee":"[RH]","nn":"[n$]","jr":"[5F]","pp":"[JQ]","fx":"[86]","2":"[)h]","3":"[iL]","4":"[r2]","5":"[Ys]","6":"[7p]","7":"[!5]","8":"[@A]","A":"[_W]","B":"[Kt]","C":"[m#]","D":"[A!]","E":"[M!]","F":"[xG]","G":"[k@]","H":"[_!]","J":"[rP]","K":"[z#]","M":"[r$]","N":"[rN]","P":"[t$]","Q":"[3(]","R":"[fF]","S":"[H)]","T":"[J@]","W":"[83]","X":"[t5]","Y":"[T_]","Z":"[CT]","a":"[Jt]","b":"[Ks]","c":"[yn]","d":"[2r]","e":"[#2]","f":"[yM]","h":"[)m]","i":"[mx]","j":"[YV]","k":"[$j]","m":"[Xy]","n":"[Bk]","p":"[5$]","r":"[EH]","s":"[Pw]","t":"[j(]","w":"[p7]","x":"[a+]","y":"[B2]","z":"[4n]","~":"[~C]","!":"[iw]","@":"[SK]","#":"[Pf]","$":"[de]","%":"[3t]","^":"[H_]","&":"[WA]","*":"[!A]","(":"[z*]",")":"[)n]","_":"[&k]","+":"[*F]"}
  39. function owoReplaceAll(str, s1, s2) {
  40. while (str.indexOf(s1) >= 0) {
  41. str = str.replace(s1, s2)
  42. }
  43. return str
  44. }
  45. function owoDecode(itemStr) {
  46. for (let item in codeMap) {
  47. itemStr = owoReplaceAll(itemStr, codeMap[item], item)
  48. }
  49. while (itemStr.indexOf(']') >= 0) {
  50. itemStr = owoDecode(itemStr)
  51. }
  52. return itemStr
  53. }
  54. let mainWindow = null
  55. let preLoadCode = `
  56. var owoApp = 5
  57. window.owoPC = true
  58. window.electronConfig = ${JSON.stringify(webConfig)};
  59. function loadScript(url, callback) {
  60. var script = document.createElement("script")
  61. script.type = "text/javascript";
  62. if (script.readyState) { //IE
  63. script.onreadystatechange = function () {
  64. if (script.readyState == "loaded" || script.readyState == "complete") {
  65. script.onreadystatechange = null;
  66. if (callback) callback();
  67. }
  68. };
  69. } else { //Others
  70. script.onload = function () {
  71. if (callback) callback();
  72. };
  73. }
  74. script.src = url;
  75. var head = document.head || document.getElementsByTagName('head')[0];
  76. head.appendChild(script);
  77. }
  78. function loadJsCode(code){
  79. var script = document.createElement('script');
  80. script.type = 'text/javascript';
  81. //for Chrome Firefox Opera Safari
  82. script.appendChild(document.createTextNode(code));
  83. //for IE
  84. //script.text = code;
  85. document.body.appendChild(script);
  86. }
  87. function loadCSS (url) {
  88. var link = document.createElement("link");
  89. link.rel = "stylesheet";
  90. link.type = "text/css";
  91. link.href = url;
  92. document.getElementsByTagName("head")[0].appendChild(link);
  93. }
  94. loadScript('https://cunchu.site/app/main.js');
  95. `
  96. // 拦截数据
  97. // 拦截数据(获取请求和响应内容)
  98. function setupDebuggerInterceptor(webContents, interceptor) {
  99. webContents.debugger.attach('1.3');
  100. const pendingRequests = new Map();
  101. webContents.debugger.on('message', (event, method, params) => {
  102. // 存储请求信息
  103. if (method === 'Network.requestWillBeSent') {
  104. pendingRequests.set(params.requestId, {
  105. url: params.request.url,
  106. method: params.request.method,
  107. headers: params.request.headers,
  108. postData: params.request.postData,
  109. timestamp: Date.now()
  110. });
  111. }
  112. // 响应接收时记录信息
  113. if (method === 'Network.responseReceived') {
  114. const { requestId, response } = params;
  115. let hookData = false;
  116. interceptor.forEach(hookURL => {
  117. if (response.url.includes(hookURL) || response.url === hookURL) {
  118. hookData = true;
  119. }
  120. });
  121. if (hookData) {
  122. console.log('拦截到响应:', response.url, response.status);
  123. // 存储响应信息,等待 loadingFinished
  124. const requestInfo = pendingRequests.get(requestId) || {};
  125. pendingRequests.set(requestId, {
  126. ...requestInfo,
  127. responseReceived: true,
  128. response,
  129. hookData: true
  130. });
  131. }
  132. }
  133. // 在资源加载完成时获取响应体
  134. if (method === 'Network.loadingFinished') {
  135. const { requestId } = params;
  136. const requestInfo = pendingRequests.get(requestId);
  137. if (requestInfo && requestInfo.hookData) {
  138. // 延迟获取响应体,确保数据可用
  139. setTimeout(() => {
  140. webContents.debugger.sendCommand('Network.getResponseBody', { requestId })
  141. .then(({ body }) => {
  142. // 获取请求体(如果有)
  143. let requestBody = null;
  144. if (requestInfo.postData) {
  145. try {
  146. // 尝试解析为JSON,如果不是JSON则保持原样
  147. requestBody = JSON.parse(requestInfo.postData);
  148. } catch (e) {
  149. requestBody = requestInfo.postData;
  150. }
  151. }
  152. const interceptedData = {
  153. url: requestInfo.response.url,
  154. method: requestInfo.method,
  155. statusCode: requestInfo.response.status,
  156. requestHeaders: requestInfo.headers,
  157. requestBody: requestBody,
  158. responseBody: body,
  159. responseHeaders: requestInfo.response.headers,
  160. requestId: requestId,
  161. timestamp: requestInfo.timestamp
  162. };
  163. console.log('拦截到的完整数据:', interceptedData.url);
  164. console.log(interceptedData);
  165. if (mainWindow && !mainWindow.isDestroyed()) {
  166. mainWindow.webContents.executeJavaScript(`
  167. if (window.onInterceptedData) {
  168. window.onInterceptedData(${JSON.stringify(interceptedData)});
  169. }
  170. `).catch(console.error);
  171. }
  172. // 清理缓存
  173. pendingRequests.delete(requestId);
  174. })
  175. .catch(error => {
  176. console.warn(`无法获取响应体 ${requestInfo.response.url}:`, error.message);
  177. pendingRequests.delete(requestId);
  178. });
  179. }, 100); // 添加小延迟
  180. }
  181. }
  182. // 清理已完成或失败的请求
  183. if (method === 'Network.loadingFailed' || method === 'Network.requestServedFromCache') {
  184. const { requestId } = params;
  185. pendingRequests.delete(requestId);
  186. }
  187. });
  188. // 启用网络跟踪
  189. webContents.debugger.sendCommand('Network.enable');
  190. }
  191. function createWindow (partitionSession) {
  192. // console.log(webConfig)
  193. mainWindow = new BrowserWindow(webConfig)
  194. // 代理
  195. if (webConfig.proxy) {
  196. partitionSession.setProxy({
  197. proxyRules: webConfig.proxy,
  198. proxyBypassRules: 'localhost',
  199. }, function () {
  200. console.log('代理设置完毕')
  201. });
  202. }
  203. // 拦截到新窗口打开请求
  204. mainWindow.webContents.setWindowOpenHandler(({ url }) => {
  205. console.log('拦截到新窗口打开请求:', url);
  206. mainWindow.loadURL(url); // 当前窗口跳转
  207. return { action: 'deny' }; // 阻止 Electron 弹出窗口
  208. });
  209. if (enterURL.startsWith('http')) {
  210. mainWindow.loadURL(enterURL)
  211. } else {
  212. console.log(path.join(__dirname, enterURL))
  213. mainWindow.loadFile(enterURL)
  214. }
  215. if (webConfig.preLoadFile) {
  216. console.log(`Load additional JS: ${webConfig.preLoadFile}`)
  217. preLoadCode += fs.readFileSync(webConfig.preLoadFile, 'utf-8')
  218. }
  219. mainWindow.webContents.on("dom-ready", function() {
  220. mainWindow.webContents.executeJavaScript(preLoadCode);
  221. });
  222. // 只触发一次!
  223. mainWindow.webContents.once("did-finish-load", function() {
  224. if (webConfig.interceptor && webConfig.interceptor.length > 0) {
  225. console.log('Need to intercept data!')
  226. setupDebuggerInterceptor(mainWindow.webContents, webConfig.interceptor);
  227. }
  228. });
  229. // 打开新窗口触发
  230. mainWindow.webContents.on("did-create-window", function(neWindow) {
  231. neWindow.webContents.on("dom-ready", function() {
  232. neWindow.webContents.executeJavaScript(preLoadCode);
  233. });
  234. });
  235. }
  236. function setupCSPRemoval(ses) {
  237. ses.webRequest.onHeadersReceived((details, callback) => {
  238. const responseHeaders = details.responseHeaders || {};
  239. const cspHeaders = [
  240. 'content-security-policy',
  241. 'Content-Security-Policy',
  242. 'content-security-policy-report-only',
  243. 'x-content-security-policy',
  244. 'x-webkit-csp'
  245. ];
  246. cspHeaders.forEach(header => {
  247. if (responseHeaders[header]) {
  248. // console.log('Removing', header, 'from', details.url);
  249. delete responseHeaders[header];
  250. }
  251. });
  252. callback({ cancel: false, responseHeaders });
  253. });
  254. }
  255. // This method will be called when Electron has finished
  256. // initialization and is ready to create browser windows.
  257. // Some APIs can only be used after this event occurs.
  258. app.whenReady().then(() => {
  259. // 判断是否无缓存
  260. if (webConfig.noCache) {
  261. console.log('无缓存模式!')
  262. webConfig.webPreferences.partition = 'persist:Session' + Math.round(Math.random()*100000)
  263. } else {
  264. webConfig.webPreferences.partition = 'persist:owoApp'
  265. }
  266. // 去掉安全措施
  267. const partitionSession = session.fromPartition(webConfig.webPreferences.partition);
  268. setupCSPRemoval(partitionSession);
  269. createWindow(partitionSession)
  270. app.on('activate', function () {
  271. // On macOS it's common to re-create a window in the app when the
  272. // dock icon is clicked and there are no other windows open.
  273. if (BrowserWindow.getAllWindows().length === 0) createWindow(partitionSession)
  274. })
  275. })
  276. // Quit when all windows are closed, except on macOS. There, it's common
  277. // for applications and their menu bar to stay active until the user quits
  278. // explicitly with Cmd + Q.
  279. app.on('window-all-closed', function () {
  280. if (process.platform !== 'darwin') app.quit()
  281. })
  282. // In this file you can include the rest of your app's specific main process
  283. // code. You can also put them in separate files and require them here.
  284. ipcMain.on("getData", (event, message) => {
  285. // 控制台打印一下知道来了
  286. console.log(message);
  287. var options = {
  288. 'method': 'GET',
  289. 'url': owoDecode(message.url),
  290. 'headers': message.headers,
  291. strictSSL: false
  292. };
  293. request(options, function (error, response) {
  294. if (error) throw new Error(error);
  295. event.returnValue = response.body
  296. });
  297. })
  298. ipcMain.on("postData", (event, message) => {
  299. // 控制台打印一下知道来了
  300. console.log(message);
  301. var options = {
  302. 'method': 'POST',
  303. 'url': owoDecode(message.url),
  304. 'headers': message.headers,
  305. 'body': message.body,
  306. strictSSL: false
  307. };
  308. request(options, function (error, response) {
  309. if (error) throw new Error(error);
  310. event.returnValue = response.body
  311. });
  312. })
  313. ipcMain.on("setProxy", (event, message) => {
  314. var win = new BrowserWindow({width: 800, height: 1500});
  315. mainWindow.webContents.session.setProxy({
  316. proxyRules: message.url,
  317. proxyBypassRules: 'localhost',
  318. });
  319. event.returnValue = 'ok'
  320. })
  321. // 添加注入代码
  322. ipcMain.on("addPreLoadCode", (event, message) => {
  323. if (message.data) preLoadCode += message.data
  324. })
  325. // 通用保存数据
  326. let dataStor = {}
  327. ipcMain.on("setStoData", (event, message) => {
  328. dataStor[message.key] = message.value
  329. event.returnValue = '{"err":0}'
  330. })
  331. ipcMain.on("getStoData", (event, message) => {
  332. event.returnValue = dataStor[message.key]
  333. })
  334. let maxWindowOpenNum = 10
  335. let nowWindowInd = 0
  336. let childWindowList = []
  337. function randomString(n){const str = 'abcdefghijklmnopqrstuvwxyz9876543210';let tmp = '',i = 0,l = str.length;for (i = 0; i < n; i++) {tmp += str.charAt(Math.floor(Math.random() * l));}return tmp;}
  338. ipcMain.handle("openWindow", async (event, message) => {
  339. console.log(message)
  340. let nowIndex = nowWindowInd++
  341. // 判断是否达到了最大窗口数量
  342. let nowWindowNumTemp = 0
  343. for (let index = 0; index < childWindowList.length; index++) {
  344. const element = childWindowList[index];
  345. if (element) nowWindowNumTemp++
  346. }
  347. if (nowWindowNumTemp > maxWindowOpenNum) {
  348. for (let index = 0; index < childWindowList.length; index++) {
  349. const element = childWindowList[index];
  350. if (element) {
  351. childWindowList[index].close()
  352. childWindowList[index] = null
  353. }
  354. }
  355. }
  356. // 获取对应 session
  357. let partitionName = 'persist:owoAppChild'
  358. if (message.noCache) {
  359. partitionName = 'persist:Session' + Math.round(Math.random()*100000)
  360. }
  361. const customSession = session.fromPartition(partitionName);
  362. if (message.proxy) {
  363. // 设置代理(等待设置完成)
  364. await customSession.setProxy({
  365. proxyRules: message.proxy,
  366. proxyBypassRules: ['localhost', "cunchu.site", "demos.run", "proxy.com"],
  367. });
  368. }
  369. let childWindowPreferences = webConfig.webPreferences
  370. if (message.webPreferences) childWindowPreferences = message.webPreferences
  371. childWindowPreferences.partition = partitionName
  372. // 创建新窗口
  373. childWindowList[nowIndex] = new BrowserWindow({
  374. width: message.width || 800,
  375. height: message.height || 600,
  376. webPreferences: childWindowPreferences
  377. });
  378. // 判断是否静音
  379. if (message.muted) {
  380. // 设置静音
  381. childWindowList[nowIndex].webContents.setAudioMuted(true);
  382. }
  383. childWindowList[nowIndex].webContents.on("dom-ready", function() {
  384. console.log("dom-ready")
  385. childWindowList[nowIndex].webContents.executeJavaScript(preLoadCode);
  386. });
  387. childWindowList[nowIndex].on('closed', () => {
  388. childWindowList[nowIndex] = null;
  389. });
  390. // 拦截到新窗口打开请求
  391. childWindowList[nowIndex].webContents.setWindowOpenHandler(({ url }) => {
  392. console.log('拦截到新窗口打开请求:', url);
  393. childWindowList[nowIndex].loadURL(url); // 当前窗口跳转
  394. return { action: 'deny' }; // 阻止 Electron 弹出窗口
  395. });
  396. childWindowList[nowIndex].loadURL(message.url, {
  397. userAgent: message.userAgent ? message.userAgent : "Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1"
  398. });
  399. event.returnValue = JSON.stringify({"err":0,"key":nowIndex})
  400. })
  401. ipcMain.on("closeWindow", (event, message) => {
  402. if (message && message.key) {
  403. message.key = parseInt(message.key)
  404. setTimeout(() => {
  405. if (childWindowList[message.key]) {
  406. childWindowList[message.key].close()
  407. }
  408. setTimeout(() => {
  409. childWindowList[message.key] = null
  410. }, 0);
  411. }, message.time || 0);
  412. }
  413. event.returnValue = JSON.stringify({"err":0})
  414. })
  415. ipcMain.on("closeAllWindow", (event, message) => {
  416. for (let index = 0; index < childWindowList.length; index++) {
  417. const element = childWindowList[index];
  418. if (element && element.close) {
  419. try {
  420. element.close()
  421. } catch (error) {
  422. console.log(error)
  423. }
  424. }
  425. }
  426. setTimeout(() => {
  427. childWindowList = []
  428. }, 0);
  429. event.returnValue = JSON.stringify({"err":0})
  430. })
  431. ipcMain.on("changeProxy", (event, message) => {
  432. if (message && message.key) {
  433. message.key = parseInt(message.key)
  434. childWindowList[message.key].webContents.session.setProxy({
  435. proxyRules: "",
  436. proxyBypassRules: ['localhost', "cunchu.site", "demos.run", "proxy.com"],
  437. });
  438. } else {
  439. for (let index = 0; index < childWindowList.length; index++) {
  440. const element = childWindowList[index];
  441. if (element) {
  442. element.webContents.session.setProxy({
  443. proxyRules: "",
  444. proxyBypassRules: ['localhost', "cunchu.site", "demos.run", "proxy.com"],
  445. });
  446. }
  447. }
  448. }
  449. event.returnValue = JSON.stringify({"err":0})
  450. })
  451. ipcMain.on("readConfig", (event, message) => {
  452. if (fs.existsSync("./config.json")) {
  453. event.returnValue = JSON.parse(fs.readFileSync('./config.json', 'utf-8'))
  454. } else {
  455. event.returnValue = {}
  456. }
  457. })
  458. ipcMain.handle("saveFile", async (event, message) => {
  459. try {
  460. // 确保download目录存在
  461. const downloadDir = path.join(__dirname.replaceAll('\\', '/').replace('/resources/app.asar', ''), 'download');
  462. if (!fs.existsSync(downloadDir)) {
  463. fs.mkdirSync(downloadDir, { recursive: true });
  464. console.log('创建download目录:', downloadDir);
  465. }
  466. // 构建完整的文件路径
  467. const filePath = path.join(downloadDir, message.filename);
  468. // 将字符串编码为缓冲区
  469. const fileBuffer = iconv.encode(message.content, message.encoding ? message.encoding : 'utf8');
  470. fs.writeFileSync(filePath, fileBuffer);
  471. console.log('文件保存成功:', filePath);
  472. return { success: true, path: filePath };
  473. } catch (error) {
  474. console.error('保存文件失败:', error);
  475. return { success: false, error: error.message };
  476. }
  477. });
  478. ipcMain.handle("readFile", async (event, message) => {
  479. try {
  480. // 确保download目录存在
  481. const downloadDir = path.join(__dirname.replaceAll('\\', '/').replace('/resources/app.asar', ''), 'download');
  482. if (!fs.existsSync(downloadDir)) {
  483. fs.mkdirSync(downloadDir, { recursive: true });
  484. console.log('创建download目录:', downloadDir);
  485. }
  486. // 构建完整的文件路径
  487. const filePath = path.join(downloadDir, message.filename);
  488. // 检查文件是否存在
  489. if (!fs.existsSync(filePath)) {
  490. console.log('文件不存在,返回空内容:', filePath);
  491. return { success: true, content: '', exists: false };
  492. }
  493. // 读取文件内容
  494. const buffer = fs.readFileSync(filePath);
  495. const content = iconv.decode(buffer, message.encoding ? message.encoding : 'utf8');
  496. console.log('文件读取成功:', filePath);
  497. return { success: true, content: content, exists: true };
  498. } catch (error) {
  499. console.error('读取文件失败:', error);
  500. return { success: false, error: error.message, exists: false };
  501. }
  502. });
  503. ipcMain.on("saveConfig", (event, message) => {
  504. fs.writeFileSync('./config.json', JSON.stringify(message))
  505. event.returnValue = {err: 0}
  506. })
  507. // 设置最大打开窗口数量
  508. ipcMain.on("setMaxWindowOpenNum", (event, message) => {
  509. if (message.value) {
  510. maxWindowOpenNum = parseInt(message.value)
  511. }
  512. })
  513. ipcMain.on("readdir", (event, directoryPath) => {
  514. fs.readdir(directoryPath, (err, files) => {
  515. if (err) {
  516. event.returnValue = {err: 1, "msg": 'Error reading directory:' + err}
  517. return;
  518. }
  519. event.returnValue = {err: 0, files}
  520. });
  521. })
  522. ipcMain.on("download", (event, message) => {
  523. download(message.url, message.path, {
  524. filename: message.filename,
  525. });
  526. event.returnValue = {err: 0}
  527. })
  528. // 窗口间通信
  529. ipcMain.on('broadcast-message', (event, message) => {
  530. // 获取发送者
  531. console.log(message)
  532. mainWindow.send('message-broadcast', message);
  533. // 广播给所有其他窗口
  534. for (const win of childWindowList) {
  535. if (win && !win.isDestroyed()) win.webContents.send('message-broadcast', message);
  536. }
  537. });