当前位置 : 主页 > 网络编程 > JavaScript >

require加载js文件

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt /// /// /// /// /// /// /// /// //需要使用promise的方式進行資源的引導//promise1 require請求的資源加載完成后resolve promise1//promise2 document ready完成后 resolve promise2(function () { var runmode =
gistfile1.txt
/// 
/// 
/// 
/// 
/// 
/// 
/// 
/// 

//需要使用promise的方式進行資源的引導
//promise1 require請求的資源加載完成后resolve promise1
//promise2 document ready完成后 resolve promise2


(function () {
    var runmode = {};
    runmode.dev = "dev";
    runmode.pub = "prod";

    var mode = "dev";//"prod"// $("#RunMode").val()||"dev";
    if (mode == runmode.dev) {
        require.config({
            packages: [{
                name: "corp",
                location: "/w/js/corp",
            }, {
                name: "commonclass",
                location: "/w/js/commonclass"
            },{
                name:"toolkit",
                location:"https://hz-libs.oss-cn-hangzhou.aliyuncs.com/licheng-jslib/toolkit"
            }],
            paths: {
                "jquery": "//cdn.bootcss.com/jquery/2.2.4/jquery.min",
                "webix": "https://hz-libs.oss-cn-hangzhou.aliyuncs.com/webix/3.3.2/webix",
                "webix-zh": "https://hz-libs.oss-cn-hangzhou.aliyuncs.com/webix/3.3.2/i18n/zh",
                "webix-extend": "/w/js/commonclass/webix_extend",
                "semantic": "/w/js/commonclass/semantic",
                "app": "/w/js/app",
                "bootstrap-datepicker": "/w/js/commonclass/bootstrap-datepicker",
                "bootstrap-datepicker-cn": "/w/js/commonclass/bootstrap-datepicker.zh-CN.min",
                "table2excel": "/w/js/jquery.table2excel",
                "imageview":"/w/js/viewer"
            },
            shim: {
                "webix-zh": ["webix"],
                "semantic": ["jquery"],
                "app": ["jquery"],
                "bootstrap-datepicker": ["jquery"],
                "bootstrap-datepicker-cn": ["bootstrap-datepicker"],
                "webix-extend": ["webix"],
                "table2excel":["jquery"]
            }
        });
    } else if (mode == runmode.pub) {
        require.config({
            paths: {
                "corp": "/w/js/build/corp/corp.min",
                "jquery": "//cdn.bootcss.com/jquery/2.2.4/jquery.min",
                "webix": "https://hz-libs.oss-cn-hangzhou.aliyuncs.com/webix/3.3.2/webix",
                "webix-zh": "https://hz-libs.oss-cn-hangzhou.aliyuncs.com/webix/3.3.2/i18n/zh",
                "webix-extend": "/w/js/commonclass/webix_extend",
                "semantic": "//cdn.bootcss.com/semantic-ui/2.2.10/semantic.min",
                "app": "/w/js/app",
                "bootstrap-datepicker": "/w/js/commonclass/bootstrap-datepicker",
                "bootstrap-datepicker-cn": "/w/js/commonclass/bootstrap-datepicker.zh-CN.min",
                "table2excel": "/w/js/jquery.table2excel",
                "imageview": "/w/js/viewer"

            },
            shim: {
                "webix-zh": ["webix"],
                "semantic": ["jquery"],
                "app": ["jquery"],
                "bootstrap-datepicker": ["jquery"],
                "bootstrap-datepicker-cn": ["bootstrap-datepicker"],
                "webix-extend": ["webix"],
                "table2excel": ["jquery"]
            }
        })
    }

    var requirearr = ["corp", "imageview", "jquery", "webix", "webix-zh", "webix-extend", "semantic", "app", "bootstrap-datepicker", "bootstrap-datepicker-cn", "table2excel"];
    if (mode == runmode.dev) {

    } else if (mode == runmode.pub) {

    }

    require(requirearr, function () {
        var corp = require("corp");
        var rolemanager = corp.rolemanager;
        var DataManager = corp.CorpDataManager;
        var Message = corp.Message;
        var actionmap = corp.actionmap;
        var AccordionMenuNavigation = corp.AccordionMenuNavigation;
        $(document).ready(function () {
            templateinit();
            //globalapplication = {} || globalapplication;

            globalapplication.DataManager = corp.CorpDataManager; //new CropDataManager();

            globalapplication.Message = new Message({
                container: "#messagelabel",
                trigger: "#messagetrigger",
                getdata: function (option) {
                    var info = actionmap.message_getall;
                    return DataManager.Request(info, {}, option);
                },
                readmessage: function (id, option) {
                    var info = actionmap.message_readmessage;
                    return DataManager.Request(info, { MessageId: id }, option);
                },
                readall: function (option) {
                    var info = actionmap.message_readall;
                    return DataManager.Request(info, {}, option);
                },
                timeinterval: 60000000
            }).Init();

           

            //  globalapplication.DataManager.NodeInfo = "n002";//设置节点信息
            InitVisitList();

            //globalapplication.DataManager.GetNavInfo(rolemanager) globalapplication.DataManager
            function InitVisitList() {
                var role = globalapplication.DataManager.RequestVisitList();
                if (role.then) {
                    role.done(function (option, data) {
                        //获取用户访问集合成功
                    }

         
        

          
        });
    }, function (error) {
        console.log("js文件加载失败");
        console.log(error);
        console.log(arguments);
    });
    require(["webix", "webix-zh"], function () {
        webix.i18n.setLocale("zh-CN");
    })



}());
网友评论