'docs' . DIRECTORY_SEPARATOR . '分红说明文档.md', 'filename' => '分红说明文档.md', 'ascii_fallback' => 'commission-share-guide.md', ]; private const DOC_EN = [ 'relative' => 'docs' . DIRECTORY_SEPARATOR . 'en' . DIRECTORY_SEPARATOR . 'commission-share-guide.md', 'filename' => 'commission-share-guide.md', 'ascii_fallback' => 'commission-share-guide.md', ]; public function content(Request $request): Response { $response = $this->initializeBackend($request); if ($response !== null) { return $response; } $doc = MarkdownDocReader::resolve($request, self::DOC_ZH, self::DOC_EN); if (!is_file($doc['path'])) { return $this->error(__('Document file not found')); } $raw = file_get_contents($doc['path']); if ($raw === false) { return $this->error(__('Failed to read document')); } return $this->success('', [ 'markdown' => $raw, 'filename' => $doc['filename'], 'lang' => $doc['lang'], ]); } public function download(Request $request): Response { $response = $this->initializeBackend($request); if ($response !== null) { return $response; } $doc = MarkdownDocReader::resolve($request, self::DOC_ZH, self::DOC_EN); if (!is_file($doc['path'])) { return $this->error(__('Document file not found')); } $body = file_get_contents($doc['path']); if ($body === false) { return $this->error(__('Failed to read document')); } $disposition = sprintf( 'attachment; filename="%s"; filename*=UTF-8\'\'%s', $doc['ascii_fallback'], rawurlencode($doc['filename']) ); return new Response(200, [ 'Content-Type' => 'text/markdown; charset=UTF-8', 'Content-Disposition' => $disposition, 'Cache-Control' => 'private, max-age=0, must-revalidate', ], $body); } }