|
@@ -11,7 +11,6 @@ let webConfig = {
|
|
|
height: 667,
|
|
height: 667,
|
|
|
webPreferences: {
|
|
webPreferences: {
|
|
|
webSecurity: false,
|
|
webSecurity: false,
|
|
|
- nativeWindowOpen: false,
|
|
|
|
|
contextIsolation: true,
|
|
contextIsolation: true,
|
|
|
preload: path.join(__dirname, "preload.js")
|
|
preload: path.join(__dirname, "preload.js")
|
|
|
},
|
|
},
|
|
@@ -50,7 +49,7 @@ function owoDecode(itemStr) {
|
|
|
const xxx_filter = {
|
|
const xxx_filter = {
|
|
|
urls: webConfig.redirect || []
|
|
urls: webConfig.redirect || []
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+let mainWindow = null
|
|
|
function createWindow () {
|
|
function createWindow () {
|
|
|
// Create the browser window.
|
|
// Create the browser window.
|
|
|
|
|
|
|
@@ -60,29 +59,25 @@ function createWindow () {
|
|
|
// }
|
|
// }
|
|
|
if (!webConfig.webPreferences.preload) webConfig.webPreferences.preload = path.join(__dirname, "preload.js")
|
|
if (!webConfig.webPreferences.preload) webConfig.webPreferences.preload = path.join(__dirname, "preload.js")
|
|
|
console.log(webConfig)
|
|
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')) {
|
|
if (enterURL.startsWith('http')) {
|
|
|
mainWindow.loadURL(enterURL)
|
|
mainWindow.loadURL(enterURL)
|
|
|
} else {
|
|
} else {
|
|
|
console.log(path.join(__dirname, enterURL))
|
|
console.log(path.join(__dirname, enterURL))
|
|
|
mainWindow.loadFile(path.join(__dirname, enterURL))
|
|
mainWindow.loadFile(path.join(__dirname, enterURL))
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
mainWindow.webContents.on("dom-ready", function() {
|
|
mainWindow.webContents.on("dom-ready", function() {
|
|
|
- // 代理
|
|
|
|
|
- if (webConfig.proxy) {
|
|
|
|
|
- mainWindow.webContents.session.setProxy({
|
|
|
|
|
- proxyRules: webConfig.proxy,
|
|
|
|
|
- proxyBypassRules: 'localhost',
|
|
|
|
|
- }, function () {
|
|
|
|
|
- console.log('代理设置完毕')
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
let preLoadCode = `
|
|
let preLoadCode = `
|
|
|
var owoApp = 4
|
|
var owoApp = 4
|
|
@@ -125,8 +120,10 @@ function createWindow () {
|
|
|
document.getElementsByTagName("head")[0].appendChild(link);
|
|
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) {
|
|
function owoReload (data) {
|
|
|
data.forEach(element => {
|
|
data.forEach(element => {
|
|
|
if (element.type == 'app') {
|
|
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) => {
|
|
ipcMain.on("readConfig", (event, message) => {
|
|
|
if (fs.existsSync("./config.json")) {
|
|
if (fs.existsSync("./config.json")) {
|