require-frontend.js 6.4 KB

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