feat: 整合門市領料日誌、API 文件存取、修改庫存與併發編號問題、供應商商品內聯編輯及日誌 UI 優化
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m0s
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m0s
This commit is contained in:
@@ -13,6 +13,43 @@ use Stancl\Tenancy\Middleware\InitializeTenancyByDomainOrSubdomain;
|
||||
// 登入/登出路由
|
||||
|
||||
|
||||
Route::get('/api/docs', function () {
|
||||
$path = resource_path('markdown/manual/api-integration.md');
|
||||
|
||||
if (!file_exists($path)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$markdown = file_get_contents($path);
|
||||
|
||||
// 解析 Markdown 內容
|
||||
$content = Illuminate\Support\Str::markdown($markdown, [
|
||||
'html_input' => 'strip',
|
||||
'allow_unsafe_links' => false,
|
||||
]);
|
||||
|
||||
// 萃取 TOC (簡單的正則表達式抓取 ## 標題)
|
||||
preg_match_all('/^##\s+(.+)$/m', $markdown, $matches);
|
||||
$toc = collect($matches[1])->map(function ($text) {
|
||||
return [
|
||||
'id' => Illuminate\Support\Str::slug($text),
|
||||
'text' => $text,
|
||||
];
|
||||
});
|
||||
|
||||
// 替換內容中的 ## 標題以加入 ID 錨點 (讓左側導覽能跳轉)
|
||||
foreach ($toc as $item) {
|
||||
$content = str_replace("<h2>{$item['text']}</h2>", "<h2 id=\"{$item['id']}\">{$item['text']}</h2>", $content);
|
||||
}
|
||||
|
||||
return view('docs.api', [
|
||||
'content' => $content,
|
||||
'toc' => $toc,
|
||||
'title' => '外部系統 API 對接手冊'
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Route::middleware('auth')->group(function () {
|
||||
// 儀表板 - 所有登入使用者皆可存取
|
||||
|
||||
|
||||
Reference in New Issue
Block a user