浏览代码

Merge branch 'main' of https://github.com/PUGE/myApp

PUGE 1 月之前
父节点
当前提交
5084331be6

+ 1 - 1
config.json

@@ -1,5 +1,5 @@
 {
-    "enterURL": "https://web.whatsapp.com/",
+    "enterURL": "http://selftest.umlchina.com/",
     "width": 800,
     "height": 600,
     "webPreferences": {

文件差异内容过多而无法显示
+ 48 - 0
dist/whatsapp发消息/preLoadFile.js


+ 26 - 0
dist/自助答题/config.json

@@ -0,0 +1,26 @@
+{
+    "enterURL": "http://selftest.umlchina.com/",
+    "width": 800,
+    "height": 600,
+    "webPreferences": {
+        "webSecurity": false,
+        "nodeIntegration": false,
+        "nativeWindowOpen": false,
+        "preload": "<dir>/preload.js",
+        "worldSafeExecuteJavaScript": true,
+        "enableRemoteModule": false,
+        "safeDialogs": false
+    },
+    "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1",
+    "autoHideMenuBar": true,
+    "redirect":[],
+    "redirectURL":"",
+    "proxy":"",
+    "noCache": false,
+    "interceptor":[
+        "https://selftest.umlchina.com/api/%E8%87%AA%E6%B5%8B/%E6%8F%90%E4%BA%A4%E7%AD%94%E6%A1%88",
+        "https://selftest.umlchina.com/api/%E8%87%AA%E6%B5%8B/%E5%BC%80%E5%A7%8B%E8%87%AA%E6%B5%8B",
+        "https://selftest.umlchina.com/api/%E8%87%AA%E6%B5%8B/%E5%88%87%E6%8D%A2%E9%A2%98%E7%9B%AE"
+    ],
+    "preLoadFile": "<dir>/preLoadFile.js"
+}

+ 1 - 0
dist/自助答题/data.json

@@ -0,0 +1 @@
+{}

+ 63 - 0
dist/自助答题/preLoadFile.js

@@ -0,0 +1,63 @@
+let dataTemp = {}
+window.electronAPI.readFile({filename: 'data.json', encoding: "utf8"}).then(result => {
+    if (result.success) {
+      console.log(result.content);
+      dataTemp = JSON.parse(result.content)
+    } else {
+      console.error('文件读取失败:', result.error);
+    }
+});
+
+window.onInterceptedData = function (data) {
+  console.log(data)
+  if (data.url.includes('%E6%8F%90%E4%BA%A4%E7%AD%94%E6%A1%88')) {
+    const pageID = data.requestBody['试题Id']
+    const resb = JSON.parse(data.responseBody)
+    console.log(resb['正确选项Id列表'], pageID)
+    dataTemp[pageID] = resb['正确选项Id列表']
+    const fileData = {
+      filename: 'data.json',
+      content: JSON.stringify(dataTemp)
+    };
+
+    // 调用保存方法
+    window.electronAPI.saveFile(fileData).then(result => {
+      if (result.success) {
+        console.log('文件保存成功:', result.path);
+      } else {
+        console.error('文件保存失败:', result.error);
+      }
+    });
+  }
+  if (data.url.includes('%E5%BC%80%E5%A7%8B%E8%87%AA%E6%B5%8B')) {
+    const resb = JSON.parse(data.responseBody)
+    const dqst = resb['当前题目']['Id']
+    if (dataTemp[dqst]) {
+      setTimeout(() => {
+        if (window.optionsArea) {
+          dataTemp[dqst].forEach(creatID => {
+            window.optionsArea.querySelector(`[data-option-id="${creatID}"]`).style.backgroundColor = 'aliceblue'
+          });
+          
+        }
+      }, 1000);
+    }
+    
+  }
+  if (data.url.includes('%E5%88%87%E6%8D%A2%E9%A2%98%E7%9B%AE')) {
+    const resb = JSON.parse(data.responseBody)
+    const dqst = resb['当前试题']['Id']
+    if (dataTemp[dqst]) {
+      setTimeout(() => {
+        if (window.optionsArea) {
+          dataTemp[dqst].forEach(creatID => {
+            window.optionsArea.querySelector(`[data-option-id="${creatID}"]`).style.backgroundColor = 'aliceblue'
+          });
+          
+        }
+      }, 1000);
+    }
+    
+  }
+};
+

+ 23 - 0
dist/自助答题/preload.js

@@ -0,0 +1,23 @@
+const { contextBridge, ipcRenderer } = require('electron');
+
+
+contextBridge.exposeInMainWorld('electronAPI', {
+  openWindow: (msg) => ipcRenderer.invoke('openWindow', msg),
+  closeAllWindow: (msg) => ipcRenderer.send('closeAllWindow', msg),
+  getData: (msg) => ipcRenderer.send('getData', msg),
+  postData: (msg) => ipcRenderer.send('postData', msg),
+  setProxy: (msg) => ipcRenderer.send('setProxy', msg),
+  addPreLoadCode: (msg) => ipcRenderer.send('addPreLoadCode', msg),
+  setStoData: (msg) => ipcRenderer.send('setStoData', msg),
+  getStoData: (msg) => ipcRenderer.send('getStoData', msg),
+  closeWindow: (msg) => ipcRenderer.send('closeWindow', msg),
+  changeProxy: (msg) => ipcRenderer.send('changeProxy', msg),
+  readConfig: (msg) => ipcRenderer.send('readConfig', msg),
+  saveConfig: (msg) => ipcRenderer.send('saveConfig', msg),
+  setMaxWindowOpenNum: (msg) => ipcRenderer.send('setMaxWindowOpenNum', msg),
+  readdir: (msg) => ipcRenderer.send('readdir', msg),
+  download: (msg) => ipcRenderer.send('download', msg),
+  broadcast: (msg) => ipcRenderer.send('broadcast-message', msg),
+  onBroadcast: (callback) => ipcRenderer.on('message-broadcast', (event, data) => callback(data)),
+});
+

+ 10 - 0
main.js

@@ -516,6 +516,16 @@ app.on('window-all-closed', function () {
   if (process.platform !== 'darwin') app.quit()
 })
 
+app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
+  // 阻止默认的错误处理
+  event.preventDefault();
+  // 允许证书错误
+  callback(true);
+  
+  // 如果需要,可以记录日志
+  console.warn(`忽略证书错误: ${error} - ${url}`);
+});
+
 // In this file you can include the rest of your app's specific main process
 // code. You can also put them in separate files and require them here.
 

部分文件因为文件数量过多而无法显示