|
@@ -7,7 +7,6 @@ const url = require('url');//引入url处理模块
|
|
|
const autoUpdater = require('electron-updater').autoUpdater;
|
|
const autoUpdater = require('electron-updater').autoUpdater;
|
|
|
const {ipcMain} = require('electron');
|
|
const {ipcMain} = require('electron');
|
|
|
const dialog = require('electron').dialog;
|
|
const dialog = require('electron').dialog;
|
|
|
-const regedit = require('regedit'); //引入regedit
|
|
|
|
|
const Menu = electron.Menu;//引入菜单慕课
|
|
const Menu = electron.Menu;//引入菜单慕课
|
|
|
const debug = (process.argv.indexOf('--debug')>0);
|
|
const debug = (process.argv.indexOf('--debug')>0);
|
|
|
let message={
|
|
let message={
|
|
@@ -28,7 +27,14 @@ try {
|
|
|
process.argv[1]='https://www.flash.cn/';
|
|
process.argv[1]='https://www.flash.cn/';
|
|
|
}
|
|
}
|
|
|
var version=require(__dirname+"/package.json").version;
|
|
var version=require(__dirname+"/package.json").version;
|
|
|
|
|
+const startOnBoot = require('./startOnBoot.js');//自启动
|
|
|
function createCampusWindow(flag) {
|
|
function createCampusWindow(flag) {
|
|
|
|
|
+ if(CampusWindow){
|
|
|
|
|
+ CampusWindow.show();
|
|
|
|
|
+ CampusWindow.restore();
|
|
|
|
|
+ CampusWindow.focus();
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
createIndexWindow(false);
|
|
createIndexWindow(false);
|
|
|
if(!flag) {
|
|
if(!flag) {
|
|
|
setTimeout(function () {
|
|
setTimeout(function () {
|
|
@@ -40,9 +46,6 @@ function createCampusWindow(flag) {
|
|
|
}, 1000 * 60*5);
|
|
}, 1000 * 60*5);
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- CampusWindow.show();
|
|
|
|
|
- CampusWindow.restore();
|
|
|
|
|
- CampusWindow.focus();
|
|
|
|
|
}
|
|
}
|
|
|
function createIndexWindow(flag) {
|
|
function createIndexWindow(flag) {
|
|
|
CampusWindow = new BrowserWindow({ width: 750, height: 540, maxWidth: 750, maxHeight: 540,resizable:false,frame: false });
|
|
CampusWindow = new BrowserWindow({ width: 750, height: 540, maxWidth: 750, maxHeight: 540,resizable:false,frame: false });
|
|
@@ -64,6 +67,7 @@ function createIndexWindow(flag) {
|
|
|
autoUpdater.setFeedURL('http://client.1473.cn/update');//设置检查更新的 url,并且初始化自动更新。这个 url 一旦设置就无法更改。
|
|
autoUpdater.setFeedURL('http://client.1473.cn/update');//设置检查更新的 url,并且初始化自动更新。这个 url 一旦设置就无法更改。
|
|
|
function createWindow(request_url) {
|
|
function createWindow(request_url) {
|
|
|
if(mainWindow){
|
|
if(mainWindow){
|
|
|
|
|
+ mainWindow.show();
|
|
|
mainWindow.focus();
|
|
mainWindow.focus();
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -211,19 +215,10 @@ function BindIpc(){
|
|
|
ipc.on('window-close', function () {
|
|
ipc.on('window-close', function () {
|
|
|
CampusWindow.close();
|
|
CampusWindow.close();
|
|
|
});
|
|
});
|
|
|
- /*校园资讯写注册表*/
|
|
|
|
|
- regedit.putValue({
|
|
|
|
|
- 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run':{
|
|
|
|
|
- 'CampusInfo' : {
|
|
|
|
|
- value : process.argv[0]+' start',
|
|
|
|
|
- type : 'REG_SZ'
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- },function () {
|
|
|
|
|
- });
|
|
|
|
|
/*校园资讯打开浏览器*/
|
|
/*校园资讯打开浏览器*/
|
|
|
ipcMain.on('open-browers',function (e,arg) {
|
|
ipcMain.on('open-browers',function (e,arg) {
|
|
|
mainWindow.webContents.send('url', arg);
|
|
mainWindow.webContents.send('url', arg);
|
|
|
|
|
+ mainWindow.show();
|
|
|
mainWindow.focus();
|
|
mainWindow.focus();
|
|
|
});
|
|
});
|
|
|
/*浏览器ipc*/
|
|
/*浏览器ipc*/
|
|
@@ -231,13 +226,7 @@ function BindIpc(){
|
|
|
childProcess.exec(process.argv[0]);//启动新的浏览器
|
|
childProcess.exec(process.argv[0]);//启动新的浏览器
|
|
|
});
|
|
});
|
|
|
ipc.on('CampusInfo',function () {
|
|
ipc.on('CampusInfo',function () {
|
|
|
- if(CampusWindow){
|
|
|
|
|
- CampusWindow.show();
|
|
|
|
|
- CampusWindow.restore();
|
|
|
|
|
- CampusWindow.focus();
|
|
|
|
|
- }else{
|
|
|
|
|
- createCampusWindow(true);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ createCampusWindow(true);
|
|
|
});
|
|
});
|
|
|
ipc.on('window-all-closed', function () {//退出
|
|
ipc.on('window-all-closed', function () {//退出
|
|
|
mainWindow.close();
|
|
mainWindow.close();
|
|
@@ -296,18 +285,22 @@ function BindIpc(){
|
|
|
autoUpdater.quitAndInstall();
|
|
autoUpdater.quitAndInstall();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
-const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
|
|
|
|
|
- if (CampusWindow) {
|
|
|
|
|
- if (CampusWindow.isMinimized()){
|
|
|
|
|
- CampusWindow.restore()
|
|
|
|
|
- }
|
|
|
|
|
- CampusWindow.focus();
|
|
|
|
|
- CampusWindow.show();
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
|
|
+const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {});
|
|
|
app.on('ready',function () {
|
|
app.on('ready',function () {
|
|
|
|
|
+ startOnBoot.enableAutoStart('有思浏览器', process.execPath+" start");
|
|
|
BindIpc();//ipc通信绑定
|
|
BindIpc();//ipc通信绑定
|
|
|
|
|
+ createWindow();
|
|
|
if(process.argv[1]==='start'){
|
|
if(process.argv[1]==='start'){
|
|
|
|
|
+ mainWindow.hide();
|
|
|
|
|
+ if (shouldQuit) {
|
|
|
|
|
+ if (CampusWindow){
|
|
|
|
|
+ CampusWindow.restore();
|
|
|
|
|
+ CampusWindow.focus();
|
|
|
|
|
+ CampusWindow.show();
|
|
|
|
|
+ }
|
|
|
|
|
+ app.quit();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
createCampusWindow();
|
|
createCampusWindow();
|
|
|
}else{
|
|
}else{
|
|
|
if(process.argv[1]&&process.argv[1].indexOf('--')<0) {
|
|
if(process.argv[1]&&process.argv[1].indexOf('--')<0) {
|
|
@@ -315,9 +308,9 @@ app.on('ready',function () {
|
|
|
}
|
|
}
|
|
|
createWindow();
|
|
createWindow();
|
|
|
CreateAboutUs();
|
|
CreateAboutUs();
|
|
|
- if(!CampusWindow&&!shouldQuit){//让校园资讯在多个浏览器窗口开启的情况下也只有一个实例存在
|
|
|
|
|
|
|
+ /* if(!CampusWindow&&!shouldQuit){//让校园资讯在多个浏览器窗口开启的情况下也只有一个实例存在
|
|
|
createCampusWindow();
|
|
createCampusWindow();
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
}
|
|
}
|
|
|
} );
|
|
} );
|
|
|
app.on('window-all-closed', function () {
|
|
app.on('window-all-closed', function () {
|