StorageController.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-02-17
  10. // +—————————————————————————————————————————————————————————————————————
  11. namespace app\admin\controller;
  12. use cmf\controller\AdminBaseController;
  13. class StorageController extends AdminBaseController
  14. {
  15. /**
  16. * 文件存储
  17. * @adminMenu(
  18. * 'name' => '文件存储',
  19. * 'parent' => 'admin/Setting/default',
  20. * 'display'=> true,
  21. * 'hasView'=> true,
  22. * 'order' => 10000,
  23. * 'icon' => '',
  24. * 'remark' => '文件存储',
  25. * 'param' => ''
  26. * )
  27. */
  28. public function index()
  29. {
  30. $storage = cmf_get_option('storage');
  31. /*var_dump($storage);
  32. die;*/
  33. if (empty($storage)) {
  34. $storage['type'] = 'Local';
  35. $storage['storages'] = ['Local' => ['name' => '本地']];
  36. } else {
  37. if (empty($storage['type'])) {
  38. $storage['type'] = 'Local';
  39. }
  40. if (empty($storage['storages']['Local'])) {
  41. $storage['storages']['Local'] = ['name' => '本地'];
  42. }
  43. }
  44. $this->assign($storage);
  45. return $this->fetch();
  46. }
  47. /**
  48. * 文件存储
  49. * @adminMenu(
  50. * 'name' => '文件存储设置提交',
  51. * 'parent' => 'index',
  52. * 'display'=> false,
  53. * 'hasView'=> false,
  54. * 'order' => 10000,
  55. * 'icon' => '',
  56. * 'remark' => '文件存储设置提交',
  57. * 'param' => ''
  58. * )
  59. */
  60. public function settingPost()
  61. {
  62. $post = $this->request->post();
  63. $storage = cmf_get_option('storage');
  64. if($storage['type']!=$post['type']){
  65. $type=[
  66. 'Local'=>'本地',
  67. 'Qiniu'=>'七牛云存储'
  68. ];
  69. }
  70. $storage['type'] = $post['type'];
  71. cmf_set_option('storage', $storage);
  72. $this->success("设置成功!", '');
  73. }
  74. }