require-frontend.js 7.5 KB

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