|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Created by PhpStorm.
|
|
|
|
* User: zhl
|
|
|
|
* Date: 2024/2/19
|
|
|
|
* Time: 15:46
|
|
|
|
*/
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
class CreateHtmlService
|
|
|
|
{
|
|
|
|
public function __construct(){}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 返回最终需要的HTML
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHtml($project, $route, $lang = [], $page = 0)
|
|
|
|
{
|
|
|
|
// 获取页面信息
|
|
|
|
$page_info = $this->getInfoByRoute($route);
|
|
|
|
|
|
|
|
// 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
|
|
|
|
if ($project && $page_info) {
|
|
|
|
$html = $this->getHtmlV6();
|
|
|
|
} else {
|
|
|
|
$html = $this->getHtmlV5();
|
|
|
|
}
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 返回5.0页面最终HTML
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getHtmlV5()
|
|
|
|
{
|
|
|
|
$html = '';
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 返回6.0页面最终HTML
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function getHtmlV6()
|
|
|
|
{
|
|
|
|
// 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
|
|
|
|
|
|
|
|
$origin_html = $this->originHtml();
|
|
|
|
$html = $this->renderData($origin_html);
|
|
|
|
/** ... 调用其他方法, 直至返回完整的正确的HTML */
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据路由信息 返回 路由属性及详细信息
|
|
|
|
* @param string $route
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getInfoByRoute($route)
|
|
|
|
{
|
|
|
|
// TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取可视化HTML
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function originHtml()
|
|
|
|
{
|
|
|
|
$html = '根据路由查询数据库,并拼装HTML';
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 补充其他信息
|
|
|
|
* TDK a链接 mate信息等
|
|
|
|
* @param string $html
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function plugHead($html)
|
|
|
|
{
|
|
|
|
/** 渲染tdk信息、 mate信息、 嵌入信息、 图标信息*/
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 处理最终信息
|
|
|
|
* 处理标签、最后代码标识、特殊规则或者字符等
|
|
|
|
* @param string $html
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function processFinal($html)
|
|
|
|
{
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 渲染页面数据
|
|
|
|
* @param string $html
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function renderData($html)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 根据可视化HTML中关键词渲染数据
|
|
|
|
* 这个方法还需要进行拆分, 这个功能内容应该会比较多
|
|
|
|
* 并且还会根据路由信息和分页信息不同, 渲染不同数据, 只要针对列表页面
|
|
|
|
*/
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|