mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 23:42:48 +08:00
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
namespace app\index\controller;
|
|
|
|
use app\BaseController as AppBaseController;
|
|
use think\facade\Config;
|
|
use think\facade\View;
|
|
use think\helper\Str;
|
|
|
|
class BaseController extends AppBaseController
|
|
{
|
|
|
|
/**
|
|
* 是否使用多模板
|
|
* 仅当名称为空或者指定名称有效,
|
|
* 使用跨应用,跨控制器,引用模板路径的写法时无效
|
|
*
|
|
* @var boolean
|
|
*/
|
|
protected $isUseTpls = true;
|
|
|
|
public function assign($template,$value)
|
|
{
|
|
return View::assign($template,$value);
|
|
}
|
|
|
|
public function fetch($template = '',$vars = [])
|
|
{
|
|
if($this->isUseTpls && strpos($template,'@') === false && stripos($template,'/') === false){
|
|
|
|
if($template === ''){
|
|
$config_auto_rule = Config::get('view.auto_rule');
|
|
if (2 == $config_auto_rule) {
|
|
$template = $this->request->action(true);
|
|
} elseif (3 == $config_auto_rule) {
|
|
$template = $this->request->action();
|
|
} else {
|
|
$template = Str::snake($this->request->action());
|
|
}
|
|
}
|
|
return View::fetch(get_system_config('index_tpl_name').$template,$vars);
|
|
}else{
|
|
return View::fetch($template,$vars);
|
|
}
|
|
|
|
}
|
|
}
|