Plugs.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免费声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  13. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  14. // +----------------------------------------------------------------------
  15. namespace app\admin\controller\api;
  16. use think\admin\Controller;
  17. use think\admin\service\AdminService;
  18. /**
  19. * 通用插件管理
  20. * Class Plugs
  21. * @package app\admin\controller\api
  22. */
  23. class Plugs extends Controller
  24. {
  25. /**
  26. * 图标选择器
  27. * @login true
  28. */
  29. public function icon()
  30. {
  31. $this->title = '图标选择器';
  32. $this->field = $this->app->request->get('field', 'icon');
  33. $this->fetch(realpath(__DIR__ . '/../../view/api/icon.html'));
  34. }
  35. /**
  36. * 前端脚本变量
  37. * @return \think\Response
  38. * @throws \think\db\exception\DataNotFoundException
  39. * @throws \think\db\exception\DbException
  40. * @throws \think\db\exception\ModelNotFoundException
  41. */
  42. public function script(): \think\Response
  43. {
  44. $taDebug = $this->app->isDebug() ? 'true' : 'false';
  45. $taAdmin = sysuri('admin/index/index', [], false);
  46. $taEditor = sysconf('base.editor') ?: 'ckeditor4';
  47. return response(join("\n", [
  48. "window.taDebug = {$taDebug};",
  49. "window.taAdmin = '{$taAdmin}';",
  50. "window.taEditor = '{$taEditor}';",
  51. ]))->contentType('application/x-javascript');
  52. }
  53. /**
  54. * 优化数据库
  55. * @login true
  56. */
  57. public function optimize()
  58. {
  59. if (AdminService::isSuper()) {
  60. sysoplog('系统运维管理', '创建数据库优化任务');
  61. $this->_queue('优化数据库所有数据表', 'xadmin:database optimize');
  62. } else {
  63. $this->error('只有超级管理员才能操作!');
  64. }
  65. }
  66. }