东方大厦
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
yiqiu
2025-11-22 01:14:47 +08:00
parent 095ff222a1
commit 51fd1035aa
8 changed files with 299 additions and 483 deletions

View File

@@ -1,11 +1,86 @@
<!DOCTYPE html>
<html lang="en" theme-color="default" theme-mode id="addons_js" addons_js='{:json_encode($addons)}'>
<head>
<meta charset="UTF-8">
<title>{$title}</title>
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
<head>
{php}
// 在渲染阶段从主题配置插件读取配置,并覆盖 $data 与 SEO 变量,实现 SSR
if (class_exists('\\addon\\theme_configurator\\model\\ThemeConfigModel')) {
$cfgModel = new \addon\theme_configurator\model\ThemeConfigModel();
$themeCfg = $cfgModel->getConfig();
if (is_array($themeCfg)) {
$site = isset($themeCfg['site_config']) && is_array($themeCfg['site_config'])
? $themeCfg['site_config']
: [];
if (!isset($data) || !is_array($data)) {
$data = [];
}
// 覆盖 / 补充首页相关结构数据
if (isset($themeCfg['banner'])) {
$data['banner'] = $themeCfg['banner'];
}
if (isset($themeCfg['honor'])) {
$data['honor'] = $themeCfg['honor'];
}
if (isset($themeCfg['partner'])) {
$data['partner'] = $themeCfg['partner'];
}
if (isset($themeCfg['friendly_link'])) {
$data['friendly_link'] = $themeCfg['friendly_link'];
}
if (isset($themeCfg['header_nav'])) {
$data['header_nav'] = $themeCfg['header_nav'];
}
if (isset($themeCfg['footer_nav'])) {
$data['footer_nav'] = $themeCfg['footer_nav'];
}
if (isset($themeCfg['side'])) {
$data['side_floating_window'] = $themeCfg['side'];
}
// 站点基础信息,供 header/footer 与其他模板直接使用
$data['enterprise_name'] = $site['enterprise_name'] ?? ($data['enterprise_name'] ?? '');
$data['enterprise_telephone'] = $site['enterprise_telephone'] ?? ($data['enterprise_telephone'] ?? '');
$data['enterprise_mailbox'] = $site['enterprise_mailbox'] ?? ($data['enterprise_mailbox'] ?? '');
$data['enterprise_qrcode'] = $site['enterprise_qrcode'] ?? ($data['enterprise_qrcode'] ?? '');
$data['official_website_logo']= $site['official_website_logo']?? ($data['official_website_logo']?? '');
$data['online_customer_service_link'] =
$site['online_customer_service_link'] ?? ($data['online_customer_service_link'] ?? '');
$data['icp_info'] = $site['icp_info'] ?? ($data['icp_info'] ?? '');
$data['icp_info_link'] = $site['icp_info_link'] ?? ($data['icp_info_link'] ?? '');
$data['public_security_network_preparation'] =
$site['public_security_network_preparation'] ??
($data['public_security_network_preparation'] ?? '');
$data['public_security_network_preparation_link'] =
$site['public_security_network_preparation_link'] ??
($data['public_security_network_preparation_link'] ?? '');
$data['telecom_appreciation'] = $site['telecom_appreciation'] ?? ($data['telecom_appreciation'] ?? '');
$data['copyright_info'] = $site['copyright_info'] ?? ($data['copyright_info'] ?? '');
$data['terms_service_url'] = $site['terms_service_url'] ?? ($data['terms_service_url'] ?? '');
$data['terms_privacy_url'] = $site['terms_privacy_url'] ?? ($data['terms_privacy_url'] ?? '');
$data['cloud_product_link'] = $site['cloud_product_link'] ?? ($data['cloud_product_link'] ?? '');
$data['dcim_product_link'] = $site['dcim_product_link'] ?? ($data['dcim_product_link'] ?? '');
// SEO如插件配置了 SEO则覆盖控制器传入的标题/关键词/描述
if (!empty($themeCfg['seo']['title'])) {
$title = $themeCfg['seo']['title'];
}
if (!empty($themeCfg['seo']['keywords'])) {
$keywords = $themeCfg['seo']['keywords'];
}
if (!empty($themeCfg['seo']['description'])) {
$description = $themeCfg['seo']['description'];
}
}
}
{/php}
<meta charset="UTF-8">
<title>{$title}</title>
<meta name="keywords" content="{$keywords}" />
<meta name="description" content="{$description}" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -33,13 +108,22 @@
<link rel="alternate" hreflang="zh-Hans" href="{$url}">
<link rel="canonical" href="{$url}">
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{$url}",
<script type="application/ld+json">
{
"@context": "https://ziyuan.baidu.com/contexts/cambrian.jsonld",
"@id": "{$url}",
"title": "{$title}",
"description": "{$description}",
"pubDate": "{$pub_date}",
"upDate": "{$up_date}"
}
</script>
"upDate": "{$up_date}"
}
</script>
<script>
// 将后端注入的配置映射到前端变量,供旧脚本兼容使用,避免再次通过接口请求主题配置
window.__themeCommon = {:json_encode(isset($data) ? $data : [])};
try {
if (!sessionStorage.commentData) {
sessionStorage.commentData = JSON.stringify(window.__themeCommon || {});
}
} catch (e) {}
</script>