bootstrap.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. use App\Exceptions\Form\CutImage;
  3. use App\Exceptions\Form\MultipleCutImage;
  4. use App\Exceptions\Form\TradImage;
  5. use Dcat\Admin\Admin;
  6. use App\Exceptions\Form\TradFile;
  7. use Dcat\Admin\Form\Field\MultipleImage;
  8. use Dcat\Admin\Grid;
  9. use Dcat\Admin\Form;
  10. use Dcat\Admin\Grid\Filter;
  11. use Dcat\Admin\Show;
  12. use Dcat\Admin\Layout\Content;
  13. use Illuminate\Support\ServiceProvider;
  14. use Dcat\Admin\Form\Field\Editor;
  15. /**
  16. * Dcat-admin - admin builder based on Laravel.
  17. * @author jqh <https://github.com/jqhph>
  18. *
  19. * Bootstraper for Admin.
  20. *
  21. * Here you can remove builtin form field:
  22. *
  23. * extend custom field:
  24. * Dcat\Admin\Form::extend('php', PHPEditor::class);
  25. * Dcat\Admin\Grid\Column::extend('php', PHPEditor::class);
  26. * Dcat\Admin\Grid\Filter::extend('php', PHPEditor::class);
  27. *
  28. * Or require js and css assets:
  29. * Admin::css('/packages/prettydocs/css/styles.css');
  30. * Admin::js('/packages/prettydocs/js/main.js');
  31. *
  32. */
  33. // 设置后台布局
  34. $newContent = new Content();
  35. $newContent->view('admin.layouts.content');
  36. app()->singleton(Content::class, function () use ($newContent) {
  37. return $newContent;
  38. });
  39. // 覆盖默认配置
  40. #config(['admin' => user_admin_config()]);
  41. #config(['app.locale' => config('admin.lang') ?: config('app.locale')]);
  42. // 获取当前登录用户
  43. $user = Admin::guard()->check() ? Admin::user() : null;
  44. // 设置应用程序的本地化
  45. config(['app.locale' => Cookie::get('lang') ?: config('app.locale')]);
  46. //编辑器配置
  47. Editor::resolving(function (Editor $editor) {
  48. // 设置默认配置
  49. $editor->options([
  50. 'plugins'=>["advlist","autolink","link","image","media","lists","preview","code","help","fullscreen","table","autoresize","codesample"],
  51. 'toolbar'=>["undo redo | preview fullscreen | formatselect | fontsizeselect bold italic underline strikethrough forecolor backcolor | link image media blockquote removeformat codesample","alignleft aligncenter alignright alignjustify| indent outdent bullist numlist table subscript superscript | code"],
  52. ]);
  53. });
  54. //裁剪图片表单扩展
  55. Form::extend('multipleCutImage', MultipleCutImage::class);
  56. Form::extend('cutImage', CutImage::class);
  57. Form::extend('tradFile', TradFile::class);
  58. Form::extend('tradImage', TradImage::class);