Skip to content

Commit cb39394

Browse files
Peter XiePeter Xie
authored andcommitted
v0.8.7
1 parent 80e9ada commit cb39394

File tree

9 files changed

+123
-109
lines changed

9 files changed

+123
-109
lines changed

app/public/scripts/home.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3424,7 +3424,7 @@ var view_layout;
34243424
doingProcessBar();
34253425
data.showExtraContent(false);
34263426
data.showRegionConnectProcessBar(true);
3427-
socketIo.emit('QTGateGatewayConnectRequest', connect, _data => {
3427+
socketIo.emit('QTGateGatewayConnectRequest', connect, (_data) => {
34283428
clearTimeout(doingProcessBarTime);
34293429
data.showRegionConnectProcessBar(false);
34303430
if (_data.error > -1) {
@@ -3433,7 +3433,8 @@ var view_layout;
34333433
//this.QTGateGatewayActiveProcess ( false )
34343434
return data.error(_data.error);
34353435
}
3436-
return this.QTGateGatewayConnectRequestCallBack(this, _data);
3436+
const data1 = _data.Args[0];
3437+
return this.QTGateGatewayConnectRequestCallBack(this, data1);
34373438
});
34383439
return false;
34393440
});

app/public/scripts/home.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ const infoDefine = [
775775
QTGateGateway: {
776776
title: 'QTGate服务使用详细',
777777
processing: '正在尝试连接QTGate代理服务器...',
778-
error: ['错误:您的账号下已经有一个正在使用QTGate代理服务器的连接,请先把它断开后再尝试连接。',
778+
error: [ '错误:您的账号下已经有一个正在使用QTGate代理服务器的连接,请先把它断开后再尝试连接。',
779779
'错误:您的账号已经无可使用流量,如果您需要继续使用QTGate代理服务器,请升级您的账户类型。如果是免费用户已经使用当天100M流量,请等待到明天继续使用,如您是免费用户已经用完当月1G流量,请等待到下月继续使用。',
780780
'错误:数据错误,请退出并重新启动QTGate!'],
781781
connected:'已连接。',
@@ -3751,7 +3751,7 @@ module view_layout {
37513751
data.showExtraContent ( false )
37523752
data.showRegionConnectProcessBar ( true )
37533753

3754-
socketIo.emit( 'QTGateGatewayConnectRequest', connect, _data => {
3754+
socketIo.emit( 'QTGateGatewayConnectRequest', connect, ( _data: QTGateAPIRequestCommand ) => {
37553755
clearTimeout ( doingProcessBarTime )
37563756
data.showRegionConnectProcessBar ( false )
37573757
if ( _data.error > -1 ) {
@@ -3760,7 +3760,8 @@ module view_layout {
37603760
//this.QTGateGatewayActiveProcess ( false )
37613761
return data.error ( _data.error )
37623762
}
3763-
return this.QTGateGatewayConnectRequestCallBack ( this, _data )
3763+
const data1 = _data.Args[0]
3764+
return this.QTGateGatewayConnectRequestCallBack ( this, data1 )
37643765

37653766
})
37663767

@@ -3771,7 +3772,7 @@ module view_layout {
37713772
}
37723773

37733774
private QTGateGatewayConnectRequestCallBack ( _self: view, _data: IConnectCommand ) {
3774-
const self = _self|| this
3775+
const self = _self || this
37753776
self.QTTransferData ( _data.transferData )
37763777
self.QTConnectData ( _data )
37773778
$( '.userDetail' ).progress()

app/server.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,19 @@ class localServer {
585585
CallBack(res.Args[0]);
586586
// Have gateway connect!
587587
if (res.Args[1]) {
588+
const uu = res.Args[1];
589+
if (!this.connectCommand) {
590+
this.connectCommand = uu;
591+
}
592+
if (!this.proxyServer) {
593+
const runCom = uu.connectType === 1 ? '@Opn' : 'iOpn';
594+
this.proxyServer = new RendererProcess(runCom, uu, true, () => {
595+
saveLog(`proxyServerWindow on exit!`);
596+
this.proxyServer = null;
597+
this.connectCommand = null;
598+
});
599+
}
600+
return socket.emit('QTGateGatewayConnectRequest', this.connectCommand);
588601
}
589602
});
590603
});
@@ -649,7 +662,6 @@ class localServer {
649662
});
650663
});
651664
socket.on('QTGateGatewayConnectRequest', (cmd, CallBack) => {
652-
saveLog('socket.on QTGateGatewayConnectRequest');
653665
// already have proxy
654666
if (this.proxyServer) {
655667
return;
@@ -675,24 +687,19 @@ class localServer {
675687
return this.QTClass.request(com, (err, res) => {
676688
const arg = res.Args[0];
677689
arg.localServerIp = this.config.localIpAddress[0];
678-
this.connectCommand = arg;
679690
saveLog(`this.proxyServer = new RendererProcess type = [${arg.connectType}] data = [${JSON.stringify(arg)}]`);
680691
// no error
681-
CallBack(arg);
682-
if (arg.error < 0) {
683-
// @QTGate connect
684-
if (arg.connectType === 1) {
685-
return this.proxyServer = new RendererProcess('@Opn', arg, true, () => {
686-
saveLog(`proxyServerWindow on exit!`);
687-
});
688-
}
689-
//
690-
// iQTGate connect
691-
return this.proxyServer = new RendererProcess('iOpn', arg, true, () => {
692+
CallBack(res);
693+
if (res.error < 0) {
694+
this.connectCommand = arg;
695+
const runCom = arg.connectType === 1 ? '@Opn' : 'iOpn';
696+
return this.proxyServer = new RendererProcess(runCom, arg, false, () => {
692697
saveLog(`proxyServerWindow on exit!`);
698+
this.proxyServer = null;
699+
this.connectCommand = null;
693700
});
694701
}
695-
return CallBack(arg);
702+
saveLog(`res.error [${res.error}]`);
696703
});
697704
});
698705
});

app/server.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,19 @@ export class localServer {
609609
CallBack( res.Args[0] )
610610
// Have gateway connect!
611611
if ( res.Args[1]) {
612-
612+
const uu: IConnectCommand = res.Args[1]
613+
if ( !this.connectCommand ) {
614+
this.connectCommand = uu
615+
}
616+
if ( ! this.proxyServer ) {
617+
const runCom = uu.connectType === 1 ? '@Opn' : 'iOpn'
618+
this.proxyServer = new RendererProcess ( runCom, uu, true, () => {
619+
saveLog ( `proxyServerWindow on exit!`)
620+
this.proxyServer = null
621+
this.connectCommand = null
622+
})
623+
}
624+
return socket.emit ( 'QTGateGatewayConnectRequest', this.connectCommand )
613625
}
614626
})
615627
})
@@ -688,7 +700,7 @@ export class localServer {
688700
})
689701

690702
socket.on ( 'QTGateGatewayConnectRequest', ( cmd: IConnectCommand, CallBack ) => {
691-
saveLog ('socket.on QTGateGatewayConnectRequest')
703+
692704
// already have proxy
693705
if ( this.proxyServer ) {
694706
return
@@ -722,28 +734,21 @@ export class localServer {
722734
return this.QTClass.request ( com, ( err: number, res: QTGateAPIRequestCommand ) => {
723735
const arg: IConnectCommand = res.Args[0]
724736
arg.localServerIp = this.config.localIpAddress[0]
725-
this.connectCommand = arg
737+
726738
saveLog ( `this.proxyServer = new RendererProcess type = [${ arg.connectType }] data = [${ JSON.stringify( arg )}]` )
727739
// no error
728-
CallBack ( arg )
729-
if ( arg.error < 0 ) {
730-
// @QTGate connect
731-
if ( arg.connectType === 1 ) {
732-
return this.proxyServer = new RendererProcess ( '@Opn', arg, true, () => {
733-
saveLog ( `proxyServerWindow on exit!`)
734-
})
735-
736-
}
737-
//
738-
// iQTGate connect
739-
740-
return this.proxyServer = new RendererProcess ( 'iOpn', arg, true, () => {
741-
saveLog (`proxyServerWindow on exit!`)
740+
741+
CallBack ( res )
742+
if ( res.error < 0 ) {
743+
this.connectCommand = arg
744+
const runCom = arg.connectType === 1 ? '@Opn' : 'iOpn'
745+
return this.proxyServer = new RendererProcess ( runCom, arg, false, () => {
746+
saveLog ( `proxyServerWindow on exit!`)
747+
this.proxyServer = null
748+
this.connectCommand = null
742749
})
743-
744750
}
745-
return CallBack ( arg )
746-
751+
saveLog ( `res.error [${ res.error }]`)
747752
})
748753

749754
})

app/views/home/index.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ block jumbotron1
564564
.ui.divider
565565
p
566566
i.icon.spy.grey
567-
span( data-bind = " text: infoDefine [ languageIndex() ].QTGateGateway.userType [ QTTransferData().productionPackage === 'free' ? 0 : 1]" style="font-size: small;" )
567+
span( data-bind = " text: infoDefine [ languageIndex() ].QTGateGateway.userType [ QTTransferData().productionPackage === 'free' ? 0 : 1 ]" style="font-size: small;" )
568568
span( data-bind = " text: QTConnectData().connectType === 2 ? 'iOPN' : '@OPN'" style="margin: 10px;font-size: small;color:darkmagenta;")
569569
i.small.icon.random.grey
570570
//-span( data-bind = " text: infoDefine [ $root.languageIndex() ].QTGateGateway.gatewayInfo[0] " style="margin-left: 10px;" )

index.js

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,27 @@ const path_1 = require("path");
1111
const async_1 = require("async");
1212
const freePort = require("portastic");
1313
const url_1 = require("url");
14-
const child_process_1 = require("child_process");
1514
const { app, BrowserWindow, Tray, Menu, dialog, remote } = require('electron');
16-
const handleSquirrelEvent = (CallBack) => {
15+
function handleSquirrelEvent() {
1716
if (process.argv.length === 1 || process.platform !== 'win32') {
18-
return CallBack(false);
17+
return false;
1918
}
20-
const appFolder = path_1.resolve(process.execPath, '..');
21-
const rootAtomFolder = path_1.resolve(appFolder, '..');
22-
const updateDotExe = path_1.resolve(path_1.join(rootAtomFolder, 'Update.exe'));
23-
const exeName = path_1.basename(process.execPath);
24-
const _spawn = (command, args) => {
19+
const ChildProcess = require('child_process');
20+
const path = require('path');
21+
const appFolder = path.resolve(process.execPath, '..');
22+
const rootAtomFolder = path.resolve(appFolder, '..');
23+
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
24+
const exeName = path.basename(process.execPath);
25+
const spawn = function (command, args) {
2526
let spawnedProcess, error;
2627
try {
27-
spawnedProcess = child_process_1.spawn(command, args, { detached: true });
28+
spawnedProcess = ChildProcess.spawn(command, args, { detached: true });
2829
}
2930
catch (error) { }
3031
return spawnedProcess;
3132
};
32-
const spawnUpdate = args => {
33-
return _spawn(updateDotExe, args);
33+
const spawnUpdate = function (args) {
34+
return spawn(updateDotExe, args);
3435
};
3536
const squirrelEvent = process.argv[1];
3637
switch (squirrelEvent) {
@@ -42,24 +43,27 @@ const handleSquirrelEvent = (CallBack) => {
4243
// explorer context menus
4344
// Install desktop and start menu shortcuts
4445
spawnUpdate(['--createShortcut', exeName]);
45-
return setTimeout(() => {
46-
return CallBack(true);
47-
}, 1000);
46+
setTimeout(app.quit, 1000);
47+
return true;
4848
case '--squirrel-uninstall':
4949
// Undo anything you did in the --squirrel-install and
5050
// --squirrel-updated handlers
5151
// Remove desktop and start menu shortcuts
5252
spawnUpdate(['--removeShortcut', exeName]);
53-
return setTimeout(() => {
54-
return CallBack(true);
55-
}, 1000);
53+
setTimeout(app.quit, 1000);
54+
return true;
5655
case '--squirrel-obsolete':
5756
// This is called on the outgoing version of your app before
5857
// we update to the new version - it's the opposite of
5958
// --squirrel-updated
60-
return CallBack(true);
59+
app.quit();
60+
return true;
6161
}
62-
};
62+
}
63+
if (handleSquirrelEvent()) {
64+
// squirrel event handled and app will exit in 1000ms, so don't do anything else
65+
return;
66+
}
6367
// squirrel event handled and app will exit in 1000ms, so don't do anything else
6468
const version = app.getVersion();
6569
const debug = false;
@@ -280,9 +284,4 @@ const initialize = () => {
280284
app.quit();
281285
});
282286
};
283-
handleSquirrelEvent(isReset => {
284-
if (isReset) {
285-
return app.quit();
286-
}
287-
initialize();
288-
});
287+
initialize();

index.ts

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,37 @@ import { format } from 'url'
1212
import { spawn } from 'child_process'
1313
const { app, BrowserWindow, Tray, Menu, dialog, remote } = require ( 'electron' )
1414

15-
const handleSquirrelEvent = ( CallBack ) => {
15+
16+
17+
function handleSquirrelEvent() {
1618
if ( process.argv.length === 1 || process.platform !== 'win32') {
17-
return CallBack ( false )
19+
return false;
1820
}
1921

20-
const appFolder = resolve ( process.execPath, '..')
21-
const rootAtomFolder = resolve ( appFolder, '..')
22-
const updateDotExe = resolve ( join ( rootAtomFolder, 'Update.exe' ))
23-
const exeName = basename ( process.execPath )
22+
const ChildProcess = require('child_process');
23+
const path = require('path');
24+
25+
const appFolder = path.resolve(process.execPath, '..');
26+
const rootAtomFolder = path.resolve(appFolder, '..');
27+
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
28+
const exeName = path.basename(process.execPath);
2429

25-
const _spawn = ( command, args ) => {
26-
let spawnedProcess, error
30+
const spawn = function(command, args) {
31+
let spawnedProcess, error;
2732

2833
try {
29-
spawnedProcess = spawn ( command, args, { detached: true })
30-
} catch ( error ) {}
34+
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
35+
} catch (error) {}
3136

32-
return spawnedProcess
33-
}
37+
return spawnedProcess;
38+
};
3439

35-
const spawnUpdate = args => {
36-
return _spawn ( updateDotExe, args )
37-
}
40+
const spawnUpdate = function(args) {
41+
return spawn(updateDotExe, args);
42+
};
3843

39-
const squirrelEvent = process.argv[1]
40-
switch ( squirrelEvent ) {
44+
const squirrelEvent = process.argv[1];
45+
switch (squirrelEvent) {
4146
case '--squirrel-install':
4247
case '--squirrel-updated':
4348
// Optionally do things such as:
@@ -46,33 +51,34 @@ const handleSquirrelEvent = ( CallBack ) => {
4651
// explorer context menus
4752

4853
// Install desktop and start menu shortcuts
49-
spawnUpdate([ '--createShortcut', exeName ])
54+
spawnUpdate(['--createShortcut', exeName]);
5055

51-
return setTimeout (() => {
52-
return CallBack ( true )
53-
}, 1000 )
54-
56+
setTimeout(app.quit, 1000);
57+
return true;
5558

5659
case '--squirrel-uninstall':
5760
// Undo anything you did in the --squirrel-install and
5861
// --squirrel-updated handlers
5962

6063
// Remove desktop and start menu shortcuts
61-
spawnUpdate(['--removeShortcut', exeName])
64+
spawnUpdate(['--removeShortcut', exeName]);
6265

63-
return setTimeout (() => {
64-
return CallBack ( true )
65-
}, 1000 )
66-
66+
setTimeout(app.quit, 1000);
67+
return true;
6768

6869
case '--squirrel-obsolete':
6970
// This is called on the outgoing version of your app before
7071
// we update to the new version - it's the opposite of
7172
// --squirrel-updated
7273

73-
return CallBack ( true )
74+
app.quit();
75+
return true;
7476
}
75-
}
77+
}
78+
if (handleSquirrelEvent()) {
79+
// squirrel event handled and app will exit in 1000ms, so don't do anything else
80+
return
81+
}
7682
// squirrel event handled and app will exit in 1000ms, so don't do anything else
7783
const version = app.getVersion()
7884

@@ -313,9 +319,4 @@ const initialize = () => {
313319

314320

315321

316-
handleSquirrelEvent( isReset => {
317-
if ( isReset ) {
318-
return app.quit ()
319-
}
320-
initialize()
321-
})
322+
initialize()

0 commit comments

Comments
 (0)