@pisell/pisellos 1.0.41 → 1.0.43

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 (51) hide show
  1. package/dist/effects/index.d.ts +1 -1
  2. package/dist/modules/Order/index.js +4 -1
  3. package/dist/modules/Order/utils.d.ts +12 -0
  4. package/dist/modules/Order/utils.js +39 -0
  5. package/dist/modules/Payment/types.d.ts +2 -2
  6. package/dist/modules/Rules/index.js +5 -5
  7. package/dist/modules/Rules/types.d.ts +1 -1
  8. package/dist/modules/Schedule/type.d.ts +7 -7
  9. package/dist/modules/Schedule/types.d.ts +9 -9
  10. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  11. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  12. package/dist/types/index.d.ts +1 -1
  13. package/lib/core/index.js +27 -28
  14. package/lib/effects/index.d.ts +1 -1
  15. package/lib/effects/index.js +3 -7
  16. package/lib/modules/Account/index.js +9 -10
  17. package/lib/modules/AccountList/index.js +14 -11
  18. package/lib/modules/BaseModule.js +6 -3
  19. package/lib/modules/Cart/index.js +14 -9
  20. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  21. package/lib/modules/Date/index.js +8 -4
  22. package/lib/modules/Date/types.js +1 -0
  23. package/lib/modules/Discount/index.js +11 -6
  24. package/lib/modules/Guests/index.js +10 -15
  25. package/lib/modules/Order/index.js +6 -2
  26. package/lib/modules/Order/utils.d.ts +12 -0
  27. package/lib/modules/Order/utils.js +19 -2
  28. package/lib/modules/Payment/index.js +10 -14
  29. package/lib/modules/Payment/types.d.ts +2 -2
  30. package/lib/modules/Product/index.js +6 -5
  31. package/lib/modules/ProductList/index.js +5 -4
  32. package/lib/modules/Resource/index.js +8 -12
  33. package/lib/modules/Rules/index.js +14 -17
  34. package/lib/modules/Rules/types.d.ts +1 -1
  35. package/lib/modules/Schedule/index.js +8 -5
  36. package/lib/modules/Schedule/type.d.ts +7 -7
  37. package/lib/modules/Schedule/types.d.ts +9 -9
  38. package/lib/modules/Schedule/utils.js +2 -4
  39. package/lib/modules/Step/index.js +7 -4
  40. package/lib/modules/Summary/index.js +9 -4
  41. package/lib/plugins/request.js +34 -33
  42. package/lib/plugins/window.js +101 -113
  43. package/lib/solution/BookingByStep/index.js +46 -69
  44. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  45. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  46. package/lib/solution/BookingByStep/utils/timeslots.js +6 -12
  47. package/lib/solution/BuyTickets/index.js +15 -15
  48. package/lib/solution/ShopDiscount/index.js +15 -11
  49. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  50. package/lib/types/index.d.ts +1 -1
  51. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- type EffectCallback = (payload: any) => void | Promise<void | {
1
+ declare type EffectCallback = (payload: any) => void | Promise<void | {
2
2
  status: boolean;
3
3
  message?: string;
4
4
  }>;
@@ -22,7 +22,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
22
22
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
23
23
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
24
  import { BaseModule } from "../BaseModule";
25
- import { generateDuration } from "./utils";
25
+ import { generateDuration, mergeRelationForms } from "./utils";
26
26
  import { isNormalProduct } from "../Product/utils";
27
27
  export var OrderModule = /*#__PURE__*/function (_BaseModule) {
28
28
  _inherits(OrderModule, _BaseModule);
@@ -92,6 +92,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
92
92
  (_order$relation_forms = order.relation_forms).push.apply(_order$relation_forms, _toConsumableArray(relationForms));
93
93
  delete item._origin.relation_forms;
94
94
  } else {
95
+ // 合并关联表单
96
+ var _relationForms = mergeRelationForms(item._origin.relation_forms || []);
97
+ item._origin.relation_forms = _relationForms;
95
98
  order.bookings.push(item._origin);
96
99
  }
97
100
  if (item !== null && item !== void 0 && item.deposit) {
@@ -8,3 +8,15 @@ export declare const generateDuration: (cartItem: CartItem) => {
8
8
  duration: number;
9
9
  durationType: string;
10
10
  };
11
+ /**
12
+ * 合并关联表单
13
+ * @param relationForms 关联表单
14
+ * @returns 合并后的关联表单
15
+ */
16
+ export declare const mergeRelationForms: (relationForms: {
17
+ form_id: number;
18
+ form_record_ids: number[];
19
+ }[]) => {
20
+ form_id: number;
21
+ form_record_ids: number[];
22
+ }[];
@@ -1,3 +1,9 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1
7
  import dayjs from "dayjs";
2
8
  /**
3
9
  * 通过 session 类商品的开始时间结束时间生成商品的时长
@@ -12,4 +18,37 @@ export var generateDuration = function generateDuration(cartItem) {
12
18
  duration: duration,
13
19
  durationType: 'minutes'
14
20
  };
21
+ };
22
+
23
+ /**
24
+ * 合并关联表单
25
+ * @param relationForms 关联表单
26
+ * @returns 合并后的关联表单
27
+ */
28
+ export var mergeRelationForms = function mergeRelationForms(relationForms) {
29
+ return Object.values(relationForms.reduce(function (acc, cur) {
30
+ var _acc$form_id$form_rec;
31
+ var form_id = cur.form_id,
32
+ form_record_ids = cur.form_record_ids;
33
+ // 如果 acc 中没有 form_id,则初始化一个空数组
34
+ if (!acc[form_id]) {
35
+ acc[form_id] = {
36
+ form_id: form_id,
37
+ form_record_ids: []
38
+ };
39
+ }
40
+
41
+ // 兼容 form_record_id 可能是数组或单个数字
42
+ var ids = Array.isArray(form_record_ids) ? form_record_ids : [form_record_ids];
43
+ // 过滤掉空值(null、undefined等)
44
+ var validIds = ids.filter(function (id) {
45
+ return id != null;
46
+ });
47
+ (_acc$form_id$form_rec = acc[form_id].form_record_ids).push.apply(_acc$form_id$form_rec, _toConsumableArray(validIds));
48
+ // 去重
49
+ acc[form_id].form_record_ids = _toConsumableArray(new Set(acc[form_id].form_record_ids));
50
+ return acc;
51
+ }, {})).filter(function (item) {
52
+ return item.form_record_ids.length > 0;
53
+ }); // 过滤掉没有有效记录的表单
15
54
  };
@@ -7,11 +7,11 @@ export declare enum PaymentHooks {
7
7
  /**
8
8
  * 支付方式
9
9
  */
10
- export type PaymentMethod = 'credit_card' | 'debit_card' | 'paypal' | 'alipay' | 'wechat_pay' | 'bank_transfer';
10
+ export declare type PaymentMethod = 'credit_card' | 'debit_card' | 'paypal' | 'alipay' | 'wechat_pay' | 'bank_transfer';
11
11
  /**
12
12
  * 支付状态
13
13
  */
14
- export type PaymentStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'refunded';
14
+ export declare type PaymentStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'refunded';
15
15
  /**
16
16
  * 支付信息
17
17
  */
@@ -429,7 +429,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
429
429
  }));
