@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
110 lines (108 loc) • 2.79 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/modules/Product/index.ts
var Product_exports = {};
__export(Product_exports, {
Product: () => Product
});
module.exports = __toCommonJS(Product_exports);
var import_BaseModule = require("../BaseModule");
__reExport(Product_exports, require("./types"), module.exports);
var Product = class extends import_BaseModule.BaseModule {
constructor(name, version) {
super(name, version);
this.defaultName = "product";
this.defaultVersion = "1.0.0";
this.otherParams = {
scheduler: []
};
}
async initialize(core, options) {
this.core = core;
this.store = options.store || {};
}
updateData(data) {
Object.assign(this.store, data);
}
/**
* 获取商品数据
*/
getData() {
return this.store;
}
/**
* 获取商品ID
*/
getId() {
var _a;
return ((_a = this.store) == null ? void 0 : _a.id) ?? null;
}
/**
* 获取商品标题
*/
getTitle() {
var _a;
return ((_a = this.store) == null ? void 0 : _a.title) ?? null;
}
/**
* 获取商品捆绑组
*/
getBundleGroups() {
return this.store.bundle_groups;
}
/**
* 获取商品媒体
*/
getMedia() {
return this.store.media;
}
/**
* 获取商品标签
*/
getTags() {
return this.store.tags;
}
/**
* 获取商品分类
*/
getCategories() {
return this.store.categories;
}
setOtherParams(key, value) {
this.otherParams[key] = value;
}
getOtherParams() {
return this.otherParams;
}
getProductType() {
var _a;
if (this.store.duration) {
return "duration";
}
if ((_a = this.store["schedule.ids"]) == null ? void 0 : _a.length) {
return "session";
}
return "normal";
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Product,
...require("./types")
});