* @version : HUOSDK 7.2 */ namespace agent\common\controller; use think\Session; class BaseController extends \cmf\controller\BaseController { protected $web_info = []; public function _initialize() { Session::boot(); $this->common_assign(); parent::_initialize(); } // 初始化视图配置 protected function _initializeView() { $cmfAdminThemePath = config('cmf_theme_path'); $cmfAdminDefaultTheme = config('cmf_default_theme'); $themePath = "{$cmfAdminThemePath}{$cmfAdminDefaultTheme}"; $root = cmf_get_root(); //使cdn设置生效 $cdnSettings = cmf_get_option('cdn_settings'); if (empty($cdnSettings['cdn_static_root'])) { $viewReplaceStr = [ '__ROOT__' => $root, '__TMPL__' => "{$root}/{$themePath}", '__STATIC__' => STATICSITE, '__WEB_ROOT__' => $root ]; } else { $cdnStaticRoot = rtrim($cdnSettings['cdn_static_root'], '/'); $viewReplaceStr = [ '__ROOT__' => $root, '__TMPL__' => "{$cdnStaticRoot}/{$themePath}", '__STATIC__' => "{$cdnStaticRoot}", '__WEB_ROOT__' => $cdnStaticRoot ]; } $viewReplaceStr = array_merge(config('view_replace_str'), $viewReplaceStr); config('template.view_base', "$themePath/"); config('view_replace_str', $viewReplaceStr); } /** * 设置通用内容 */ public function common_assign() { $_path = $this->request->path(); $_selected = [ '1' => 'active', '2' => '', '3' => '', '4' => '', ]; if (strpos($_path, 'notice/index') !== false) { $_selected = [ '1' => '', '2' => '', '3' => 'active', '4' => '', ]; } elseif (strpos($_path, 'management/index') !== false) { $_selected = [ '1' => '', '2' => 'active', '3' => '', '4' => '', ]; } elseif (strpos($_path, 'document/index') !== false) { $_selected = [ '1' => '', '2' => '', '3' => '', '4' => 'active', ]; } elseif (strpos($_path, 'notice/read') !== false) { $_selected = [ '1' => '', '2' => '', '3' => 'active', '4' => '', ]; } $this->assign('selected', $_selected); } }