getList(Yii::$app->request->post()); if ($result['code']) { return $this->outJson(1, $result['data']); } else { return $this->outJson(0, [], $result['message']); } } /** * 查看日志 */ public function actionView() { $path = trim(Yii::$app->request->get('path')); $file = Yii::$app->getRuntimePath() . '/logs/app.log'; if (is_file($file)) { $contents = @file_get_contents($file); return $this->outJson(1, ['contents' => $contents]); } return $this->outJson(0, ['contents' => ''], '文件不存在'); } /** * 清空日志 */ public function actionTruncate() { $path = trim(Yii::$app->request->get('path')); $file = Yii::$app->getRuntimePath() . '/logs/app.log'; if (is_file($file)) { @file_put_contents($file, ''); return $this->outJson(1); } return $this->outJson(0); } }