更新网站架构
This commit is contained in:
@@ -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
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user