审查视图

public/assets/js/require-frontend.js 6.6 KB
Karson authored
1
require.config({
Karson authored
2
    urlArgs: "v=" + requirejs.s.contexts._.config.config.site.version,
Karson authored
3 4 5 6
    packages: [{
            name: 'moment',
            location: '../libs/moment',
            main: 'moment'
Karson authored
7 8
        }
    ],
9
    //在打包压缩时将会把include中的模块合并到主文件中
10
    include: ['css', 'layer', 'toastr', 'fast', 'frontend', 'frontend-init'],
Karson authored
11
    paths: {
12
        'lang': "empty:",
Karson authored
13 14 15
        'form': 'require-form',
        'table': 'require-table',
        'upload': 'require-upload',
16
        'validator': 'require-validator',
Karson authored
17 18
        'drag': 'jquery.drag.min',
        'drop': 'jquery.drop.min',
19
        'echarts': 'echarts.min',
Karson authored
20 21
        'echarts-theme': 'echarts-theme',
        'adminlte': 'adminlte',
Karson authored
22
        'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
23
        'bootstrap-table-template': 'bootstrap-table-template',
Karson authored
24 25 26 27 28
        //
        // 以下的包从bower的libs目录加载
        'jquery': '../libs/jquery/dist/jquery.min',
        'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
        'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
Karson authored
29
        'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
Karson authored
30
        'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
31
        'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
Karson authored
32 33 34 35 36
        'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
        'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
        'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
        'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
        'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
37
        'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
Karson authored
38
        'sortable': '../libs/Sortable/Sortable.min',
39
        'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
Karson authored
40
        'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
41 42
        'validator-core': '../libs/nice-validator/dist/jquery.validator',
        'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
Karson authored
43
        'plupload': '../libs/plupload/js/plupload.min',
Karson authored
44
        'toastr': '../libs/toastr/toastr',
Karson authored
45
        'jstree': '../libs/jstree/dist/jstree.min',
46
        'layer': '../libs/layer/dist/layer',
Karson authored
47
        'cookie': '../libs/jquery.cookie/jquery.cookie',
48
        'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
49
        'template': '../libs/art-template/dist/template-native',
50
        'selectpage': '../libs/fastadmin-selectpage/selectpage',
Karson authored
51 52
        'citypicker': '../libs/city-picker/dist/js/city-picker.min',
        'citypicker-data': '../libs/city-picker/dist/js/city-picker.data',
Karson authored
53 54 55
    },
    // shim依赖配置
    shim: {
56
        'addons': ['frontend'],
Karson authored
57 58
        'bootstrap': ['jquery'],
        'bootstrap-table': {
59 60 61 62
            deps: [
                'bootstrap',
//                'css!../libs/bootstrap-table/dist/bootstrap-table.min.css'
            ],
Karson authored
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
            exports: '$.fn.bootstrapTable'
        },
        'bootstrap-table-lang': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-export': {
            deps: ['bootstrap-table', 'tableexport'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-mobile': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
        'bootstrap-table-advancedsearch': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
81 82 83 84
        'bootstrap-table-commonsearch': {
            deps: ['bootstrap-table'],
            exports: '$.fn.bootstrapTable.defaults'
        },
85 86 87 88
        'bootstrap-table-template': {
            deps: ['bootstrap-table', 'template'],
            exports: '$.fn.bootstrapTable.defaults'
        },
Karson authored
89 90 91 92 93 94 95 96 97 98 99 100 101
        'tableexport': {
            deps: ['jquery'],
            exports: '$.fn.extend'
        },
        'slimscroll': {
            deps: ['jquery'],
            exports: '$.fn.extend'
        },
        'adminlte': {
            deps: ['bootstrap', 'slimscroll'],
            exports: '$.AdminLTE'
        },
        'bootstrap-datetimepicker': [
102
            'moment/locale/zh-cn',
103
//            'css!../libs/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
Karson authored
104 105
        ],
        'bootstrap-select': ['css!../libs/bootstrap-select/dist/css/bootstrap-select.min.css', ],
106
        'bootstrap-select-lang': ['bootstrap-select'],
Karson authored
107 108 109
//        'toastr': ['css!../libs/toastr/toastr.min.css'],
        'jstree': ['css!../libs/jstree/dist/themes/default/style.css', ],
        'plupload': {
110
            deps: ['../libs/plupload/js/moxie.min'],
Karson authored
111 112
            exports: "plupload"
        },
113
//        'layer': ['css!../libs/layer/dist/theme/default/layer.css'],
114 115
//        'validator-core': ['css!../libs/nice-validator/dist/jquery.validator.css'],
        'validator-lang': ['validator-core'],
116
//        'selectpage': ['css!../libs/fastadmin-selectpage/selectpage.css'],
Karson authored
117
        'citypicker': ['citypicker-data', 'css!../libs/city-picker/dist/css/city-picker.css']
Karson authored
118
    },
Karson authored
119
    baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
Karson authored
120 121 122 123 124
    map: {
        '*': {
            'css': '../libs/require-css/css.min'
        }
    },
125
    waitSeconds: 30,
Karson authored
126 127 128
    charset: 'utf-8' // 文件编码
});
Karson authored
129 130 131 132 133
require(['jquery', 'bootstrap'], function ($, undefined) {
    //初始配置
    var Config = requirejs.s.contexts._.config.config;
    //将Config渲染到全局
    window.Config = Config;
Karson authored
134 135
    // 配置语言包的路径
    var paths = {};
136
    paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername;
Karson authored
137
    // 避免目录冲突
138
    paths['frontend/'] = 'frontend/';
Karson authored
139 140 141 142
    require.config({paths: paths});

    // 初始化
    $(function () {
Karson authored
143 144 145 146 147 148 149 150 151 152
        require(['fast'], function (Fast) {
            require(['frontend', 'addons'], function (Frontend, Addons) {
                //加载相应模块
                if (Config.jsname) {
                    require([Config.jsname], function (Controller) {
                        Controller[Config.actionname] != undefined && Controller[Config.actionname]();
                    }, function (e) {
                        console.error(e);
                        // 这里可捕获模块加载的错误
                    });
Karson authored
153 154 155 156 157
                }
            });
        });
    });
});