@pisell/pisellos 0.0.207 → 0.0.209

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.
Files changed (58) hide show
  1. package/dist/effects/index.d.ts +1 -1
  2. package/dist/modules/Cart/index.d.ts +1 -0
  3. package/dist/modules/Cart/index.js +42 -14
  4. package/dist/modules/Cart/utils/changePrice.d.ts +1 -1
  5. package/dist/modules/Cart/utils/changePrice.js +8 -3
  6. package/dist/modules/Order/index.js +2 -2
  7. package/dist/modules/Rules/index.js +5 -5
  8. package/dist/modules/Rules/types.d.ts +1 -1
  9. package/dist/modules/Schedule/type.d.ts +7 -7
  10. package/dist/modules/Schedule/types.d.ts +9 -9
  11. package/dist/solution/BookingByStep/index.d.ts +1 -0
  12. package/dist/solution/BookingByStep/index.js +10 -5
  13. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  14. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  15. package/dist/types/index.d.ts +1 -1
  16. package/lib/core/index.js +28 -27
  17. package/lib/effects/index.d.ts +1 -1
  18. package/lib/effects/index.js +7 -3
  19. package/lib/modules/Account/index.js +10 -9
  20. package/lib/modules/AccountList/index.js +11 -14
  21. package/lib/modules/BaseModule.js +3 -6
  22. package/lib/modules/Cart/index.d.ts +1 -0
  23. package/lib/modules/Cart/index.js +19 -14
  24. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  25. package/lib/modules/Cart/utils/changePrice.d.ts +1 -1
  26. package/lib/modules/Cart/utils/changePrice.js +5 -1
  27. package/lib/modules/Date/index.js +4 -8
  28. package/lib/modules/Date/types.js +0 -1
  29. package/lib/modules/Discount/index.js +6 -11
  30. package/lib/modules/Guests/index.js +15 -10
  31. package/lib/modules/Order/index.js +4 -6
  32. package/lib/modules/Payment/cash.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +86 -98
  35. package/lib/modules/Payment/wallet.js +1 -1
  36. package/lib/modules/Product/index.js +5 -6
  37. package/lib/modules/ProductList/index.js +4 -5
  38. package/lib/modules/Resource/index.js +12 -8
  39. package/lib/modules/Rules/index.js +17 -14
  40. package/lib/modules/Rules/types.d.ts +1 -1
  41. package/lib/modules/Schedule/index.js +5 -8
  42. package/lib/modules/Schedule/type.d.ts +7 -7
  43. package/lib/modules/Schedule/types.d.ts +9 -9
  44. package/lib/modules/Schedule/utils.js +4 -2
  45. package/lib/modules/Step/index.js +4 -7
  46. package/lib/modules/Summary/index.js +4 -9
  47. package/lib/plugins/request.js +33 -34
  48. package/lib/plugins/window.js +113 -101
  49. package/lib/solution/BookingByStep/index.d.ts +1 -0
  50. package/lib/solution/BookingByStep/index.js +79 -53
  51. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  52. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  53. package/lib/solution/BookingByStep/utils/timeslots.js +12 -6
  54. package/lib/solution/BuyTickets/index.js +15 -15
  55. package/lib/solution/ShopDiscount/index.js +11 -15
  56. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  57. package/lib/types/index.d.ts +1 -1
  58. package/package.json +1 -1
