require-backend.js 7.3 KB

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