| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- declare(strict_types=1);
- namespace Glacier\Controllers;
- use Glacier\Core\Logger;
- use Glacier\Core\Response;
- /**
- * 首页控制器(本期"开发中"占位;后期公司新闻 + 功能导航)。
- * P1 暂用内联 HTML,P2 切换为 Twig 模板渲染。
- */
- final class HomeController
- {
- public function index(array $params = []): never
- {
- Response::html($this->page('Glacier · 开发中', '<h1>Glacier 公司管理系统</h1><p>开发中,敬请期待。</p>'));
- }
- /** 参数路由演示(P1 验证用,后续移除)。 */
- public function demo(array $params = []): never
- {
- $name = $params['name'] ?? '';
- Logger::info('demo route hit', ['name' => $name]);
- Response::html($this->page('Demo · ' . $name, '<h1>参数路由演示</h1><p>参数 <code>name</code> = ' . e($name) . '</p>'));
- }
- /** 可选段演示(P1 验证用,后续移除)。 */
- public function demoPage(array $params = []): never
- {
- $page = $params['page'] ?? '1';
- Response::html($this->page('DemoPage · ' . $page, '<h1>可选段演示</h1><p>当前页 = ' . e($page) . '</p>'));
- }
- private function page(string $title, string $body): string
- {
- return '<!doctype html><html lang="zh-CN"><head><meta charset="utf-8">'
- . '<meta name="viewport" content="width=device-width, initial-scale=1">'
- . '<title>' . e($title) . '</title>'
- . '<style>body{font-family:system-ui,sans-serif;max-width:800px;margin:40px auto;padding:0 16px;color:#333}'
- . 'h1{color:#0b7a5f;border-bottom:2px solid #0b7a5f;padding-bottom:8px}'
- . 'code{background:#f0f0f0;padding:2px 6px;border-radius:4px}</style>'
- . '</head><body>' . $body . '</body></html>';
- }
- }
|