+86
++86
+diff --git a/app/admin/controller/Cms/Banner/BannerController.php b/app/admin/controller/Cms/Banner/BannerController.php index fb37f0a..03794fa 100644 --- a/app/admin/controller/Cms/Banner/BannerController.php +++ b/app/admin/controller/Cms/Banner/BannerController.php @@ -23,7 +23,7 @@ class BannerController extends BaseController try { $banners = Banner::where('delete_time', null) ->where('tid', $this->getTenantId()) - ->order('sort', 'asc') + ->order('sort desc, id desc') ->field('id, title, desc, url, image, sort, create_time, update_time') ->select() ->toArray(); diff --git a/app/admin/controller/SiteSettingsController.php b/app/admin/controller/SiteSettingsController.php index cb35e59..0ed1604 100644 --- a/app/admin/controller/SiteSettingsController.php +++ b/app/admin/controller/SiteSettingsController.php @@ -34,6 +34,8 @@ class SiteSettingsController extends BaseController 'sitename' => '', 'logo' => '', 'logow' => '', + 'ico' => '', + 'companyintroduction' => '', 'description' => '', 'copyright' => '', 'companyname' => '', @@ -44,6 +46,8 @@ class SiteSettingsController extends BaseController 'sitename' => $siteSetting->sitename ?? '', 'logo' => $siteSetting->logo ?? '', 'logow' => $siteSetting->logow ?? '', + 'ico' => $siteSetting->ico ?? '', + 'companyintroduction' => $siteSetting->companyintroduction ?? '', 'description' => $siteSetting->description ?? '', 'copyright' => $siteSetting->copyright ?? '', 'companyname' => $siteSetting->companyname ?? '', @@ -85,12 +89,18 @@ class SiteSettingsController extends BaseController if (isset($rawData['sitename'])) { $siteSetting->sitename = (string)$rawData['sitename']; } + if (isset($rawData['companyintroduction'])) { + $siteSetting->companyintroduction = (string)$rawData['companyintroduction']; + } if (isset($rawData['logo'])) { $siteSetting->logo = (string)$rawData['logo']; } if (isset($rawData['logow'])) { $siteSetting->logow = (string)$rawData['logow']; } + if (isset($rawData['ico'])) { + $siteSetting->ico = (string)$rawData['ico']; + } if (isset($rawData['description'])) { $siteSetting->description = (string)$rawData['description']; } diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 748e185..d5f0303 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -6,9 +6,9 @@ namespace app\index\controller; use app\model\Banner; use app\index\BaseController; -use app\model\FrontMenu; -use app\model\OnePage; -use app\model\System\SystemSiteSettings; +use app\model\Cms\FrontMenu; +use app\model\Cms\OnePage; +use app\model\System\SystemSiteSetting; use app\service\ThemeService; use think\db\exception\DbException; use think\facade\Env; @@ -29,21 +29,21 @@ class Index extends BaseController { // 获取请求对象 $request = $this->request ?? Request::instance(); - + // 优先从请求对象获取中间件设置的租户ID(通过域名解析) $tid = $request->tenantId ?? 0; - + // 兼容:从header获取 if ($tid == 0) { $headerTid = $request->header('X-Tenant-Id'); - $tid = $headerTid ? (int)$headerTid : 0; + $tid = $headerTid ? (int) $headerTid : 0; } - + // 调试:检查tid if ($tid === 0) { die('tenantId未获取到,请检查域名解析'); } - + // 获取租户选择的模板 $themeKey = 'default'; if ($tid > 0) { @@ -54,11 +54,11 @@ class Index extends BaseController ->find(); $themeKey = $config['value'] ?? 'default'; } - + // 模板路径:/themes/{theme_key}/,优先使用index.php,其次index.html $themeBasePath = root_path() . 'public' . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $themeKey; $themeUrlPath = '/themes/' . $themeKey . '/'; - + if (is_file($themeBasePath . DIRECTORY_SEPARATOR . 'index.php')) { // 渲染PHP模板(直接include) return $this->renderPhpTemplate($themeBasePath . DIRECTORY_SEPARATOR . 'index.php', $themeUrlPath); @@ -69,11 +69,11 @@ class Index extends BaseController $content = $this->fixTemplateAssets($content, $themeUrlPath); return response($content, 200, ['Content-Type' => 'text/html; charset=utf-8']); } - + // 模板不存在,返回默认 return view('index/index'); } - + /** * 修复模板中的资源路径 * 将相对路径 (assets/, css/, js/, images/) 转换为绝对路径 (/themes/xxx/) @@ -82,7 +82,7 @@ class Index extends BaseController { // 需要修复的资源目录 $assetsDirs = ['assets', 'css', 'js', 'images', 'img', 'fonts', 'plugins', 'libs']; - + foreach ($assetsDirs as $dir) { // 匹配 src="assets/..." 或 href="css/..." 等相对路径 // 不匹配已以 / 开头的绝对路径 @@ -98,10 +98,10 @@ class Index extends BaseController $content ); } - + return $content; } - + /** * 渲染PHP模板文件 */ @@ -111,17 +111,17 @@ class Index extends BaseController if (!defined('THEME_URL')) { define('THEME_URL', $themeUrlPath); } - + ob_start(); // 获取URL参数 $getParams = Request::get(); extract($getParams, EXTR_OVERWRITE); include $templateFile; $content = ob_get_clean(); - + // 修复PHP模板输出中的资源路径 $content = $this->fixTemplateAssets($content, $themeUrlPath); - + return response($content, 200, ['Content-Type' => 'text/html; charset=utf-8']); } @@ -133,10 +133,10 @@ class Index extends BaseController { // 优先从请求对象获取中间件设置的租户ID(通过域名解析) $tid = $this->request->tenantId ?? 0; - + // 兼容:URL参数传递的tid作为备用 $tid = $tid > 0 ? $tid : Request::param('tid', 0, 'int'); - + // 从TemplateSiteConfig获取配置(根据租户ID) $config = null; if ($tid > 0) { @@ -144,12 +144,12 @@ class Index extends BaseController ->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 { @@ -158,9 +158,9 @@ class Index extends BaseController return json([ 'code' => 200, - 'msg' => 'success', + 'msg' => 'success', 'data' => [ - 'theme_key' => $themeKey, + 'theme_key' => $themeKey, 'theme_path' => $themePath ] ]); @@ -324,39 +324,13 @@ class Index extends BaseController } /** - * 前端底部数据 + * 获取首页综合数据 * @return \think\response\Json */ - public function getFooterData() + public function getHomeData() { try { - $footerData = SystemSiteSettings::where('delete_time', null) - ->field('label, value') - ->select() - ->toArray(); - - return json([ - 'code' => 200, - 'msg' => 'success', - 'data' => $footerData - ]); - } catch (DbException $e) { - return json([ - 'code' => 500, - 'msg' => 'fail:' . $e->getMessage(), - 'data' => null - ]); - } - } - - /** - * 获取友情链接列表 - * @return \think\response\Json - */ - public function getFriendlinkList() - { - try { - // 通过域名获取租户ID + // 1. 通过域名获取租户ID $tid = BaseController::getTenantIdByDomain(); if (empty($tid)) { @@ -367,23 +341,34 @@ class Index extends BaseController ]); } + // 2. 获取站点基础信息 (normalinfos) + $normalInfos = SystemSiteSetting::where('tid', $tid) + ->field('sitename,logo,logow,ico,description,copyright,companyname,icp,companyintroduction') + ->find(); + + // 3. 获取友情链接列表 $friendlinkList = Friendlink::where('delete_time', null) ->where('tid', $tid) ->where('status', 1) ->order('sort', 'asc') - ->field('id,link_name,link_url,link_logo,description') + ->field('id,link_name,link_url,link_logo') ->select() ->toArray(); + // 4. 合并返回 return json([ 'code' => 200, 'msg' => 'success', - 'data' => $friendlinkList + 'data' => [ + 'normal' => $normalInfos ?: (object) [], + 'links' => $friendlinkList + ] ]); - } catch (DbException $e) { + + } catch (\Exception $e) { return json([ 'code' => 500, - 'msg' => 'fail:' . $e->getMessage(), + 'msg' => '服务器错误:' . $e->getMessage(), 'data' => null ]); } diff --git a/app/index/route/app.php b/app/index/route/app.php index 24626fa..35ad6a4 100644 --- a/app/index/route/app.php +++ b/app/index/route/app.php @@ -12,7 +12,7 @@ Route::get('init', 'app\index\controller\Index@init'); Route::get('footerdata', 'app\index\controller\Index@getFooterData'); Route::get('companyInfos', 'app\index\controller\Index@getCompanyInfos'); Route::post('requirement', 'app\index\controller\Index@requirement'); -Route::get('friendlinks', 'app\index\controller\Index@getFriendlinkList'); +Route::get('homeData', 'app\index\controller\Index@getHomeData'); // --- 客户需求路由 --- diff --git a/app/model/System/SystemSiteSetting.php b/app/model/System/SystemSiteSetting.php index bb93125..723b62d 100644 --- a/app/model/System/SystemSiteSetting.php +++ b/app/model/System/SystemSiteSetting.php @@ -32,6 +32,8 @@ class SystemSiteSetting extends Model 'sitename' => 'string', 'logo' => 'string', 'logow' => 'string', + 'ico' => 'string', + 'companyintroduction' => 'string', 'description' => 'string', 'copyright' => 'string', 'companyname' => 'string', diff --git a/public/.htaccess b/public/.htaccess index a93d18b..2f9cd71 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -6,6 +6,16 @@ RewriteCond %{REQUEST_METHOD} OPTIONS RewriteRule ^(.*)$ $1 [R=204,L] + # 排除静态文件和特定PHP文件 + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_URI} !^/themes/ + RewriteCond %{REQUEST_URI} !^/static/ + RewriteCond %{REQUEST_URI} !^/storage/ + RewriteCond %{REQUEST_URI} !^/favicon.ico$ + RewriteCond %{REQUEST_URI} !^/robots.txt$ + RewriteRule ^(.*)$ index.php [L] + # 添加 CORS 头 Header set Access-Control-Allow-Origin "http://localhost:5173" Header set Access-Control-Allow-Credentials "true" diff --git a/public/news/article_detail.php b/public/news/article_detail.php new file mode 100644 index 0000000..8b894a3 --- /dev/null +++ b/public/news/article_detail.php @@ -0,0 +1,5 @@ +initialize(); + +// 获取基础环境信息 +$host = $_SERVER['HTTP_HOST'] ?? ''; +$scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; +$baseUrl = $scheme . '://' . $host; +$themeBase = '/themes/default'; + +// 获取文章 ID +$articleId = isset($_GET['id']) ? (int)$_GET['id'] : 0; + +// 辅助处理函数 +function formatImageUrl($path, $baseUrl) +{ + if (empty($path)) return ''; + if (preg_match('/^https?:\/\//', $path)) return $path; + return $baseUrl . (strpos($path, '/') === 0 ? '' : '/') . $path; +} + +try { + // 1. 获取租户 ID + $tenantDomain = Db::name('mete_tenant_domain') + ->where('full_domain', $host) + ->where('status', 1) + ->whereNull('delete_time') + ->find(); + $tid = $tenantDomain ? (int)$tenantDomain['tid'] : 0; + + if ($tid === 0 || $articleId === 0) { + die("未找到相关内容"); + } + + // 2. 获取站点基础信息 + $setting = Db::name('mete_system_site_setting')->where('tid', $tid)->whereNull('delete_time')->find(); + $tenant = Db::name('mete_tenant')->where('id', $tid)->whereNull('delete_time')->find(); + $siteInfo = array_merge($tenant ?: [], $setting ?: []); + + // 3. 获取文章详细数据 + $article = Db::name('mete_articles') + ->where('id', $articleId) + ->where('tid', $tid) + ->whereNull('delete_time') + ->find(); + + if (!$article) { + die("文章不存在或已删除"); + } + + // 更新阅读数 (可选) + Db::name('mete_articles')->where('id', $articleId)->inc('views')->update(); +} catch (\Exception $e) { + die("系统错误: " . $e->getMessage()); +} +?> + + + +
+ + +最新动态与行业资讯,持续更新。
+Stop wasting time and money designing and managing a website that doesn’t get results. Happiness guaranteed,
++ +
我们始终以专业、高效、创新为核心,深耕行业多年,形成了独具优势的特色业务体系。凭借成熟的服务流程、过硬的技术实力与丰富的实战经验,为客户提供一站式、定制化解决方案。
++ 我们始终以专业、高效、创新为核心,深耕行业多年,形成了独具优势的特色业务体系。凭借成熟的服务流程、过硬的技术实力与丰富的实战经验,为客户提供一站式、定制化解决方案。
+86
++86
+
+
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ Call To Action +Necessitatibus eius consequatur ex aliquid fuga eum quidem sint consectetur velit
+
+
+
+
+
+
+
+
+