@maiyunnet/kebab 9.19.0 → 9.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/doc/kebab-rag.md CHANGED
@@ -1438,7 +1438,7 @@ index/variables/VER.md
1438
1438
 
1439
1439
  # Variable: VER
1440
1440
 
1441
- > `const` **VER**: `"9.19.0"` = `'9.19.0'`
1441
+ > `const` **VER**: `"9.19.1"` = `'9.19.1'`
1442
1442
 
1443
1443
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1444
1444
 
@@ -132498,7 +132498,7 @@ sys/ctr/classes/Ctr.md
132498
132498
 
132499
132499
  # Class: Ctr
132500
132500
 
132501
- Defined in: [sys/ctr.ts:123](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L123)
132501
+ Defined in: [sys/ctr.ts:142](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L142)
132502
132502
 
132503
132503
  ## Constructors
132504
132504
 
@@ -132506,7 +132506,7 @@ Defined in: [sys/ctr.ts:123](https://github.com/maiyunnet/kebab/blob/master/sys/
132506
132506
 
132507
132507
  > **new Ctr**(`config`, `req`, `res?`): `Ctr`
132508
132508
 
132509
- Defined in: [sys/ctr.ts:185](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L185)
132509
+ Defined in: [sys/ctr.ts:204](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L204)
132510
132510
 
132511
132511
  #### Parameters
132512
132512
 
@@ -132532,7 +132532,7 @@ Defined in: [sys/ctr.ts:185](https://github.com/maiyunnet/kebab/blob/master/sys/
132532
132532
 
132533
132533
  > `protected` **\_action**: `string` = `''`
132534
132534
 
132535
- Defined in: [sys/ctr.ts:129](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L129)
132535
+ Defined in: [sys/ctr.ts:148](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L148)
132536
132536
 
132537
132537
  当前的 action 名
132538
132538
 
@@ -132542,7 +132542,7 @@ Defined in: [sys/ctr.ts:129](https://github.com/maiyunnet/kebab/blob/master/sys/
132542
132542
 
132543
132543
  > `protected` **\_cacheTTL**: `number`
132544
132544
 
132545
- Defined in: [sys/ctr.ts:159](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L159)
132545
+ Defined in: [sys/ctr.ts:178](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L178)
132546
132546
 
132547
132547
  页面浏览器客户端缓存(单位:秒)
132548
132548
 
@@ -132552,7 +132552,7 @@ Defined in: [sys/ctr.ts:159](https://github.com/maiyunnet/kebab/blob/master/sys/
132552
132552
 
132553
132553
  > `protected` `readonly` **\_config**: [`IConfig`](../../../index/interfaces/IConfig.md)
132554
132554
 
132555
- Defined in: [sys/ctr.ts:171](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L171)
132555
+ Defined in: [sys/ctr.ts:190](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L190)
132556
132556
 
132557
132557
  vhost 的 kebab.json 以及全局常量
132558
132558
 
@@ -132562,7 +132562,7 @@ vhost 的 kebab.json 以及全局常量
132562
132562
 
132563
132563
  > `protected` **\_cookie**: `Record`\<`string`, `string`\> = `{}`
132564
132564
 
132565
- Defined in: [sys/ctr.ts:150](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L150)
132565
+ Defined in: [sys/ctr.ts:169](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L169)
132566
132566
 
132567
132567
  Cookie 数组
132568
132568
 
@@ -132572,7 +132572,7 @@ Cookie 数组
132572
132572
 
132573
132573
  > `protected` **\_files**: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\> = `{}`
132574
132574
 
132575
- Defined in: [sys/ctr.ts:147](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L147)
132575
+ Defined in: [sys/ctr.ts:166](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L166)
132576
132576
 
132577
132577
  上传的文件列表
132578
132578
 
@@ -132582,7 +132582,7 @@ Defined in: [sys/ctr.ts:147](https://github.com/maiyunnet/kebab/blob/master/sys/
132582
132582
 
132583
132583
  > `protected` **\_get**: `Record`\<`string`, `string`\>
132584
132584
 
132585
- Defined in: [sys/ctr.ts:135](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L135)
132585
+ Defined in: [sys/ctr.ts:154](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L154)
132586
132586
 
132587
132587
  GET 数据
132588
132588
 
@@ -132592,7 +132592,7 @@ GET 数据
132592
132592
 
132593
132593
  > `protected` **\_headers**: `IncomingHttpHeaders` = `{}`
132594
132594
 
132595
- Defined in: [sys/ctr.ts:132](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L132)
132595
+ Defined in: [sys/ctr.ts:151](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L151)
132596
132596
 
132597
132597
  请求的 header 列表,key 均为小写
132598
132598
 
@@ -132602,7 +132602,7 @@ Defined in: [sys/ctr.ts:132](https://github.com/maiyunnet/kebab/blob/master/sys/
132602
132602
 
132603
132603
  > `protected` **\_httpCode**: `number` = `0`
132604
132604
 
132605
- Defined in: [sys/ctr.ts:165](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L165)
132605
+ Defined in: [sys/ctr.ts:184](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L184)
132606
132606
 
132607
132607
  自定义 http code
132608
132608
 
@@ -132612,7 +132612,7 @@ Defined in: [sys/ctr.ts:165](https://github.com/maiyunnet/kebab/blob/master/sys/
132612
132612
 
132613
132613
  > `protected` **\_input**: `string` = `''`
132614
132614
 
132615
- Defined in: [sys/ctr.ts:144](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L144)
132615
+ Defined in: [sys/ctr.ts:163](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L163)
132616
132616
 
132617
132617
  原始 input 字符串
132618
132618
 
@@ -132622,7 +132622,7 @@ Defined in: [sys/ctr.ts:144](https://github.com/maiyunnet/kebab/blob/master/sys/
132622
132622
 
132623
132623
  > `protected` **\_locale**: `string` = `'en'`
132624
132624
 
132625
- Defined in: [sys/ctr.ts:168](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L168)
132625
+ Defined in: [sys/ctr.ts:187](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L187)
132626
132626
 
132627
132627
  当前语言名
132628
132628
 
@@ -132632,7 +132632,7 @@ Defined in: [sys/ctr.ts:168](https://github.com/maiyunnet/kebab/blob/master/sys/
132632
132632
 
132633
132633
  > `protected` **\_localeData**: `Record`\<`string`, `Record`\<`string`, `string`\>\> = `{}`
132634
132634
 
132635
- Defined in: [sys/ctr.ts:183](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L183)
132635
+ Defined in: [sys/ctr.ts:202](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L202)
132636
132636
 
132637
132637
  本 ctr 的 locale data
132638
132638
 
@@ -132642,7 +132642,7 @@ Defined in: [sys/ctr.ts:183](https://github.com/maiyunnet/kebab/blob/master/sys/
132642
132642
 
132643
132643
  > `protected` **\_localeFiles**: `string`[] = `[]`
132644
132644
 
132645
- Defined in: [sys/ctr.ts:180](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L180)
132645
+ Defined in: [sys/ctr.ts:199](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L199)
132646
132646
 
132647
132647
  本 ctr 已加载的语言文件列表
132648
132648
 
@@ -132652,7 +132652,7 @@ Defined in: [sys/ctr.ts:180](https://github.com/maiyunnet/kebab/blob/master/sys/
132652
132652
 
132653
132653
  > `protected` **\_param**: `string`[] = `[]`
132654
132654
 
132655
- Defined in: [sys/ctr.ts:126](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L126)
132655
+ Defined in: [sys/ctr.ts:145](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L145)
132656
132656
 
132657
132657
  路由参数序列数组
132658
132658
 
@@ -132662,7 +132662,7 @@ Defined in: [sys/ctr.ts:126](https://github.com/maiyunnet/kebab/blob/master/sys/
132662
132662
 
132663
132663
  > `protected` **\_post**: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\> = `{}`
132664
132664
 
132665
- Defined in: [sys/ctr.ts:141](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L141)
132665
+ Defined in: [sys/ctr.ts:160](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L160)
132666
132666
 
132667
132667
  POST 数据
132668
132668
 
@@ -132672,7 +132672,7 @@ POST 数据
132672
132672
 
132673
132673
  > `protected` **\_rawPost**: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\> = `{}`
132674
132674
 
132675
- Defined in: [sys/ctr.ts:138](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L138)
132675
+ Defined in: [sys/ctr.ts:157](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L157)
132676
132676
 
132677
132677
  原始 POST 数据
132678
132678
 
@@ -132682,7 +132682,7 @@ Defined in: [sys/ctr.ts:138](https://github.com/maiyunnet/kebab/blob/master/sys/
132682
132682
 
132683
132683
  > `protected` `readonly` **\_req**: `IncomingMessage` \| `Http2ServerRequest`
132684
132684
 
132685
- Defined in: [sys/ctr.ts:173](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L173)
132685
+ Defined in: [sys/ctr.ts:192](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L192)
132686
132686
 
132687
132687
  ***
132688
132688
 
@@ -132690,7 +132690,7 @@ Defined in: [sys/ctr.ts:173](https://github.com/maiyunnet/kebab/blob/master/sys/
132690
132690
 
132691
132691
  > `protected` `readonly` **\_res**: `Http2ServerResponse`\<`Http2ServerRequest`\> \| `ServerResponse`\<`IncomingMessage`\>
132692
132692
 
132693
- Defined in: [sys/ctr.ts:175](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L175)
132693
+ Defined in: [sys/ctr.ts:194](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L194)
132694
132694
 
132695
132695
  ***
132696
132696
 
@@ -132698,7 +132698,7 @@ Defined in: [sys/ctr.ts:175](https://github.com/maiyunnet/kebab/blob/master/sys/
132698
132698
 
132699
132699
  > `protected` **\_sess**: [`Session`](../../../lib/session/classes/Session.md) \| `null` = `null`
132700
132700
 
132701
- Defined in: [sys/ctr.ts:156](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L156)
132701
+ Defined in: [sys/ctr.ts:175](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L175)
132702
132702
 
132703
132703
  Session --- 对象
132704
132704
 
@@ -132708,7 +132708,7 @@ Session --- 对象
132708
132708
 
132709
132709
  > `protected` **\_session**: `Record`\<`string`, `any`\> = `{}`
132710
132710
 
132711
- Defined in: [sys/ctr.ts:153](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L153)
132711
+ Defined in: [sys/ctr.ts:172](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L172)
132712
132712
 
132713
132713
  Session 数组
132714
132714
 
@@ -132718,7 +132718,7 @@ Session 数组
132718
132718
 
132719
132719
  > `protected` `readonly` **\_socket**: [`Socket`](../../../lib/ws/classes/Socket.md)
132720
132720
 
132721
- Defined in: [sys/ctr.ts:177](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L177)
132721
+ Defined in: [sys/ctr.ts:196](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L196)
132722
132722
 
132723
132723
  ***
132724
132724
 
@@ -132726,7 +132726,7 @@ Defined in: [sys/ctr.ts:177](https://github.com/maiyunnet/kebab/blob/master/sys/
132726
132726
 
132727
132727
  > `protected` `optional` **\_timer?**: `object`
132728
132728
 
132729
- Defined in: [sys/ctr.ts:210](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L210)
132729
+ Defined in: [sys/ctr.ts:229](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L229)
132730
132730
 
132731
132731
  timeout 的 timer
132732
132732
 
@@ -132752,7 +132752,7 @@ timeout 的 timer
132752
132752
 
132753
132753
  > `protected` **\_xsrf**: `string` = `''`
132754
132754
 
132755
- Defined in: [sys/ctr.ts:162](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L162)
132755
+ Defined in: [sys/ctr.ts:181](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L181)
132756
132756
 
132757
132757
  XSRF TOKEN 值
132758
132758
 
@@ -132764,7 +132764,7 @@ XSRF TOKEN 值
132764
132764
 
132765
132765
  > **get** `protected` **\_isAvail**(): `boolean`
132766
132766
 
132767
- Defined in: [sys/ctr.ts:199](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L199)
132767
+ Defined in: [sys/ctr.ts:218](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L218)
132768
132768
 
132769
132769
  当前用户连接是否还在连接中
132770
132770
 
@@ -132780,7 +132780,7 @@ Defined in: [sys/ctr.ts:199](https://github.com/maiyunnet/kebab/blob/master/sys/
132780
132780
 
132781
132781
  > **get** **timeout**(): `number`
132782
132782
 
132783
- Defined in: [sys/ctr.ts:217](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L217)
132783
+ Defined in: [sys/ctr.ts:236](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L236)
132784
132784
 
132785
132785
  获取当前过期时间(毫秒)
132786
132786
 
@@ -132792,7 +132792,7 @@ Defined in: [sys/ctr.ts:217](https://github.com/maiyunnet/kebab/blob/master/sys/
132792
132792
 
132793
132793
  > **set** **timeout**(`num`): `void`
132794
132794
 
132795
- Defined in: [sys/ctr.ts:224](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L224)
132795
+ Defined in: [sys/ctr.ts:243](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L243)
132796
132796
 
132797
132797
  设置当前过期时间(毫秒)
132798
132798
 
@@ -132812,7 +132812,7 @@ Defined in: [sys/ctr.ts:224](https://github.com/maiyunnet/kebab/blob/master/sys/
132812
132812
 
132813
132813
  > `protected` **\_asyncTask**(`func`): `void`
132814
132814
 
132815
- Defined in: [sys/ctr.ts:258](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L258)
132815
+ Defined in: [sys/ctr.ts:277](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L277)
132816
132816
 
132817
132817
  执行一段跳出堆栈的异步代码,代码执行完成前,热更新不会杀死当面进程 且 ftmp 临时文件不会被清除
132818
132818
 
@@ -132834,7 +132834,7 @@ Defined in: [sys/ctr.ts:258](https://github.com/maiyunnet/kebab/blob/master/sys/
132834
132834
 
132835
132835
  > `protected` **\_checkInput**(`input`, `rule`, `rtn`): `boolean`
132836
132836
 
132837
- Defined in: [sys/ctr.ts:721](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L721)
132837
+ Defined in: [sys/ctr.ts:720](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L720)
132838
132838
 
132839
132839
  检测提交的数据类型
132840
132840
 
@@ -132868,7 +132868,7 @@ Defined in: [sys/ctr.ts:721](https://github.com/maiyunnet/kebab/blob/master/sys/
132868
132868
 
132869
132869
  > `protected` **\_checkXInput**(`input`, `rule`, `rtn`, `ignore?`): `boolean`
132870
132870
 
132871
- Defined in: [sys/ctr.ts:900](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L900)
132871
+ Defined in: [sys/ctr.ts:899](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L899)
132872
132872
 
132873
132873
  检测提交的数据类型(会检测 XSRF)
132874
132874
 
@@ -132908,7 +132908,7 @@ Defined in: [sys/ctr.ts:900](https://github.com/maiyunnet/kebab/blob/master/sys/
132908
132908
 
132909
132909
  > `protected` **\_cross**(`opt?`): `boolean`
132910
132910
 
132911
- Defined in: [sys/ctr.ts:1135](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1135)
132911
+ Defined in: [sys/ctr.ts:1136](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1136)
132912
132912
 
132913
132913
  开启跨域请求
132914
132914
 
@@ -132953,7 +132953,7 @@ Defined in: [sys/ctr.ts:1135](https://github.com/maiyunnet/kebab/blob/master/sys
132953
132953
 
132954
132954
  > `protected` **\_device**(): `"unknown"` \| `"android"` \| `"linux"` \| `"windows"` \| `"macintosh"` \| `"ipad"`
132955
132955
 
132956
- Defined in: [sys/ctr.ts:945](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L945)
132956
+ Defined in: [sys/ctr.ts:944](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L944)
132957
132957
 
132958
132958
  根据用户 ua 获取当前用户的设备类型
132959
132959
 
@@ -132967,7 +132967,7 @@ Defined in: [sys/ctr.ts:945](https://github.com/maiyunnet/kebab/blob/master/sys/
132967
132967
 
132968
132968
  > `protected` **\_enabledXsrf**(`opt?`): `void`
132969
132969
 
132970
- Defined in: [sys/ctr.ts:914](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L914)
132970
+ Defined in: [sys/ctr.ts:913](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L913)
132971
132971
 
132972
132972
  当前页面开启 XSRF 支持(主要检测 cookie 是否存在)
132973
132973
  如果当前页面有 CDN,请不要使用
@@ -132990,7 +132990,7 @@ Defined in: [sys/ctr.ts:914](https://github.com/maiyunnet/kebab/blob/master/sys/
132990
132990
 
132991
132991
  > `protected` **\_end**(`code?`, `reason?`): `void`
132992
132992
 
132993
- Defined in: [sys/ctr.ts:1245](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1245)
132993
+ Defined in: [sys/ctr.ts:1246](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1246)
132994
132994
 
132995
132995
  主动关闭当前 socket 连接
132996
132996
 
@@ -133018,7 +133018,7 @@ WebSocket 关闭码
133018
133018
 
133019
133019
  > `protected` **\_getBasicAuth**(`user`, `pwd`): `string`
133020
133020
 
133021
- Defined in: [sys/ctr.ts:938](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L938)
133021
+ Defined in: [sys/ctr.ts:937](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L937)
133022
133022
 
133023
133023
  获取 Auth 字符串,用于客户端提交
133024
133024
 
@@ -133046,7 +133046,7 @@ Defined in: [sys/ctr.ts:938](https://github.com/maiyunnet/kebab/blob/master/sys/
133046
133046
 
133047
133047
  > `protected` **\_getLocale**(): `string`
133048
133048
 
133049
- Defined in: [sys/ctr.ts:1126](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1126)
133049
+ Defined in: [sys/ctr.ts:1127](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1127)
133050
133050
 
133051
133051
  获取当前语言名
133052
133052
 
@@ -133060,7 +133060,7 @@ Defined in: [sys/ctr.ts:1126](https://github.com/maiyunnet/kebab/blob/master/sys
133060
133060
 
133061
133061
  > `protected` **\_getLocaleJsonString**(): `string`
133062
133062
 
133063
- Defined in: [sys/ctr.ts:1114](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1114)
133063
+ Defined in: [sys/ctr.ts:1115](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1115)
133064
133064
 
133065
133065
  根据当前后台语言包设置情况获取 JSON 字符串传输到前台
133066
133066
 
@@ -133076,7 +133076,7 @@ string
133076
133076
 
133077
133077
  > `protected` **\_getMemoryUsage**(): `number`
133078
133078
 
133079
- Defined in: [sys/ctr.ts:408](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L408)
133079
+ Defined in: [sys/ctr.ts:427](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L427)
133080
133080
 
133081
133081
  获取截止当前内存的使用情况
133082
133082
 
@@ -133090,7 +133090,7 @@ Defined in: [sys/ctr.ts:408](https://github.com/maiyunnet/kebab/blob/master/sys/
133090
133090
 
133091
133091
  > `protected` **\_getRunTime**(`ms?`): `number`
133092
133092
 
133093
- Defined in: [sys/ctr.ts:400](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L400)
133093
+ Defined in: [sys/ctr.ts:419](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L419)
133094
133094
 
133095
133095
  获取截止当前时间的总运行时间
133096
133096
 
@@ -133112,7 +133112,7 @@ Defined in: [sys/ctr.ts:400](https://github.com/maiyunnet/kebab/blob/master/sys/
133112
133112
 
133113
133113
  > `protected` **\_handleFormData**(`events?`, `limits?`): `Promise`\<`boolean`\>
133114
133114
 
133115
- Defined in: [sys/ctr.ts:1254](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1254)
133115
+ Defined in: [sys/ctr.ts:1255](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1255)
133116
133116
 
133117
133117
  获取 formdata 的信息
133118
133118
 
@@ -133190,7 +133190,7 @@ multipart 字段与文件总数量,默认 1000
133190
133190
 
133191
133191
  > **\_l**(`key`, `data?`): `string`
133192
133192
 
133193
- Defined in: [sys/ctr.ts:1178](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1178)
133193
+ Defined in: [sys/ctr.ts:1179](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1179)
133194
133194
 
133195
133195
  获取语言包值
133196
133196
 
@@ -133216,7 +133216,7 @@ Defined in: [sys/ctr.ts:1178](https://github.com/maiyunnet/kebab/blob/master/sys
133216
133216
 
133217
133217
  > `protected` **\_loadData**\<`T`\>(`path`): `Promise`\<`false` \| `T` \| `null`\>
133218
133218
 
133219
- Defined in: [sys/ctr.ts:1014](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1014)
133219
+ Defined in: [sys/ctr.ts:1013](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1013)
133220
133220
 
133221
133221
  获取 data JSON 数据
133222
133222
 
@@ -133244,7 +133244,7 @@ Defined in: [sys/ctr.ts:1014](https://github.com/maiyunnet/kebab/blob/master/sys
133244
133244
 
133245
133245
  > `protected` **\_loadLocale**(`loc`, `pkg?`): `Promise`\<`boolean`\>
133246
133246
 
133247
- Defined in: [sys/ctr.ts:1065](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1065)
133247
+ Defined in: [sys/ctr.ts:1066](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1066)
133248
133248
 
133249
133249
  设定语言并加载语言包
133250
133250
 
@@ -133272,7 +133272,7 @@ Defined in: [sys/ctr.ts:1065](https://github.com/maiyunnet/kebab/blob/master/sys
133272
133272
 
133273
133273
  > `protected` **\_loadReactPage**(`path`, `props?`, `opt?`): `Promise`\<`string`\>
133274
133274
 
133275
- Defined in: [sys/ctr.ts:444](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L444)
133275
+ Defined in: [sys/ctr.ts:463](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L463)
133276
133276
 
133277
133277
  加载 React 全页面进行 SSR 渲染,组件需渲染完整 HTML 文档(含 html/head/body),无需 EJS
133278
133278
  框架自动注入 props:_urlBase/_urlFull/_urlStc/_staticVer/_staticPath/_staticPathFull
@@ -133295,35 +133295,9 @@ Defined in: [sys/ctr.ts:444](https://github.com/maiyunnet/kebab/blob/master/sys/
133295
133295
 
133296
133296
  ##### opt?
133297
133297
 
133298
- 可选配置
133299
-
133300
- ###### hydrate?
133301
-
133302
- `boolean`
133303
-
133304
- 是否注入客户端水合 bundle,默认 true;设为 false 时仅输出服务端渲染的 HTML
133305
-
133306
- ###### router?
133307
-
133308
- `"browser"`
133309
-
133310
- 路由模式,不传则不注入任何 Router,组件自行管理路由(如 MemoryRouter)或无路由
133311
- 'browser':服务端用 StaticRouter,客户端用 BrowserRouter,地址栏与路由联动
133312
- 组件本身只需使用 Routes/Route/Link 等,不要包含任何 Router 包裹层
133313
-
133314
- ###### routerBase?
133315
-
133316
- `string`
133317
-
133318
- BrowserRouter 的 basename,相对于 urlBase,默认空字符串
133319
- 例如组件挂载在 /test/react-router-page,则填 'test/react-router-page'
133320
-
133321
- ###### staticPath?
133298
+ [`IReactPageOptions`](../interfaces/IReactPageOptions.md) = `{}`
133322
133299
 
133323
- `string`
133324
-
133325
- 静态资源基础路径,覆盖 config.set.staticPath,用于指定 CDN 或自定义路径
133326
- 影响 _staticPath prop 以及水合脚本中 JS 文件的 URL 前缀
133300
+ 可选配置
133327
133301
 
133328
133302
  #### Returns
133329
133303
 
@@ -133335,7 +133309,7 @@ BrowserRouter 的 basename,相对于 urlBase,默认空字符串
133335
133309
 
133336
133310
  > `protected` **\_loadView**(`path`, `data?`): `Promise`\<`string`\>
133337
133311
 
133338
- Defined in: [sys/ctr.ts:417](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L417)
133312
+ Defined in: [sys/ctr.ts:436](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L436)
133339
133313
 
133340
133314
  加载视图
133341
133315
 
@@ -133357,11 +133331,11 @@ Defined in: [sys/ctr.ts:417](https://github.com/maiyunnet/kebab/blob/master/sys/
133357
133331
 
133358
133332
  ### \_location()
133359
133333
 
133360
- > `protected` **\_location**(`location`): `false`
133334
+ > `protected` **\_location**(`location`, `httpCode?`): `false`
133361
133335
 
133362
133336
  Defined in: [sys/ctr.ts:1035](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1035)
133363
133337
 
133364
- 跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径
133338
+ 跳转,支持相对本项目根路径的路径或绝对路径
133365
133339
 
133366
133340
  #### Parameters
133367
133341
 
@@ -133371,6 +133345,12 @@ Defined in: [sys/ctr.ts:1035](https://github.com/maiyunnet/kebab/blob/master/sys
133371
133345
 
133372
133346
  相对或绝对网址
133373
133347
 
133348
+ ##### httpCode?
133349
+
133350
+ [`TRedirectHttpCode`](../type-aliases/TRedirectHttpCode.md) = `302`
133351
+
133352
+ HTTP 重定向状态码,默认 302
133353
+
133374
133354
  #### Returns
133375
133355
 
133376
133356
  `false`
@@ -133381,7 +133361,7 @@ Defined in: [sys/ctr.ts:1035](https://github.com/maiyunnet/kebab/blob/master/sys
133381
133361
 
133382
133362
  > `protected` **\_ping**(`data?`): `boolean`
133383
133363
 
133384
- Defined in: [sys/ctr.ts:1228](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1228)
133364
+ Defined in: [sys/ctr.ts:1229](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1229)
133385
133365
 
133386
133366
  发送 socket ping
133387
133367
 
@@ -133403,7 +133383,7 @@ Defined in: [sys/ctr.ts:1228](https://github.com/maiyunnet/kebab/blob/master/sys
133403
133383
 
133404
133384
  > `protected` **\_pong**(`data?`): `boolean`
133405
133385
 
133406
- Defined in: [sys/ctr.ts:1236](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1236)
133386
+ Defined in: [sys/ctr.ts:1237](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1237)
133407
133387
 
133408
133388
  发送 socket pong
133409
133389
 
@@ -133425,7 +133405,7 @@ Defined in: [sys/ctr.ts:1236](https://github.com/maiyunnet/kebab/blob/master/sys
133425
133405
 
133426
133406
  > `protected` **\_startSession**(`link`, `auth?`, `opt?`): `Promise`\<`boolean`\>
133427
133407
 
133428
- Defined in: [sys/ctr.ts:1049](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1049)
133408
+ Defined in: [sys/ctr.ts:1050](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1050)
133429
133409
 
133430
133410
  开启 Session
133431
133411
 
@@ -133459,7 +133439,7 @@ Kv 或 Db 实例
133459
133439
 
133460
133440
  > `protected` **\_valibot**\<`TSchema`\>(`schema`, `input`, `options?`): [`TValibotResult`](../type-aliases/TValibotResult.md)\<`TSchema`\>
133461
133441
 
133462
- Defined in: [sys/ctr.ts:640](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L640)
133442
+ Defined in: [sys/ctr.ts:639](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L639)
133463
133443
 
133464
133444
  使用 Valibot schema 校验并解析输入,成功后 output 会自动推导类型
133465
133445
 
@@ -133501,7 +133481,7 @@ Valibot 配置和自定义客户端返回值
133501
133481
 
133502
133482
  > `protected` **\_valibotx**\<`TSchema`\>(`schema`, `input`, `options?`): [`TValibotResult`](../type-aliases/TValibotResult.md)\<`TSchema`, [`IValibotXsrfIssue`](../interfaces/IValibotXsrfIssue.md) \| [`InferIssue`](../../../lib/core/namespaces/v/type-aliases/InferIssue.md)\<`TSchema`\>\>
133503
133483
 
133504
- Defined in: [sys/ctr.ts:664](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L664)
133484
+ Defined in: [sys/ctr.ts:663](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L663)
133505
133485
 
133506
133486
  使用 Valibot schema 校验并解析输入,同时检测 XSRF
133507
133487
 
@@ -133543,7 +133523,7 @@ Valibot 配置、自定义客户端返回值和 XSRF 选项
133543
133523
 
133544
133524
  > `protected` **\_writeBinary**(`data`): `boolean`
133545
133525
 
133546
- Defined in: [sys/ctr.ts:1220](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1220)
133526
+ Defined in: [sys/ctr.ts:1221](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1221)
133547
133527
 
133548
133528
  发送 socket 二进制
133549
133529
 
@@ -133565,7 +133545,7 @@ Defined in: [sys/ctr.ts:1220](https://github.com/maiyunnet/kebab/blob/master/sys
133565
133545
 
133566
133546
  > `protected` **\_writeResult**(`data`): `boolean`
133567
133547
 
133568
- Defined in: [sys/ctr.ts:1212](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1212)
133548
+ Defined in: [sys/ctr.ts:1213](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1213)
133569
133549
 
133570
133550
  发送结果对象文本
133571
133551
 
@@ -133587,7 +133567,7 @@ Defined in: [sys/ctr.ts:1212](https://github.com/maiyunnet/kebab/blob/master/sys
133587
133567
 
133588
133568
  > `protected` **\_writeText**(`data`): `boolean`
133589
133569
 
133590
- Defined in: [sys/ctr.ts:1204](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1204)
133570
+ Defined in: [sys/ctr.ts:1205](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1205)
133591
133571
 
133592
133572
  发送 socket 文本
133593
133573
 
@@ -133609,7 +133589,7 @@ Defined in: [sys/ctr.ts:1204](https://github.com/maiyunnet/kebab/blob/master/sys
133609
133589
 
133610
133590
  > **getAuthorization**(): `false` \| \{ `pwd`: `string`; `type`: `"basic"`; `user`: `string`; \} \| \{ `token`: `string`; `type`: `"bearer"`; \}
133611
133591
 
133612
- Defined in: [sys/ctr.ts:966](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L966)
133592
+ Defined in: [sys/ctr.ts:965](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L965)
133613
133593
 
133614
133594
  通过 header 或 _auth 获取鉴权信息,支持 Basic Auth 和 Bearer Token
133615
133595
 
@@ -133625,7 +133605,7 @@ Defined in: [sys/ctr.ts:966](https://github.com/maiyunnet/kebab/blob/master/sys/
133625
133605
 
133626
133606
  > **getPrototype**(`name`): [`IConfig`](../../../index/interfaces/IConfig.md)
133627
133607
 
133628
- Defined in: [sys/ctr.ts:282](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L282)
133608
+ Defined in: [sys/ctr.ts:301](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L301)
133629
133609
 
133630
133610
  获取类内部的 prototype
133631
133611
 
@@ -133643,7 +133623,7 @@ Defined in: [sys/ctr.ts:282](https://github.com/maiyunnet/kebab/blob/master/sys/
133643
133623
 
133644
133624
  > **getPrototype**(`name`): [`Session`](../../../lib/session/classes/Session.md) \| `null`
133645
133625
 
133646
- Defined in: [sys/ctr.ts:283](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L283)
133626
+ Defined in: [sys/ctr.ts:302](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L302)
133647
133627
 
133648
133628
  获取类内部的 prototype
133649
133629
 
@@ -133661,7 +133641,7 @@ Defined in: [sys/ctr.ts:283](https://github.com/maiyunnet/kebab/blob/master/sys/
133661
133641
 
133662
133642
  > **getPrototype**(`name`): `IncomingHttpHeaders`
133663
133643
 
133664
- Defined in: [sys/ctr.ts:284](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L284)
133644
+ Defined in: [sys/ctr.ts:303](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L303)
133665
133645
 
133666
133646
  获取类内部的 prototype
133667
133647
 
@@ -133679,7 +133659,7 @@ Defined in: [sys/ctr.ts:284](https://github.com/maiyunnet/kebab/blob/master/sys/
133679
133659
 
133680
133660
  > **getPrototype**(`name`): `IncomingMessage` \| `Http2ServerRequest`
133681
133661
 
133682
- Defined in: [sys/ctr.ts:285](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L285)
133662
+ Defined in: [sys/ctr.ts:304](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L304)
133683
133663
 
133684
133664
  获取类内部的 prototype
133685
133665
 
@@ -133697,7 +133677,7 @@ Defined in: [sys/ctr.ts:285](https://github.com/maiyunnet/kebab/blob/master/sys/
133697
133677
 
133698
133678
  > **getPrototype**(`name`): `Http2ServerResponse`\<`Http2ServerRequest`\> \| `ServerResponse`\<`IncomingMessage`\>
133699
133679
 
133700
- Defined in: [sys/ctr.ts:286](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L286)
133680
+ Defined in: [sys/ctr.ts:305](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L305)
133701
133681
 
133702
133682
  获取类内部的 prototype
133703
133683
 
@@ -133715,7 +133695,7 @@ Defined in: [sys/ctr.ts:286](https://github.com/maiyunnet/kebab/blob/master/sys/
133715
133695
 
133716
133696
  > **getPrototype**(`name`): [`Socket`](../../../lib/ws/classes/Socket.md)
133717
133697
 
133718
- Defined in: [sys/ctr.ts:287](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L287)
133698
+ Defined in: [sys/ctr.ts:306](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L306)
133719
133699
 
133720
133700
  获取类内部的 prototype
133721
133701
 
@@ -133733,7 +133713,7 @@ Defined in: [sys/ctr.ts:287](https://github.com/maiyunnet/kebab/blob/master/sys/
133733
133713
 
133734
133714
  > **getPrototype**(`name`): `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>
133735
133715
 
133736
- Defined in: [sys/ctr.ts:288](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L288)
133716
+ Defined in: [sys/ctr.ts:307](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L307)
133737
133717
 
133738
133718
  获取类内部的 prototype
133739
133719
 
@@ -133751,7 +133731,7 @@ Defined in: [sys/ctr.ts:288](https://github.com/maiyunnet/kebab/blob/master/sys/
133751
133731
 
133752
133732
  > **getPrototype**(`name`): `string`
133753
133733
 
133754
- Defined in: [sys/ctr.ts:289](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L289)
133734
+ Defined in: [sys/ctr.ts:308](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L308)
133755
133735
 
133756
133736
  获取类内部的 prototype
133757
133737
 
@@ -133769,7 +133749,7 @@ Defined in: [sys/ctr.ts:289](https://github.com/maiyunnet/kebab/blob/master/sys/
133769
133749
 
133770
133750
  > **getPrototype**(`name`): `any`
133771
133751
 
133772
- Defined in: [sys/ctr.ts:290](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L290)
133752
+ Defined in: [sys/ctr.ts:309](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L309)
133773
133753
 
133774
133754
  获取类内部的 prototype
133775
133755
 
@@ -133789,7 +133769,7 @@ Defined in: [sys/ctr.ts:290](https://github.com/maiyunnet/kebab/blob/master/sys/
133789
133769
 
133790
133770
  > **onClose**(): `void` \| `Promise`\<`void`\>
133791
133771
 
133792
- Defined in: [sys/ctr.ts:384](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L384)
133772
+ Defined in: [sys/ctr.ts:403](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L403)
133793
133773
 
133794
133774
  WebSocket 下连接被终止后会自动被调用的事件,可重写此方法
133795
133775
 
@@ -133803,7 +133783,7 @@ WebSocket 下连接被终止后会自动被调用的事件,可重写此方法
133803
133783
 
133804
133784
  > **onData**(`data`, `opcode`): `any`
133805
133785
 
133806
- Defined in: [sys/ctr.ts:349](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L349)
133786
+ Defined in: [sys/ctr.ts:368](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L368)
133807
133787
 
133808
133788
  WebSocket 下当收到数据时会自动被调用的事件,即只文本和二进制数据,返回内容会被发送给 socket
133809
133789
 
@@ -133833,7 +133813,7 @@ WebSocket 下当收到数据时会自动被调用的事件,即只文本和二
133833
133813
 
133834
133814
  > **onDrain**(): `void` \| `Promise`\<`void`\>
133835
133815
 
133836
- Defined in: [sys/ctr.ts:370](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L370)
133816
+ Defined in: [sys/ctr.ts:389](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L389)
133837
133817
 
133838
133818
  WebSocket 下连接恢复可写入状态后会调用此事件,可重写此方法
133839
133819
 
@@ -133847,7 +133827,7 @@ WebSocket 下连接恢复可写入状态后会调用此事件,可重写此方
133847
133827
 
133848
133828
  > **onEnd**(): `void` \| `Promise`\<`void`\>
133849
133829
 
133850
- Defined in: [sys/ctr.ts:377](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L377)
133830
+ Defined in: [sys/ctr.ts:396](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L396)
133851
133831
 
133852
133832
  WebSocket 下连接被 end 后会自动被调用的事件,可重写此方法
133853
133833
 
@@ -133861,7 +133841,7 @@ WebSocket 下连接被 end 后会自动被调用的事件,可重写此方法
133861
133841
 
133862
133842
  > **onLoad**(): `string` \| `boolean` \| [`DbValue`](../../../index/type-aliases/DbValue.md)[] \| `Promise`\<`string` \| `boolean` \| [`DbValue`](../../../index/type-aliases/DbValue.md)[]\>
133863
133843
 
133864
- Defined in: [sys/ctr.ts:308](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L308)
133844
+ Defined in: [sys/ctr.ts:327](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L327)
133865
133845
 
133866
133846
  实例化后会执行的方法,可重写此方法
133867
133847
 
@@ -133877,7 +133857,7 @@ Defined in: [sys/ctr.ts:308](https://github.com/maiyunnet/kebab/blob/master/sys/
133877
133857
 
133878
133858
  > **onMessage**(`data`, `opcode`): `boolean` \| `Promise`\<`boolean` \| `undefined`\> \| `undefined`
133879
133859
 
133880
- Defined in: [sys/ctr.ts:361](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L361)
133860
+ Defined in: [sys/ctr.ts:380](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L380)
133881
133861
 
133882
133862
  包含所有 opcode 的消息,若要发送数据需自行调用 write 方法,data 恒定为原始 buffer
133883
133863
  返回 false 则不会执行默认方法,一般请什么都不要返回
@@ -133907,7 +133887,7 @@ opcode
133907
133887
 
133908
133888
  > **onReady**(): `string` \| `boolean` \| [`DbValue`](../../../index/type-aliases/DbValue.md)[] \| `Promise`\<`string` \| `boolean` \| [`DbValue`](../../../index/type-aliases/DbValue.md)[]\>
133909
133889
 
133910
- Defined in: [sys/ctr.ts:317](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L317)
133890
+ Defined in: [sys/ctr.ts:336](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L336)
133911
133891
 
133912
133892
  onLoad 执行后会执行的方法,可重写此方法
133913
133893
 
@@ -133923,7 +133903,7 @@ onLoad 执行后会执行的方法,可重写此方法
133923
133903
 
133924
133904
  > **onReqStart**(): `number` \| `Promise`\<`number`\>
133925
133905
 
133926
- Defined in: [sys/ctr.ts:392](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L392)
133906
+ Defined in: [sys/ctr.ts:411](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L411)
133927
133907
 
133928
133908
  请求发送开始时调用(仅会在 middle 内触发)
133929
133909
 
@@ -133939,7 +133919,7 @@ Defined in: [sys/ctr.ts:392](https://github.com/maiyunnet/kebab/blob/master/sys/
133939
133919
 
133940
133920
  > **onUnload**(`rtn`): `string` \| `boolean` \| [`DbValue`](../../../index/type-aliases/DbValue.md)[] \| `Promise`\<`string` \| `boolean` \| [`DbValue`](../../../index/type-aliases/DbValue.md)[]\>
133941
133921
 
133942
- Defined in: [sys/ctr.ts:327](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L327)
133922
+ Defined in: [sys/ctr.ts:346](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L346)
133943
133923
 
133944
133924
  整个结束前会执行本方法,可重写此方法对输出结果再处理一次(Websocket 模式无效)
133945
133925
 
@@ -133963,7 +133943,7 @@ Defined in: [sys/ctr.ts:327](https://github.com/maiyunnet/kebab/blob/master/sys/
133963
133943
 
133964
133944
  > **onUpgrade**(): `object`
133965
133945
 
133966
- Defined in: [sys/ctr.ts:336](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L336)
133946
+ Defined in: [sys/ctr.ts:355](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L355)
133967
133947
 
133968
133948
  WebSocket 下在建立 Server 连接之前可对 WebSocket 的信息进行配置
133969
133949
 
@@ -133987,7 +133967,7 @@ WebSocket 配置参数,包含自定义 header 和超时时间
133987
133967
 
133988
133968
  > **setPrototype**(`name`, `val`): `void`
133989
133969
 
133990
- Defined in: [sys/ctr.ts:296](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L296)
133970
+ Defined in: [sys/ctr.ts:315](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L315)
133991
133971
 
133992
133972
  设置类内部的 prototype
133993
133973
 
@@ -134039,7 +134019,7 @@ sys/ctr/functions/isHttpRequestAvailable.md
134039
134019
 
134040
134020
  > **isHttpRequestAvailable**(`req`, `res`): `boolean`
134041
134021
 
134042
- Defined in: [sys/ctr.ts:104](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L104)
134022
+ Defined in: [sys/ctr.ts:123](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L123)
134043
134023
 
134044
134024
  判断当前 HTTP 请求是否仍可响应
134045
134025
 
@@ -134080,12 +134060,14 @@ sys/ctr/index.md
134080
134060
 
134081
134061
  ## Interfaces
134082
134062
 
134063
+ - [IReactPageOptions](interfaces/IReactPageOptions.md)
134083
134064
  - [IValibotOptions](interfaces/IValibotOptions.md)
134084
134065
  - [IValibotXOptions](interfaces/IValibotXOptions.md)
134085
134066
  - [IValibotXsrfIssue](interfaces/IValibotXsrfIssue.md)
134086
134067
 
134087
134068
  ## Type Aliases
134088
134069
 
134070
+ - [TRedirectHttpCode](type-aliases/TRedirectHttpCode.md)
134089
134071
  - [TValibotResponse](type-aliases/TValibotResponse.md)
134090
134072
  - [TValibotResult](type-aliases/TValibotResult.md)
134091
134073
  - [TValibotTranslate](type-aliases/TValibotTranslate.md)
@@ -134095,6 +134077,63 @@ sys/ctr/index.md
134095
134077
  - [clearLocaleData](functions/clearLocaleData.md)
134096
134078
  - [isHttpRequestAvailable](functions/isHttpRequestAvailable.md)
134097
134079
 
134080
+ sys/ctr/interfaces/IReactPageOptions.md
134081
+ ---
134082
+
134083
+ [**Documents for @maiyunnet/kebab**](../../../index.md)
134084
+
134085
+ ***
134086
+
134087
+ [Documents for @maiyunnet/kebab](../../../index.md) / [sys/ctr](../index.md) / IReactPageOptions
134088
+
134089
+ # Interface: IReactPageOptions
134090
+
134091
+ Defined in: [sys/ctr.ts:102](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L102)
134092
+
134093
+ React SSR 页面选项
134094
+
134095
+ ## Properties
134096
+
134097
+ ### hydrate?
134098
+
134099
+ > `optional` **hydrate?**: `boolean`
134100
+
134101
+ Defined in: [sys/ctr.ts:104](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L104)
134102
+
134103
+ 是否注入客户端水合 bundle,默认 true;设为 false 时仅输出服务端渲染的 HTML
134104
+
134105
+ ***
134106
+
134107
+ ### router?
134108
+
134109
+ > `optional` **router?**: `"browser"`
134110
+
134111
+ Defined in: [sys/ctr.ts:110](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L110)
134112
+
134113
+ 路由模式,不传则不注入任何 Router,组件自行管理路由(如 MemoryRouter)或无路由
134114
+ 'browser':服务端用 StaticRouter,客户端用 BrowserRouter,地址栏与路由联动
134115
+ 组件本身只需使用 Routes/Route/Link 等,不要包含任何 Router 包裹层
134116
+
134117
+ ***
134118
+
134119
+ ### routerBase?
134120
+
134121
+ > `optional` **routerBase?**: `string`
134122
+
134123
+ Defined in: [sys/ctr.ts:112](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L112)
134124
+
134125
+ BrowserRouter 的 basename,相对于 urlBase,默认空字符串
134126
+
134127
+ ***
134128
+
134129
+ ### staticPath?
134130
+
134131
+ > `optional` **staticPath?**: `string`
134132
+
134133
+ Defined in: [sys/ctr.ts:114](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L114)
134134
+
134135
+ 静态资源基础路径,覆盖 config.set.staticPath(支持 CDN)
134136
+
134098
134137
  sys/ctr/interfaces/IValibotOptions.md
134099
134138
  ---
134100
134139
 
@@ -134106,7 +134145,7 @@ sys/ctr/interfaces/IValibotOptions.md
134106
134145
 
134107
134146
  # Interface: IValibotOptions\<TIssue\>
134108
134147
 
134109
- Defined in: [sys/ctr.ts:53](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L53)
134148
+ Defined in: [sys/ctr.ts:56](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L56)
134110
134149
 
134111
134150
  Valibot 同步校验选项
134112
134151
 
@@ -134122,7 +134161,7 @@ Valibot 同步校验选项
134122
134161
 
134123
134162
  > `optional` **config?**: [`Config`](../../../lib/core/namespaces/v/interfaces/Config.md)\<`TIssue`\>
134124
134163
 
134125
- Defined in: [sys/ctr.ts:55](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L55)
134164
+ Defined in: [sys/ctr.ts:58](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L58)
134126
134165
 
134127
134166
  传给 Valibot 的校验配置
134128
134167
 
@@ -134132,7 +134171,7 @@ Defined in: [sys/ctr.ts:55](https://github.com/maiyunnet/kebab/blob/master/sys/c
134132
134171
 
134133
134172
  > `optional` **response?**: [`TValibotResponse`](../type-aliases/TValibotResponse.md)\<`TIssue`\>
134134
134173
 
134135
- Defined in: [sys/ctr.ts:57](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L57)
134174
+ Defined in: [sys/ctr.ts:60](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L60)
134136
134175
 
134137
134176
  校验失败时返回给客户端的内容,默认使用首个 issue 的消息
134138
134177
 
@@ -134142,7 +134181,7 @@ Defined in: [sys/ctr.ts:57](https://github.com/maiyunnet/kebab/blob/master/sys/c
134142
134181
 
134143
134182
  > `optional` **translate?**: [`TValibotTranslate`](../type-aliases/TValibotTranslate.md)
134144
134183
 
134145
- Defined in: [sys/ctr.ts:59](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L59)
134184
+ Defined in: [sys/ctr.ts:62](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L62)
134146
134185
 
134147
134186
  使用完整 issue 路径翻译消息
134148
134187
 
@@ -134157,7 +134196,7 @@ sys/ctr/interfaces/IValibotXOptions.md
134157
134196
 
134158
134197
  # Interface: IValibotXOptions\<TIssue\>
134159
134198
 
134160
- Defined in: [sys/ctr.ts:69](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L69)
134199
+ Defined in: [sys/ctr.ts:72](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L72)
134161
134200
 
134162
134201
  带 XSRF 检测的 Valibot 同步校验选项
134163
134202
 
@@ -134173,7 +134212,7 @@ Defined in: [sys/ctr.ts:69](https://github.com/maiyunnet/kebab/blob/master/sys/c
134173
134212
 
134174
134213
  > `optional` **config?**: [`Config`](../../../lib/core/namespaces/v/interfaces/Config.md)\<`TIssue`\>
134175
134214
 
134176
- Defined in: [sys/ctr.ts:71](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L71)
134215
+ Defined in: [sys/ctr.ts:74](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L74)
134177
134216
 
134178
134217
  传给 Valibot 的校验配置
134179
134218
 
@@ -134183,7 +134222,7 @@ Defined in: [sys/ctr.ts:71](https://github.com/maiyunnet/kebab/blob/master/sys/c
134183
134222
 
134184
134223
  > `optional` **ignoreXsrf?**: `boolean`
134185
134224
 
134186
- Defined in: [sys/ctr.ts:77](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L77)
134225
+ Defined in: [sys/ctr.ts:80](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L80)
134187
134226
 
134188
134227
  是否忽略 XSRF 检测
134189
134228
 
@@ -134193,7 +134232,7 @@ Defined in: [sys/ctr.ts:77](https://github.com/maiyunnet/kebab/blob/master/sys/c
134193
134232
 
134194
134233
  > `optional` **response?**: [`TValibotResponse`](../type-aliases/TValibotResponse.md)\<[`IValibotXsrfIssue`](IValibotXsrfIssue.md) \| `TIssue`\>
134195
134234
 
134196
- Defined in: [sys/ctr.ts:73](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L73)
134235
+ Defined in: [sys/ctr.ts:76](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L76)
134197
134236
 
134198
134237
  校验失败时返回给客户端的内容,回调同时可能收到 XSRF issue
134199
134238
 
@@ -134203,7 +134242,7 @@ Defined in: [sys/ctr.ts:73](https://github.com/maiyunnet/kebab/blob/master/sys/c
134203
134242
 
134204
134243
  > `optional` **translate?**: [`TValibotTranslate`](../type-aliases/TValibotTranslate.md)
134205
134244
 
134206
- Defined in: [sys/ctr.ts:75](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L75)
134245
+ Defined in: [sys/ctr.ts:78](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L78)
134207
134246
 
134208
134247
  使用完整 issue 路径翻译消息,包括 XSRF issue
134209
134248
 
@@ -134218,7 +134257,7 @@ sys/ctr/interfaces/IValibotXsrfIssue.md
134218
134257
 
134219
134258
  # Interface: IValibotXsrfIssue
134220
134259
 
134221
- Defined in: [sys/ctr.ts:63](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L63)
134260
+ Defined in: [sys/ctr.ts:66](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L66)
134222
134261
 
134223
134262
  XSRF 校验失败的问题描述
134224
134263
 
@@ -134302,7 +134341,7 @@ The sub issues.
134302
134341
 
134303
134342
  > `readonly` **kind**: `"validation"`
134304
134343
 
134305
- Defined in: [sys/ctr.ts:64](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L64)
134344
+ Defined in: [sys/ctr.ts:67](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L67)
134306
134345
 
134307
134346
  The issue kind.
134308
134347
 
@@ -134386,7 +134425,7 @@ The input requirement.
134386
134425
 
134387
134426
  > `readonly` **type**: `"xsrf"`
134388
134427
 
134389
- Defined in: [sys/ctr.ts:65](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L65)
134428
+ Defined in: [sys/ctr.ts:68](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L68)
134390
134429
 
134391
134430
  The issue type.
134392
134431
 
@@ -134394,6 +134433,23 @@ The issue type.
134394
134433
 
134395
134434
  [`BaseIssue`](../../../lib/core/namespaces/v/interfaces/BaseIssue.md).[`type`](../../../lib/core/namespaces/v/interfaces/BaseIssue.md#type)
134396
134435
 
134436
+ sys/ctr/type-aliases/TRedirectHttpCode.md
134437
+ ---
134438
+
134439
+ [**Documents for @maiyunnet/kebab**](../../../index.md)
134440
+
134441
+ ***
134442
+
134443
+ [Documents for @maiyunnet/kebab](../../../index.md) / [sys/ctr](../index.md) / TRedirectHttpCode
134444
+
134445
+ # Type Alias: TRedirectHttpCode
134446
+
134447
+ > **TRedirectHttpCode** = `301` \| `302` \| `303` \| `307` \| `308`
134448
+
134449
+ Defined in: [sys/ctr.ts:53](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L53)
134450
+
134451
+ HTTP 重定向状态码
134452
+
134397
134453
  sys/ctr/type-aliases/TValibotResponse.md
134398
134454
  ---
134399
134455
 
@@ -134430,7 +134486,7 @@ sys/ctr/type-aliases/TValibotResult.md
134430
134486
 
134431
134487
  > **TValibotResult**\<`TSchema`, `TIssue`\> = \{ `issues`: `undefined`; `output`: [`InferOutput`](../../../lib/core/namespaces/v/type-aliases/InferOutput.md)\<`TSchema`\>; `response`: `undefined`; `success`: `true`; `typed`: `true`; \} \| \{ `issues`: \[`TIssue`, `...TIssue[]`\]; `output`: `undefined`; `response`: [`Json`](../../../index/type-aliases/Json.md)[]; `success`: `false`; `typed`: `boolean`; \}
134432
134488
 
134433
- Defined in: [sys/ctr.ts:81](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L81)
134489
+ Defined in: [sys/ctr.ts:84](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L84)
134434
134490
 
134435
134491
  Valibot 校验结果:仅成功分支提供 schema 推导后的 output
134436
134492
 
@@ -137190,7 +137246,7 @@ sys/route/functions/getFormData.md
137190
137246
 
137191
137247
  > **getFormData**(`req`, `events?`, `limits?`): `Promise`\<`false` \| \{ `files`: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\>; `post`: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>; \}\>
137192
137248
 
137193
- Defined in: [sys/route.ts:1037](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1037)
137249
+ Defined in: [sys/route.ts:1039](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1039)
137194
137250
 
137195
137251
  获取 formdata 的 post
137196
137252
 
@@ -137287,7 +137343,7 @@ sys/route/functions/getPost.md
137287
137343
 
137288
137344
  > **getPost**(`req`): `Promise`\<`false` \| \{ `input`: `string`; `post`: `Record`\<`string`, `any`\>; `raw`: `Record`\<`string`, `any`\>; \}\>
137289
137345
 
137290
- Defined in: [sys/route.ts:912](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L912)
137346
+ Defined in: [sys/route.ts:914](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L914)
137291
137347
 
137292
137348
  获取 post 对象(通常已自动获取),如果是文件上传(formdata)的情况则不获取
137293
137349
 
@@ -137405,7 +137461,7 @@ sys/route/functions/unlinkUploadFiles.md
137405
137461
 
137406
137462
  > **unlinkUploadFiles**(`cctr`): `Promise`\<`void`\>
137407
137463
 
137408
- Defined in: [sys/route.ts:870](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L870)
137464
+ Defined in: [sys/route.ts:872](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L872)
137409
137465
 
137410
137466
  删除本次请求所有已上传的临时文件
137411
137467
 
@@ -137434,7 +137490,7 @@ sys/route/functions/waitCtr.md
137434
137490
 
137435
137491
  > **waitCtr**(`cctr`): `Promise`\<`void`\>
137436
137492
 
137437
- Defined in: [sys/route.ts:890](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L890)
137493
+ Defined in: [sys/route.ts:892](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L892)
137438
137494
 
137439
137495
  等待异步任务结束,并删除临时文件,如果结束后还有事务没关闭,则会在本函数中打印控制台并且写入 log 文件
137440
137496
  此时其实已经给客户端返回了,此处等待不消耗客户端的等待时间
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.19.0";
8
+ export declare const VER = "9.19.1";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.19.0';
9
+ export const VER = '9.19.1';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.19.0",
3
+ "version": "9.19.1",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/ctr.d.ts CHANGED
@@ -19,6 +19,8 @@ export declare function clearLocaleData(): void;
19
19
  export type TValibotResponse<TIssue extends v.BaseIssue<unknown>> = kebab.Json[] | ((issues: [TIssue, ...TIssue[]]) => kebab.Json[]);
20
20
  /** --- 在 issue 路径完整后,根据 Kebab 生成的语言键翻译消息 --- */
21
21
  export type TValibotTranslate = (key: string, issue: v.BaseIssue<unknown>) => string;
22
+ /** --- HTTP 重定向状态码 --- */
23
+ export type TRedirectHttpCode = 301 | 302 | 303 | 307 | 308;
22
24
  /** --- Valibot 同步校验选项 --- */
23
25
  export interface IValibotOptions<TIssue extends v.BaseIssue<unknown>> {
24
26
  /** --- 传给 Valibot 的校验配置 --- */
@@ -58,6 +60,21 @@ export type TValibotResult<TSchema extends v.GenericSchema, TIssue extends v.Bas
58
60
  readonly issues: [TIssue, ...TIssue[]];
59
61
  readonly response: kebab.Json[];
60
62
  };
63
+ /** --- React SSR 页面选项 --- */
64
+ export interface IReactPageOptions {
65
+ /** --- 是否注入客户端水合 bundle,默认 true;设为 false 时仅输出服务端渲染的 HTML --- */
66
+ 'hydrate'?: boolean;
67
+ /**
68
+ * --- 路由模式,不传则不注入任何 Router,组件自行管理路由(如 MemoryRouter)或无路由 ---
69
+ * --- 'browser':服务端用 StaticRouter,客户端用 BrowserRouter,地址栏与路由联动 ---
70
+ * --- 组件本身只需使用 Routes/Route/Link 等,不要包含任何 Router 包裹层 ---
71
+ */
72
+ 'router'?: 'browser';
73
+ /** --- BrowserRouter 的 basename,相对于 urlBase,默认空字符串 --- */
74
+ 'routerBase'?: string;
75
+ /** --- 静态资源基础路径,覆盖 config.set.staticPath(支持 CDN) --- */
76
+ 'staticPath'?: string;
77
+ }
61
78
  /**
62
79
  * --- 判断当前 HTTP 请求是否仍可响应 ---
63
80
  * @param req 请求对象
@@ -219,26 +236,14 @@ export declare class Ctr {
219
236
  * @param props 传入组件的 props,框架常量自动合并,整体序列化为内联 JSON 供客户端水合复用
220
237
  * @param opt 可选配置
221
238
  */
222
- protected _loadReactPage(path: string, props?: Record<string, kebab.Json>, opt?: {
223
- /** --- 是否注入客户端水合 bundle,默认 true;设为 false 时仅输出服务端渲染的 HTML --- */
224
- 'hydrate'?: boolean;
225
- /**
226
- * --- 路由模式,不传则不注入任何 Router,组件自行管理路由(如 MemoryRouter)或无路由 ---
227
- * --- 'browser':服务端用 StaticRouter,客户端用 BrowserRouter,地址栏与路由联动 ---
228
- * --- 组件本身只需使用 Routes/Route/Link 等,不要包含任何 Router 包裹层 ---
229
- */
230
- 'router'?: 'browser';
231
- /**
232
- * --- BrowserRouter 的 basename,相对于 urlBase,默认空字符串 ---
233
- * --- 例如组件挂载在 /test/react-router-page,则填 'test/react-router-page' ---
234
- */
235
- 'routerBase'?: string;
236
- /**
237
- * --- 静态资源基础路径,覆盖 config.set.staticPath,用于指定 CDN 或自定义路径 ---
238
- * --- 影响 _staticPath prop 以及水合脚本中 JS 文件的 URL 前缀 ---
239
- */
240
- 'staticPath'?: string;
241
- }): Promise<string>;
239
+ protected _loadReactPage(path: string, props?: Record<string, kebab.Json>, opt?: IReactPageOptions): Promise<string>;
240
+ /**
241
+ * --- 记录 React 页面错误并返回脱敏响应 ---
242
+ * @param message 调试信息
243
+ * @param detail 日志详情
244
+ * @returns 脱敏后的 500 页面
245
+ */
246
+ private _reactPageError;
242
247
  /**
243
248
  * --- 设置校验错误返回值 ---
244
249
  * @param rtn 返回值数组
@@ -333,10 +338,11 @@ export declare class Ctr {
333
338
  */
334
339
  protected _loadData<T>(path: string): Promise<T | false | null>;
335
340
  /**
336
- * --- 跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径 ---
341
+ * --- 跳转,支持相对本项目根路径的路径或绝对路径 ---
337
342
  * @param location 相对或绝对网址
343
+ * @param httpCode HTTP 重定向状态码,默认 302
338
344
  */
339
- protected _location(location: string): false;
345
+ protected _location(location: string, httpCode?: TRedirectHttpCode): false;
340
346
  /**
341
347
  * --- 开启 Session ---
342
348
  * @param link Kv 或 Db 实例
package/sys/ctr.js CHANGED
@@ -271,35 +271,28 @@ export class Ctr {
271
271
  * @param opt 可选配置
272
272
  */
273
273
  async _loadReactPage(path, props = {}, opt = {}) {
274
- // --- 约定:传入路径不含 .page 后缀,框架自动补全(对应 build 命令的 *.page.tsx 约定)---
275
- // --- 服务端读取 tsc 生成的组件 JS,浏览器读取 kebab build 生成的 bundle ---
276
- const componentPath = this._config.const.rootPath + 'stc/' + path + '.page.js';
274
+ // --- 校验服务端组件与客户端水合产物 ---
275
+ const hydrate = opt.hydrate !== false;
276
+ const pagePath = `${this._config.const.rootPath}stc/${path}.page`;
277
+ const componentPath = `${pagePath}.js`;
277
278
  if (!await lFs.isFile(componentPath)) {
278
- lCore.debug(`[CTR][_loadReactPage] componentPath ${componentPath} is not a file`);
279
- lCore.log(this, `[CTR][_loadReactPage] componentPath ${componentPath} is not a file`, '-error');
280
- return '';
279
+ return this._reactPageError(`componentPath ${componentPath} is not a file`);
281
280
  }
282
- const bundlePath = this._config.const.rootPath + 'stc/' + path + '.page.bundle.js';
283
- if ((opt.hydrate !== false) && !await lFs.isFile(bundlePath)) {
284
- /** --- 完整错误仅写入服务端日志,避免向客户端暴露文件系统路径 --- */
285
- const message = `[CTR][_loadReactPage] bundlePath ${bundlePath} is not a file; ` +
286
- `run "npx kebab build -d ${this._config.const.rootPath}stc"`;
287
- lCore.debug(message);
288
- lCore.log(this, message, '-error');
289
- this._httpCode = 500;
290
- return '<h1>500 Server Error</h1><hr>Kebab';
281
+ const bundlePath = `${pagePath}.bundle.js`;
282
+ if (hydrate && !await lFs.isFile(bundlePath)) {
283
+ return this._reactPageError(`bundlePath ${bundlePath} is not a file; run "npx kebab build -d ${this._config.const.rootPath}stc"`);
291
284
  }
292
285
  try {
293
- const reactDomServer = await import('react-dom/server');
286
+ // --- 并行加载 SSR 依赖与页面组件 ---
294
287
  const importPath = componentPath.startsWith('/')
295
288
  ? componentPath
296
289
  : `file:///${componentPath.replace(/\\/g, '/')}`;
297
- const mod = await import(importPath);
298
- const component = mod.default;
299
- const react = await import('react');
300
- // --- 语言包数据:当前语种的各命名包已由 _loadLocale 合并 ---
301
- const localeData = { ...(this._localeData[this._locale] ?? {}) };
302
- // --- 把框架常量合并进 props,与 _loadView 行为一致 ---
290
+ const [react, reactDomServer, page] = await Promise.all([
291
+ import('react'),
292
+ import('react-dom/server'),
293
+ import(importPath),
294
+ ]);
295
+ // --- 合并框架 Props 与路由配置 ---
303
296
  const staticPath = opt.staticPath ?? this._config.set.staticPath;
304
297
  const fullProps = {
305
298
  ...props,
@@ -310,50 +303,50 @@ export class Ctr {
310
303
  '_staticPath': staticPath,
311
304
  '_staticPathFull': this._config.set.staticPathFull,
312
305
  '_locale': this._locale,
313
- '_localeData': localeData,
306
+ '_localeData': { ...(this._localeData[this._locale] ?? {}) },
314
307
  };
315
308
  if (opt.router === 'browser') {
316
- // --- BrowserRouter 的 basename 同时用于服务端 StaticRouter 和客户端水合 ---
317
- const base = opt.routerBase ?? '';
318
- const routerBase = this._config.const.urlBase + base.replace(/^\//, '');
309
+ const routerBase = `${this._config.const.urlBase}${(opt.routerBase ?? '').replace(/^\//, '')}`;
319
310
  fullProps['_routerBase'] = routerBase.replace(/\/$/, '');
320
311
  }
321
- // --- 框架自动注入的 HTML 片段,用户组件无需手动渲染 ---
322
- let bodyInject = '';
323
- if (opt.hydrate !== false) {
324
- // --- propsJson 在渲染前序列化,框架直接注入 HTML,组件无需手动渲染 ---
325
- const propsJson = lText.stringifyJson(fullProps).replace(/<\/script>/gi, '<\\/script>');
326
- const clientUrl = `${staticPath}${path}.page.bundle.js?v=${this._config.set.staticVer}`;
327
- // --- props JSON + 水合脚本注入到 </body> 前 ---
328
- bodyInject =
329
- `<script id="__kebab_props__" type="application/json">${propsJson}</script>` +
330
- `<script type="module">import'${clientUrl}';</script>`;
331
- }
332
- // --- BrowserRouter 模式:服务端用 StaticRouter 渲染,与客户端的 BrowserRouter 等价 ---
333
- // --- component 来自动态 import,TypeScript 无法精确推断,需要明确限定 element 类型 ---
334
- let element = react.createElement(component, fullProps);
312
+ // --- 创建页面元素,BrowserRouter 模式下由 StaticRouter 包裹 ---
313
+ const component = page.default;
314
+ const pageElement = react.createElement(component, fullProps);
315
+ let element = pageElement;
335
316
  if (opt.router === 'browser') {
336
- // --- StaticRouter 在 react-router-dom v7 中从主包直接导出,无需 /server 子路径 ---
337
- const lReactRouter = await import('react-router-dom');
338
- const reqUrl = this._req.url ?? '/';
339
- element = react.createElement(lReactRouter.StaticRouter, {
340
- 'location': reqUrl,
317
+ const reactRouter = await import('react-router-dom');
318
+ element = react.createElement(reactRouter.StaticRouter, {
319
+ 'location': this._req.url ?? '/',
341
320
  'basename': fullProps['_routerBase'],
342
- }, react.createElement(component, fullProps));
321
+ }, pageElement);
343
322
  }
344
- // --- 框架将 props JSON + 水合 bundle 注入到 </body> 前 ---
345
- let html = '<!DOCTYPE html>' + reactDomServer.renderToString(element);
346
- if (opt.hydrate !== false) {
347
- html = html.replace('</body>', bodyInject + '</body>');
323
+ // --- 渲染完整 HTML,并按需注入客户端水合数据与 bundle ---
324
+ const html = `<!DOCTYPE html>${reactDomServer.renderToString(element)}`;
325
+ if (!hydrate) {
326
+ return html;
348
327
  }
349
- return html;
328
+ const propsJson = lText.stringifyJson(fullProps).replace(/<\/script>/gi, '<\\/script>');
329
+ const clientUrl = `${staticPath}${path}.page.bundle.js?v=${this._config.set.staticVer}`;
330
+ const propsScript = `<script id="__kebab_props__" type="application/json">${propsJson}</script>`;
331
+ const hydrateScript = `<script type="module">import'${clientUrl}';</script>`;
332
+ return html.replace('</body>', `${propsScript}${hydrateScript}</body>`);
350
333
  }
351
334
  catch (e) {
352
- lCore.debug(`[CTR][_loadReactPage] ${e.message ?? ''}`);
353
- lCore.log(this, '[CTR][_loadReactPage] ' + lText.stringifyError(e), '-error');
354
- return '';
335
+ return this._reactPageError(e.message ?? '', lText.stringifyError(e));
355
336
  }
356
337
  }
338
+ /**
339
+ * --- 记录 React 页面错误并返回脱敏响应 ---
340
+ * @param message 调试信息
341
+ * @param detail 日志详情
342
+ * @returns 脱敏后的 500 页面
343
+ */
344
+ _reactPageError(message, detail = message) {
345
+ lCore.debug(`[CTR][_loadReactPage] ${message}`);
346
+ lCore.log(this, `[CTR][_loadReactPage] ${detail}`, '-error');
347
+ this._httpCode = 500;
348
+ return '<h1>500 Server Error</h1><hr>Kebab';
349
+ }
357
350
  /**
358
351
  * --- 设置校验错误返回值 ---
359
352
  * @param rtn 返回值数组
@@ -783,13 +776,15 @@ export class Ctr {
783
776
  return json;
784
777
  }
785
778
  /**
786
- * --- 跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径 ---
779
+ * --- 跳转,支持相对本项目根路径的路径或绝对路径 ---
787
780
  * @param location 相对或绝对网址
781
+ * @param httpCode HTTP 重定向状态码,默认 302
788
782
  */
789
- _location(location) {
783
+ _location(location, httpCode = 302) {
784
+ this._httpCode = httpCode;
790
785
  if (this._res) {
791
786
  this._res.setHeader('location', lText.urlResolve(this._config.const.urlBase, location));
792
- // this._res.writeHead(302); Kebab 中要在最后设置,否则会报错:ERR_HTTP_HEADERS_SENT
787
+ // this._res.writeHead(httpCode); Kebab 中要在最后设置,否则会报错:ERR_HTTP_HEADERS_SENT
793
788
  }
794
789
  return false;
795
790
  }
package/sys/route.js CHANGED
@@ -581,6 +581,8 @@ export async function run(data) {
581
581
  data.res.setHeader('expires', new Date(Date.now() + cacheTTL * 1_000).toUTCString());
582
582
  data.res.setHeader('cache-control', 'max-age=' + cacheTTL.toString());
583
583
  }
584
+ // --- 记录控制器是否显式设置状态码;未设置时,带 Location 的空响应仍兼容为 302 ---
585
+ const hasCustomHttpCode = httpCode !== 0;
584
586
  // --- 设置自定义 hcode ---
585
587
  if (httpCode === 0) {
586
588
  httpCode = 200;
@@ -591,7 +593,7 @@ export async function run(data) {
591
593
  // --- 已经自行输出过 writeHead,可能自行处理了内容,如 pipe,则不再 writeHead ---
592
594
  }
593
595
  else {
594
- lCore.writeHead(data.res, data.res.getHeader('location') ? 302 : httpCode);
596
+ lCore.writeHead(data.res, data.res.getHeader('location') && !hasCustomHttpCode ? 302 : httpCode);
595
597
  }
596
598
  if (!data.res.writableEnded) {
597
599
  // --- 如果当前还没结束,则强制关闭连接,一切 pipe 请自行在方法中 await,否则会被中断 ---