1.新增显示分红说明文档菜单

2.文档新增英文版
This commit is contained in:
2026-05-29 11:18:10 +08:00
parent f3677eb0e3
commit 9be9e2666b
13 changed files with 1669 additions and 17 deletions

View File

@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
namespace app\admin\controller\docs;
use app\common\controller\Backend;
use app\common\library\docs\MarkdownDocReader;
use support\Response;
use Webman\Http\Request;
/**
* 后台只读展示《分红说明文档》Markdown并提供下载。
*/
class DocCommissionShare extends Backend
{
private const DOC_ZH = [
'relative' => '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);
}
}