huqi 5 лет назад
Родитель
Сommit
4f35da75e1

+ 49 - 1
o2web/gulpfile.js

@@ -297,6 +297,54 @@ function createO2ConcatTask(path, isMin, thisOptions) {
             })))
             .pipe(gulp.dest(dest))
     });
+
+    gulp.task(path+" : bundle", function(){
+        var option = thisOptions || options;
+        var src = [
+            'source/o2_lib/mootools/mootools-1.6.0_all.js',
+            'source/o2_lib/mootools/plugin/mBox.js',
+            'source/' + path + '/o2.js',
+            'source/x_desktop/js/base.js',
+            "source/o2_core/o2/framework.js"
+        ];
+        var dest = option.dest+'/' + path + '/';
+        return gulp.src(src)
+            .pipe(concat('bundle.js'))
+            .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
+            .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || '@anonymous',
+                port: option.port || 21,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || null,
+                port: option.port || 22,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulp.dest(dest))
+            .pipe(uglify())
+            .pipe(rename({ extname: '.min.js' }))
+            .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
+            .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || '@anonymous',
+                port: option.port || 21,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
+                host: option.host,
+                user: option.user || 'anonymous',
+                pass: option.pass || null,
+                port: option.port || 22,
+                remotePath: (option.remotePath || '/') + path
+            })))
+            .pipe(gulp.dest(dest))
+    });
 }
 
 function getAppTask(path, isMin, thisOptions) {
@@ -307,7 +355,7 @@ function getAppTask(path, isMin, thisOptions) {
     }else if (path==="o2_core"){
         createDefaultTask(path, isMin, thisOptions);
         createO2ConcatTask(path, isMin, thisOptions);
-        return gulp.series(path, path+" : concat", path+".xDesktop : concat");
+        return gulp.series(path, path+" : concat", path+".xDesktop : concat",  path+" : bundle");
     }else{
         createDefaultTask(path, isMin, thisOptions);
         return gulp.series(path);

+ 23 - 0
o2web/source/o2_core/o2/framework.js

@@ -0,0 +1,23 @@
+layout.addReady(function(){
+    MWF.require("MWF.xScript.Environment", null, false);
+    MWF.require("MWF.xScript.PageEnvironment", null, false);
+
+    var page = {
+        "businessData": {},
+        "json": {
+            "application": ""
+        },
+        "options": {}
+    };
+    var environment = {
+        "form": page,
+        "forms": page.forms,
+        "all": page.all,
+        "data": page.businessData.data,
+        "status": page.businessData.status,
+        "pageInfor": page.businessData.pageInfor,
+        "target": null,
+        "event": null
+    };
+    o2.env = new MWF.xScript.PageEnvironment(environment);
+});

+ 4 - 1
o2web/source/o2_core/o2/xDesktop/Common.js

@@ -452,6 +452,7 @@ MWF.xDesktop.getServiceAddress = function(config, callback){
             contentNode.setStyle("background-color", "#666666");
         }
     };
+
     if (typeOf(config.center)==="object"){
         MWF.xDesktop.getServiceAddressConfigObject(config.center, callback, error);
     }else if (typeOf(config.center)==="array"){
@@ -514,7 +515,9 @@ MWF.xDesktop.getServiceAddressConfigObject = function(center, callback, error){
     }else{
         uri = layout.config.app_protocol+"//"+host+":"+port+"/x_program_center/jaxrs/distribute/assemble/source/{source}";
     }
-    var currenthost = window.location.hostname;
+
+    var currenthost = (layout.config.applicationServer && layout.config.applicationServer.host) ? layout.config.applicationServer.host : window.location.hostname;
+    //var currenthost = window.location.hostname;
     uri = uri.replace(/{source}/g, currenthost);
     //var uri = "http://"+layout.config.center+"/x_program_center/jaxrs/distribute/assemble";