@pisell/pisellos 0.0.176 → 0.0.177
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/dist/modules/Date/index.js +10 -7
- package/lib/modules/Date/index.js +14 -12
- package/package.json +1 -1
|
@@ -93,11 +93,14 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
93
93
|
key: "getResourceDates",
|
|
94
94
|
value: function () {
|
|
95
95
|
var _getResourceDates = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
96
|
-
var _params$query;
|
|
97
|
-
var currentDateList, currentDateListMap, resourceIds, hasResource, dates;
|
|
96
|
+
var _params$query, currentDateList, currentDateListMap, resourceIds, hasResource, dates;
|
|
98
97
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
99
98
|
while (1) switch (_context2.prev = _context2.next) {
|
|
100
99
|
case 0:
|
|
100
|
+
if (!params.useCache) {
|
|
101
|
+
_context2.next = 7;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
101
104
|
// 发请求之前,做一道检测,看 dateList 里是否有对应日期,且对应日期里是否都有对应 resource_ids 的资源
|
|
102
105
|
currentDateList = this.getDateList() || [];
|
|
103
106
|
currentDateListMap = new Map(currentDateList.map(function (item) {
|
|
@@ -112,18 +115,18 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
112
115
|
});
|
|
113
116
|
});
|
|
114
117
|
if (!hasResource) {
|
|
115
|
-
_context2.next =
|
|
118
|
+
_context2.next = 7;
|
|
116
119
|
break;
|
|
117
120
|
}
|
|
118
121
|
return _context2.abrupt("return", currentDateList);
|
|
119
|
-
case
|
|
120
|
-
_context2.next =
|
|
122
|
+
case 7:
|
|
123
|
+
_context2.next = 9;
|
|
121
124
|
return this.getResourceAvailableTimeList(params);
|
|
122
|
-
case
|
|
125
|
+
case 9:
|
|
123
126
|
dates = _context2.sent;
|
|
124
127
|
this.setDateList(dates);
|
|
125
128
|
return _context2.abrupt("return", dates);
|
|
126
|
-
case
|
|
129
|
+
case 12:
|
|
127
130
|
case "end":
|
|
128
131
|
return _context2.stop();
|
|
129
132
|
}
|
|
@@ -70,18 +70,20 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
70
70
|
}
|
|
71
71
|
async getResourceDates(params) {
|
|
72
72
|
var _a;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
73
|
+
if (params.useCache) {
|
|
74
|
+
const currentDateList = this.getDateList() || [];
|
|
75
|
+
const currentDateListMap = new Map(
|
|
76
|
+
currentDateList.map((item) => [item.date, item])
|
|
77
|
+
);
|
|
78
|
+
const resourceIds = ((_a = params.query) == null ? void 0 : _a.resource_ids) || [];
|
|
79
|
+
const hasResource = resourceIds.every((id) => {
|
|
80
|
+
var _a2;
|
|
81
|
+
const currentItem = currentDateListMap.get(id.toString());
|
|
82
|
+
return (_a2 = currentItem == null ? void 0 : currentItem.resource) == null ? void 0 : _a2.some((n) => n.id === id);
|
|
83
|
+
});
|
|
84
|
+
if (hasResource) {
|
|
85
|
+
return currentDateList;
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
88
|
const dates = await this.getResourceAvailableTimeList(params);
|
|
87
89
|
this.setDateList(dates);
|