|
@@ -420,18 +420,43 @@ o2.addReady(function () {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ var _setLayoutService = function(service, center){
|
|
|
|
|
+ layout.serviceAddressList = service;
|
|
|
|
|
+ layout.centerServer = center;
|
|
|
|
|
+ layout.desktop.serviceAddressList = service;
|
|
|
|
|
+ layout.desktop.centerServer = center;
|
|
|
|
|
+ };
|
|
|
var _getDistribute = function (callback) {
|
|
var _getDistribute = function (callback) {
|
|
|
|
|
+ debugger;
|
|
|
if (layout.config.app_protocol === "auto") {
|
|
if (layout.config.app_protocol === "auto") {
|
|
|
layout.config.app_protocol = window.location.protocol;
|
|
layout.config.app_protocol = window.location.protocol;
|
|
|
}
|
|
}
|
|
|
- o2.xDesktop.getServiceAddress(layout.config, function (service, center) {
|
|
|
|
|
- layout.serviceAddressList = service;
|
|
|
|
|
- layout.centerServer = center;
|
|
|
|
|
- layout.desktop.serviceAddressList = service;
|
|
|
|
|
- layout.desktop.centerServer = center;
|
|
|
|
|
- _loadProgressBar();
|
|
|
|
|
- if (callback) callback();
|
|
|
|
|
- }.bind(this));
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (layout.config.configMapping && layout.config.configMapping[window.location.host]){
|
|
|
|
|
+ var mapping = layout.config.configMapping[window.location.host];
|
|
|
|
|
+ if (mapping.servers){
|
|
|
|
|
+ layout.serviceAddressList = mapping.servers;
|
|
|
|
|
+ layout.desktop.serviceAddressList = mapping.servers;
|
|
|
|
|
+ if (mapping.center) center = (o2.typeOf(mapping.center)==="array") ? mapping.center[0] : mapping.center;
|
|
|
|
|
+ layout.centerServer = center;
|
|
|
|
|
+ layout.desktop.centerServer = center;
|
|
|
|
|
+ if (callback) callback();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if (mapping.center) layout.config.center = (o2.typeOf(mapping.center)==="array") ? mapping.center : [mapping.center];
|
|
|
|
|
+ o2.xDesktop.getServiceAddress(layout.config, function (service, center) {
|
|
|
|
|
+ _setLayoutService(service, center);
|
|
|
|
|
+ _loadProgressBar();
|
|
|
|
|
+ if (callback) callback();
|
|
|
|
|
+ }.bind(this));
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ o2.xDesktop.getServiceAddress(layout.config, function (service, center) {
|
|
|
|
|
+ _setLayoutService(service, center);
|
|
|
|
|
+ _loadProgressBar();
|
|
|
|
|
+ if (callback) callback();
|
|
|
|
|
+ }.bind(this));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
var _load = function () {
|
|
var _load = function () {
|
|
@@ -447,6 +472,7 @@ o2.addReady(function () {
|
|
|
|
|
|
|
|
_loadProgressBar(true);
|
|
_loadProgressBar(true);
|
|
|
while (layout.readys && layout.readys.length) {
|
|
while (layout.readys && layout.readys.length) {
|
|
|
|
|
+ console.log("load app ...")
|
|
|
layout.readys.shift().apply(window);
|
|
layout.readys.shift().apply(window);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -458,36 +484,71 @@ o2.addReady(function () {
|
|
|
Cookie.write("x-token", options["x-token"]);
|
|
Cookie.write("x-token", options["x-token"]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _loadApp();
|
|
|
|
|
|
|
+ layout.sessionPromise = {
|
|
|
|
|
+ "resolveList": [],
|
|
|
|
|
+ "rejectList": [],
|
|
|
|
|
+ "init": function(resolve, reject){
|
|
|
|
|
+ if (resolve) this.resolveList.push(resolve);
|
|
|
|
|
+ if (reject) this.rejectList.push(reject);
|
|
|
|
|
+ this.status = "pending";
|
|
|
|
|
+ this.resolveReturn = this;
|
|
|
|
|
+
|
|
|
|
|
+ //先判断用户是否登录
|
|
|
|
|
+ o2.Actions.get("x_organization_assemble_authentication").getAuthentication(function (json) {
|
|
|
|
|
+ this.status = "fulfilled";
|
|
|
|
|
+ this.resolveReturn = json.data;
|
|
|
|
|
+ this.runResolve(this.resolveReturn);
|
|
|
|
|
+ }.bind(this), function (xhr, text, error) {
|
|
|
|
|
+ this.status = "rejected";
|
|
|
|
|
+ this.resolveReturn = {"xhr": xhr, "text": text, "error": error};
|
|
|
|
|
+ this.runReject(this.resolveReturn);
|
|
|
|
|
+ }.bind(this));
|
|
|
|
|
+ },
|
|
|
|
|
+ "runResolve": function(json){
|
|
|
|
|
+ while (this.resolveList.length){
|
|
|
|
|
+ var r = this.resolveList.shift()(this.resolveReturn);
|
|
|
|
|
+ if (r) this.resolveReturn = r;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ "runReject": function(json){
|
|
|
|
|
+ while (this.rejectList.length){
|
|
|
|
|
+ var r = this.rejectList.shift()(json);
|
|
|
|
|
+ if (r) this.resolveReturn = r;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ "then": function(resolve, reject){
|
|
|
|
|
+ if (resolve) this.resolveList.push(resolve);
|
|
|
|
|
+ if (reject) this.rejectList.push(reject);
|
|
|
|
|
+ switch (this.status){
|
|
|
|
|
+ case "fulfilled":
|
|
|
|
|
+ this.runResolve();
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "rejected":
|
|
|
|
|
+ this.runReject();
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ //nothing
|
|
|
|
|
+ }
|
|
|
|
|
+ return this;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- //先判断用户是否登录
|
|
|
|
|
- o2.Actions.get("x_organization_assemble_authentication").getAuthentication(function (json) {
|
|
|
|
|
|
|
+ layout.sessionPromise.init(function(data){
|
|
|
//已经登录
|
|
//已经登录
|
|
|
- //_loadProgressBar();
|
|
|
|
|
-
|
|
|
|
|
- layout.user = json.data;
|
|
|
|
|
|
|
+ layout.user = data;
|
|
|
layout.session = layout.session || {};
|
|
layout.session = layout.session || {};
|
|
|
- layout.session.user = json.data;
|
|
|
|
|
- layout.session.token = json.data.token;
|
|
|
|
|
|
|
+ layout.session.user = data;
|
|
|
|
|
+ layout.session.token = data.token;
|
|
|
layout.desktop.session = layout.session;
|
|
layout.desktop.session = layout.session;
|
|
|
-
|
|
|
|
|
- //_loadApp(json);
|
|
|
|
|
- }.bind(this), function (json) {
|
|
|
|
|
- //_loadProgressBar();
|
|
|
|
|
|
|
+ }, function(){
|
|
|
//允许匿名访问
|
|
//允许匿名访问
|
|
|
if (layout.anonymous) {
|
|
if (layout.anonymous) {
|
|
|
- //_loadProgressBar(true);
|
|
|
|
|
- // _loadApp({
|
|
|
|
|
- // data : {
|
|
|
|
|
- // user: "anonymous",
|
|
|
|
|
- // session: {
|
|
|
|
|
- // user: {
|
|
|
|
|
- // name: "anonymous",
|
|
|
|
|
- // roleList: []
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ var data = { user: "anonymous", session: { user: { name: "anonymous", roleList: [] } } };
|
|
|
|
|
+ layout.user = data;
|
|
|
|
|
+ layout.session = layout.session || {};
|
|
|
|
|
+ layout.session.user = data;
|
|
|
|
|
+ layout.session.token = data.token;
|
|
|
|
|
+ layout.desktop.session = layout.session;
|
|
|
} else {
|
|
} else {
|
|
|
_loadProgressBar(true);
|
|
_loadProgressBar(true);
|
|
|
if (layout.yqwx) {
|
|
if (layout.yqwx) {
|
|
@@ -497,6 +558,47 @@ o2.addReady(function () {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
+ _loadApp();
|
|
|
|
|
+
|
|
|
|
|
+ // //先判断用户是否登录
|
|
|
|
|
+ // o2.Actions.get("x_organization_assemble_authentication").getAuthentication(function (json) {
|
|
|
|
|
+ // //已经登录
|
|
|
|
|
+ // //_loadProgressBar();
|
|
|
|
|
+ //
|
|
|
|
|
+ // layout.user = json.data;
|
|
|
|
|
+ // layout.session = layout.session || {};
|
|
|
|
|
+ // layout.session.user = json.data;
|
|
|
|
|
+ // layout.session.token = json.data.token;
|
|
|
|
|
+ // layout.desktop.session = layout.session;
|
|
|
|
|
+ //
|
|
|
|
|
+ // //_loadApp(json);
|
|
|
|
|
+ // }.bind(this), function (json) {
|
|
|
|
|
+ // //_loadProgressBar();
|
|
|
|
|
+ // //允许匿名访问
|
|
|
|
|
+ // if (layout.anonymous) {
|
|
|
|
|
+ // //_loadProgressBar(true);
|
|
|
|
|
+ // // _loadApp({
|
|
|
|
|
+ // // data : {
|
|
|
|
|
+ // // user: "anonymous",
|
|
|
|
|
+ // // session: {
|
|
|
|
|
+ // // user: {
|
|
|
|
|
+ // // name: "anonymous",
|
|
|
|
|
+ // // roleList: []
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // // });
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // _loadProgressBar(true);
|
|
|
|
|
+ // if (layout.yqwx) {
|
|
|
|
|
+ // layout.openLoginQywx();
|
|
|
|
|
+ // } else {
|
|
|
|
|
+ // layout.openLogin();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
layout.openLogin = function () {
|
|
layout.openLogin = function () {
|
|
|
layout.authentication = new o2.xDesktop.Authentication({
|
|
layout.authentication = new o2.xDesktop.Authentication({
|