新增配置插件
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
yiqiu
2025-11-20 23:37:31 +08:00
parent 3e345e9e22
commit 8a1fa3fb8b
14 changed files with 923 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
<?php
namespace addon\theme_configurator;
use addon\theme_configurator\model\ThemeConfigModel;
use think\facade\Db;
/**
* 主题可配置项插件主要类
*/
class ThemeConfigurator
{
/** @var array 插件基础信息 */
public $info = [
'name' => 'ThemeConfigurator',
'title' => '主题可视化配置',
'description' => '通过插件管理 BlackFruit-UI 导航、页脚、SEO、轮播与侧边栏等主题参数',
'author' => 'yiqiu',
'version' => '1.0.0',
];
/** @var bool 标记不需要默认插件导航 */
public $noNav = false;
/**
* 安装插件 - 初始化存储表以及默认配置
*/
public function install()
{
try {
Db::execute(
"CREATE TABLE IF NOT EXISTS `addon_theme_configurator`(
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`config` longtext NOT NULL,
`update_time` int(11) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
);
} catch (\Throwable $throwable) {
return [
'status' => 400,
'msg' => $throwable->getMessage(),
];
}
(new ThemeConfigModel())->initConfig();
return [
'status' => 200,
'msg' => lang_plugins('theme_configurator_install_success'),
];
}
/**
* 卸载插件 - 移除存储表
*/
public function uninstall()
{
try {
Db::execute("DROP TABLE IF EXISTS `addon_theme_configurator`;");
} catch (\Throwable $throwable) {
return [
'status' => 400,
'msg' => $throwable->getMessage(),
];
}
return [
'status' => 200,
'msg' => lang_plugins('theme_configurator_uninstall_success'),
];
}
/**
* 供其他业务调用,快速获取主题配置
*/
public function getThemeConfig()
{
return (new ThemeConfigModel())->getConfig();
}
}