modelClass = new ModelsModel; //取得当前内容模型模板存放目录 $this->filepath = TEMPLATE_PATH . (empty(config('site.theme')) ? "default" : config('site.theme')) . DS . "cms" . DS; } //模型列表 public function index() { if ($this->request->isAjax()) { $data = $this->modelClass->where('module', 'cms')->select(); return json(["code" => 0, "data" => $data]); } return $this->fetch(); } /** * 获取模板列表 */ public function get_tpl_list() { $type = $this->request->param('type', 'category'); $keyValue = $this->request->param('keyValue'); $path = $this->filepath . $type; $list = str_replace($this->filepath, '', glob($path . '*.html')); $arr = []; foreach ($list as $key => $value) { if (!empty($keyValue) && $value != $keyValue) { continue; } $arr[]['name'] = $value; } return json(['count' => count($arr), 'data' => $arr]); } }