returnJson($msg, $code, $data); } /** * 缓存页面(具体视图驱动完成此功能) * @param bool $param * @return $this */ protected function cache($param = true) { view_cache($param); return $this; } /** * 赋值到视图 * @param $name * @param $value */ protected function param($name, $value) { view_param($name, $value); } /** * 渲染视图 * @param string $file * @param array $param * @param bool $cache * @return mixed */ protected function view($file = '', $param = [], $cache = false) { return view($file, $param, $cache); } /** * 跳转 * @param $url */ protected function redirect($url) { return redirect($url); } /** * 显示提示页面 * @param $message * @param string $url * @param int $sec * @return false|mixed|string */ protected function tips($message, $url = '', $sec = 3) { if (request()->isAjax()) { return $this->json($message, '', 'tips', ['url' => $url, 'sec' => $sec]); } else { $viewConfig = Config::instance()->get('view'); $tipsTemplate = $viewConfig['dir'] . 'tips.' . $viewConfig['ext']; (!file_exists($tipsTemplate)) && file_put_contents($tipsTemplate, ''); return view('tips', [ 'message' => $message, 'url' => $url, 'sec' => $sec ]); } } }