diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index cdccb83e..1e6a8e2f 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -343,4 +343,32 @@ public function getPageJSON(Request $request, $id, $page_id) 'updated_at' => $pageItem->updated_at->format('Y-m-d H:i:s'), ]; } + + /** + * read mode + * + * @param $id + * @param $page_id + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function readMode($id, $page_id) + { + /** @var Project $project */ + $project = Project::query()->findOrFail($id); + $policy = new ProjectPolicy(); + if (!$policy->view(\Auth::user(), $project)) { + abort(403, '您没有访问该项目的权限'); + } + + $page = Document::where('project_id', $id)->where('id', $page_id)->firstOrFail(); + $type = $page->type == Document::TYPE_DOC ? 'markdown' : 'swagger'; + + return view('share-show', [ + 'project' => $project, + 'pageItem' => $page, + 'type' => $type, + 'noheader' => true, + ]); + } } \ No newline at end of file diff --git a/resources/lang/en/document.php b/resources/lang/en/document.php index b4b72a47..1463579b 100644 --- a/resources/lang/en/document.php +++ b/resources/lang/en/document.php @@ -27,6 +27,7 @@ 'document_differ' => 'Document Differ', 'latest_document' => 'Latest', 'history_document' => 'History Archive', + 'read_mode' => 'Read Mode', 'after_modified' => 'After', 'select_template' => 'Choose Template', diff --git a/resources/lang/zh/document.php b/resources/lang/zh/document.php index 60fa1936..49ca1412 100644 --- a/resources/lang/zh/document.php +++ b/resources/lang/zh/document.php @@ -29,6 +29,7 @@ 'document_differ' => '文档差异对比', 'latest_document' => '最新文档', 'history_document' => '历史版本', + 'read_mode' => '阅读模式', 'after_modified' => '修改后', 'select_template' => '选择模板', diff --git a/resources/views/components/page-menus.blade.php b/resources/views/components/page-menus.blade.php index e8405c5c..b4fdc1fb 100644 --- a/resources/views/components/page-menus.blade.php +++ b/resources/views/components/page-menus.blade.php @@ -9,6 +9,10 @@ @lang('common.btn_share') + + + @lang('document.read_mode') + @if($pageItem->type == \App\Repositories\Document::TYPE_DOC) diff --git a/routes/web.php b/routes/web.php index 194cb17f..02fc5650 100644 --- a/routes/web.php +++ b/routes/web.php @@ -131,6 +131,9 @@ // 文档分享 Route::post('/{id}/doc/{page_id}/share', 'ShareController@create')->name('doc:share'); + // 阅读模式 + Route::get('/{id}/doc/{page_id}/read', 'DocumentController@readMode')->name('doc:read'); + // 文档评论 Route::post('/{id}/doc/{page_id}/comments', 'CommentController@publish')->name('doc:comment');