@@ -5,7 +5,7 @@ export type ChapterItem = {
55 link : string ;
66 // 初始时是否折叠, 如果未指定,侧边栏组不可折叠
77 collapsed ?: boolean ;
8- // 子项
8+ // 子项,元素顺序影响页面、章节顺序
99 items ?: ChapterItem [ ] ;
1010 // 返回上级章节
1111 goback ?: boolean ;
@@ -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 } ;
@@ -53,15 +56,15 @@ const items_xrobot_api = [
5356
5457const items_xrobot_device = [
5558 {
56- text : "设备指南 " ,
59+ text : "设备使用 " ,
5760 items : [
5861 { text : "设备使用指南" , link : "device-intro" } ,
5962 { text : "设备绑定" , link : "device-bind" } ,
6063 { text : "设备服务通信协议" , link : "device-protocol" } ,
6164 { text : "智能体连接指南" , link : "device-connection" } ,
6265 ] . map ( ( item ) => apply_prefix ( item , Chapters . xrobot_device ) ) ,
6366 link : Chapters . xrobot_device ,
64- collapsed : false ,
67+ collapsed : true ,
6568 } ,
6669 // 子章节
6770] ;
@@ -73,18 +76,46 @@ const items_xrobot_faq = [
7376 apply_prefix ( item , Chapters . xrobot_faq )
7477 ) ,
7578 link : Chapters . xrobot_faq ,
76- collapsed : false ,
79+ // collapsed: false,
7780 } ,
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 , ...items_xrobot_device ] ,
104+ } ,
105+ ] ;
106+
81107// xrobot章节整体
82108const items_xrobot = [
83109 {
84- text : "Xrobot" ,
85- items : [ ...items_xrobot_api , ...items_xrobot_device , ...items_xrobot_faq ] ,
110+ text : "" ,
111+ items : [
112+ ...items_xrobot_guide ,
113+ ...items_xrobot_api ,
114+ // ...items_xrobot_device,
115+ ...items_xrobot_faq ,
116+ ] ,
86117 link : Chapters . xrobot ,
87- collapsed : false ,
118+ // collapsed: false,
88119 } ,
89120] ;
90121
@@ -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