430
430
  }
431
431
  for (var _i = 0; _i < splitCount; _i++) {
432
- var _originProduct$_produ, _product$discount_lis11;
432
+ var _product$discount_lis11, _originProduct$_produ;
433
433
  // 如果用过折扣卡,也就不存在拆分的情况了,这里直接使用上面计算出来的折扣卡
434
434
  var _selectedDiscount = selectedDiscountCard || applicableDiscounts[_i];
435
435
  // 标记优惠券为已使用
@@ -440,14 +440,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
440
440
 
441
441
  // 优先从 origin_total拿,可能会拿不到(比如用户端预约在没有配置 original_price 的情况下)
442
442
  var productOriginTotal = product.origin_total || product.total || 0;
443
+ // 如果当前 product 有 discount_list,则先从 origin_total 拿
444
+ if ((_product$discount_lis11 = product.discount_list) !== null && _product$discount_lis11 !== void 0 && _product$discount_lis11.length && product.origin_total) {
445
+ productOriginTotal = product.origin_total;
446
+ }
443
447
  // 如果originProduct?._productInit?.original_price为 0,product.origin_total可能为空,此时取 product.total
444
448
  if (Number((originProduct === null || originProduct === void 0 || (_originProduct$_produ = originProduct._productInit) === null || _originProduct$_produ === void 0 ? void 0 : _originProduct$_produ.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
445
449
  productOriginTotal = product.total;
446
450
  }
447
- // 如果当前 product 有 discount_list,则必须从 origin_total 拿
448
- if ((_product$discount_lis11 = product.discount_list) !== null && _product$discount_lis11 !== void 0 && _product$discount_lis11.length && product.origin_total) {
449
- productOriginTotal = product.origin_total;
450
- }
451
451
 
452
452
  // 计算使用折扣卡/商品券以后,单个商品的总 total
453
453
  var targetProductTotal = _selectedDiscount.tag === 'good_pass' ? new Decimal(productOriginTotal).minus(new Decimal(product.price || 0)).toNumber() : new Decimal(100).minus(_selectedDiscount.par_value || 0).div(100).mul(new Decimal(productOriginTotal)).toNumber();
@@ -24,7 +24,7 @@ export interface RulesModuleAPI {
24
24
  productList: any[];
25
25
  }) => DiscountResult;
26
26
  }
27
- type ProductDetail = {
27
+ declare type ProductDetail = {
28
28
  isClient?: boolean;
29
29
  isManualDiscount?: boolean;
30
30
  booking_id: any;
@@ -1,4 +1,4 @@
1
- export type ScheduleItem = {
1
+ export declare type ScheduleItem = {
2
2
  /** 颜色 */
3
3
  color: string;
4
4
  /** 创建时间 */
@@ -65,7 +65,7 @@ export type ScheduleItem = {
65
65
  schedule_id: number;
66
66
  }[];
67
67
  };
68
- export type ScheduleFormOtherValue = {
68
+ export declare type ScheduleFormOtherValue = {
69
69
  /** 截止模式
70
70
  * 1: 永不截止
71
71
  * 2: 按日期截止
@@ -79,11 +79,11 @@ export type ScheduleFormOtherValue = {
79
79
  includeStatus: boolean;
80
80
  type: 'standard' | 'time-slots' | 'designation';
81
81
  };
82
- export type ExcIncDate = {
82
+ export declare type ExcIncDate = {
83
83
  start: string;
84
84
  end: string;
85
85
  };
86
- export type ScheduleFormData = {
86
+ export declare type ScheduleFormData = {
87
87
  /** 颜色 */
88
88
  color: string;
89
89
  /** 日程名称 */
@@ -131,20 +131,20 @@ export type ScheduleFormData = {
131
131
  start_time: any;
132
132
  end_time: any;
133
133
  };
134
- export type CalendarDataItem = {
134
+ export declare 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 type RequestData<Data> = {
141
+ export declare type RequestData<Data> = {
142
142
  data: Data;
143
143
  status: boolean;
144
144
  message: string;
145
145
  code: number;
146
146
  };
147
- export type ResponseListData<Data> = {
147
+ export declare 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 type ScheduleAvailabilityDateItem = {
7
+ export declare 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 type ScheduleItem = {
27
+ export declare type ScheduleItem = {
28
28
  /** 颜色 */
29
29
  color: string;
30
30
  /** 创建时间 */
@@ -91,7 +91,7 @@ export type ScheduleItem = {
91
91
  schedule_id: number;
92
92
  }[];
93
93
  };
94
- export type ScheduleFormOtherValue = {
94
+ export declare type ScheduleFormOtherValue = {
95
95
  /** 截止模式
96
96
  * 1: 永不截止
97
97
  * 2: 按日期截止
@@ -105,11 +105,11 @@ export type ScheduleFormOtherValue = {
105
105
  includeStatus: boolean;
106
106
  type: 'standard' | 'time-slots' | 'designation';
107
107
  };
108
- export type ExcIncDate = {
108
+ export declare type ExcIncDate = {
109
109
  start: string;
110
110
  end: string;
111
111
  };
112
- export type ScheduleFormData = {
112
+ export declare type ScheduleFormData = {
113
113
  /** 颜色 */
114
114
  color: string;
115
115
  /** 日程名称 */
@@ -157,20 +157,20 @@ export type ScheduleFormData = {
157
157
  start_time: any;
158
158
  end_time: any;
159
159
  };
160
- export type CalendarDataItem = {
160
+ export declare 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 type RequestData<Data> = {
167
+ export declare type RequestData<Data> = {
168
168
  data: Data;
169
169
  status: boolean;
170
170
  message: string;
171
171
  code: number;
172
172
  };
173
- export type ResponseListData<Data> = {
173
+ export declare type ResponseListData<Data> = {
174
174
  status: boolean;
175
175
  message: string;
176
176
  code: number;
@@ -181,7 +181,7 @@ export type ResponseListData<Data> = {
181
181
  skip: number;
182
182
  };
183
183
  };
184
- export type ScheduleAllMap = Record<string, {
184
+ export declare type ScheduleAllMap = Record<string, {
185
185
  minTime: dayjs.Dayjs | null;
186
186
  maxTime: dayjs.Dayjs | null;
187
187
  minTimeStr: string | null;
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
6
6
  * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
7
7
  *
8
8
  */
9
- type DateType = Dayjs;
9
+ declare type DateType = Dayjs;
10
10
  export interface TimeSliceItem {
11
11
  start_time: string;
12
12
  end_time: string;
@@ -10,7 +10,7 @@ export declare enum ShopDiscountHooks {
10
10
  onRulesListChange = "shopDiscount:onRulesListChange",
11
11
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
12
12
  }
13
- export type Customer = {
13
+ export declare type Customer = {
14
14
  id: string | number;
15
15
  name: string;
16
16
  email: string;
@@ -27,7 +27,7 @@ export interface ModuleOptions {
27
27
  initialState?: Record<string, any>;
28
28
  otherParams?: Record<string, any>;
29
29
  }
30
- export type EventHandler = (data?: any) => void;
30
+ export declare type EventHandler = (data?: any) => void;
31
31
  export interface PisellCore {
32
32
  registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
33
33
  getPlugin: <T extends Plugin>(name: string) => T | null;
package/lib/core/index.js CHANGED
@@ -26,13 +26,13 @@ module.exports = __toCommonJS(core_exports);
26
26
  var import_createStore = require("../store/createStore");
27
27
  var import_effects = require("../effects");
28
28
  var PisellOSCore = class {
29
+ plugins = /* @__PURE__ */ new Map();
30
+ modules = /* @__PURE__ */ new Map();
31
+ stores = /* @__PURE__ */ new Map();
32
+ effects = new import_effects.EffectsManager();
33
+ debug = false;
34
+ context = {};
29
35
  constructor(options) {
30
- this.plugins = /* @__PURE__ */ new Map();
31
- this.modules = /* @__PURE__ */ new Map();
32
- this.stores = /* @__PURE__ */ new Map();
33
- this.effects = new import_effects.EffectsManager();
34
- this.debug = false;
35
- this.context = {};
36
36
  this.debug = (options == null ? void 0 : options.debug) || false;
37
37
  this.context = (options == null ? void 0 : options.context) || {};
38
38
  this.initialize(options);
@@ -48,7 +48,7 @@ var PisellOSCore = class {
48
48
  this.registerModule(item.module, item.options);
49
49
  });
50
50
  }
51
- this.log("PisellOS 核心初始化完成");
51
+ this.log("PisellOS \u6838\u5FC3\u521D\u59CB\u5316\u5B8C\u6210");
52
52
  }
53
53
  // 日志方法
54
54
  log(message, level = "info") {
@@ -71,12 +71,12 @@ var PisellOSCore = class {
71
71
  // 插件相关方法
72
72
  registerPlugin(plugin, options) {
73
73
  if (this.plugins.has(plugin.name)) {
74
- this.log(`插件 ${plugin.name} 已经注册过,将被覆盖`, "warn");
74
+ this.log(`\u63D2\u4EF6 ${plugin.name} \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6`, "warn");
75
75
  }
76
76
  if (options == null ? void 0 : options.dependencies) {
77
77
  for (const dep of options.dependencies) {
78
78
  if (!this.plugins.has(dep)) {
79
- throw new Error(`注册插件 ${plugin.name} 失败:缺少依赖插件 ${dep}`);
79
+ throw new Error(`\u6CE8\u518C\u63D2\u4EF6 ${plugin.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u63D2\u4EF6 ${dep}`);
80
80
  }
81
81
  }
82
82
  }
@@ -84,14 +84,14 @@ var PisellOSCore = class {
84
84
  const result = plugin.initialize();
85
85
  if (result instanceof Promise) {
86
86
  result.catch((err) => {
87
- this.log(`插件 ${plugin.name} 初始化失败: ${err.message}`, "error");
87
+ this.log(`\u63D2\u4EF6 ${plugin.name} \u521D\u59CB\u5316\u5931\u8D25: ${err.message}`, "error");
88
88
  throw err;
89
89
  });
90
90
  }
91
91
  this.plugins.set(plugin.name, plugin);
92
- this.log(`插件 ${plugin.name} v${plugin.version} 注册成功`);
92
+ this.log(`\u63D2\u4EF6 ${plugin.name} v${plugin.version} \u6CE8\u518C\u6210\u529F`);
93
93
  } catch (error) {
94
- this.log(`插件 ${plugin.name} 初始化过程中出错: ${error}`, "error");
94
+ this.log(`\u63D2\u4EF6 ${plugin.name} \u521D\u59CB\u5316\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error}`, "error");
95
95
  throw error;
96
96
  }
97
97
  }
@@ -104,12 +104,12 @@ var PisellOSCore = class {
104
104
  // 模块相关方法
105
105
  registerModule(module2, options) {
106
106
  if (this.modules.has(module2.name)) {
107
- this.log(`模块 ${module2.name} 已经注册过,将被覆盖`, "warn");
107
+ this.log(`\u6A21\u5757 ${module2.name} \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6`, "warn");
108
108
  }
109
109
  if (options == null ? void 0 : options.dependencies) {
110
110
  for (const dep of options.dependencies) {
111
111
  if (!this.modules.has(dep)) {
112
- throw new Error(`注册模块 ${module2.name} 失败:缺少依赖模块 ${dep}`);
112
+ throw new Error(`\u6CE8\u518C\u6A21\u5757 ${module2.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u6A21\u5757 ${dep}`);
113
113
  }
114
114
  }
115
115
  }
@@ -117,7 +117,7 @@ var PisellOSCore = class {
117
117
  for (const plugin of options.plugins) {
118
118
  if (!this.plugins.has(plugin)) {
119
119
  throw new Error(
120
- `注册模块 ${module2.name} 失败:缺少依赖插件 ${plugin}`
120
+ `\u6CE8\u518C\u6A21\u5757 ${module2.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u63D2\u4EF6 ${plugin}`
121
121
  );
122
122
  }
123
123
  }
@@ -126,10 +126,9 @@ var PisellOSCore = class {
126
126
  (options == null ? void 0 : options.initialState) || {},
127
127
  module2.name,
128
128
  (path, value) => {
129
- console.log("core 检测到模块值更新", module2.name, path, value);
129
+ console.log("core \u68C0\u6D4B\u5230\u6A21\u5757\u503C\u66F4\u65B0", module2.name, path, value);
130
130
  this.effects.emit(`${module2.name}:changed`, { path, value });
131
- if (module2.storeChange)
132
- module2.storeChange(path, value);
131
+ if (module2.storeChange) module2.storeChange(path, value);
133
132
  }
134
133
  );
135
134
  this.stores.set(module2.name, proxy);
@@ -137,14 +136,14 @@ var PisellOSCore = class {
137
136
  const result = module2.initialize(this, { store: proxy, ...options });
138
137
  if (result instanceof Promise) {
139
138
  result.catch((err) => {
140
- this.log(`模块 ${module2.name} 初始化失败: ${err.message}`, "error");
139
+ this.log(`\u6A21\u5757 ${module2.name} \u521D\u59CB\u5316\u5931\u8D25: ${err.message}`, "error");
141
140
  throw err;
142
141
  });
143
142
  }
144
143
  this.modules.set(module2.name, module2);
145
- this.log(`模块 ${module2.name} v${module2.version} 注册成功`);
144
+ this.log(`\u6A21\u5757 ${module2.name} v${module2.version} \u6CE8\u518C\u6210\u529F`);
146
145
  } catch (error) {
147
- this.log(`模块 ${module2.name} 初始化过程中出错: ${error}`, "error");
146
+ this.log(`\u6A21\u5757 ${module2.name} \u521D\u59CB\u5316\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error}`, "error");
148
147
  throw error;
149
148
  }
150
149
  }
@@ -168,9 +167,9 @@ var PisellOSCore = class {
168
167
  if (module2.destroy) {
169
168
  try {
170
169
  await Promise.resolve(module2.destroy());
171
- this.log(`模块 ${name} 已销毁`);
170
+ this.log(`\u6A21\u5757 ${name} \u5DF2\u9500\u6BC1`);
172
171
  } catch (error) {
173
- this.log(`销毁模块 ${name} 时出错: ${error}`, "error");
172
+ this.log(`\u9500\u6BC1\u6A21\u5757 ${name} \u65F6\u51FA\u9519: ${error}`, "error");
174
173
  }
175
174
  }
176
175
  }
@@ -179,14 +178,14 @@ var PisellOSCore = class {
179
178
  if (plugin.destroy) {
180
179
  try {
181
180
  await Promise.resolve(plugin.destroy());
182
- this.log(`插件 ${name} 已销毁`);
181
+ this.log(`\u63D2\u4EF6 ${name} \u5DF2\u9500\u6BC1`);
183
182
  } catch (error) {
184
- this.log(`销毁插件 ${name} 时出错: ${error}`, "error");
183
+ this.log(`\u9500\u6BC1\u63D2\u4EF6 ${name} \u65F6\u51FA\u9519: ${error}`, "error");
185
184
  }
186
185
  }
187
186
  }
188
187
  this.plugins.clear();
189
- this.log("PisellOS 核心已销毁");
188
+ this.log("PisellOS \u6838\u5FC3\u5DF2\u9500\u6BC1");
190
189
  }
191
190
  /**
192
191
  * 验证上下文参数
@@ -196,7 +195,7 @@ var PisellOSCore = class {
196
195
  const value = this.context[rule.name];
197
196
  if (rule.required && (value === void 0 || value === null)) {
198
197
  this.log(
199
- `模块 ${config.name} 缺少必需的上下文参数: ${rule.name}`,
198
+ `\u6A21\u5757 ${config.name} \u7F3A\u5C11\u5FC5\u9700\u7684\u4E0A\u4E0B\u6587\u53C2\u6570: ${rule.name}`,
200
199
  "error"
201
200
  );
202
201
  return false;
@@ -204,7 +203,7 @@ var PisellOSCore = class {
204
203
  if (rule.validate && value !== void 0 && value !== null) {
205
204
  if (!rule.validate(value)) {
206
205
  this.log(
207
- `模块 ${config.name} 上下文参数验证失败: ${rule.name} - ${rule.message || "验证失败"}`,
206
+ `\u6A21\u5757 ${config.name} \u4E0A\u4E0B\u6587\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ${rule.name} - ${rule.message || "\u9A8C\u8BC1\u5931\u8D25"}`,
208
207
  "error"
209
208
  );
210
209
  return false;
@@ -1,4 +1,4 @@
1
- type EffectCallback = (payload: any) => void | Promise<void | {
1
+ declare type EffectCallback = (payload: any) => void | Promise<void | {
2
2
  status: boolean;
3
3
  message?: string;
4
4
  }>;
@@ -23,13 +23,10 @@ __export(effects_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(effects_exports);
25
25
  var EffectsManager = class {
26
- constructor() {
27
- this.listeners = /* @__PURE__ */ new Map();
28
- }
26
+ listeners = /* @__PURE__ */ new Map();
29
27
  on(event, callback) {
30
28
  var _a;
31
- if (!this.listeners.has(event))
32
- this.listeners.set(event, /* @__PURE__ */ new Set());
29
+ if (!this.listeners.has(event)) this.listeners.set(event, /* @__PURE__ */ new Set());
33
30
  (_a = this.listeners.get(event)) == null ? void 0 : _a.add(callback);
34
31
  }
35
32
  off(event, callback) {
@@ -53,8 +50,7 @@ var EffectsManager = class {
53
50
  }
54
51
  async emit(event, payload) {
55
52
  const callbacks = this.listeners.get(event);
56
- if (!callbacks)
57
- return { status: true, data: [] };
53
+ if (!callbacks) return { status: true, data: [] };
58
54
  return new Promise(async (resolve) => {
59
55
  const res = [];
60
56
  for (const cb of callbacks) {
@@ -27,16 +27,16 @@ var import_BaseModule = require("../BaseModule");
27
27
  var import_types = require("./types");
28
28
  __reExport(Account_exports, require("./types"), module.exports);
29
29
  var AccountModule = class extends import_BaseModule.BaseModule {
30
+ defaultName = "account";
31
+ defaultVersion = "1.0.0";
32
+ isGuest = false;
33
+ store = {
34
+ accountInfo: null,
35
+ isLoggedIn: false,
36
+ active: false
37
+ };
30
38
  constructor(name, version) {
31
39
  super(name, version);
32
- this.defaultName = "account";
33
- this.defaultVersion = "1.0.0";
34
- this.isGuest = false;
35
- this.store = {
36
- accountInfo: null,
37
- isLoggedIn: false,
38
- active: false
39
- };
40
40
  }
41
41
  async initialize(core, options) {
42
42
  this.core = core;
@@ -65,8 +65,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
65
65
  return this.store.accountInfo;
66
66
  }
67
67
  async updateProfile(updates) {
68
- if (!this.store.accountInfo)
69
- return;
68
+ if (!this.store.accountInfo) return;
70
69
  this.store.accountInfo = {
71
70
  ...this.store.accountInfo,
72
71
  ...updates
@@ -28,19 +28,22 @@ var import_BaseModule = require("../BaseModule");
28
28
  var import_types = require("./types");
29
29
  var import_utils = require("./utils");
30
30
  var AccountListModule = class extends import_BaseModule.BaseModule {
31
+ defaultName = "accountList";
32
+ defaultVersion = "1.0.0";
33
+ store = {
34
+ accountList: [],
35
+ // 账号的纯数据列表
36
+ accounts: [],
37
+ // 账号的 module 列表
38
+ isLoading: false,
39
+ error: null
40
+ };
41
+ request;
42
+ cacheId;
43
+ openCache = false;
44
+ fatherModule;
31
45
  constructor(name, version) {
32
46
  super(name, version);
33
- this.defaultName = "accountList";
34
- this.defaultVersion = "1.0.0";
35
- this.store = {
36
- accountList: [],
37
- // 账号的纯数据列表
38
- accounts: [],
39
- // 账号的 module 列表
40
- isLoading: false,
41
- error: null
42
- };
43
- this.openCache = false;
44
47
  }
45
48
  async initialize(core, options) {
46
49
  var _a, _b, _c;
@@ -23,10 +23,13 @@ __export(BaseModule_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(BaseModule_exports);
25
25
  var BaseModule = class {
26
+ defaultName = "baseModule";
27
+ defaultVersion = "1.0.0";
28
+ name;
29
+ version;
30
+ isSolution = false;
31
+ core;
26
32
  constructor(name, version) {
27
- this.defaultName = "baseModule";
28
- this.defaultVersion = "1.0.0";
29
- this.isSolution = false;
30
33
  this.name = name || this.defaultName;
31
34
  this.version = version || this.defaultVersion;
32
35
  }
@@ -30,12 +30,17 @@ var import_lodash_es = require("lodash-es");
30
30
  var import_utils2 = require("../Product/utils");
31
31
  __reExport(Cart_exports, require("./types"), module.exports);
32
32
  var CartModule = class extends import_BaseModule.BaseModule {
33
+ // 提供给 baseModule 用的默认名称 和 默认版本
34
+ defaultName = "cart";
35
+ defaultVersion = "1.0.0";
36
+ request;
37
+ window;
38
+ store;
39
+ cacheId;
40
+ openCache = false;
41
+ fatherModule;
33
42
  constructor(name, version) {
34
43
  super(name, version);
35
- // 提供给 baseModule 用的默认名称 和 默认版本
36
- this.defaultName = "cart";
37
- this.defaultVersion = "1.0.0";
38
- this.openCache = false;
39
44
  }
40
45
  /**
41
46
  * 初始化购物车模块
@@ -60,12 +65,12 @@ var CartModule = class extends import_BaseModule.BaseModule {
60
65
  this.request = core.getPlugin("request");
61
66
  this.window = core.getPlugin("window");
62
67
  if (!this.request) {
63
- throw new Error("购物车模块需要 request 插件支持");
68
+ throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
64
69
  }
65
70
  if (!this.window) {
66
- throw new Error("购物车模块需要 window 插件支持");
71
+ throw new Error("\u8D2D\u7269\u8F66\u6A21\u5757\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
67
72
  }
68
- console.log("[CartModule] 初始化完成");
73
+ console.log("[CartModule] \u521D\u59CB\u5316\u5B8C\u6210");
69
74
  }
70
75
  /**
71
76
  * 添加商品到购物车
@@ -116,7 +121,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
116
121
  this.store.list = [...items];
117
122
  await this.core.effects.emit(`${this.name}:onUpdateItem`, tempCartItem);
118
123
  } catch (error) {
119
- console.error("[CartModule] 更新购物车商品失败", error);
124
+ console.error("[CartModule] \u66F4\u65B0\u8D2D\u7269\u8F66\u5546\u54C1\u5931\u8D25", error);
120
125
  }
121
126
  }
122
127
  /**
@@ -142,7 +147,7 @@ var CartModule = class extends import_BaseModule.BaseModule {
142
147
  quantity = (tempCartItem == null ? void 0 : tempCartItem.num) || 1;
143
148
  }
144
149
  if (!tempCartItem) {
145
- throw new Error("[CartModule] 格式化数据到购物车失败,商品不存在");
150
+ throw new Error("[CartModule] \u683C\u5F0F\u5316\u6570\u636E\u5230\u8D2D\u7269\u8F66\u5931\u8D25\uFF0C\u5546\u54C1\u4E0D\u5B58\u5728");
146
151
  }
147
152
  if (cartItem) {
148
153
  tempCartItem = cartItem;