WebSettingLogic.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\logic\setting\web;
  15. use app\common\logic\BaseLogic;
  16. use app\common\service\ConfigService;
  17. use app\common\service\FileService;
  18. /**
  19. * 网站设置
  20. * Class WebSettingLogic
  21. * @package app\adminapi\logic\setting
  22. */
  23. class WebSettingLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 获取网站信息
  27. * @return array
  28. * @author 段誉
  29. * @date 2021/12/28 15:43
  30. */
  31. public static function getWebsiteInfo(): array
  32. {
  33. return [
  34. 'name' => ConfigService::get('website', 'name'),
  35. 'web_favicon' => FileService::getFileUrl(ConfigService::get('website', 'web_favicon')),
  36. 'web_logo' => FileService::getFileUrl(ConfigService::get('website', 'web_logo')),
  37. 'login_image' => FileService::getFileUrl(ConfigService::get('website', 'login_image')),
  38. 'shop_name' => ConfigService::get('website', 'shop_name'),
  39. 'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
  40. 'pc_logo' => FileService::getFileUrl(ConfigService::get('website', 'pc_logo')),
  41. 'pc_title' => ConfigService::get('website', 'pc_title', ''),
  42. 'pc_ico' => FileService::getFileUrl(ConfigService::get('website', 'pc_ico')),
  43. 'pc_desc' => ConfigService::get('website', 'pc_desc', ''),
  44. 'pc_keywords' => ConfigService::get('website', 'pc_keywords', ''),
  45. 'h5_favicon' => FileService::getFileUrl(ConfigService::get('website', 'h5_favicon')),
  46. ];
  47. }
  48. /**
  49. * @notes 设置网站信息
  50. * @param array $params
  51. * @author 段誉
  52. * @date 2021/12/28 15:43
  53. */
  54. public static function setWebsiteInfo(array $params)
  55. {
  56. $h5favicon = FileService::setFileUrl($params['h5_favicon']);
  57. $favicon = FileService::setFileUrl($params['web_favicon']);
  58. $logo = FileService::setFileUrl($params['web_logo']);
  59. $login = FileService::setFileUrl($params['login_image']);
  60. $shopLogo = FileService::setFileUrl($params['shop_logo']);
  61. $pcLogo = FileService::setFileUrl($params['pc_logo']);
  62. $pcIco = FileService::setFileUrl($params['pc_ico'] ?? '');
  63. ConfigService::set('website', 'name', $params['name']);
  64. ConfigService::set('website', 'mobile', $params['mobile']);
  65. ConfigService::set('website', 'web_favicon', $favicon);
  66. ConfigService::set('website', 'web_logo', $logo);
  67. ConfigService::set('website', 'login_image', $login);
  68. ConfigService::set('website', 'shop_name', $params['shop_name']);
  69. ConfigService::set('website', 'shop_logo', $shopLogo);
  70. ConfigService::set('website', 'pc_logo', $pcLogo);
  71. ConfigService::set('website', 'pc_title', $params['pc_title']);
  72. ConfigService::set('website', 'pc_ico', $pcIco);
  73. ConfigService::set('website', 'pc_desc', $params['pc_desc'] ?? '');
  74. ConfigService::set('website', 'pc_keywords', $params['pc_keywords'] ?? '');
  75. ConfigService::set('website', 'h5_favicon', $h5favicon);
  76. }
  77. /**
  78. * @notes 获取版权备案
  79. * @return array
  80. * @author 段誉
  81. * @date 2021/12/28 16:09
  82. */
  83. public static function getCopyright() : array
  84. {
  85. return ConfigService::get('copyright', 'config', []);
  86. }
  87. /**
  88. * @notes 设置版权备案
  89. * @param array $params
  90. * @return bool
  91. * @author 段誉
  92. * @date 2022/8/8 16:33
  93. */
  94. public static function setCopyright(array $params)
  95. {
  96. try {
  97. if (!is_array($params['config'])) {
  98. throw new \Exception('参数异常');
  99. }
  100. ConfigService::set('copyright', 'config', $params['config'] ?? []);
  101. return true;
  102. } catch (\Exception $e) {
  103. self::$error = $e->getMessage();
  104. return false;
  105. }
  106. }
  107. /**
  108. * @notes 设置政策协议
  109. * @param array $params
  110. * @author ljj
  111. * @date 2022/2/15 10:59 上午
  112. */
  113. public static function setAgreement(array $params)
  114. {
  115. $serviceContent = clear_file_domain($params['service_content'] ?? '');
  116. $privacyContent = clear_file_domain($params['privacy_content'] ?? '');
  117. ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
  118. ConfigService::set('agreement', 'service_content', $serviceContent);
  119. ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
  120. ConfigService::set('agreement', 'privacy_content', $privacyContent);
  121. }
  122. /**
  123. * @notes 获取政策协议
  124. * @return array
  125. * @author ljj
  126. * @date 2022/2/15 11:15 上午
  127. */
  128. public static function getAgreement() : array
  129. {
  130. $config = [
  131. 'service_title' => ConfigService::get('agreement', 'service_title'),
  132. 'service_content' => ConfigService::get('agreement', 'service_content'),
  133. 'privacy_title' => ConfigService::get('agreement', 'privacy_title'),
  134. 'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
  135. ];
  136. $config['service_content'] = get_file_domain($config['service_content']);
  137. $config['privacy_content'] = get_file_domain($config['privacy_content']);
  138. return $config;
  139. }
  140. /**
  141. * @notes 获取站点统计配置
  142. * @return array
  143. * @author yfdong
  144. * @date 2024/09/20 22:25
  145. */
  146. public static function getSiteStatistics()
  147. {
  148. return [
  149. 'clarity_code' => ConfigService::get('siteStatistics', 'clarity_code')
  150. ];
  151. }
  152. /**
  153. * @notes 设置站点统计配置
  154. * @param array $params
  155. * @return void
  156. * @author yfdong
  157. * @date 2024/09/20 22:31
  158. */
  159. public static function setSiteStatistics(array $params)
  160. {
  161. ConfigService::set('siteStatistics', 'clarity_code', $params['clarity_code']);
  162. }
  163. }