@@ -19,15 +19,18 @@ export enum Chapters {
1919 xrobot_device = "/xrobot/device/" ,
2020 xrobot_api = "/xrobot/api/" ,
2121 xrobot_faq = "/xrobot/faq/" ,
22+ xrobot_guide = "/xrobot/guide" ,
23+ xrobot_guide_mp = "/xrobot/guide/mini-program" ,
2224}
2325
24- // 判断一个link是否是章节link
26+ // 判断一个link 字符串是否是章节link
2527export function isChapter < T extends Record < string , string > > (
2628 link : string
2729) : link is T [ keyof T ] {
28- return Object . values ( Chapters ) . includes ( link ) ;
30+ return Object . values ( Chapters ) . includes ( link as Chapters ) ;
2931}
3032
33+ // 给 ChapterItem 的 link 字段追加当前章节的 link 前缀
3134function apply_prefix ( item : ChapterItem , prefix : Chapters ) {
3235 if ( item ?. link . startsWith ( "/" ) && prefix . endsWith ( "/" ) ) {
3336 return { ...item , link : prefix . slice ( 0 , - 1 ) + item . link } ;
@@ -78,11 +81,39 @@ const items_xrobot_faq = [
7881 // 子章节
7982] ;
8083
84+ const items_xrobot_guide_mp = [
85+ {
86+ text : "微信小程序" ,
87+ link : Chapters . xrobot_guide_mp ,
88+ collapsed : true ,
89+ items : [
90+ { text : "智能体管理" , link : "agent-management" } ,
91+ { text : "角色配置" , link : "role-config" } ,
92+ { text : "设备管理" , link : "device-management" } ,
93+ { text : "设备配网" , link : "device-net-config" } ,
94+ ] . map ( ( item ) => apply_prefix ( item , Chapters . xrobot_guide_mp ) ) ,
95+ } ,
96+ ] ;
97+
98+ const items_xrobot_guide = [
99+ {
100+ text : "操作指南" ,
101+ link : Chapters . xrobot_guide ,
102+ collapsed : false ,
103+ items : [ ...items_xrobot_guide_mp ] ,
104+ } ,
105+ ] ;
106+
81107// xrobot章节整体
82108const items_xrobot = [
83109 {
84110 text : "Xrobot" ,
85- items : [ ...items_xrobot_api , ...items_xrobot_device , ...items_xrobot_faq ] ,
111+ items : [
112+ ...items_xrobot_api ,
113+ ...items_xrobot_device ,
114+ ...items_xrobot_faq ,
115+ ...items_xrobot_guide ,
116+ ] ,
86117 link : Chapters . xrobot ,
87118 collapsed : false ,
88119 } ,
@@ -105,4 +136,9 @@ export const ChapterItems: Record<Chapters, ChapterItem[]> = {
105136 ] ,
106137 [ Chapters . xrobot_api ] : [ gobackItem ( Chapters . xrobot ) , ...items_xrobot_api ] ,
107138 [ Chapters . xrobot_faq ] : [ gobackItem ( Chapters . xrobot ) , ...items_xrobot_faq ] ,
139+ [ Chapters . xrobot_guide ] : [ gobackItem ( Chapters . xrobot ) , ...items_xrobot_guide ] ,
140+ [ Chapters . xrobot_guide_mp ] : [
141+ gobackItem ( Chapters . xrobot_guide ) ,
142+ ...items_xrobot_guide_mp ,
143+ ] ,
108144} ;
0 commit comments