This commit is contained in:
Default
2025-04-07 02:45:57 +08:00
parent ddbf53bd2b
commit 46fbd69470
3 changed files with 16 additions and 53 deletions

View File

@@ -83,44 +83,12 @@ abstract class BaseController
]);
}
/**
* 验证数据
* @access protected
* @param array $data 数据
* @param string|array $validate 验证器名或者验证规则数组
* @param array $message 提示信息
* @param bool $batch 是否批量验证
* @return array|string|true
* @throws ValidateException
* return fomart view string
*
* @param string $strTemplate
* @return string
*/
protected function validate(array $data, string|array $validate, array $message = [], bool $batch = false)
{
if (is_array($validate)) {
$v = new Validate();
$v->rule($validate);
} else {
if (strpos($validate, '.')) {
// 支持场景
[$validate, $scene] = explode('.', $validate);
}
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
$v = new $class();
if (!empty($scene)) {
$v->scene($scene);
}
}
$v->message($message);
// 是否批量验证
if ($batch || $this->batchValidate) {
$v->batch(true);
}
return $v->failException(true)->check($data);
}
public function rending($strTemplate = '')
{
View::assign("DomainModel", $this->request->DomainModel);

View File

@@ -40,7 +40,7 @@ class Index extends BaseController
$arrMoonRankNovel = $NovelModel->getRankNovelOnCache($strKey, 10, 0, 'monthly');
$strStatus = '已完结';
$arrEndNovelRankNovel = $NovelModel->getRankNovelOnCache($strKey, 10, 0, 'total',$strStatus);
$arrEndNovelRankNovel = $NovelModel->getRankNovelOnCache($strKey, 10, 0, 'total', $strStatus);
// Title 模板
ConverterMovel::setVal([
@@ -49,9 +49,9 @@ class Index extends BaseController
'strIndexDescription' => $this->request->DomainModel->d_index_description,
]);
// $strTitle = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__));
$strTitleTemplate = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__).'@TITLE');
$strKeywordsTemplate = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__).'@KEYWORDS');
$strDescriptionTemplate = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__).'@DESCRIPTION');
$strTitleTemplate = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__) . '@TITLE');
$strKeywordsTemplate = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__) . '@KEYWORDS');
$strDescriptionTemplate = $Request->DomainModel->getFomartSubject(getFomartSubjectKey(__METHOD__) . '@DESCRIPTION');
$strTitle = ConverterMovel::convert($strTitleTemplate);
@@ -71,11 +71,9 @@ class Index extends BaseController
'strDescription' => $strDescription,
]);
if ($boolIsMobile) {
return View::fetch();
} else {
return View::fetch('pc/index');
}
$strView = $boolIsMobile ? '' : 'pc/index';
return $this->rending($strView);
}
/**
@@ -92,7 +90,7 @@ class Index extends BaseController
// 推荐等级为9的连载的 随机15个小说
$arrRecommendSerializationNovel = $NovelModel->getHighLevelNovelOnCache($Request->DomainModel->d_domain, 13);
// 推荐等级为9的完结的 随机12个小说
$arrRecommendEndNovel = $NovelModel->getFinishedNovelOnCache($Request->DomainModel->d_domain, 12);
@@ -157,11 +155,8 @@ class Index extends BaseController
'strDescription' => $strDescription,
]);
$strView = $boolIsMobile ? '' : 'pc/index';
if ($boolIsMobile) {
return View::fetch();
} else {
return View::fetch('pc/index');
}
return $this->rending($strView);
}
}

View File

@@ -91,14 +91,14 @@
<!-- 现在是使用这个 -->
{$DomainModel->d_statis|raw}
{Request->DomainModel->d_statis|raw}
{:request()->DomainModel->d_statis}
<!-- FIXED 打开TP模板文档找到变量原样输出 -->
<!-- TODO 问题描述:下面 -->
<!-- 我这边测试: 无法调用用 Request 渲染 只能渲染 通过 view:assign() 传递过来的变量 START-->
<!-- 1.{Request->DomainModel->d_statis|raw} 这个在页面上展示的 就是: {Request->DomainModel->d_statis} -->
<!-- 2.{$DomainModel->d_statis|raw} 使用这个是可以正常渲染的这个在basecontroll 里面 加入 assign了你看看这样操作行不-->
<!-- TODO END -->
{:request()->DomainModel->d_domian}
</body>
</html>