require-frontend.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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', 'frontend', 'frontend-init'],
  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. '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-core': '../libs/nice-validator/dist/jquery.validator',
  42. 'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
  43. 'plupload': '../libs/plupload/js/plupload.min',
  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: [
  60. 'bootstrap',
  61. // 'css!../libs/bootstrap-table/dist/bootstrap-table.min.css'
  62. ],
  63. exports: '$.fn.bootstrapTable'
  64. },
  65. 'bootstrap-table-lang': {
  66. deps: ['bootstrap-table'],
  67. exports: '$.fn.bootstrapTable.defaults'
  68. },
  69. 'bootstrap-table-export': {
  70. deps: ['bootstrap-table', 'tableexport'],
  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. 'tableexport': {
  90. deps: ['jquery'],
  91. exports: '$.fn.extend'
  92. },
  93. 'slimscroll': {
  94. deps: ['jquery'],
  95. exports: '$.fn.extend'
  96. },
  97. 'adminlte': {
  98. deps: ['bootstrap', 'slimscroll'],
  99. exports: '$.AdminLTE'
  100. },
  101. 'bootstrap-datetimepicker': [
  102. 'moment/locale/zh-cn',
  103. // 'css!../libs/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
  104. ],
  105. // 'bootstrap-select': ['css!../libs/bootstrap-select/dist/css/bootstrap-select.min.css', ],
  106. 'bootstrap-select-lang': ['bootstrap-select'],
  107. // 'toastr': ['css!../libs/toastr/toastr.min.css'],
  108. 'jstree': ['css!../libs/jstree/dist/themes/default/style.css', ],
  109. 'plupload': {
  110. deps: ['../libs/plupload/js/moxie.min'],
  111. exports: "plupload"
  112. },
  113. // 'layer': ['css!../libs/fastadmin-layer/dist/theme/default/layer.css'],
  114. // 'validator-core': ['css!../libs/nice-validator/dist/jquery.validator.css'],
  115. 'validator-lang': ['validator-core'],
  116. // 'selectpage': ['css!../libs/fastadmin-selectpage/selectpage.css'],
  117. 'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
  118. },
  119. baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
  120. map: {
  121. '*': {
  122. 'css': '../libs/require-css/css.min'
  123. }
  124. },
  125. waitSeconds: 30,
  126. charset: 'utf-8' // 文件编码
  127. });
  128. require(['jquery', 'bootstrap'], function ($, undefined) {
  129. //初始配置
  130. var Config = requirejs.s.contexts._.config.config;
  131. //将Config渲染到全局
  132. window.Config = Config;
  133. // 配置语言包的路径
  134. var paths = {};
  135. paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername;
  136. // 避免目录冲突
  137. paths['frontend/'] = 'frontend/';
  138. require.config({paths: paths});
  139. // 初始化
  140. $(function () {
  141. require(['fast'], function (Fast) {
  142. require(['frontend', 'frontend-init', 'addons'], function (Frontend, Addons) {
  143. //加载相应模块
  144. if (Config.jsname) {
  145. require([Config.jsname], function (Controller) {
  146. Controller[Config.actionname] != undefined && Controller[Config.actionname]();
  147. }, function (e) {
  148. console.error(e);
  149. // 这里可捕获模块加载的错误
  150. });
  151. }
  152. });
  153. });
  154. });
  155. });