require-backend.js 6.4 KB

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