// +---------------------------------------------------------------------- declare (strict_types = 1); namespace app\frontend\controller; use ywxapp\controller\FrontendBase; /** * Index 类 * * @author ywxapp */ class Index extends FrontendBase { /** * Summary of needLogin * @var array */ protected $noNeedLogin = ["index", "hello"]; /** * Summary of needRight * @var array */ protected $noNeedVerify = []; /** * 控制器初始化 initialize * @return void */ protected function initialize() { } public function index() { // 模拟新闻数据(实际从数据库获取) $latest_news = [ [ 'id' => 1, 'title' => '公司荣获2023年度创新企业奖', 'description' => '在近日举办的行业峰会上...', 'create_at' => date('Y-m-d H:i:s'), 'views' => 128, ], [ 'id' => 2, 'title' => '智创科技发布新一代企业服务平台', 'description' => '全新平台整合了...', 'create_at' => date('Y-m-d H:i:s', strtotime('-2 days')), 'views' => 256, ], // ...更多数据 ]; return view('index', [ 'site_name' => '智创科技', 'seo_keywords' => '企业服务,数字化转型,软件开发', 'seo_description' => '智创科技专注企业数字化解决方案,10年行业经验,服务1000+企业客户', 'contact_phone' => '400-888-9999', 'contact_email' => 'service@zhichuang.com', 'company_address' => '北京市海淀区中关村大厦18层', 'icp_number' => '京ICP备12345678号', 'controller' => $this->request->controller(), 'latest_news' => $latest_news, ]); } public function hello($name = 'ThinkPHP8') { return 'hello,' . $name; } }