Theme.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\admin\controller\cms;
  3. use app\common\controller\Backend;
  4. use think\Session;
  5. /**
  6. * 移动端主题
  7. *
  8. * @icon fa fa-gears
  9. */
  10. class Theme extends Backend
  11. {
  12. /**
  13. * 查看
  14. */
  15. public function index()
  16. {
  17. if ($this->request->isPost()) {
  18. $preview = $this->request->post('preview');
  19. $navbar = $this->request->post('navbar/a', []);
  20. $theme = $this->request->post('theme/a', []);
  21. $tabbar = $this->request->post('tabbar/a', []);
  22. $tabbar['midButton'] = (bool)$tabbar['midButton'];
  23. $tabbar['borderTop'] = (bool)$tabbar['borderTop'];
  24. if (isset($tabbar['list'])) {
  25. foreach ($tabbar['list'] as $index => &$item) {
  26. $item['midButton'] = isset($item['midButton']) && $item['midButton'] ? true : false;
  27. $item = array_merge($item, [
  28. 'count' => 0,
  29. 'isDot' => false,
  30. 'badgeColor' => $theme['color'], //字体颜色
  31. 'badgeBgColor' => $theme['bgColor'], //背景颜色
  32. ]);
  33. }
  34. $tabbar['list'] = array_values($tabbar['list']);
  35. }
  36. $navbar['isshow'] = true;
  37. $tabbar['isshow'] = true;
  38. $config = [
  39. 'navbar' => $navbar,
  40. 'theme' => $theme,
  41. 'tabbar' => $tabbar,
  42. ];
  43. //如果是预览模式则写入session
  44. if ($preview) {
  45. Session::set("previewtheme", $config);
  46. } else {
  47. \addons\cms\library\Theme::set($config);
  48. }
  49. $this->success();
  50. }
  51. $config = \addons\cms\library\Theme::get();
  52. $this->view->assign("themeConfig", $config);
  53. $this->assignconfig("themeConfig", $config);
  54. return $this->view->fetch();
  55. }
  56. }