require-backend.js 6.8 KB

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