修改插件代码格式
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
yiqiu
2025-11-21 13:01:04 +08:00
parent 5834ab9a74
commit b05595e090
3 changed files with 409 additions and 48 deletions

View File

@@ -2,32 +2,28 @@
namespace addon\theme_configurator\controller;
use addon\theme_configurator\model\ThemeConfigModel;
use app\admin\controller\PluginAdminBaseController;
use think\App;
use app\event\controller\PluginAdminBaseController;
use think\Response;
/**
* 后台主题配置控制器
*
* 注意:结构尽量与官方示例插件保持一致,避免因基类或构造方式不一致导致 500。
*/
class ThemeController extends PluginAdminBaseController
{
protected ThemeConfigModel $model;
public function __construct(App $app = null)
{
parent::__construct($app);
$this->model = new ThemeConfigModel();
}
/**
* 获取配置
*/
public function config(): Response
{
$model = new ThemeConfigModel();
$config = $model->getConfig();
return json([
'status' => 200,
'msg' => lang_plugins('theme_configurator_success'),
'data' => $this->model->getConfig(),
'data' => $config,
]);
}
@@ -37,6 +33,8 @@ class ThemeController extends PluginAdminBaseController
public function save(): Response
{
$param = $this->request->param();
// 与前端 payload 结构保持一致,只取需要的字段入库
$payload = [
'seo' => $param['seo'] ?? [],
'header_nav' => $param['header_nav'] ?? [],
@@ -45,13 +43,13 @@ class ThemeController extends PluginAdminBaseController
'friendly_link' => $param['friendly_link'] ?? [],
'banner' => $param['banner'] ?? [],
'side' => $param['side'] ?? [],
// 额外配置:荣誉、合作伙伴、反馈类型
'feedback_type' => $param['feedback_type'] ?? [],
'honor' => $param['honor'] ?? [],
'partner' => $param['partner'] ?? [],
];
$config = $this->model->saveConfig($payload);
$model = new ThemeConfigModel();
$config = $model->saveConfig($payload);
return json([
'status' => 200,