增加特色服务
This commit is contained in:
@@ -1,7 +1,65 @@
|
||||
<!-- header.php -->
|
||||
<?php
|
||||
// #########默认头部开始#########
|
||||
// 引入 ThinkPHP 应用
|
||||
require_once __DIR__ . '/../../../vendor/autoload.php';
|
||||
use think\facade\Db;
|
||||
use think\App;
|
||||
|
||||
$host = $_SERVER['HTTP_HOST'] ?? '';
|
||||
$scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http';
|
||||
$baseUrl = $scheme . '://' . $host;
|
||||
$baseUrl = $baseUrl ?? ($scheme . '://' . $host);
|
||||
$apiUrl = $apiUrl ?? 'https://api.yunzer.cn';
|
||||
|
||||
|
||||
/**
|
||||
* 核心请求函数:fetchApiData
|
||||
* 用于发送 GET 请求并解析 JSON
|
||||
*/
|
||||
function fetchApiData($url) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
// 如果是 HTTPS 接口且本地环境没配置证书,可以临时跳过验证(生产环境建议配置)
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($error) {
|
||||
return ['error' => $error];
|
||||
}
|
||||
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
// #########默认头部结束#########
|
||||
|
||||
// 调用 banner 接口
|
||||
$bannerUrl = $apiUrl . '/getBanners?baseUrl=' . urlencode($host);
|
||||
$bannersRes = fetchApiData($bannerUrl);
|
||||
$bannersList = $bannersRes['list'] ?? [];
|
||||
|
||||
// 调用 homeData 接口获取全局数据
|
||||
$homeDataUrl = $apiUrl . '/homeData?baseUrl=' . urlencode($host);
|
||||
$homeDataRes = fetchApiData($homeDataUrl);
|
||||
$homeInfo = $homeDataRes['data'] ?? [];
|
||||
|
||||
// 调用 getCenterNews 接口获取新闻数据
|
||||
$newsUrl = $apiUrl . '/getCenterNews?baseUrl=' . urlencode($host);
|
||||
$newsRes = fetchApiData($newsUrl);
|
||||
$newsList = $newsRes['list'] ?? [];
|
||||
|
||||
// 获取友链数据
|
||||
$friendlinkList = $homeInfo['links'] ?? [];
|
||||
|
||||
// 动态设置 SEO 变量
|
||||
$seoTitle = $pageTitle ?? ($homeInfo['normal']['sitename'] ?? '云泽网 默认标题');
|
||||
$seoDescription = $pageDescription ?? ($homeInfo['normal']['description'] ?? '');
|
||||
$seoKeywords = $pageKeywords ?? ($homeInfo['normal']['keywords'] ?? '');
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
@@ -10,10 +68,10 @@ $baseUrl = $scheme . '://' . $host;
|
||||
<meta charset="utf-8">
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
||||
<base href="/themes/template3/">
|
||||
<title><?php echo isset($pageTitle) ? $pageTitle : 'Nova'; ?></title>
|
||||
<meta name="description" content="<?php echo isset($pageDescription) ? $pageDescription : ''; ?>">
|
||||
<meta name="keywords" content="<?php echo isset($pageKeywords) ? $pageKeywords : ''; ?>">
|
||||
|
||||
|
||||
<title><?php echo htmlspecialchars($homeInfo['normal']['sitename']); ?></title>
|
||||
<meta name="description" content="<?php echo $homeInfo['normal']['description']; ?>">
|
||||
<meta name="keywords" content="<?php echo $seoKeywords; ?>">
|
||||
<link href="<?php echo $baseUrl; ?>/themes/template3/assets/img/favicon.png" rel="icon">
|
||||
<link href="<?php echo $baseUrl; ?>/themes/template3/assets/img/apple-touch-icon.png" rel="apple-touch-icon">
|
||||
|
||||
@@ -23,6 +81,7 @@ $baseUrl = $scheme . '://' . $host;
|
||||
<link href="<?php echo $baseUrl; ?>/themes/template3/assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
|
||||
<link href="<?php echo $baseUrl; ?>/themes/template3/assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet">
|
||||
|
||||
<link href="<?php echo $baseUrl; ?>/themes/template3/assets/css/style.css" rel="stylesheet">
|
||||
<link href="<?php echo $baseUrl; ?>/themes/template3/assets/css/main.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
@@ -32,7 +91,7 @@ $baseUrl = $scheme . '://' . $host;
|
||||
<div class="container-fluid container-xl position-relative d-flex align-items-center justify-content-between">
|
||||
|
||||
<a href="<?php echo $baseUrl; ?>/" class="logo d-flex align-items-center">
|
||||
<h1 class="sitename">Nova</h1>
|
||||
<img src="<?php echo $baseUrl . $homeInfo['normal']['logow']; ?>" alt="">
|
||||
</a>
|
||||
|
||||
<nav id="navmenu" class="navmenu">
|
||||
|
||||
Reference in New Issue
Block a user