Files
YwxAppThink/addon/seo/controller/Index.php
T

58 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp <admin@ywxapp.cn>
// +----------------------------------------------------------------------
declare(strict_types=1);
namespace addon\seo\controller;
use ywxapp\controller\FrontendBase;
use think\Response;
/**
* SEO增强前台控制器
*
* 对外提供站点地图、robots 与状态页。无需登录即可访问。
*/
class Index extends FrontendBase
{
protected $noNeedLogin = ['*'];
protected $noNeedVerify = ['*'];
/**
* 前台状态页
*/
public function index()
{
// TODO: 前台展示/状态页
$this->view->assign('title', 'SEO增强');
return $this->view->fetch('index/index');
}
/**
* 站点地图(/seo/sitemap.xml
*/
public function sitemap()
{
// TODO: 遍历站点 URL 生成符合 sitemaps.org 规范的 XML
$xml = '<?xml version="1.0" encoding="UTF-8"?>'
. '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"></urlset>';
return Response::create($xml, 'xml')->contentType('application/xml');
}
/**
* robots.txt/seo/robots.txt
*/
public function robots()
{
// TODO: 读取 wxapp_seo_config.robots 输出;此处为默认兜底
$txt = "Member-agent: *\nAllow: /";
return Response::create($txt)->contentType('text/plain');
}
}