require-frontend.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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', 'frontend', 'frontend-init', 'table', 'form', 'dragsort', 'drag', 'drop', '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. 'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
  38. 'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
  39. 'sortable': '../libs/Sortable/Sortable.min',
  40. 'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
  41. 'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
  42. 'validator': '../libs/nice-validator/dist/jquery.validator',
  43. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  44. 'toastr': '../libs/toastr/toastr',
  45. 'jstree': '../libs/jstree/dist/jstree.min',
  46. 'layer': '../libs/fastadmin-layer/dist/layer',
  47. 'cookie': '../libs/jquery.cookie/jquery.cookie',
  48. 'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
  49. 'template': '../libs/art-template/dist/template-native',
  50. 'selectpage': '../libs/fastadmin-selectpage/selectpage',
  51. 'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
  52. 'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data'
  53. },
  54. // shim依赖配置
  55. shim: {
  56. 'addons': ['frontend'],
  57. 'bootstrap': ['jquery'],
  58. 'bootstrap-table': {
  59. deps: ['bootstrap'],
  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-fixed-columns': {
  71. deps: ['bootstrap-table'],
  72. exports: '$.fn.bootstrapTable.defaults'
  73. },
  74. 'bootstrap-table-mobile': {
  75. deps: ['bootstrap-table'],
  76. exports: '$.fn.bootstrapTable.defaults'
  77. },
  78. 'bootstrap-table-advancedsearch': {
  79. deps: ['bootstrap-table'],
  80. exports: '$.fn.bootstrapTable.defaults'
  81. },
  82. 'bootstrap-table-commonsearch': {
  83. deps: ['bootstrap-table'],
  84. exports: '$.fn.bootstrapTable.defaults'
  85. },
  86. 'bootstrap-table-template': {
  87. deps: ['bootstrap-table', 'template'],
  88. exports: '$.fn.bootstrapTable.defaults'
  89. },
  90. 'bootstrap-table-jumpto': {
  91. deps: ['bootstrap-table'],
  92. exports: '$.fn.bootstrapTable.defaults'
  93. },
  94. 'tableexport': {
  95. deps: ['jquery'],
  96. exports: '$.fn.extend'
  97. },
  98. 'slimscroll': {
  99. deps: ['jquery'],
  100. exports: '$.fn.extend'
  101. },
  102. 'adminlte': {
  103. deps: ['bootstrap', 'slimscroll'],
  104. exports: '$.AdminLTE'
  105. },
  106. 'bootstrap-daterangepicker': [
  107. 'moment/locale/zh-cn'
  108. ],
  109. 'bootstrap-datetimepicker': [
  110. 'moment/locale/zh-cn',
  111. ],
  112. 'bootstrap-select-lang': ['bootstrap-select'],
  113. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
  114. 'validator-lang': ['validator'],
  115. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  116. },
  117. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  118. map: {
  119. '*': {
  120. 'css': '../libs/require-css/css.min'
  121. }
  122. },
  123. waitSeconds: 60,
  124. charset: 'utf-8' // 文件编码
  125. });
  126. require(['jquery', 'bootstrap'], function ($, undefined) {
  127. //初始配置
  128. var Config = requirejs.s.contexts._.config.config;
  129. //将Config渲染到全局
  130. window.Config = Config;
  131. // 配置语言包的路径
  132. var paths = {};
  133. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
  134. // 避免目录冲突
  135. paths['frontend/'] = 'frontend/';
  136. require.config({paths: paths});
  137. // 初始化
  138. $(function () {
  139. require(['fast'], function (Fast) {
  140. require(['frontend', 'frontend-init', 'addons'], function (Frontend, Addons) {
  141. //加载相应模块
  142. if (Config.jsname) {
  143. require([Config.jsname], function (Controller) {
  144. Controller[Config.actionname] != undefined && Controller[Config.actionname]();
  145. }, function (e) {
  146. console.error(e);
  147. // 这里可捕获模块加载的错误
  148. });
  149. }
  150. });
  151. });
  152. });
  153. });