require-backend.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. require.config({
  2. urlArgs: "v=" + requirejs.s.contexts._.config.config.config.site.version,
  3. packages: [{
  4. name: 'moment',
  5. location: '../libs/moment',
  6. main: 'moment'
  7. }],
  8. //在打包压缩时将会把include中的模块合并到主文件中
  9. include: ['css', 'layer', 'toastr', 'backend', 'table', 'form', 'dragsort', 'drag', 'drop', 'addtabs'],
  10. paths: {
  11. 'lang': "empty:",
  12. 'config': 'require-config',
  13. 'bootstrap-checkbox': 'bootstrap-checkbox',
  14. 'bootstrap-radio': 'bootstrap-radio',
  15. 'bootstrap-switch': 'bootstrap-switch',
  16. 'form': 'require-form',
  17. 'table': 'require-table',
  18. 'upload': 'require-upload',
  19. 'drag': 'jquery.drag.min',
  20. 'drop': 'jquery.drop.min',
  21. 'echarts-theme': 'echarts-theme',
  22. 'adminlte': 'adminlte',
  23. //
  24. // 以下的包从bower的libs目录加载
  25. 'jquery': '../libs/jquery/dist/jquery.min',
  26. 'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
  27. 'bootstrap-validator': '../libs/bootstrap-validator/dist/validator.min',
  28. 'bootstrap-typeahead': '../libs/bootstrap3-typeahead/bootstrap3-typeahead.min',
  29. 'bootstrap-tagsinput': '../libs/bootstrap-tagsinput/dist/bootstrap-tagsinput.min',
  30. 'bootstrap-dialog': '../libs/bootstrap3-dialog/dist/js/bootstrap-dialog.min',
  31. 'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
  32. 'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
  33. 'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
  34. 'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
  35. 'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
  36. 'bootstrap-table-advancedsearch': 'bootstrap-table-advancedsearch',
  37. 'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
  38. 'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
  39. 'typeahead': '../libs/typeahead.js/dist/typeahead.jquery.min',
  40. 'bloodhound': '../libs/typeahead.js/dist/bloodhound.min',
  41. 'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
  42. 'dropzone': '../libs/dropzone/dist/min/dropzone-amd-module.min',
  43. 'less': '../libs/less/dist/less.min',
  44. 'dragsort': '../libs/dragsort/jquery.dragsort',
  45. 'sortable': '../libs/Sortable/Sortable.min',
  46. 'addtabs': '../libs/jquery-addtabs/jquery.addtabs',
  47. 'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
  48. 'crontab': '../libs/jqcron/src/jqCron.cn',
  49. 'summernote': '../libs/summernote/dist/lang/summernote-zh-CN.min',
  50. 'validator': '../libs/nice-validator/dist/local/zh-CN',
  51. 'plupload': '../libs/plupload/js/plupload.min',
  52. 'toastr': '../libs/toastr/toastr',
  53. 'jstree': '../libs/jstree/dist/jstree.min',
  54. 'layer': '../libs/layer/src/layer',
  55. 'echarts': '../libs/echarts/dist/echarts.min',
  56. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  57. 'template': '../libs/art-template/dist/template-native',
  58. },
  59. // shim依赖配置
  60. shim: {
  61. 'bootstrap': ['jquery'],
  62. 'bootstrap-table': {
  63. deps: ['bootstrap', 'css!../libs/bootstrap-table/dist/bootstrap-table.min.css'],
  64. exports: '$.fn.bootstrapTable'
  65. },
  66. 'bootstrap-table-lang': {
  67. deps: ['bootstrap-table'],
  68. exports: '$.fn.bootstrapTable.defaults'
  69. },
  70. 'bootstrap-table-export': {
  71. deps: ['bootstrap-table', 'tableexport'],
  72. exports: '$.fn.bootstrapTable.defaults'
  73. },
  74. 'bootstrap-table-mobile': {
  75. deps: ['bootstrap-table'],
  76. exports: '$.fn.bootstrapTable.defaults'
  77. },
  78. 'bootstrap-table-advancedsearch': {
  79. deps: ['bootstrap-table'],
  80. exports: '$.fn.bootstrapTable.defaults'
  81. },
  82. 'bootstrap-table-commonsearch': {
  83. deps: ['bootstrap-table'],
  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. 'typeahead': {
  99. deps: ['jquery'],
  100. init: function ($) {
  101. return require.s.contexts._.registry['typeahead.js'].factory($);
  102. }
  103. },
  104. 'crontab': ['../libs/jqcron/src/jqCron', 'css!../libs/jqcron/src/jqCron.css'],
  105. 'bootstrap-checkbox': ['jquery'],
  106. 'bootstrap-radio': ['jquery'],
  107. 'bootstrap-switch': ['jquery'],
  108. 'bootstrap-dialog': ['css!../libs/bootstrap3-dialog/dist/css/bootstrap-dialog.min.css'],
  109. 'bootstrap-datetimepicker': [
  110. 'css!../libs/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
  111. 'moment/locale/zh-cn'
  112. ],
  113. 'bootstrap-tagsinput': [
  114. 'css!../libs/bootstrap-tagsinput/dist/bootstrap-tagsinput-typeahead.css',
  115. 'css!../libs/bootstrap-tagsinput/dist/bootstrap-tagsinput.css',
  116. 'jquery',
  117. 'typeahead'
  118. ],
  119. 'bootstrap-select': ['css!../libs/bootstrap-select/dist/css/bootstrap-select.min.css', ],
  120. 'summernote': ['../libs/summernote/dist/summernote.min', 'css!../libs/summernote/dist/summernote.css'],
  121. // 'toastr': ['css!../libs/toastr/toastr.min.css'],
  122. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css', ],
  123. 'plupload': {
  124. deps: [
  125. '../libs/plupload/js/moxie.min'
  126. ],
  127. exports: "plupload"
  128. },
  129. // 'layer': ['css!../libs/layer/build/skin/default/layer.css'],
  130. validator: {
  131. deps: ['../libs/nice-validator/dist/jquery.validator', 'css!../libs/nice-validator/dist/jquery.validator.css']
  132. }
  133. },
  134. baseUrl: requirejs.s.contexts._.config.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  135. map: {
  136. '*': {
  137. 'css': '../libs/require-css/css.min'
  138. }
  139. },
  140. charset: 'utf-8' // 文件编码
  141. });
  142. require(['jquery', 'bootstrap', 'config'], function ($, undefined, Config) {
  143. // 配置语言包的路径
  144. var paths = {};
  145. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername;
  146. // 避免目录冲突
  147. paths['backend/'] = 'backend/';
  148. require.config({paths: paths});
  149. // 初始化
  150. $(function () {
  151. require(['backend'], function (Module) {
  152. // 对相对地址进行处理
  153. $.ajaxSetup({
  154. beforeSend: function (xhr, setting) {
  155. setting.url = Module.api.fixurl(setting.url);
  156. }
  157. });
  158. // 绑定ESC关闭窗口事件
  159. $(window).keyup(function (e) {
  160. if (e.keyCode == 27) {
  161. if ($(".layui-layer").size() > 0) {
  162. var index = 0;
  163. $(".layui-layer").each(function () {
  164. index = Math.max(index, parseInt($(this).attr("times")));
  165. });
  166. if (index) {
  167. Module.api.layer.close(index);
  168. }
  169. }
  170. }
  171. });
  172. //加载相应模块
  173. require([Config.jsname], function (Controller) {
  174. Controller[Config.actionname] != undefined && Controller[Config.actionname]();
  175. }, function (e) {
  176. // 这里可捕获模块加载的错误
  177. });
  178. });
  179. });
  180. });