AppController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-present http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 老猫 <zxxjjforever@163.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\controller;
  12. use app\admin\logic\AppLogic;
  13. use cmf\controller\AdminBaseController;
  14. use app\admin\model\AppModel;
  15. use app\admin\model\HookAppModel;
  16. use mindplay\annotations\Annotations;
  17. use think\facade\Cache;
  18. use think\Model;
  19. use think\Validate;
  20. class AppController extends AdminBaseController
  21. {
  22. /**
  23. * 应用管理
  24. * @adminMenu(
  25. * 'name' => '应用管理',
  26. * 'parent' => 'admin/Plugin/default',
  27. * 'display'=> true,
  28. * 'hasView'=> true,
  29. * 'order' => 10000,
  30. * 'icon' => '',
  31. * 'remark' => '应用管理',
  32. * 'param' => ''
  33. * )
  34. */
  35. public function index()
  36. {
  37. $apps = AppLogic::getList();
  38. $this->assign("apps", $apps);
  39. return $this->fetch();
  40. }
  41. /**
  42. * 应用安装
  43. * @adminMenu(
  44. * 'name' => '应用安装',
  45. * 'parent' => 'index',
  46. * 'display'=> false,
  47. * 'hasView'=> false,
  48. * 'order' => 10000,
  49. * 'icon' => '',
  50. * 'remark' => '应用安装',
  51. * 'param' => ''
  52. * )
  53. */
  54. public function install()
  55. {
  56. if ($this->request->isPost()) {
  57. $appName = $this->request->param('name', '', 'trim');
  58. $result = AppLogic::install($appName);
  59. if ($result !== true) {
  60. $this->error($result);
  61. }
  62. $this->success('安装成功!');
  63. }
  64. }
  65. /**
  66. * 应用更新
  67. * @adminMenu(
  68. * 'name' => '应用更新',
  69. * 'parent' => 'index',
  70. * 'display'=> false,
  71. * 'hasView'=> false,
  72. * 'order' => 10000,
  73. * 'icon' => '',
  74. * 'remark' => '应用更新',
  75. * 'param' => ''
  76. * )
  77. */
  78. public function update()
  79. {
  80. if ($this->request->isPost()) {
  81. $appName = $this->request->param('name', '', 'trim');
  82. $result = AppLogic::update($appName);
  83. if ($result !== true) {
  84. $this->error($result);
  85. }
  86. $this->success('更新成功!');
  87. }
  88. }
  89. /**
  90. * 卸载应用
  91. * @adminMenu(
  92. * 'name' => '卸载应用',
  93. * 'parent' => 'index',
  94. * 'display'=> false,
  95. * 'hasView'=> false,
  96. * 'order' => 10000,
  97. * 'icon' => '',
  98. * 'remark' => '卸载应用',
  99. * 'param' => ''
  100. * )
  101. */
  102. public function uninstall()
  103. {
  104. if ($this->request->isPost()) {
  105. $appName = $this->request->param('name', '', 'trim');
  106. $result = AppLogic::uninstall($id);
  107. if ($result !== true) {
  108. $this->error('卸载失败!');
  109. }
  110. Cache::clear('init_hook_apps');
  111. Cache::clear('admin_menus');// 删除后台菜单缓存
  112. $this->success('卸载成功!');
  113. }
  114. }
  115. }