chore: 重写初始提交(清空历史,整理后全量提交)

This commit is contained in:
ywxapp
2026-08-16 16:54:14 +08:00
commit 6c1a106bc1
1808 changed files with 238144 additions and 0 deletions
+81
View File
@@ -0,0 +1,81 @@
<?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\docs\controller;
use addon\docs\model\DocsProject;
use ywxapp\controller\FrontendBase;
/**
* 文档中心前台基类
*
* 统一注入站点标题与项目列表,供顶部导航与项目切换使用。
*
* @author ywxapp <admin@ywxapp.cn>
*/
class DocsFrontend extends FrontendBase
{
// 文档为公开内容,不做登录拦截
protected $noNeedLogin = ['*'];
protected $noNeedVerify = ['*'];
/**
* 插件配置
* @var array
*/
protected $docsConfig = [];
/**
* 初始化
*/
public function _initialize()
{
parent::_initialize();
$this->docsConfig = $this->loadConfig();
$this->view->assign([
'docsTitle' => $this->docsConfig['site_title'] ?? 'YwxApp 文档中心',
'projectList' => DocsProject::enabledList(),
'currentYear' => date('Y'),
]);
}
/**
* 模板变量赋值
*
* AddonFrontend 基类只暴露 $this->view,这里补一个代理方法,
* 使前台控制器与后台 AddonBackend 保持一致的 assign() 写法。
*
* @param string|array $name 变量名或键值数组
* @param mixed $value 变量值
* @return $this
*/
public function assign($name, $value = null)
{
$this->view->assign($name, $value);
return $this;
}
/**
* 读取插件配置
*
* @return array
*/
protected function loadConfig(): array
{
try {
$config = get_addon_config('docs');
return is_array($config) ? $config : [];
} catch (\Throwable $e) {
return [];
}
}
}