更新网站架构

This commit is contained in:
2026-03-09 16:35:17 +08:00
parent 4cbc52c51b
commit bf0daf987b
180 changed files with 60682 additions and 491 deletions
+26 -6
View File
@@ -12,6 +12,8 @@ use app\model\System\SystemSiteSettings;
use app\service\ThemeService;
use think\db\exception\DbException;
use think\facade\Env;
use think\facade\Request;
use app\model\Template\TemplateSiteConfig;
class Index extends BaseController
{
@@ -33,16 +35,34 @@ class Index extends BaseController
*/
public function init()
{
// 直接返回默认模板数据
// 获取租户ID(从请求参数)
$tid = Request::param('tid', 0, 'int');
// 从TemplateSiteConfig获取配置(根据租户ID
$config = null;
if ($tid > 0) {
$config = TemplateSiteConfig::where('tid', $tid)
->where('key', 'current_theme')
->find();
}
$themeKey = $config['value'] ?? 'default';
// 模板路径:/themes/{theme_key}/,优先使用index.php,其次index.html
$themeBasePath = root_path() . 'public' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $themeKey;
if (is_file($themeBasePath . DIRECTORY_SEPARATOR . 'index.php')) {
$themePath = '/themes/' . $themeKey . '/index.php';
} else {
$themePath = '/themes/' . $themeKey . '/index.html';
}
return json([
'code' => 200,
'msg' => 'success',
'data' => [
'theme_key' => 'default',
'theme_path' => '/themes/default/index.html',
'data' => [
'site_name' => '企业官网'
]
'theme_key' => $themeKey,
'theme_path' => $themePath
]
]);
}
+1
View File
@@ -1,5 +1,6 @@
<?php
return [
\app\common\middleware\AllowCrossDomain::class,
\app\common\middleware\DomainParse::class,
\think\middleware\SessionInit::class,
];