All checks were successful
continuous-integration/drone/push Build is passing
前端部分: - 删除 index.html 中的"聚焦核心场景,助力数智升级"模块 - 删除 js/index.js 中处理 partner 数据的相关代码 主题配置插件部分: - 从 ThemeConfigModel.php 的默认配置中移除 partner 字段 - 从后台配置界面移除"合作伙伴/成功案例"配置区块 - 删除 JavaScript 中的 addPartner 和 removePartner 方法 - 更新 README.md 移除合作伙伴相关说明 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
116 lines
3.9 KiB
PHP
116 lines
3.9 KiB
PHP
<?php
|
|
namespace addon\theme_configurator\model;
|
|
|
|
use think\facade\Config;
|
|
use think\facade\Db;
|
|
|
|
/**
|
|
* 主题配置模型
|
|
*/
|
|
class ThemeConfigModel
|
|
{
|
|
public const TABLE = 'addon_theme_configurator';
|
|
|
|
public static function tableName(): string
|
|
{
|
|
$connections = Config::get('database.connections', []);
|
|
$defaultConnection = Config::get('database.default', 'mysql');
|
|
$prefix = $connections[$defaultConnection]['prefix'] ?? Config::get('database.prefix', '');
|
|
return $prefix . self::TABLE;
|
|
}
|
|
|
|
protected function query()
|
|
{
|
|
return Db::name(self::TABLE);
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
*/
|
|
public function getConfig(): array
|
|
{
|
|
$row = $this->query()->order('id', 'asc')->find();
|
|
if (!$row) {
|
|
return $this->defaultConfig();
|
|
}
|
|
|
|
$config = json_decode($row['config'], true);
|
|
return is_array($config) ? $config : $this->defaultConfig();
|
|
}
|
|
|
|
/**
|
|
* 保存配置
|
|
*/
|
|
public function saveConfig(array $config): array
|
|
{
|
|
$payload = [
|
|
'config' => json_encode($config, JSON_UNESCAPED_UNICODE),
|
|
'update_time' => time(),
|
|
];
|
|
|
|
$exists = $this->query()->order('id', 'asc')->find();
|
|
if ($exists) {
|
|
$this->query()->where('id', $exists['id'])->update($payload);
|
|
} else {
|
|
$this->query()->insert($payload);
|
|
}
|
|
|
|
return $config;
|
|
}
|
|
|
|
/**
|
|
* 安装时写入默认配置
|
|
*/
|
|
public function initConfig(): void
|
|
{
|
|
$exists = $this->query()->order('id', 'asc')->find();
|
|
if (!$exists) {
|
|
$this->saveConfig($this->defaultConfig());
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 默认结构
|
|
*/
|
|
protected function defaultConfig(): array
|
|
{
|
|
return [
|
|
'seo' => [
|
|
'title' => 'BlackFruit-UI',
|
|
'keywords' => '云服务器,主题云,BlackFruit',
|
|
'description' => 'BlackFruit-UI 默认站点说明',
|
|
],
|
|
// 顶部/底部导航
|
|
'header_nav' => [],
|
|
'footer_nav' => [],
|
|
// 站点基础信息
|
|
'site_config' => [
|
|
'enterprise_name' => '主题云',
|
|
'enterprise_telephone' => '400-000-0000',
|
|
'enterprise_mailbox' => 'support@example.com',
|
|
'enterprise_qrcode' => '/upload/qrcode.png',
|
|
'official_website_logo' => '/upload/logo.png',
|
|
// 在线客服链接,对应原主题中的 online_customer_service_link
|
|
'online_customer_service_link' => 'http://www.test.com',
|
|
'icp_info' => '京ICP备示例号',
|
|
'icp_info_link' => 'https://beian.miit.gov.cn/#/Integrated/index',
|
|
'public_security_network_preparation' => '京公网安备示例号',
|
|
'public_security_network_preparation_link' => 'https://beian.mps.gov.cn/#/query/webSearch',
|
|
'telecom_appreciation' => '增值电信业务经营许可证',
|
|
'copyright_info' => '© ' . date('Y') . ' 主题云',
|
|
'terms_service_url' => '/agreement/service.html',
|
|
'terms_privacy_url' => '/agreement/privacy.html',
|
|
'cloud_product_link' => '/cart/goods.htm?id=1',
|
|
'dcim_product_link' => '/cart/goods.htm?id=2',
|
|
],
|
|
// 友情链接、轮播、侧边浮窗等
|
|
'friendly_link' => [],
|
|
'banner' => [],
|
|
'side' => [],
|
|
// 用于 /console/v1/common 的扩展字段
|
|
'feedback_type' => [],
|
|
'honor' => [],
|
|
];
|
|
}
|
|
}
|