@kengic/uni 0.6.3-beta.24 → 0.6.3-beta.26

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.
@@ -34,7 +34,7 @@ uni.addInterceptor('request', {
34
34
  args.data = keys.map((i) => args.data[i]);
35
35
  }
36
36
 
37
- args.data = Kg.parseParams(args.data);
37
+ args.data = Kg.parseParams(null, args.data);
38
38
  },
39
39
  success(args) {
40
40
  uni.hideLoading();
@@ -214,19 +214,41 @@ const _httpClient: IHttpClient = {
214
214
  if (options?.dynamicQueryOperatorModel) {
215
215
  let params: any = {};
216
216
 
217
- if (config.method === 'GET') {
218
- params = config.params;
219
- } else if (config.method === 'POST' && !config.data && config.params) {
220
- params = config.params;
221
- } else if (config.method === 'POST' && config.data) {
222
- params = config.data;
217
+ switch (config.method) {
218
+ case 'GET': {
219
+ if (config.params) {
220
+ params = config.params;
221
+ break;
222
+ }
223
+
224
+ if (config.data && !config.params) {
225
+ params = config.data;
226
+ break;
227
+ }
228
+
229
+ break;
230
+ }
231
+
232
+ case 'POST': {
233
+ if (config.data) {
234
+ params = config.data;
235
+ break;
236
+ }
237
+
238
+ if (!config.data && config.params) {
239
+ params = config.params;
240
+ break;
241
+ }
242
+
243
+ break;
244
+ }
223
245
  }
224
246
 
225
247
  const { sql, whereSql, orderBySql, offsetSql, operatorJSON } = Kg.getQueryHeaders({
226
248
  $dayjs: options?.$dayjs,
227
249
  dynamicQueryExcludeProperties: options?.dynamicQueryExcludeProperties,
228
250
  dynamicQueryOperatorModel: options?.dynamicQueryOperatorModel,
229
- params: Kg.parseParams(params),
251
+ params: Kg.parseParams(options?.$dayjs, params),
230
252
  });
231
253
 
232
254
  header = {
package/dist/util/kg.ts CHANGED
@@ -36,9 +36,10 @@ export class Kg {
36
36
  * </li>
37
37
  * </ol>
38
38
  *
39
+ * @param $dayjs.
39
40
  * @param params 请求参数.
40
41
  */
41
- public static parseParams(params?: Record<string, any> | null): any {
42
+ public static parseParams($dayjs: typeof dayjs | null | undefined, params?: Record<string, any> | null): any {
42
43
  let _params = toRaw(unref(params))!;
43
44
 
44
45
  if (!_params || !isObjectLike(_params)) {
@@ -52,8 +53,13 @@ export class Kg {
52
53
  const value = _params[key];
53
54
 
54
55
  switch (true) {
56
+ case !!$dayjs && isArray(value) && value.length === 2 && $dayjs.isDayjs(value[0]) && $dayjs.isDayjs(value[1]): {
57
+ resultParams[key] = value;
58
+ break;
59
+ }
60
+
55
61
  case isObjectLike(value):
56
- resultParams[key] = this.parseParams(value);
62
+ resultParams[key] = this.parseParams($dayjs, value);
57
63
  break;
58
64
 
59
65
  case typeof value === 'string':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.6.3-beta.24",
3
+ "version": "0.6.3-beta.26",
4
4
  "scripts": {
5
5
  "build": "npm run use-node && rimraf dist && vue-tsc && vite build",
6
6
  "------ -------------------------------------------": "",