@maiyunnet/kebab 9.13.3 → 9.13.5

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
@@ -1360,7 +1360,7 @@ index/variables/VER.md
1360
1360
 
1361
1361
  # Variable: VER
1362
1362
 
1363
- > `const` **VER**: `"9.13.3"` = `'9.13.3'`
1363
+ > `const` **VER**: `"9.13.5"` = `'9.13.5'`
1364
1364
 
1365
1365
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1366
1366
 
@@ -22762,9 +22762,9 @@ Defined in: [sys/ctr.ts:571](https://github.com/maiyunnet/kebab/blob/master/sys/
22762
22762
 
22763
22763
  ### \_checkXInput()
22764
22764
 
22765
- > `protected` **\_checkXInput**(`input`, `rule`, `rtn`): `boolean`
22765
+ > `protected` **\_checkXInput**(`input`, `rule`, `rtn`, `ignore?`): `boolean`
22766
22766
 
22767
- Defined in: [sys/ctr.ts:749](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L749)
22767
+ Defined in: [sys/ctr.ts:750](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L750)
22768
22768
 
22769
22769
  检测提交的数据类型(会检测 XSRF)
22770
22770
 
@@ -22788,6 +22788,12 @@ Defined in: [sys/ctr.ts:749](https://github.com/maiyunnet/kebab/blob/master/sys/
22788
22788
 
22789
22789
  返回值
22790
22790
 
22791
+ ##### ignore?
22792
+
22793
+ `boolean` = `false`
22794
+
22795
+ 忽略 xsrf 判断
22796
+
22791
22797
  #### Returns
22792
22798
 
22793
22799
  `boolean`
@@ -22798,7 +22804,7 @@ Defined in: [sys/ctr.ts:749](https://github.com/maiyunnet/kebab/blob/master/sys/
22798
22804
 
22799
22805
  > `protected` **\_cross**(`opt?`): `boolean`
22800
22806
 
22801
- Defined in: [sys/ctr.ts:978](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L978)
22807
+ Defined in: [sys/ctr.ts:985](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L985)
22802
22808
 
22803
22809
  开启跨域请求
22804
22810
 
@@ -22843,7 +22849,7 @@ Defined in: [sys/ctr.ts:978](https://github.com/maiyunnet/kebab/blob/master/sys/
22843
22849
 
22844
22850
  > `protected` **\_device**(): `"unknown"` \| `"android"` \| `"linux"` \| `"windows"` \| `"macintosh"` \| `"ipad"`
22845
22851
 
22846
- Defined in: [sys/ctr.ts:791](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L791)
22852
+ Defined in: [sys/ctr.ts:795](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L795)
22847
22853
 
22848
22854
  根据用户 ua 获取当前用户的设备类型
22849
22855
 
@@ -22857,7 +22863,7 @@ Defined in: [sys/ctr.ts:791](https://github.com/maiyunnet/kebab/blob/master/sys/
22857
22863
 
22858
22864
  > `protected` **\_enabledXsrf**(`opt?`): `void`
22859
22865
 
22860
- Defined in: [sys/ctr.ts:760](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L760)
22866
+ Defined in: [sys/ctr.ts:764](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L764)
22861
22867
 
22862
22868
  当前页面开启 XSRF 支持(主要检测 cookie 是否存在)
22863
22869
  如果当前页面有 CDN,请不要使用
@@ -22880,7 +22886,7 @@ Defined in: [sys/ctr.ts:760](https://github.com/maiyunnet/kebab/blob/master/sys/
22880
22886
 
22881
22887
  > `protected` **\_end**(): `void`
22882
22888
 
22883
- Defined in: [sys/ctr.ts:1086](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1086)
22889
+ Defined in: [sys/ctr.ts:1093](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1093)
22884
22890
 
22885
22891
  主动关闭当前 socket 连接
22886
22892
 
@@ -22894,7 +22900,7 @@ Defined in: [sys/ctr.ts:1086](https://github.com/maiyunnet/kebab/blob/master/sys
22894
22900
 
22895
22901
  > `protected` **\_getBasicAuth**(`user`, `pwd`): `string`
22896
22902
 
22897
- Defined in: [sys/ctr.ts:784](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L784)
22903
+ Defined in: [sys/ctr.ts:788](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L788)
22898
22904
 
22899
22905
  获取 Auth 字符串,用于客户端提交
22900
22906
 
@@ -22922,7 +22928,7 @@ Defined in: [sys/ctr.ts:784](https://github.com/maiyunnet/kebab/blob/master/sys/
22922
22928
 
22923
22929
  > `protected` **\_getLocale**(): `string`
22924
22930
 
22925
- Defined in: [sys/ctr.ts:969](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L969)
22931
+ Defined in: [sys/ctr.ts:976](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L976)
22926
22932
 
22927
22933
  获取当前语言名
22928
22934
 
@@ -22936,7 +22942,7 @@ Defined in: [sys/ctr.ts:969](https://github.com/maiyunnet/kebab/blob/master/sys/
22936
22942
 
22937
22943
  > `protected` **\_getLocaleJsonString**(): `string`
22938
22944
 
22939
- Defined in: [sys/ctr.ts:957](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L957)
22945
+ Defined in: [sys/ctr.ts:964](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L964)
22940
22946
 
22941
22947
  根据当前后台语言包设置情况获取 JSON 字符串传输到前台
22942
22948
 
@@ -22988,7 +22994,7 @@ Defined in: [sys/ctr.ts:315](https://github.com/maiyunnet/kebab/blob/master/sys/
22988
22994
 
22989
22995
  > `protected` **\_handleFormData**(`events?`, `limits?`): `Promise`\<`boolean`\>
22990
22996
 
22991
- Defined in: [sys/ctr.ts:1095](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1095)
22997
+ Defined in: [sys/ctr.ts:1102](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1102)
22992
22998
 
22993
22999
  获取 formdata 的信息
22994
23000
 
@@ -23036,7 +23042,7 @@ Defined in: [sys/ctr.ts:1095](https://github.com/maiyunnet/kebab/blob/master/sys
23036
23042
 
23037
23043
  > **\_l**(`key`, `data?`): `string`
23038
23044
 
23039
- Defined in: [sys/ctr.ts:1021](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1021)
23045
+ Defined in: [sys/ctr.ts:1028](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1028)
23040
23046
 
23041
23047
  获取语言包值
23042
23048
 
@@ -23060,11 +23066,17 @@ Defined in: [sys/ctr.ts:1021](https://github.com/maiyunnet/kebab/blob/master/sys
23060
23066
 
23061
23067
  ### \_loadData()
23062
23068
 
23063
- > `protected` **\_loadData**(`path`): `Promise`\<`Record`\<`string`, `string`\> \| `null`\>
23069
+ > `protected` **\_loadData**\<`T`\>(`path`): `Promise`\<`false` \| `T` \| `null`\>
23064
23070
 
23065
- Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L860)
23071
+ Defined in: [sys/ctr.ts:864](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L864)
23066
23072
 
23067
- 获取 data 数据
23073
+ 获取 data JSON 数据
23074
+
23075
+ #### Type Parameters
23076
+
23077
+ ##### T
23078
+
23079
+ `T`
23068
23080
 
23069
23081
  #### Parameters
23070
23082
 
@@ -23076,7 +23088,7 @@ Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/
23076
23088
 
23077
23089
  #### Returns
23078
23090
 
23079
- `Promise`\<`Record`\<`string`, `string`\> \| `null`\>
23091
+ `Promise`\<`false` \| `T` \| `null`\>
23080
23092
 
23081
23093
  ***
23082
23094
 
@@ -23084,7 +23096,7 @@ Defined in: [sys/ctr.ts:860](https://github.com/maiyunnet/kebab/blob/master/sys/
23084
23096
 
23085
23097
  > `protected` **\_loadLocale**(`loc`, `pkg?`): `Promise`\<`boolean`\>
23086
23098
 
23087
- Defined in: [sys/ctr.ts:908](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L908)
23099
+ Defined in: [sys/ctr.ts:915](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L915)
23088
23100
 
23089
23101
  设定语言并加载语言包
23090
23102
 
@@ -23205,7 +23217,7 @@ Defined in: [sys/ctr.ts:332](https://github.com/maiyunnet/kebab/blob/master/sys/
23205
23217
 
23206
23218
  > `protected` **\_location**(`location`): `false`
23207
23219
 
23208
- Defined in: [sys/ctr.ts:878](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L878)
23220
+ Defined in: [sys/ctr.ts:885](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L885)
23209
23221
 
23210
23222
  跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径
23211
23223
 
@@ -23227,7 +23239,7 @@ Defined in: [sys/ctr.ts:878](https://github.com/maiyunnet/kebab/blob/master/sys/
23227
23239
 
23228
23240
  > `protected` **\_ping**(`data?`): `boolean`
23229
23241
 
23230
- Defined in: [sys/ctr.ts:1071](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1071)
23242
+ Defined in: [sys/ctr.ts:1078](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1078)
23231
23243
 
23232
23244
  发送 socket ping
23233
23245
 
@@ -23249,7 +23261,7 @@ Defined in: [sys/ctr.ts:1071](https://github.com/maiyunnet/kebab/blob/master/sys
23249
23261
 
23250
23262
  > `protected` **\_pong**(`data?`): `boolean`
23251
23263
 
23252
- Defined in: [sys/ctr.ts:1079](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1079)
23264
+ Defined in: [sys/ctr.ts:1086](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1086)
23253
23265
 
23254
23266
  发送 socket pong
23255
23267
 
@@ -23271,7 +23283,7 @@ Defined in: [sys/ctr.ts:1079](https://github.com/maiyunnet/kebab/blob/master/sys
23271
23283
 
23272
23284
  > `protected` **\_startSession**(`link`, `auth?`, `opt?`): `Promise`\<`boolean`\>
23273
23285
 
23274
- Defined in: [sys/ctr.ts:892](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L892)
23286
+ Defined in: [sys/ctr.ts:899](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L899)
23275
23287
 
23276
23288
  开启 Session
23277
23289
 
@@ -23305,7 +23317,7 @@ Kv 或 Db 实例
23305
23317
 
23306
23318
  > `protected` **\_writeBinary**(`data`): `boolean`
23307
23319
 
23308
- Defined in: [sys/ctr.ts:1063](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1063)
23320
+ Defined in: [sys/ctr.ts:1070](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1070)
23309
23321
 
23310
23322
  发送 socket 二进制
23311
23323
 
@@ -23327,7 +23339,7 @@ Defined in: [sys/ctr.ts:1063](https://github.com/maiyunnet/kebab/blob/master/sys
23327
23339
 
23328
23340
  > `protected` **\_writeResult**(`data`): `boolean`
23329
23341
 
23330
- Defined in: [sys/ctr.ts:1055](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1055)
23342
+ Defined in: [sys/ctr.ts:1062](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1062)
23331
23343
 
23332
23344
  发送结果对象文本
23333
23345
 
@@ -23349,7 +23361,7 @@ Defined in: [sys/ctr.ts:1055](https://github.com/maiyunnet/kebab/blob/master/sys
23349
23361
 
23350
23362
  > `protected` **\_writeText**(`data`): `boolean`
23351
23363
 
23352
- Defined in: [sys/ctr.ts:1047](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1047)
23364
+ Defined in: [sys/ctr.ts:1054](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L1054)
23353
23365
 
23354
23366
  发送 socket 文本
23355
23367
 
@@ -23371,7 +23383,7 @@ Defined in: [sys/ctr.ts:1047](https://github.com/maiyunnet/kebab/blob/master/sys
23371
23383
 
23372
23384
  > **getAuthorization**(): `false` \| \{ `pwd`: `string`; `type`: `"basic"`; `user`: `string`; \} \| \{ `token`: `string`; `type`: `"bearer"`; \}
23373
23385
 
23374
- Defined in: [sys/ctr.ts:812](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L812)
23386
+ Defined in: [sys/ctr.ts:816](https://github.com/maiyunnet/kebab/blob/master/sys/ctr.ts#L816)
23375
23387
 
23376
23388
  通过 header 或 _auth 获取鉴权信息,支持 Basic Auth 和 Bearer Token
23377
23389
 
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.13.3";
8
+ export declare const VER = "9.13.5";
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.13.3';
9
+ export const VER = '9.13.5';
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.13.3",
3
+ "version": "9.13.5",
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
@@ -212,8 +212,9 @@ export declare class Ctr {
212
212
  * @param input 要校验的输入项
213
213
  * @param rule 规则, int, double, num(可字符串), array, bool, string, ascii
214
214
  * @param rtn 返回值
215
+ * @param ignore 忽略 xsrf 判断
215
216
  */
216
- protected _checkXInput(input: Record<string, kebab.Json>, rule: Record<string, kebab.Json[]>, rtn: kebab.Json[]): boolean;
217
+ protected _checkXInput(input: Record<string, kebab.Json>, rule: Record<string, kebab.Json[]>, rtn: kebab.Json[], ignore?: boolean): boolean;
217
218
  /**
218
219
  * --- 当前页面开启 XSRF 支持(主要检测 cookie 是否存在) ---
219
220
  * --- 如果当前页面有 CDN,请不要使用 ---
@@ -245,10 +246,10 @@ export declare class Ctr {
245
246
  'token': string;
246
247
  } | false;
247
248
  /**
248
- * --- 获取 data 数据 ---
249
+ * --- 获取 data JSON 数据 ---
249
250
  * @param path 文件路径(不含扩展名)
250
251
  */
251
- protected _loadData(path: string): Promise<Record<string, string> | null>;
252
+ protected _loadData<T>(path: string): Promise<T | false | null>;
252
253
  /**
253
254
  * --- 跳转(302临时跳转),支持相对本项目根路径的路径或绝对路径 ---
254
255
  * @param location 相对或绝对网址
package/sys/ctr.js CHANGED
@@ -595,9 +595,12 @@ export class Ctr {
595
595
  * @param input 要校验的输入项
596
596
  * @param rule 规则, int, double, num(可字符串), array, bool, string, ascii
597
597
  * @param rtn 返回值
598
+ * @param ignore 忽略 xsrf 判断
598
599
  */
599
- _checkXInput(input, rule, rtn) {
600
- rule['_xsrf'] ??= ['require', this._cookie['XSRF-TOKEN'], [0, 'Bad request, no permission.']];
600
+ _checkXInput(input, rule, rtn, ignore = false) {
601
+ if (!ignore) {
602
+ rule['_xsrf'] ??= ['require', this._cookie['XSRF-TOKEN'], [0, 'Bad request, no permission.']];
603
+ }
601
604
  return this._checkInput(input, rule, rtn);
602
605
  }
603
606
  /**
@@ -692,7 +695,7 @@ export class Ctr {
692
695
  return this._authorization;
693
696
  }
694
697
  /**
695
- * --- 获取 data 数据 ---
698
+ * --- 获取 data JSON 数据 ---
696
699
  * @param path 文件路径(不含扩展名)
697
700
  */
698
701
  async _loadData(path) {
@@ -705,6 +708,9 @@ export class Ctr {
705
708
  return null;
706
709
  }
707
710
  const json = lText.parseJson(content);
711
+ if (!json) {
712
+ return false;
713
+ }
708
714
  loadedData[realPath] = json;
709
715
  return json;
710
716
  }
@@ -744,7 +750,7 @@ export class Ctr {
744
750
  if (!localeFiles.includes(lPath)) {
745
751
  // --- 全局缓存没有,先加载全局缓存 ---
746
752
  const locData = await this._loadData('locale/' + lName);
747
- if (locData === null) {
753
+ if (!locData) {
748
754
  return false;
749
755
  }
750
756
  this._locale = loc;