@@ -26,14 +26,13 @@ module.exports = __toCommonJS(Product_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
27
  __reExport(Product_exports, require("./types"), module.exports);
28
28
  var Product = class extends import_BaseModule.BaseModule {
29
- defaultName = "product";
30
- defaultVersion = "1.0.0";
31
- store;
32
- otherParams = {
33
- scheduler: []
34
- };
35
29
  constructor(name, version) {
36
30
  super(name, version);
31
+ this.defaultName = "product";
32
+ this.defaultVersion = "1.0.0";
33
+ this.otherParams = {
34
+ scheduler: []
35
+ };
37
36
  }
38
37
  async initialize(core, options) {
39
38
  this.core = core;
@@ -29,12 +29,10 @@ var import_types = require("./types");
29
29
  var import_lodash_es = require("lodash-es");
30
30
  __reExport(ProductList_exports, require("./types"), module.exports);
31
31
  var ProductList = class extends import_BaseModule.BaseModule {
32
- defaultName = "productList";
33
- defaultVersion = "1.0.0";
34
- store;
35
- request;
36
32
  constructor(name, version) {
37
33
  super(name, version);
34
+ this.defaultName = "productList";
35
+ this.defaultVersion = "1.0.0";
38
36
  }
39
37
  async initialize(core, options) {
40
38
  var _a;
@@ -142,7 +140,8 @@ var ProductList = class extends import_BaseModule.BaseModule {
142
140
  this.store.list
143
141
  );
144
142
  const product = this.store.productMap.get(`${id}`);
145
- if (product) return product;
143
+ if (product)
144
+ return product;
146
145
  return void 0;
147
146
  }
148
147
  async addProduct(products) {
@@ -25,11 +25,10 @@ module.exports = __toCommonJS(Resource_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var import_types = require("./types");
27
27
  var ResourceListModule = class extends import_BaseModule.BaseModule {
28
- defaultName = "resourceList";
29
- defaultVersion = "1.0.0";
30
- store;
31
28
  constructor(name, version) {
32
29
  super(name, version);
30
+ this.defaultName = "resourceList";
31
+ this.defaultVersion = "1.0.0";
33
32
  }
34
33
  async initialize(core, options) {
35
34
  this.core = core;
@@ -40,7 +39,8 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
40
39
  }
41
40
  async selectResource(resourceId) {
42
41
  const resource = this.store.list.find((r) => r.id === resourceId);
43
- if (!resource) return;
42
+ if (!resource)
43
+ return;
44
44
  this.store.selectedResource = resource;
45
45
  await this.core.effects.emit(import_types.ResourceHooks.OnResourceSelect, resource);
46
46
  }
@@ -49,19 +49,22 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
49
49
  }
50
50
  async checkAvailability(resourceId, start, end) {
51
51
  const resource = this.store.list.find((r) => r.id === resourceId);
52
- if (!resource) return false;
52
+ if (!resource)
53
+ return false;
53
54
  return resource.timeSlots.some(
54
55
  (slot) => slot.start.getTime() <= start.getTime() && slot.end.getTime() >= end.getTime() && slot.availableCapacity > 0
55
56
  );
56
57
  }
57
58
  async getAvailableTimeSlots(resourceId) {
58
59
  const resource = this.store.list.find((r) => r.id === resourceId);
59
- if (!resource) return [];
60
+ if (!resource)
61
+ return [];
60
62
  return resource.timeSlots.filter((slot) => slot.availableCapacity > 0);
61
63
  }
62
64
  getAvailableCapacity(resourceId, timeSlot) {
63
65
  const resource = this.store.list.find((r) => r.id === resourceId);
64
- if (!resource) return 0;
66
+ if (!resource)
67
+ return 0;
65
68
  const slot = resource.timeSlots.find(
66
69
  (s) => s.start.getTime() === timeSlot.start.getTime() && s.end.getTime() === timeSlot.end.getTime()
67
70
  );
@@ -69,7 +72,8 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
69
72
  }
70
73
  async updateResource(resourceId, updates) {
71
74
  const index = this.store.list.findIndex((r) => r.id === resourceId);
72
- if (index === -1) return;
75
+ if (index === -1)
76
+ return;
73
77
  this.store.list[index] = {
74
78
  ...this.store.list[index],
75
79
  ...updates
@@ -38,12 +38,10 @@ var import_utils = require("../../solution/ShopDiscount/utils");
38
38
  var import_utils2 = require("../Cart/utils");
39
39
  var import_decimal = __toESM(require("decimal.js"));
40
40
  var RulesModule = class extends import_BaseModule.BaseModule {
41
- defaultName = "rules";
42
- defaultVersion = "1.0.0";
43
- store;
44
- hooks;
45
41
  constructor(name, version) {
46
42
  super(name, version);
43
+ this.defaultName = "rules";
44
+ this.defaultVersion = "1.0.0";
47
45
  this.hooks = {};
48
46
  }
49
47
  async initialize(core, options) {
@@ -133,8 +131,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
133
131
  return !discount.isManualSelect;
134
132
  });
135
133
  const sortedDiscountList = [...filteredDiscountList].sort((a, b) => {
136
- if (a.tag === "good_pass" && b.tag !== "good_pass") return -1;
137
- if (b.tag === "good_pass" && a.tag !== "good_pass") return 1;
134
+ if (a.tag === "good_pass" && b.tag !== "good_pass")
135
+ return -1;
136
+ if (b.tag === "good_pass" && a.tag !== "good_pass")
137
+ return 1;
138
138
  if (a.tag === "good_pass" && b.tag === "good_pass") {
139
139
  return compareByExpireTime(a, b);
140
140
  } else if (a.tag === "product_discount_card" && b.tag === "product_discount_card") {
@@ -215,13 +215,16 @@ var RulesModule = class extends import_BaseModule.BaseModule {
215
215
  }
216
216
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
217
217
  var _a2;
218
- if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass") return false;
218
+ if ((Number(product.price) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
219
+ return false;
219
220
  if ((Number(product.total) === 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
220
221
  var _a3;
221
222
  return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
222
- })) && (discount.tag || discount.type) !== "good_pass") return false;
223
+ })) && (discount.tag || discount.type) !== "good_pass")
224
+ return false;
223
225
  const targetUsedDiscounts = usedDiscounts.get(discount.id);
224
- if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass") return false;
226
+ if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
227
+ return false;
225
228
  const limitedData = discount.limited_relation_product_data;
226
229
  if (limitedData.type === "product_all") {
227
230
  return true;
@@ -299,12 +302,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
299
302
  usedDiscounts.set(selectedDiscount2.id, true);
300
303
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
301
304
  let productOriginTotal = product.origin_total || product.total || 0;
302
- if (Number(((_g = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _g.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
303
- productOriginTotal = product.total;
304
- }
305
- if (((_h = product.discount_list) == null ? void 0 : _h.length) && product.origin_total) {
305
+ if (((_g = product.discount_list) == null ? void 0 : _g.length) && product.origin_total) {
306
306
  productOriginTotal = product.origin_total;
307
307
  }
308
+ if (Number(((_h = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _h.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
309
+ productOriginTotal = product.total;
310
+ }
308
311
  const targetProductTotal = selectedDiscount2.tag === "good_pass" ? new import_decimal.default(productOriginTotal).minus(new import_decimal.default(product.price || 0)).toNumber() : new import_decimal.default(100).minus(selectedDiscount2.par_value || 0).div(100).mul(new import_decimal.default(productOriginTotal)).toNumber();
309
312
  const discountDetail = {
310
313
  amount: new import_decimal.default(productOriginTotal).minus(new import_decimal.default(targetProductTotal)).toNumber(),
@@ -450,7 +453,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
450
453
  async destroy() {
451
454
  this.core.effects.offByModuleDestroy(this.name);
452
455
  await this.core.effects.emit(import_types.RulesHooks.OnDestroy, {});
453
- console.log("[Rules] \u5DF2\u9500\u6BC1");
456
+ console.log("[Rules] 已销毁");
454
457
  }
455
458
  async clear() {
456
459
  console.log("[Rules] clear");
@@ -24,7 +24,7 @@ export interface RulesModuleAPI {
24
24
  productList: any[];
25
25
  }) => DiscountResult;
26
26
  }
27
- declare type ProductDetail = {
27
+ type ProductDetail = {
28
28
  isClient?: boolean;
29
29
  isManualDiscount?: boolean;
30
30
  booking_id: any;
@@ -41,22 +41,19 @@ var import_utils = require("../Date/utils");
41
41
  import_dayjs.default.extend(import_isSameOrBefore.default);
42
42
  import_dayjs.default.extend(import_isSameOrAfter.default);
43
43
  var ScheduleModule = class extends import_BaseModule.BaseModule {
44
- defaultName = "schedule";
45
- defaultVersion = "1.0.0";
46
- request;
47
- store = {};
48
- cacheId;
49
- openCache = false;
50
- fatherModule;
51
44
  constructor(name, version) {
52
45
  super(name, version);
46
+ this.defaultName = "schedule";
47
+ this.defaultVersion = "1.0.0";
48
+ this.store = {};
49
+ this.openCache = false;
53
50
  }
54
51
  async initialize(core, options) {
55
52
  var _a, _b;
56
53
  this.core = core;
57
54
  this.request = core.getPlugin("request");
58
55
  if (!this.request) {
59
- throw new Error("ScheduleModule \u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
56
+ throw new Error("ScheduleModule 需要 request 插件支持");
60
57
  }
61
58
  this.store = options == null ? void 0 : options.store;
62
59
  if (options.initialState) {
@@ -1,4 +1,4 @@
1
- export declare type ScheduleItem = {
1
+ export type ScheduleItem = {
2
2
  /** 颜色 */
3
3
  color: string;
4
4
  /** 创建时间 */
@@ -65,7 +65,7 @@ export declare type ScheduleItem = {
65
65
  schedule_id: number;
66
66
  }[];
67
67
  };
68
- export declare type ScheduleFormOtherValue = {
68
+ export type ScheduleFormOtherValue = {
69
69
  /** 截止模式
70
70
  * 1: 永不截止
71
71
  * 2: 按日期截止
@@ -79,11 +79,11 @@ export declare type ScheduleFormOtherValue = {
79
79
  includeStatus: boolean;
80
80
  type: 'standard' | 'time-slots' | 'designation';
81
81
  };
82
- export declare type ExcIncDate = {
82
+ export type ExcIncDate = {
83
83
  start: string;
84
84
  end: string;
85
85
  };
86
- export declare type ScheduleFormData = {
86
+ export type ScheduleFormData = {
87
87
  /** 颜色 */
88
88
  color: string;
89
89
  /** 日程名称 */
@@ -131,20 +131,20 @@ export declare type ScheduleFormData = {
131
131
  start_time: any;
132
132
  end_time: any;
133
133
  };
134
- export declare type CalendarDataItem = {
134
+ export type CalendarDataItem = {
135
135
  date: string;
136
136
  color: string[];
137
137
  isExcluded: boolean;
138
138
  schedule_ids?: number[];
139
139
  [key: string]: any;
140
140
  };
141
- export declare type RequestData<Data> = {
141
+ export type RequestData<Data> = {
142
142
  data: Data;
143
143
  status: boolean;
144
144
  message: string;
145
145
  code: number;
146
146
  };
147
- export declare type ResponseListData<Data> = {
147
+ export type ResponseListData<Data> = {
148
148
  status: boolean;
149
149
  message: string;
150
150
  code: number;
@@ -4,7 +4,7 @@ export interface ScheduleState {
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
5
5
  otherProductsIds: number[];
6
6
  }
7
- export declare type ScheduleAvailabilityDateItem = {
7
+ export type ScheduleAvailabilityDateItem = {
8
8
  date: string;
9
9
  schedule_id: number[];
10
10
  product_ids: number[];
@@ -24,7 +24,7 @@ export interface LoadScheduleAvailableDateParams {
24
24
  }
25
25
  export interface ScheduleModuleAPI {
26
26
  }
27
- export declare type ScheduleItem = {
27
+ export type ScheduleItem = {
28
28
  /** 颜色 */
29
29
  color: string;
30
30
  /** 创建时间 */
@@ -91,7 +91,7 @@ export declare type ScheduleItem = {
91
91
  schedule_id: number;
92
92
  }[];
93
93
  };
94
- export declare type ScheduleFormOtherValue = {
94
+ export type ScheduleFormOtherValue = {
95
95
  /** 截止模式
96
96
  * 1: 永不截止
97
97
  * 2: 按日期截止
@@ -105,11 +105,11 @@ export declare type ScheduleFormOtherValue = {
105
105
  includeStatus: boolean;
106
106
  type: 'standard' | 'time-slots' | 'designation';
107
107
  };
108
- export declare type ExcIncDate = {
108
+ export type ExcIncDate = {
109
109
  start: string;
110
110
  end: string;
111
111
  };
112
- export declare type ScheduleFormData = {
112
+ export type ScheduleFormData = {
113
113
  /** 颜色 */
114
114
  color: string;
115
115
  /** 日程名称 */
@@ -157,20 +157,20 @@ export declare type ScheduleFormData = {
157
157
  start_time: any;
158
158
  end_time: any;
159
159
  };
160
- export declare type CalendarDataItem = {
160
+ export type CalendarDataItem = {
161
161
  date: string;
162
162
  color: string[];
163
163
  isExcluded: boolean;
164
164
  schedule_ids?: number[];
165
165
  [key: string]: any;
166
166
  };
167
- export declare type RequestData<Data> = {
167
+ export type RequestData<Data> = {
168
168
  data: Data;
169
169
  status: boolean;
170
170
  message: string;
171
171
  code: number;
172
172
  };
173
- export declare type ResponseListData<Data> = {
173
+ export type ResponseListData<Data> = {
174
174
  status: boolean;
175
175
  message: string;
176
176
  code: number;
@@ -181,7 +181,7 @@ export declare type ResponseListData<Data> = {
181
181
  skip: number;
182
182
  };
183
183
  };
184
- export declare type ScheduleAllMap = Record<string, {
184
+ export type ScheduleAllMap = Record<string, {
185
185
  minTime: dayjs.Dayjs | null;
186
186
  maxTime: dayjs.Dayjs | null;
187
187
  minTimeStr: string | null;
@@ -343,7 +343,8 @@ var calcCalendarDataByTimeSlots = (values, others, isGetRange) => {
343
343
  time_slot
344
344
  } = values;
345
345
  const { endRadio, excludedStatus, includeStatus } = others;
346
- if (!start_time) return [];
346
+ if (!start_time)
347
+ return [];
347
348
  const start = (0, import_dayjs.default)(start_time);
348
349
  const end = (0, import_dayjs.default)(start_time);
349
350
  return processDateRange(
@@ -577,7 +578,8 @@ function getAllSortedDateRanges(schedules) {
577
578
  }
578
579
  let sortedDateRanges = allDateRanges.sort((a, b) => {
579
580
  const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
580
- if (startTimeCompare !== 0) return startTimeCompare;
581
+ if (startTimeCompare !== 0)
582
+ return startTimeCompare;
581
583
  const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
582
584
  const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
583
585
  return durationA - durationB;
@@ -24,14 +24,11 @@ __export(Step_exports, {
24
24
  module.exports = __toCommonJS(Step_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var StepModule = class extends import_BaseModule.BaseModule {
27
- defaultName = "step";
28
- defaultVersion = "1.0.0";
29
- store;
30
- cacheId;
31
- openCache = false;
32
- fatherModule;
33
27
  constructor(name, version) {
34
28
  super(name, version);
29
+ this.defaultName = "step";
30
+ this.defaultVersion = "1.0.0";
31
+ this.openCache = false;
35
32
  }
36
33
  async initialize(core, options) {
37
34
  var _a, _b;
@@ -116,7 +113,7 @@ var StepModule = class extends import_BaseModule.BaseModule {
116
113
  let stepList = this.store.stepList;
117
114
  const index = stepList.findIndex((n) => n.key === step.key);
118
115
  if (index !== -1) {
119
- console.log("[StepModule] \u6B65\u9AA4\u5DF2\u5B58\u5728\uFF0C\u6DFB\u52A0\u5931\u8D25");
116
+ console.log("[StepModule] 步骤已存在,添加失败");
120
117
  return;
121
118
  }
122
119
  if (key) {
@@ -25,16 +25,11 @@ module.exports = __toCommonJS(Summary_exports);
25
25
  var import_BaseModule = require("../BaseModule");
26
26
  var import_utils = require("./utils");
27
27
  var SummaryModule = class extends import_BaseModule.BaseModule {
28
- defaultName = "summary";
29
- defaultVersion = "1.0.0";
30
- shopStore;
31
- store;
32
- request;
33
- cacheId;
34
- openCache = false;
35
- fatherModule;
36
28
  constructor(name, version) {
37
29
  super(name, version);
30
+ this.defaultName = "summary";
31
+ this.defaultVersion = "1.0.0";
32
+ this.openCache = false;
38
33
  }
39
34
  async initialize(core, options) {
40
35
  var _a, _b;
@@ -53,7 +48,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
53
48
  this.fatherModule = options.otherParams.fatherModule;
54
49
  }
55
50
  if (!this.shopStore) {
56
- throw new Error("SummaryModule \u9700\u8981 shopStore \u63D2\u4EF6\u652F\u6301");
51
+ throw new Error("SummaryModule 需要 shopStore 插件支持");
57
52
  }
58
53
  }
59
54
  async getSummary(cartItems) {
@@ -24,9 +24,6 @@ __export(request_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(request_exports);
26
26
  var RequestError = class extends Error {
27
- response;
28
- request;
29
- config;
30
27
  constructor(message, config, request, response) {
31
28
  super(message);
32
29
  this.name = "RequestError";
@@ -36,36 +33,38 @@ var RequestError = class extends Error {
36
33
  }
37
34
  };
38
35
  var RequestPluginImpl = class {
39
- name = "request";
40
- version = "1.0.0";
41
- core = null;
42
- /**
43
- * 默认请求选项
44
- */
45
- defaultOptions = {
46
- method: "GET",
47
- headers: {
48
- "Content-Type": "application/json"
49
- },
50
- timeout: 3e4,
51
- responseType: "json"
52
- };
53
- /**
54
- * 全局拦截器
55
- */
56
- interceptors = {
57
- request: [],
58
- response: [],
59
- error: []
60
- };
36
+ constructor() {
37
+ this.name = "request";
38
+ this.version = "1.0.0";
39
+ this.core = null;
40
+ /**
41
+ * 默认请求选项
42
+ */
43
+ this.defaultOptions = {
44
+ method: "GET",
45
+ headers: {
46
+ "Content-Type": "application/json"
47
+ },
48
+ timeout: 3e4,
49
+ responseType: "json"
50
+ };
51
+ /**
52
+ * 全局拦截器
53
+ */
54
+ this.interceptors = {
55
+ request: [],
56
+ response: [],
57
+ error: []
58
+ };
59
+ }
61
60
  // 初始化方法
62
61
  initialize() {
63
62
  this.core = globalThis.pisellOS;
64
- console.log("[RequestPlugin] \u521D\u59CB\u5316\u5B8C\u6210");
63
+ console.log("[RequestPlugin] 初始化完成");
65
64
  }
66
65
  // 销毁方法
67
66
  destroy() {
68
- console.log("[RequestPlugin] \u5DF2\u9500\u6BC1");
67
+ console.log("[RequestPlugin] 已销毁");
69
68
  }
70
69
  /**
71
70
  * 添加请求拦截器
@@ -150,7 +149,7 @@ var RequestPluginImpl = class {
150
149
  config = await Promise.resolve(interceptor(config));
151
150
  } catch (error) {
152
151
  const requestError = error instanceof RequestError ? error : new RequestError(
153
- error instanceof Error ? error.message : "\u8BF7\u6C42\u62E6\u622A\u5668\u9519\u8BEF",
152
+ error instanceof Error ? error.message : "请求拦截器错误",
154
153
  config
155
154
  );
156
155
  let processedError = requestError;
@@ -175,7 +174,7 @@ var RequestPluginImpl = class {
175
174
  );
176
175
  } catch (error) {
177
176
  const requestError = error instanceof RequestError ? error : new RequestError(
178
- error instanceof Error ? error.message : "\u54CD\u5E94\u62E6\u622A\u5668\u9519\u8BEF",
177
+ error instanceof Error ? error.message : "响应拦截器错误",
179
178
  config,
180
179
  null,
181
180
  response
@@ -195,7 +194,7 @@ var RequestPluginImpl = class {
195
194
  return processedResponse.data;
196
195
  } catch (error) {
197
196
  const requestError = error instanceof RequestError ? error : new RequestError(
198
- error instanceof Error ? error.message : "\u8BF7\u6C42\u9519\u8BEF",
197
+ error instanceof Error ? error.message : "请求错误",
199
198
  config
200
199
  );
201
200
  let processedError = requestError;
@@ -226,7 +225,7 @@ var RequestPluginImpl = class {
226
225
  withCredentials
227
226
  } = config;
228
227
  if (!url) {
229
- throw new RequestError("URL\u4E0D\u80FD\u4E3A\u7A7A", config);
228
+ throw new RequestError("URL不能为空", config);
230
229
  }
231
230
  let fullUrl = url;
232
231
  if (params && Object.keys(params).length > 0) {
@@ -256,13 +255,13 @@ var RequestPluginImpl = class {
256
255
  const timeoutPromise = new Promise((_, reject) => {
257
256
  if (timeout) {
258
257
  timeoutId = setTimeout(() => {
259
- reject(new RequestError(`\u8BF7\u6C42\u8D85\u65F6: ${timeout}ms`, config));
258
+ reject(new RequestError(`请求超时: ${timeout}ms`, config));
260
259
  }, timeout);
261
260
  }
262
261
  });
263
262
  try {
264
263
  const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
265
- new RequestError("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301 fetch API", config)
264
+ new RequestError("当前环境不支持 fetch API", config)
266
265
  );
267
266
  const response = await Promise.race([fetchPromise, timeoutPromise]);
268
267
  const responseHeaders = {};
@@ -298,7 +297,7 @@ var RequestPluginImpl = class {
298
297
  };
299
298
  if (!response.ok) {
300
299
  throw new RequestError(
301
- `\u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${response.status}`,
300
+ `请求失败,状态码: ${response.status}`,
302
301
  config,
303
302
  fetchOptions,
304
303
  result