dcat-app.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*=========================================================================================
  2. File Name: app.js
  3. Description: Dcat Admin JS脚本.
  4. ----------------------------------------------------------------------------------------
  5. Item Name: Dcat Admin
  6. Author: Jqh
  7. Author URL: https://github.com/jqhph
  8. ==========================================================================================*/
  9. import Dcat from './Dcat'
  10. import NProgress from './nprogress/NProgress.min'
  11. import Ajax from './extensions/Ajax'
  12. import Toastr from './extensions/Toastr'
  13. import SweetAlert2 from './extensions/SweetAlert2'
  14. import RowSelector from './extensions/RowSelector'
  15. import Grid from './extensions/Grid'
  16. import Form from './extensions/Form'
  17. import DialogForm from './extensions/DialogForm'
  18. import Debouncen from './extensions/Debounce'
  19. import Footer from './bootstrappers/Footer'
  20. import Pjax from './bootstrappers/Pjax'
  21. let win = window,
  22. $ = jQuery;
  23. // 扩展Dcat对象
  24. function extend (Dcat) {
  25. new Ajax(Dcat);
  26. new Toastr(Dcat);
  27. new SweetAlert2(Dcat);
  28. new Grid(Dcat);
  29. // NProgress
  30. Dcat.NP = NProgress;
  31. // 行选择器
  32. Dcat.RowSelector = function (options) {
  33. return new RowSelector(options)
  34. };
  35. // 弹窗表单
  36. Dcat.DialogForm = function (options) {
  37. return new DialogForm(Dcat, options);
  38. };
  39. Dcat.debounce = Debouncen;
  40. }
  41. // 初始化事件监听
  42. function listen(Dcat) {
  43. Dcat.booting(function () {
  44. new Footer(Dcat);
  45. new Pjax(Dcat);
  46. Dcat.NP.configure({parent: '.app-content'});
  47. });
  48. }
  49. // 初始化
  50. function boot(Dcat) {
  51. extend(Dcat);
  52. listen(Dcat);
  53. $(Dcat.boot);
  54. return Dcat;
  55. }
  56. win.CreateDcat = function(config) {
  57. return boot(new Dcat(config));
  58. };