💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 后端新增代码 * [ ] `介绍` 由于有些功能尚未开发,在原有基础上新加的功能,用法详见模板使用。 ***** ## 路径:\application\common.php;功能:判断是否是在首页 ``` //判断是否是在首页 function isIndex(){ $request = \think\Request::instance(); if( strtolower($request->controller()) == 'index' && strtolower($request->action()) == 'index'){ return true; }else{ return false; } } ``` ***** ## 路径:\application\common.php;功能:获取栏目信息 ``` /** * 获取栏目信息 * @param $outlink :所属标签的路径 * eg:路径通常用$__指定标签__['url'];表单比较特殊,列表表单用$__表单标签__['url'],提交表单用url($__表单标签__['redirecturl']) * @return 栏目信息 */ function outlinkFindChannel($outlink) { $channel = \addons\cms\model\Channel::field('*')->where('outlink', $outlink)->find(); return $channel; } ``` ## 路径:\application\common.php;功能:根据id获取栏目信息 ~~~ /** * 根据id获取栏目信息 * @param $id :栏目ID *@return 栏目信息 */ function getParentChannel($id){ $channel = \addons\cms\model\Channel::field('*')->where('id', $id)->find(); return $channel; } ~~~ ## 路径:\addons\cms\controller\Base.php,\application\admin\controller\cms\Ajax.php,\addons\cms\config.php;功能:区分移动端跟PC端(Base.php跟config.php同时修改)。 ## 替换包(可直接下载替换包修改Ajax.php跟Base.php,config文件还是得按照下面内容修改。提取码: tbjr):[下载](https://pan.baidu.com/s/1se8Pm436xk7JMTrGwiZUNA) ~~~ Base.php(记得引入use think\Request;): 将以下代码: // 设定主题模板目录 $this->view->engine->config('view_path', $this->view->engine->config('view_path') . $config['theme'] . DS); 修改成如下: //判断是否是移动端 if (Request::instance()->isMobile()) { $theme = $config['thememobile']; } else { $theme = $config['themepc']; } // 设定主题模板目录 $this->view->engine->config('view_path', $this->view->engine->config('view_path') . $theme . DS); ---------------------------------------------------------------------------------------------- Ajax.php(记得引入use think\Request;): 将一下代码: $themeDir = ADDON_PATH . 'cms' . DS . 'view' . DS . $config['theme'] . DS; 修改成如下: //判断是否是移动端 if (Request::instance()->isMobile()) { $theme = $config['thememobile']; } else { $theme = $config['themepc']; } $themeDir = ADDON_PATH . 'cms' . DS . 'view' . DS . $theme . DS; ---------------------------------------------------------------------------------------------- config.php 将以下代码: [ 'name' => 'theme', 'title' => '皮肤', 'type' => 'string', 'content' => [], 'value' => 'default', 'rule' => 'required', 'msg' => '', 'tip' => '请确保addons/cms/view有相应的目录', 'ok' => '', 'extend' => '', ], 修改成如下: [ 'name' => 'themepc', 'title' => 'PC皮肤', 'type' => 'string', 'content' => [], 'value' => 'default', 'rule' => 'required', 'msg' => '', 'tip' => '请确保addons/cms/view有相应的目录', 'ok' => '', 'extend' => '', ], [ 'name' => 'thememobile', 'title' => '手机皮肤', 'type' => 'string', 'content' => [], 'value' => 'mobile', 'rule' => 'required', 'msg' => '', 'tip' => '请确保addons/cms/view有相应的目录', 'ok' => '', 'extend' => '', ], ~~~