Просмотр исходного кода

Merge branch 'feature/web-with-framework' into 'develop'

Merge of feature/web-with-framework to develop o2对主流前端mvc框架支持

See merge request o2oa/o2oa!699
胡起 5 лет назад
Родитель
Сommit
85bf117be8

+ 21 - 3
gulpfile.js

@@ -466,10 +466,28 @@ function build_concat_xform(){
         .pipe(rename({ extname: '.min.js' }))
         .pipe(gulp.dest(dest))
 }
+
+function build_bundle(){
+    let path = "o2_core";
+    var src = [
+        'o2web/source/o2_lib/mootools/mootools-1.6.0_all.js',
+        'o2web/source/o2_lib/mootools/plugin/mBox.js',
+        'o2web/source/o2_core/o2.js',
+        'o2web/source/x_desktop/js/base.js',
+        "o2web/source/o2_core/o2/framework.js"
+    ];
+    var dest = 'target/o2server/servers/webServer/'+path+'/';
+    return gulp.src(src)
+        .pipe(concat('bundle.js'))
+        .pipe(gulp.dest(dest))
+        .pipe(uglify())
+        .pipe(rename({ extname: '.min.js' }))
+        .pipe(gulp.dest(dest))
+}
 // function build_concat(){
 //     return gulp.parallel(build_concat_o2, build_concat_desktop, build_concat_xform);
 // }
-exports.build_concat = gulp.parallel(build_concat_o2, build_concat_desktop, build_concat_xform);
+exports.build_concat = gulp.parallel(build_concat_o2, build_concat_desktop, build_concat_xform, build_bundle);
 
 
 function build_web_v_html() {
@@ -558,9 +576,9 @@ function chmod_commons(){
 function chmod_sh(){
     return (shell.task('chmod 777 target/o2server/*.sh'))();
 }
-exports.build_web = gulp.series(build_web_minimize, build_web_move, gulp.parallel(build_concat_o2, build_concat_desktop, build_concat_xform), build_web_v_html, build_web_v_o2);
+exports.build_web = gulp.series(build_web_minimize, build_web_move, gulp.parallel(build_concat_o2, build_concat_desktop, build_concat_xform, build_bundle), build_web_v_html, build_web_v_o2);
 if (os.platform().indexOf("win")==-1){
     exports.deploy = gulp.series(deploy_server, chmod_jvm, chmod_commons, chmod_sh);
 }else{
     exports.deploy = gulp.series(deploy_server);
-}
+}

+ 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);

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

@@ -0,0 +1,64 @@
+layout.addReady(function(){
+    // MWF.require("MWF.xScript.Environment", null, false);
+    // MWF.require("MWF.xScript.PageEnvironment", null, false);
+    MWF.require("MWF.xScript.Macro", null, false);
+
+
+    var page = {
+        "businessData": {},
+        "json": {
+            "application": ""
+        },
+        "options": {},
+        "confirm": o2.xApplication.Common.Main.prototype.confirm,
+        "alert": function(type, title, text, width, height){
+            var p = o2.getCenterPosition(document.body, width, height);
+            var e = {
+                "event": {
+                    "x": p.x,
+                    "y": p.y,
+                    "clientX": p.x,
+                    "clientY": p.y
+                }
+            };
+            o2.xApplication.Common.Main.prototype.alert(type, e, title, text, width, height);
+        },
+        "notice": function(content, type, target, where, offset, option){
+            o2.xDesktop.notice(type, where, content, target, offset, option);
+        },
+        "app": {
+            "desktop": layout,
+            "content": document.body,
+            "toPortal": function(portal, page, par, nohis){
+                var url = "../x_desktop/portal.html?id="+portal;
+                if (page) url += "&page="+page;
+                if (par){
+                    if (o2.typeOf(par)==="object"){
+                        url += "&parameters="+JSON.stringify(par);
+                    }else{
+                        url += "&parameters="+par.toString();
+                    }
+
+                }
+                var a = document.createElement("a");
+                a.setAttribute("href", o2.filterUrl(url));
+                a.setAttribute("target", "_blank1");
+                a.click();
+                if (a.remove) a.remove();
+            },
+            "toPage": function(){}
+        },
+        addEvent: function(){}
+    };
+    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);
+});

+ 7 - 2
o2web/source/o2_core/o2/xDesktop/Common.js

@@ -167,7 +167,9 @@ MWF.xDesktop.getUserLayout = function(callback){
 },
 
 MWF.xDesktop.notice = function(type, where, content, target, offset, option){
-    var noticeTarget = target || layout.desktop.desktopNode;
+    if (!where) where = { "x": "right", "y": "top" };
+    if (!type) type = "ok";
+    var noticeTarget = target || layout.desktop.desktopNode || document.body;
 
     var off = offset;
     if (!off){
@@ -452,6 +454,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 +517,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";
 

+ 1 - 1
o2web/source/x_component_Common/Main.js

@@ -508,7 +508,7 @@ MWF.xApplication.Common.Main = new Class({
 	},
 	confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
 		MWF.require("MWF.xDesktop.Dialog", function () {
-			var content = layout.mobile ? $(document.body) : this.content;
+			var content = layout.mobile ? $(document.body) : this.content || $(document.body);
 			var size = content.getSize();
 			var x = 0;
 			var y = 0;

+ 1 - 2
o2web/source/x_desktop/js/app.js

@@ -12,7 +12,6 @@ layout.addReady(function(){
             // layout.message = new MWF.xDesktop.MessageMobile();
             // layout.message.load();
             //}.bind(this));
-
             layout.apps = [];
             layout.node = $("layout");
             var appName=appNames, m_status=statusObj, option=options;
@@ -29,4 +28,4 @@ layout.addReady(function(){
         };
         _load();
     })(layout);
-});
+});

+ 2 - 2
o2web/source/x_desktop/js/portal.js

@@ -5,15 +5,15 @@ layout.addReady(function(){
         var id = uri.getData("id");
         var page = uri.getData("page");
         var widget = uri.getData("widget");
+        var parameters = uri.getData("parameters");
         var statusObj = null;
-        var options = {"portalId": id, "pageId": page, "widgetId":widget };
+        var options = {"portalId": id, "pageId": page, "parameters": parameters, "widgetId":widget };
 
         var _load = function(){
             //o2.require("MWF.xDesktop.MessageMobile", function(){
             // layout.message = new MWF.xDesktop.MessageMobile();
             // layout.message.load();
             //}.bind(this));
-
             layout.apps = [];
             layout.node = $("layout");
             var appName=appNames, m_status=statusObj, option=options;