param('file_path', ''); // 验证文件路径是否有效 if (empty($filePath) || !file_exists($filePath)) { return $this->err('文件不存在或路径无效'); } // 检查文件扩展名 $extension = pathinfo($filePath, PATHINFO_EXTENSION); if (strtolower($extension) !== 'md') { return $this->err('只支持查看Markdown文件(.md)'); } // 读取文件内容 $content = file_get_contents($filePath); // 将内容传递给视图 View::assign('file_path', $filePath); View::assign('content', $content); // 返回视图 return View::fetch("Markdown/index"); } /** * 显示Markdown文件 */ public function order_info() { // 获取goods_id 和 order_id $goods_id = request()->param('goods_id', ''); $order_num = request()->param('order_num', ''); if (empty($goods_id) || empty($order_num)) { return $this->err('参数错误'); } // 拼接文件路径 $filePath = './draw_log/' . $goods_id . '/' . $order_num . '.md'; // 获取文件路径参数 //$filePath = request()->param('file_path', ''); // 验证文件路径是否有效 if (empty($filePath) || !file_exists($filePath)) { return $this->err('日志不存在'); } // 检查文件扩展名 $extension = pathinfo($filePath, PATHINFO_EXTENSION); if (strtolower($extension) !== 'md') { return $this->err('只支持查看Markdown文件(.md)'); } // 读取文件内容 $content = file_get_contents($filePath); // 将内容传递给视图 View::assign('file_path', $filePath); View::assign('content', $content); // 返回视图 return View::fetch("Markdown/index"); } }