@fonixtree/magic-design 2.0.11 → 2.0.12
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/es/core/Designer/AiImageGenerator/History/index.js +6 -3
- package/es/core/Designer/AiImageGenerator/History/index.less +1 -0
- package/es/core/Designer/AiImageGenerator/index.js +31 -17
- package/lib/core/Designer/AiImageGenerator/History/index.js +6 -3
- package/lib/core/Designer/AiImageGenerator/History/index.less +1 -0
- package/lib/core/Designer/AiImageGenerator/index.js +31 -17
- package/package.json +1 -1
- package/es/assets/fonts/.DS_Store +0 -0
- package/lib/assets/fonts/.DS_Store +0 -0
|
@@ -39,7 +39,7 @@ function History(_a) {
|
|
|
39
39
|
var source = _a.source,
|
|
40
40
|
onClick = _a.onClick,
|
|
41
41
|
onChange = _a.onChange,
|
|
42
|
-
|
|
42
|
+
selectKey = _a.selectKey;
|
|
43
43
|
|
|
44
44
|
var _b = (0, _react.useState)(false),
|
|
45
45
|
isEdit = _b[0],
|
|
@@ -65,7 +65,10 @@ function History(_a) {
|
|
|
65
65
|
var newSource = source.filter(function (src, index) {
|
|
66
66
|
return !selected.includes(index);
|
|
67
67
|
});
|
|
68
|
-
|
|
68
|
+
var newSelectIndex = source.findIndex(function (src) {
|
|
69
|
+
return src.key === selected;
|
|
70
|
+
});
|
|
71
|
+
onChange(newSource.length ? newSource : [], newSelectIndex);
|
|
69
72
|
setIsEdit(false);
|
|
70
73
|
};
|
|
71
74
|
|
|
@@ -104,7 +107,7 @@ function History(_a) {
|
|
|
104
107
|
}, source.length > 0 && source.map(function (his, index) {
|
|
105
108
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
106
109
|
className: (0, _classnames["default"])('historyNode', {
|
|
107
|
-
active:
|
|
110
|
+
active: selectKey === index
|
|
108
111
|
}),
|
|
109
112
|
onClick: function onClick() {
|
|
110
113
|
return onHisItemClick(index);
|
|
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _antd = require("antd");
|
|
13
13
|
|
|
14
|
+
var _uuid = require("uuid");
|
|
15
|
+
|
|
14
16
|
var _GenerateSize = _interopRequireDefault(require("./GenerateSize"));
|
|
15
17
|
|
|
16
18
|
var _GenerateArtist = _interopRequireDefault(require("./GenerateArtist"));
|
|
@@ -243,12 +245,18 @@ function (_super) {
|
|
|
243
245
|
|
|
244
246
|
_this.onHisConfigClick = function () {};
|
|
245
247
|
|
|
246
|
-
_this.historyChange = function (newHis) {
|
|
248
|
+
_this.historyChange = function (newHis, newIndex) {
|
|
247
249
|
(0, _storeUtil.setSessionStore)(_constants.STORAGE_KEY.FONIXTREE_AI_IMG_HIS, newHis);
|
|
248
250
|
|
|
249
251
|
_this.setState({
|
|
250
252
|
history: newHis
|
|
251
253
|
});
|
|
254
|
+
|
|
255
|
+
if (newIndex) {
|
|
256
|
+
_this.setState({
|
|
257
|
+
hisCursor: newIndex
|
|
258
|
+
});
|
|
259
|
+
}
|
|
252
260
|
};
|
|
253
261
|
|
|
254
262
|
_this.getColumnNum = function (num) {
|
|
@@ -338,6 +346,7 @@ function (_super) {
|
|
|
338
346
|
case 2:
|
|
339
347
|
result = _a.sent();
|
|
340
348
|
history.push({
|
|
349
|
+
key: (0, _uuid.v4)(),
|
|
341
350
|
images: result.imageList,
|
|
342
351
|
params: params
|
|
343
352
|
});
|
|
@@ -370,17 +379,17 @@ function (_super) {
|
|
|
370
379
|
|
|
371
380
|
_this.onRegenerate = function () {
|
|
372
381
|
return __awaiter(_this, void 0, void 0, function () {
|
|
373
|
-
var _a, history, hisCursor, params, result, e_2;
|
|
382
|
+
var _a, history, hisCursor, _b, params, key, result, e_2;
|
|
374
383
|
|
|
375
|
-
return __generator(this, function (
|
|
376
|
-
switch (
|
|
384
|
+
return __generator(this, function (_c) {
|
|
385
|
+
switch (_c.label) {
|
|
377
386
|
case 0:
|
|
378
387
|
_a = this.state, history = _a.history, hisCursor = _a.hisCursor;
|
|
379
|
-
|
|
380
|
-
|
|
388
|
+
_b = history[hisCursor], params = _b.params, key = _b.key;
|
|
389
|
+
_c.label = 1;
|
|
381
390
|
|
|
382
391
|
case 1:
|
|
383
|
-
|
|
392
|
+
_c.trys.push([1, 3,, 4]);
|
|
384
393
|
|
|
385
394
|
this.setState({
|
|
386
395
|
loading: true
|
|
@@ -390,8 +399,9 @@ function (_super) {
|
|
|
390
399
|
, (0, _commonUtil.commonFetch)('/designer/v1/ai/create-image', params, 'POST')];
|
|
391
400
|
|
|
392
401
|
case 2:
|
|
393
|
-
result =
|
|
402
|
+
result = _c.sent();
|
|
394
403
|
history[hisCursor] = {
|
|
404
|
+
key: key,
|
|
395
405
|
images: result.imageList,
|
|
396
406
|
params: params
|
|
397
407
|
};
|
|
@@ -404,7 +414,7 @@ function (_super) {
|
|
|
404
414
|
, 4];
|
|
405
415
|
|
|
406
416
|
case 3:
|
|
407
|
-
e_2 =
|
|
417
|
+
e_2 = _c.sent();
|
|
408
418
|
this.setState({
|
|
409
419
|
loading: false
|
|
410
420
|
});
|
|
@@ -577,14 +587,18 @@ function (_super) {
|
|
|
577
587
|
};
|
|
578
588
|
|
|
579
589
|
AiImageGenerator.prototype.render = function () {
|
|
580
|
-
var _a
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
history = _b.history,
|
|
585
|
-
hisCursor = _b.hisCursor;
|
|
590
|
+
var _a = this.state,
|
|
591
|
+
loading = _a.loading,
|
|
592
|
+
history = _a.history,
|
|
593
|
+
hisCursor = _a.hisCursor;
|
|
586
594
|
var visible = this.props.visible;
|
|
587
|
-
|
|
595
|
+
|
|
596
|
+
var _b = history[hisCursor] || {},
|
|
597
|
+
_c = _b.images,
|
|
598
|
+
images = _c === void 0 ? [] : _c,
|
|
599
|
+
_d = _b.key,
|
|
600
|
+
key = _d === void 0 ? '' : _d;
|
|
601
|
+
|
|
588
602
|
var columnNum = this.getColumnNum(images.length || []);
|
|
589
603
|
return /*#__PURE__*/_react["default"].createElement(_antd.Drawer, {
|
|
590
604
|
bodyStyle: {
|
|
@@ -699,7 +713,7 @@ function (_super) {
|
|
|
699
713
|
}))), /*#__PURE__*/_react["default"].createElement(_History["default"], {
|
|
700
714
|
onChange: this.historyChange,
|
|
701
715
|
onClick: this.onHistoryClick,
|
|
702
|
-
|
|
716
|
+
selectKey: key,
|
|
703
717
|
source: history
|
|
704
718
|
}))));
|
|
705
719
|
};
|
|
@@ -39,7 +39,7 @@ function History(_a) {
|
|
|
39
39
|
var source = _a.source,
|
|
40
40
|
onClick = _a.onClick,
|
|
41
41
|
onChange = _a.onChange,
|
|
42
|
-
|
|
42
|
+
selectKey = _a.selectKey;
|
|
43
43
|
|
|
44
44
|
var _b = (0, _react.useState)(false),
|
|
45
45
|
isEdit = _b[0],
|
|
@@ -65,7 +65,10 @@ function History(_a) {
|
|
|
65
65
|
var newSource = source.filter(function (src, index) {
|
|
66
66
|
return !selected.includes(index);
|
|
67
67
|
});
|
|
68
|
-
|
|
68
|
+
var newSelectIndex = source.findIndex(function (src) {
|
|
69
|
+
return src.key === selected;
|
|
70
|
+
});
|
|
71
|
+
onChange(newSource.length ? newSource : [], newSelectIndex);
|
|
69
72
|
setIsEdit(false);
|
|
70
73
|
};
|
|
71
74
|
|
|
@@ -104,7 +107,7 @@ function History(_a) {
|
|
|
104
107
|
}, source.length > 0 && source.map(function (his, index) {
|
|
105
108
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
106
109
|
className: (0, _classnames["default"])('historyNode', {
|
|
107
|
-
active:
|
|
110
|
+
active: selectKey === index
|
|
108
111
|
}),
|
|
109
112
|
onClick: function onClick() {
|
|
110
113
|
return onHisItemClick(index);
|
|
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _antd = require("antd");
|
|
13
13
|
|
|
14
|
+
var _uuid = require("uuid");
|
|
15
|
+
|
|
14
16
|
var _GenerateSize = _interopRequireDefault(require("./GenerateSize"));
|
|
15
17
|
|
|
16
18
|
var _GenerateArtist = _interopRequireDefault(require("./GenerateArtist"));
|
|
@@ -243,12 +245,18 @@ function (_super) {
|
|
|
243
245
|
|
|
244
246
|
_this.onHisConfigClick = function () {};
|
|
245
247
|
|
|
246
|
-
_this.historyChange = function (newHis) {
|
|
248
|
+
_this.historyChange = function (newHis, newIndex) {
|
|
247
249
|
(0, _storeUtil.setSessionStore)(_constants.STORAGE_KEY.FONIXTREE_AI_IMG_HIS, newHis);
|
|
248
250
|
|
|
249
251
|
_this.setState({
|
|
250
252
|
history: newHis
|
|
251
253
|
});
|
|
254
|
+
|
|
255
|
+
if (newIndex) {
|
|
256
|
+
_this.setState({
|
|
257
|
+
hisCursor: newIndex
|
|
258
|
+
});
|
|
259
|
+
}
|
|
252
260
|
};
|
|
253
261
|
|
|
254
262
|
_this.getColumnNum = function (num) {
|
|
@@ -338,6 +346,7 @@ function (_super) {
|
|
|
338
346
|
case 2:
|
|
339
347
|
result = _a.sent();
|
|
340
348
|
history.push({
|
|
349
|
+
key: (0, _uuid.v4)(),
|
|
341
350
|
images: result.imageList,
|
|
342
351
|
params: params
|
|
343
352
|
});
|
|
@@ -370,17 +379,17 @@ function (_super) {
|
|
|
370
379
|
|
|
371
380
|
_this.onRegenerate = function () {
|
|
372
381
|
return __awaiter(_this, void 0, void 0, function () {
|
|
373
|
-
var _a, history, hisCursor, params, result, e_2;
|
|
382
|
+
var _a, history, hisCursor, _b, params, key, result, e_2;
|
|
374
383
|
|
|
375
|
-
return __generator(this, function (
|
|
376
|
-
switch (
|
|
384
|
+
return __generator(this, function (_c) {
|
|
385
|
+
switch (_c.label) {
|
|
377
386
|
case 0:
|
|
378
387
|
_a = this.state, history = _a.history, hisCursor = _a.hisCursor;
|
|
379
|
-
|
|
380
|
-
|
|
388
|
+
_b = history[hisCursor], params = _b.params, key = _b.key;
|
|
389
|
+
_c.label = 1;
|
|
381
390
|
|
|
382
391
|
case 1:
|
|
383
|
-
|
|
392
|
+
_c.trys.push([1, 3,, 4]);
|
|
384
393
|
|
|
385
394
|
this.setState({
|
|
386
395
|
loading: true
|
|
@@ -390,8 +399,9 @@ function (_super) {
|
|
|
390
399
|
, (0, _commonUtil.commonFetch)('/designer/v1/ai/create-image', params, 'POST')];
|
|
391
400
|
|
|
392
401
|
case 2:
|
|
393
|
-
result =
|
|
402
|
+
result = _c.sent();
|
|
394
403
|
history[hisCursor] = {
|
|
404
|
+
key: key,
|
|
395
405
|
images: result.imageList,
|
|
396
406
|
params: params
|
|
397
407
|
};
|
|
@@ -404,7 +414,7 @@ function (_super) {
|
|
|
404
414
|
, 4];
|
|
405
415
|
|
|
406
416
|
case 3:
|
|
407
|
-
e_2 =
|
|
417
|
+
e_2 = _c.sent();
|
|
408
418
|
this.setState({
|
|
409
419
|
loading: false
|
|
410
420
|
});
|
|
@@ -577,14 +587,18 @@ function (_super) {
|
|
|
577
587
|
};
|
|
578
588
|
|
|
579
589
|
AiImageGenerator.prototype.render = function () {
|
|
580
|
-
var _a
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
history = _b.history,
|
|
585
|
-
hisCursor = _b.hisCursor;
|
|
590
|
+
var _a = this.state,
|
|
591
|
+
loading = _a.loading,
|
|
592
|
+
history = _a.history,
|
|
593
|
+
hisCursor = _a.hisCursor;
|
|
586
594
|
var visible = this.props.visible;
|
|
587
|
-
|
|
595
|
+
|
|
596
|
+
var _b = history[hisCursor] || {},
|
|
597
|
+
_c = _b.images,
|
|
598
|
+
images = _c === void 0 ? [] : _c,
|
|
599
|
+
_d = _b.key,
|
|
600
|
+
key = _d === void 0 ? '' : _d;
|
|
601
|
+
|
|
588
602
|
var columnNum = this.getColumnNum(images.length || []);
|
|
589
603
|
return /*#__PURE__*/_react["default"].createElement(_antd.Drawer, {
|
|
590
604
|
bodyStyle: {
|
|
@@ -699,7 +713,7 @@ function (_super) {
|
|
|
699
713
|
}))), /*#__PURE__*/_react["default"].createElement(_History["default"], {
|
|
700
714
|
onChange: this.historyChange,
|
|
701
715
|
onClick: this.onHistoryClick,
|
|
702
|
-
|
|
716
|
+
selectKey: key,
|
|
703
717
|
source: history
|
|
704
718
|
}))));
|
|
705
719
|
};
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|