|
|
@@ -18,8 +18,18 @@ Ext.define('saas.view.viewport.ViewportController', {
|
|
|
},
|
|
|
|
|
|
init: function() {
|
|
|
- this.originalRoute = saas.getApplication().getDefaultToken();
|
|
|
- this.restoreSession();
|
|
|
+ var me = this;
|
|
|
+ me.originalRoute = saas.getApplication().getDefaultToken();
|
|
|
+ // electron app
|
|
|
+ if (typeof require === 'function') {
|
|
|
+ me.ipc = require('electron').ipcRenderer;
|
|
|
+ me.ipc.on('session', function(e, session){
|
|
|
+ saas.util.State.set('session', Ext.decode(session));
|
|
|
+ me.restoreSession();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ me.restoreSession();
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
mainviewboxready: function() {
|
|
|
@@ -72,7 +82,7 @@ Ext.define('saas.view.viewport.ViewportController', {
|
|
|
handleUnmatchedRoute: function(route) {
|
|
|
var me = this;
|
|
|
|
|
|
- if (!me.session || !me.session.isValid()) {
|
|
|
+ if ((!me.session || !me.session.isValid()) && !me.ipc) {
|
|
|
// There is no authenticated user, let's redirect to the login page but keep track
|
|
|
// of the original route to restore the requested route after user authentication.
|
|
|
me.originalRoute = route;
|
|
|
@@ -238,14 +248,23 @@ Ext.define('saas.view.viewport.ViewportController', {
|
|
|
* @param {} session
|
|
|
*/
|
|
|
syncSessionToPortal: function(session) {
|
|
|
- const frame = window.frames[window.frames.length - 1];
|
|
|
- frame.postMessage(session ? JSON.stringify(session.data) : '', '*');
|
|
|
+ var sessionStr = session ? JSON.stringify(session) : '';
|
|
|
+ if (this.ipc) {
|
|
|
+ this.ipc.send('session.change', sessionStr);
|
|
|
+ } else {
|
|
|
+ const frame = window.frames[window.frames.length - 1];
|
|
|
+ frame.postMessage(sessionStr, '*');
|
|
|
+ }
|
|
|
},
|
|
|
/**
|
|
|
* 跳转门户
|
|
|
*/
|
|
|
redirectPortal: function() {
|
|
|
- window.location.href = Ext.manifest.server.accountCenter;
|
|
|
+ if (this.ipc) {
|
|
|
+ // window.close();
|
|
|
+ } else {
|
|
|
+ window.location.href = Ext.manifest.server.accountCenter;
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|