This commit is contained in:
80
plugins/addon/theme_configurator/ThemeConfigurator.php
Normal file
80
plugins/addon/theme_configurator/ThemeConfigurator.php
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user