PUGE 2 år sedan
förälder
incheckning
9c62973b27
4 ändrade filer med 341 tillägg och 367 borttagningar
  1. 1 1
      config.json
  2. 69 19
      main.js
  3. 2 2
      package.json
  4. 269 345
      yarn.lock

+ 1 - 1
config.json

@@ -1 +1 @@
-{"enterURL":"./dist/win-unpacked/dist/index.html","width":1200,"height":800,"webPreferences":{"webSecurity":false,"nodeIntegration":true,"nativeWindowOpen":false},"autoHideMenuBar":true,"redirect":[],"redirectURL":"","proxy":"","noCache":false,"data":[],"activeIndex":1,"username":""}
+{"enterURL":"https://demos.run/debuger/index.html#login","width":1200,"height":800,"webPreferences":{"webSecurity":false,"nodeIntegration":true,"nativeWindowOpen":false},"autoHideMenuBar":true,"redirect":[],"redirectURL":"","proxy":"","noCache":false,"data":[],"activeIndex":1,"username":"","fullscreen":false}

+ 69 - 19
main.js

@@ -11,7 +11,6 @@ let webConfig = {
   height: 667,
   webPreferences: {
     webSecurity: false,
-    nativeWindowOpen: false,
     contextIsolation: true,
     preload: path.join(__dirname, "preload.js")
   },
@@ -50,7 +49,7 @@ function owoDecode(itemStr) {
 const xxx_filter = {
   urls: webConfig.redirect || []
 }
-
+let mainWindow = null
 function createWindow () {
   // Create the browser window.
   
@@ -60,29 +59,25 @@ function createWindow () {
   // }
   if (!webConfig.webPreferences.preload) webConfig.webPreferences.preload = path.join(__dirname, "preload.js")
   console.log(webConfig)
-  const mainWindow = new BrowserWindow(webConfig)
+  mainWindow = new BrowserWindow(webConfig)
 
-  // and load the index.html of the app.
-  // mainWindow.loadFile('./resources/01.html')
-  // mainWindow.webContents.userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1 electron'
-  // mainWindow.webContents.openDevTools()
+  // 代理
+  if (webConfig.proxy) {
+    mainWindow.webContents.session.setProxy({
+      proxyRules: webConfig.proxy,
+      proxyBypassRules: 'localhost',
+    }, function () {
+      console.log('代理设置完毕')
+    });
+  }
   if (enterURL.startsWith('http')) {
     mainWindow.loadURL(enterURL)
   } else {
     console.log(path.join(__dirname, enterURL))
     mainWindow.loadFile(path.join(__dirname, enterURL))
   }
-  
+
   mainWindow.webContents.on("dom-ready", function() {
-    // 代理
-    if (webConfig.proxy) {
-      mainWindow.webContents.session.setProxy({
-        proxyRules: webConfig.proxy,
-        proxyBypassRules: 'localhost',
-      }, function () {
-        console.log('代理设置完毕')
-      });
-    }
 
     let preLoadCode = `
     var owoApp = 4
@@ -125,8 +120,10 @@ function createWindow () {
       document.getElementsByTagName("head")[0].appendChild(link);
     }
     
-    let needLoad_App = localStorage.getItem('needLoad_App')
-    needLoad_App = null
+    let needLoad_App = null
+    if (window && window.localStorage) {
+      needLoad_App = localStorage.getItem('needLoad_App')
+    }
     function owoReload (data) {
       data.forEach(element => {
         if (element.type == 'app') {
@@ -244,6 +241,59 @@ ipcMain.on("postData", (event, message) => {
   });
 })
 
+ipcMain.on("setProxy", (event, message) => {
+  var win = new BrowserWindow({width: 800, height: 1500});
+  mainWindow.webContents.session.setProxy({
+    proxyRules: message.url,
+    proxyBypassRules: 'localhost',
+  });
+  event.returnValue = 'ok'
+})
+
+let childWindowList = []
+ipcMain.on("openWindow", (event, message) => {
+  let nowIndex = childWindowList.length
+  childWindowList[nowIndex] = new BrowserWindow({
+    width: message.width || 800,
+    height: message.height || 600,
+    webPreferences: {
+      partition: 'persist:Session' + Math.round(Math.random()*100000)
+    }
+  });
+  if (message.proxy) {
+    childWindowList[nowIndex].webContents.session.setProxy({
+      proxyRules: message.proxy,
+      proxyBypassRules: ['localhost', "cunchu.site", "demos.run", "proxy.com"],
+    });
+  }
+  
+  childWindowList[nowIndex].loadURL(message.url);
+  event.returnValue = JSON.stringify({"err":0,"inx":nowIndex})
+})
+
+ipcMain.on("closeWindow", (event, message) => {
+  childWindowList.forEach(element => {
+    if (element && element.close) {
+      element.close()
+    }
+  });
+  childWindowList = []
+  event.returnValue = JSON.stringify({"err":0})
+})
+
+
+ipcMain.on("changeProxy", (event, message) => {
+  childWindowList.forEach(element => {
+    if (element) {
+      element.webContents.session.setProxy({
+        proxyRules: "",
+        proxyBypassRules: ['localhost', "cunchu.site", "demos.run", "proxy.com"],
+      });
+    }
+  });
+  event.returnValue = JSON.stringify({"err":0})
+})
+
 
 ipcMain.on("readConfig", (event, message) => {
   if (fs.existsSync("./config.json")) {

+ 2 - 2
package.json

@@ -33,8 +33,8 @@
   "author": "GitHub",
   "license": "CC0-1.0",
   "devDependencies": {
-    "electron": "17.0.1",
-    "electron-builder": "22.14.13"
+    "electron": "23.2.1",
+    "electron-builder": "23.6.0"
   },
   "dependencies": {
     "download": "^8.0.0",

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 269 - 345
yarn.lock


Vissa filer visades inte eftersom för många filer har ändrats