WebSettingLogic.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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', 'web_favicon', $favicon);
  65. ConfigService::set('website', 'web_logo', $logo);
  66. ConfigService::set('website', 'login_image', $login);
  67. ConfigService::set('website', 'shop_name', $params['shop_name']);
  68. ConfigService::set('website', 'shop_logo', $shopLogo);
  69. ConfigService::set('website', 'pc_logo', $pcLogo);
  70. ConfigService::set('website', 'pc_title', $params['pc_title']);
  71. ConfigService::set('website', 'pc_ico', $pcIco);
  72. ConfigService::set('website', 'pc_desc', $params['pc_desc'] ?? '');
  73. ConfigService::set('website', 'pc_keywords', $params['pc_keywords'] ?? '');
  74. ConfigService::set('website', 'h5_favicon', $h5favicon);
  75. }
  76. /**
  77. * @notes 获取版权备案
  78. * @return array
  79. * @author 段誉
  80. * @date 2021/12/28 16:09
  81. */
  82. public static function getCopyright() : array
  83. {
  84. return ConfigService::get('copyright', 'config', []);
  85. }
  86. /**
  87. * @notes 设置版权备案
  88. * @param array $params
  89. * @return bool
  90. * @author 段誉
  91. * @date 2022/8/8 16:33
  92. */
  93. public static function setCopyright(array $params)
  94. {
  95. try {
  96. if (!is_array($params['config'])) {
  97. throw new \Exception('参数异常');
  98. }
  99. ConfigService::set('copyright', 'config', $params['config'] ?? []);
  100. return true;
  101. } catch (\Exception $e) {
  102. self::$error = $e->getMessage();
  103. return false;
  104. }
  105. }
  106. /**
  107. * @notes 设置政策协议
  108. * @param array $params
  109. * @author ljj
  110. * @date 2022/2/15 10:59 上午
  111. */
  112. public static function setAgreement(array $params)
  113. {
  114. $serviceContent = clear_file_domain($params['service_content'] ?? '');
  115. $privacyContent = clear_file_domain($params['privacy_content'] ?? '');
  116. ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
  117. ConfigService::set('agreement', 'service_content', $serviceContent);
  118. ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
  119. ConfigService::set('agreement', 'privacy_content', $privacyContent);
  120. }
  121. /**
  122. * @notes 获取政策协议
  123. * @return array
  124. * @author ljj
  125. * @date 2022/2/15 11:15 上午
  126. */
  127. public static function getAgreement() : array
  128. {
  129. $config = [
  130. 'service_title' => ConfigService::get('agreement', 'service_title'),
  131. 'service_content' => ConfigService::get('agreement', 'service_content'),
  132. 'privacy_title' => ConfigService::get('agreement', 'privacy_title'),
  133. 'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
  134. ];
  135. $config['service_content'] = get_file_domain($config['service_content']);
  136. $config['privacy_content'] = get_file_domain($config['privacy_content']);
  137. return $config;
  138. }
  139. /**
  140. * @notes 获取站点统计配置
  141. * @return array
  142. * @author yfdong
  143. * @date 2024/09/20 22:25
  144. */
  145. public static function getSiteStatistics()
  146. {
  147. return [
  148. 'clarity_code' => ConfigService::get('siteStatistics', 'clarity_code')
  149. ];
  150. }
  151. /**
  152. * @notes 设置站点统计配置
  153. * @param array $params
  154. * @return void
  155. * @author yfdong
  156. * @date 2024/09/20 22:31
  157. */
  158. public static function setSiteStatistics(array $params)
  159. {
  160. ConfigService::set('siteStatistics', 'clarity_code', $params['clarity_code']);
  161. }
  162. }