require-frontend.js 7.3 KB

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