require-backend.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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', 'backend-init', '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. 'drag': 'jquery.drag.min',
  16. 'drop': 'jquery.drop.min',
  17. 'dropzone': 'dropzone.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-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
  29. 'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
  30. 'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
  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-fixed-columns': '../libs/bootstrap-table/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
  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': '../libs/nice-validator/dist/jquery.validator',
  44. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  45. 'toastr': '../libs/toastr/toastr',
  46. 'jstree': '../libs/jstree/dist/jstree.min',
  47. 'layer': '../libs/fastadmin-layer/dist/layer',
  48. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  49. 'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
  50. 'template': '../libs/art-template/dist/template-native',
  51. 'selectpage': '../libs/fastadmin-selectpage/selectpage',
  52. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  53. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data',
  54. },
  55. // shim依赖配置
  56. shim: {
  57. 'addons': ['backend'],
  58. 'bootstrap': ['jquery'],
  59. 'bootstrap-table': {
  60. deps: ['bootstrap'],
  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-fixed-columns': {
  72. deps: ['bootstrap-table'],
  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. ],
  113. 'bootstrap-select-lang': ['bootstrap-select'],
  114. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  115. 'validator-lang': ['validator'],
  116. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  117. },
  118. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  119. map: {
  120. '*': {
  121. 'css': '../libs/require-css/css.min'
  122. }
  123. },
  124. waitSeconds: 60,
  125. charset: 'utf-8' // 文件编码
  126. });
  127. require(['jquery', 'bootstrap'], function ($, undefined) {
  128. //初始配置
  129. var Config = requirejs.s.contexts._.config.config;
  130. //将Config渲染到全局
  131. window.Config = Config;
  132. // 配置语言包的路径
  133. var paths = {};
  134. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
  135. // 避免目录冲突
  136. paths['backend/'] = 'backend/';
  137. require.config({paths: paths});
  138. // 初始化
  139. $(function () {
  140. require(['fast'], function (Fast) {
  141. require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
  142. //加载相应模块
  143. if (Config.jsname) {
  144. require([Config.jsname], function (Controller) {
  145. if (Controller.hasOwnProperty(Config.actionname)) {
  146. Controller[Config.actionname]();
  147. } else {
  148. if (Controller.hasOwnProperty("_empty")) {
  149. Controller._empty();
  150. }
  151. }
  152. }, function (e) {
  153. console.error(e);
  154. // 这里可捕获模块加载的错误
  155. });
  156. }
  157. });
  158. });
  159. });
  160. });