@fonixtree/magic-design 0.1.74 → 0.1.76

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.
@@ -27,74 +27,46 @@
27
27
  position: relative;
28
28
  .img_wrap {
29
29
  width: 492px;
30
- height: 492px;
31
- display: grid;
32
- grid-template-columns: repeat(2, 1fr);
33
- grid-template-rows: repeat(2, 1fr);
34
- grid-gap: 12px;
35
- margin: 0 auto;
36
-
37
- .aiImageItem {
38
- position: relative;
39
- background-color: #ccc;
40
- display: flex;
41
- align-items: center;
42
- justify-content: center;
43
- font-size: 24px;
44
- img {
45
- width: 100%;
46
- }
47
- .imgHandleBtnWrap {
48
- display: flex;
49
- position: absolute;
50
- bottom: 12px;
51
- right: 12px;
52
- .refreshBtnWrap {
53
- background-color: #FFF;
54
- cursor: pointer;
55
- height: 28px;
56
- width: 28px;
57
- display: flex;
58
- align-items: center;
59
- justify-content: center;
60
- border-radius: 50%;
61
- border: 1px solid #D2D9E5;
62
- }
63
- .downloadBtnWrap {
64
- background-color: #FFF;
65
- cursor: pointer;
66
- height: 28px;
67
- width: 28px;
68
- display: flex;
69
- align-items: center;
70
- justify-content: center;
71
- margin-left: 12px;
72
- border-radius: 50%;
73
- border: 1px solid #D2D9E5;
74
- }
30
+ height: 100%;
31
+ display: flex;
32
+ flex-wrap: wrap;
33
+ align-items: center;
34
+ justify-content: center;
35
+ .aiImageWrap1 {
36
+ height: 492px;
37
+ width: 492px;
38
+ }
39
+ .aiImageWrap2 {
40
+ height: 240px;
41
+ width: 240px;
42
+ margin-bottom: 12px;
43
+ margin-left: 12px;
44
+ &:nth-child(2n - 1) {
45
+ margin-left: 0;
75
46
  }
76
- .imgSelectBtnWrap {
77
- position: absolute;
78
- top: 12px;
79
- right: 12px;
80
- border-radius: 50%;
81
- height: 22px;
82
- display: flex;
83
- background: #FFF;
47
+ img {
48
+ max-width: 100%;
84
49
  }
85
50
  }
86
- .noDataWrap {
87
- width: 100%;
88
- height: 100%;
89
- display: flex;
90
- align-items: center;
91
- justify-content: center;
92
- .no_data {
93
- height: 183px;
94
- width: 212px;
51
+
52
+ .aiImageWrap3 {
53
+ height: 156px;
54
+ width: 156px;
55
+ margin-bottom: 12px;
56
+ margin-bottom: 12px;
57
+ margin-left: 12px;
58
+ &:nth-child(3n + 1) {
59
+ margin-left: 0;
60
+ }
61
+ img {
62
+ max-width: 100%;
95
63
  }
96
64
  }
97
65
 
66
+ .no_data {
67
+ height: 183px;
68
+ width: 212px;
69
+ }
98
70
  }
99
71
  .btn_wrap {
100
72
  margin-top: 40px;
@@ -19,9 +19,9 @@ var _CopyBtn = _interopRequireDefault(require("./components/CopyBtn"));
19
19
 
20
20
  var _common = require("../../../common");
21
21
 
22
- var _FonixtreeGpt = _interopRequireDefault(require("../FonixtreeGpt"));
22
+ var _mobx = require("../../../mobx");
23
23
 
24
- var _AiImageGenerator = _interopRequireDefault(require("../AiImageGenerator"));
24
+ var _FonixtreeGpt = _interopRequireDefault(require("../FonixtreeGpt"));
25
25
 
26
26
  require("./index.less");
27
27
 
@@ -71,13 +71,12 @@ function (_super) {
71
71
  open: false,
72
72
  message: '',
73
73
  context: [],
74
- isGenerating: false,
75
- aiImageVisible: false
74
+ isGenerating: false
76
75
  };
77
76
 
78
77
  _this.scrollBottom = function () {
79
78
  var container = document.getElementById('content_wrap');
80
- container.scrollTop = container.scrollHeight + 50;
79
+ container.scrollTop = container.scrollHeight;
81
80
  };
82
81
 
83
82
  _this.onMessageChage = function (e) {
@@ -106,8 +105,6 @@ function (_super) {
106
105
  isGenerating: true,
107
106
  context: context,
108
107
  message: ''
109
- }, function () {
110
- _this.scrollBottom();
111
108
  });
112
109
  };
113
110
 
@@ -142,8 +139,8 @@ function (_super) {
142
139
  open: false
143
140
  });
144
141
 
145
- _this.setState({
146
- aiImageVisible: true
142
+ _mobx.store.setState({
143
+ imgGenVisible: true
147
144
  });
148
145
  };
149
146
 
@@ -172,6 +169,7 @@ function (_super) {
172
169
  }
173
170
 
174
171
  ChatRobot.prototype.componentDidMount = function () {
172
+ this.chatGpt.initChatGpt();
175
173
  var context = this.chatGpt.getContext();
176
174
  this.setState({
177
175
  context: context
@@ -185,8 +183,7 @@ function (_super) {
185
183
  context = _a.context,
186
184
  message = _a.message,
187
185
  open = _a.open,
188
- isGenerating = _a.isGenerating,
189
- aiImageVisible = _a.aiImageVisible;
186
+ isGenerating = _a.isGenerating;
190
187
  return /*#__PURE__*/_react["default"].createElement("div", {
191
188
  className: "chat_wrap"
192
189
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -299,19 +296,7 @@ function (_super) {
299
296
  marginRight: 5
300
297
  },
301
298
  type: "icon-refresh"
302
- }), "Regenerate Response"))), /*#__PURE__*/_react["default"].createElement(_AiImageGenerator["default"], {
303
- onClose: function onClose() {
304
- return _this.setState({
305
- aiImageVisible: false
306
- });
307
- },
308
- onConfirm: function onConfirm() {
309
- return _this.setState({
310
- aiImageVisible: false
311
- });
312
- },
313
- visible: aiImageVisible
314
- }));
299
+ }), "Regenerate Response"))));
315
300
  };
316
301
 
317
302
  return ChatRobot;
@@ -89,9 +89,6 @@
89
89
  padding: 7px 14px;
90
90
  background: #F5F6F7;
91
91
  color: #232F46;
92
- p {
93
- margin-bottom: 0;
94
- }
95
92
  }
96
93
  }
97
94
  .regenerate_btn {
@@ -11,6 +11,149 @@ var _commonUtil = require("../../../utils/commonUtil");
11
11
 
12
12
  var _storeUtil = require("../../../utils/storeUtil");
13
13
 
14
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) {
16
+ return value instanceof P ? value : new P(function (resolve) {
17
+ resolve(value);
18
+ });
19
+ }
20
+
21
+ return new (P || (P = Promise))(function (resolve, reject) {
22
+ function fulfilled(value) {
23
+ try {
24
+ step(generator.next(value));
25
+ } catch (e) {
26
+ reject(e);
27
+ }
28
+ }
29
+
30
+ function rejected(value) {
31
+ try {
32
+ step(generator["throw"](value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ }
37
+
38
+ function step(result) {
39
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
40
+ }
41
+
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+
46
+ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
47
+ var _ = {
48
+ label: 0,
49
+ sent: function sent() {
50
+ if (t[0] & 1) throw t[1];
51
+ return t[1];
52
+ },
53
+ trys: [],
54
+ ops: []
55
+ },
56
+ f,
57
+ y,
58
+ t,
59
+ g;
60
+ return g = {
61
+ next: verb(0),
62
+ "throw": verb(1),
63
+ "return": verb(2)
64
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
65
+ return this;
66
+ }), g;
67
+
68
+ function verb(n) {
69
+ return function (v) {
70
+ return step([n, v]);
71
+ };
72
+ }
73
+
74
+ function step(op) {
75
+ if (f) throw new TypeError("Generator is already executing.");
76
+
77
+ while (_) {
78
+ try {
79
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
80
+ if (y = 0, t) op = [op[0] & 2, t.value];
81
+
82
+ switch (op[0]) {
83
+ case 0:
84
+ case 1:
85
+ t = op;
86
+ break;
87
+
88
+ case 4:
89
+ _.label++;
90
+ return {
91
+ value: op[1],
92
+ done: false
93
+ };
94
+
95
+ case 5:
96
+ _.label++;
97
+ y = op[1];
98
+ op = [0];
99
+ continue;
100
+
101
+ case 7:
102
+ op = _.ops.pop();
103
+
104
+ _.trys.pop();
105
+
106
+ continue;
107
+
108
+ default:
109
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
110
+ _ = 0;
111
+ continue;
112
+ }
113
+
114
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
115
+ _.label = op[1];
116
+ break;
117
+ }
118
+
119
+ if (op[0] === 6 && _.label < t[1]) {
120
+ _.label = t[1];
121
+ t = op;
122
+ break;
123
+ }
124
+
125
+ if (t && _.label < t[2]) {
126
+ _.label = t[2];
127
+
128
+ _.ops.push(op);
129
+
130
+ break;
131
+ }
132
+
133
+ if (t[2]) _.ops.pop();
134
+
135
+ _.trys.pop();
136
+
137
+ continue;
138
+ }
139
+
140
+ op = body.call(thisArg, _);
141
+ } catch (e) {
142
+ op = [6, e];
143
+ y = 0;
144
+ } finally {
145
+ f = t = 0;
146
+ }
147
+ }
148
+
149
+ if (op[0] & 5) throw op[1];
150
+ return {
151
+ value: op[0] ? op[1] : void 0,
152
+ done: true
153
+ };
154
+ }
155
+ };
156
+
14
157
  // 角色
15
158
  var roleMap = {
16
159
  ASSISTANT: 'assistant',
@@ -30,9 +173,9 @@ function () {
30
173
 
31
174
  this.isGenerating = false; // 初始化参数
32
175
 
33
- this.initParams = {}; // 建立连接
176
+ this.initParams = {}; // 初始化
34
177
 
35
- this.initChatConnect = function () {
178
+ this.initChatGpt = function () {
36
179
  var _a = _this.initParams,
37
180
  onMessage = _a.onMessage,
38
181
  onEnd = _a.onEnd;
@@ -42,7 +185,6 @@ function () {
42
185
  var eventSource = new EventSource("/designer/v1/ai/sse/create?clientId=" + _this.clientId);
43
186
 
44
187
  eventSource.onopen = function (event) {
45
- console.log('onOpen');
46
188
  sse = event.target;
47
189
  };
48
190
 
@@ -74,9 +216,6 @@ function () {
74
216
 
75
217
  eventSource.onerror = function (event) {
76
218
  console.log('onerror', event);
77
- _this.isGenerating = false;
78
-
79
- _this.regenerate();
80
219
  };
81
220
  }; // 获取chat上下文
82
221
 
@@ -102,25 +241,28 @@ function () {
102
241
 
103
242
 
104
243
  this.sendMessage = function (message) {
105
- if (!message) {
106
- return;
107
- }
108
-
109
- _this.isGenerating = true;
110
-
111
- _this.insertMessage2Context(message);
112
-
113
- var messages = _this.getContext();
114
-
115
- _this.initChatConnect();
244
+ return __awaiter(_this, void 0, void 0, function () {
245
+ var messages;
246
+ return __generator(this, function (_a) {
247
+ if (!message) {
248
+ return [2
249
+ /*return*/
250
+ ];
251
+ }
116
252
 
117
- var newMessages = messages.splice(messages.length - 5);
118
- setTimeout(function () {
119
- (0, _commonUtil.commonFetch)('/designer/v1/ai/stream-chat-completion', {
120
- clientId: _this.clientId,
121
- messages: newMessages
122
- }, 'POST');
123
- }, 200);
253
+ this.isGenerating = true;
254
+ this.insertMessage2Context(message);
255
+ messages = this.getContext();
256
+ (0, _commonUtil.commonFetch)('/designer/v1/ai/stream-chat-completion', {
257
+ clientId: this.clientId,
258
+ messages: messages
259
+ }, 'POST');
260
+ this.initChatGpt();
261
+ return [2
262
+ /*return*/
263
+ ];
264
+ });
265
+ });
124
266
  }; // 重新生成
125
267
 
126
268
 
@@ -137,15 +279,12 @@ function () {
137
279
  (0, _storeUtil.setSessionStore)(catchKey, messages);
138
280
  }
139
281
 
140
- _this.initChatConnect();
282
+ (0, _commonUtil.commonFetch)('/designer/v1/ai/stream-chat-completion', {
283
+ clientId: _this.clientId,
284
+ messages: messages
285
+ }, 'POST');
141
286
 
142
- var newMessages = messages.splice(messages.length - 5);
143
- setTimeout(function () {
144
- (0, _commonUtil.commonFetch)('/designer/v1/ai/stream-chat-completion', {
145
- clientId: _this.clientId,
146
- messages: newMessages
147
- }, 'POST');
148
- }, 200);
287
+ _this.initChatGpt();
149
288
  }; // setSessionStore(catchKey, []);
150
289
 
151
290
 
@@ -35,6 +35,8 @@ var _LeftTitle = _interopRequireDefault(require("./LeftTitle"));
35
35
 
36
36
  var _RenderHtml = _interopRequireDefault(require("./RenderHtml"));
37
37
 
38
+ var _AiImageGenerator = _interopRequireDefault(require("./AiImageGenerator"));
39
+
38
40
  var _componentTypes = require("../../constants/component-types");
39
41
 
40
42
  var _mobx = require("../../mobx");
@@ -775,7 +777,7 @@ function (_super) {
775
777
  },
776
778
  onConfirm: this.onAppointmentConfirm,
777
779
  visible: appointmentVisible
778
- })), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_common.SystemNotification, null))), /*#__PURE__*/_react["default"].createElement(_RenderHtml["default"], {
780
+ }), /*#__PURE__*/_react["default"].createElement(_AiImageGenerator["default"], null)), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_common.SystemNotification, null))), /*#__PURE__*/_react["default"].createElement(_RenderHtml["default"], {
779
781
  ref: this.renderHtmlRef
780
782
  }));
781
783
  };
@@ -748,8 +748,11 @@ var convertToRem = function convertToRem(value) {
748
748
  return value + "px";
749
749
  }
750
750
 
751
+ var baseFont = ensure(function () {
752
+ return window.getComputedStyle(document.getElementsByTagName('html')[0]).fontSize.replace('px');
753
+ }, 50);
751
754
  var pxValue = parseFloat(value);
752
- var remValue = pxValue / 50; // 假设1rem = 50px
755
+ var remValue = pxValue / baseFont; // 假设1rem = 50px
753
756
 
754
757
  return remValue + "rem";
755
758
  };
@@ -17,8 +17,6 @@ var _ImageModal = _interopRequireDefault(require("../ImageModal"));
17
17
 
18
18
  var _ = require("..");
19
19
 
20
- var _AiImageGenerator = _interopRequireDefault(require("../../core/Designer/AiImageGenerator"));
21
-
22
20
  var _Iconfont = _interopRequireDefault(require("../Iconfont"));
23
21
 
24
22
  var _coreUtil = require("../../utils/coreUtil");
@@ -70,8 +68,7 @@ function (_super) {
70
68
 
71
69
  _this.state = {
72
70
  visible: false,
73
- inputVal: '',
74
- aiImageVisible: false
71
+ inputVal: ''
75
72
  };
76
73
 
77
74
  _this.onChange = function (v) {
@@ -96,12 +93,6 @@ function (_super) {
96
93
  }
97
94
  };
98
95
 
99
- _this.onAiImageClick = function () {
100
- _this.setState({
101
- aiImageVisible: true
102
- });
103
- };
104
-
105
96
  _this.getImagePick = function () {
106
97
  var visible = _this.state.visible;
107
98
  var value = _this.props.value;
@@ -171,19 +162,6 @@ function (_super) {
171
162
  }));
172
163
  };
173
164
 
174
- _this.onAiImageConfirm = function (data) {
175
- _this.setState({
176
- aiImageVisible: false
177
- });
178
-
179
- _this.props.onChange({
180
- contentTitle: data.fileName,
181
- contentType: 'File',
182
- imgUrl: data.oriUrl,
183
- url: data.oriUrl
184
- });
185
- };
186
-
187
165
  _this.getImageUrl = function () {
188
166
  var onChange = _this.props.onChange;
189
167
  var inputVal = _this.state.inputVal;
@@ -258,7 +236,6 @@ function (_super) {
258
236
 
259
237
  var imageSelectedWay = this.props.imageSelectedWay;
260
238
  var way = (0, _coreUtil.isPc)() ? imageSelectedWay.pc : imageSelectedWay.mobile;
261
- var aiImageVisible = this.state.aiImageVisible;
262
239
  return /*#__PURE__*/_react["default"].createElement("div", {
263
240
  className: "image-picker-wrap"
264
241
  }, /*#__PURE__*/_react["default"].createElement(_.Field, {
@@ -277,25 +254,7 @@ function (_super) {
277
254
  key: v.key,
278
255
  value: v.key
279
256
  }, v.value);
280
- })), /*#__PURE__*/_react["default"].createElement("div", {
281
- className: "ai-btn",
282
- onClick: this.onAiImageClick
283
- }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
284
- color: "#2F54EB",
285
- size: 20,
286
- type: "icon-ai"
287
- }), /*#__PURE__*/_react["default"].createElement("span", {
288
- className: "btn-txt"
289
- }, (0, _locale.i18n)('AI_IMAGE'))))), way === 'url' ? this.getImageUrl() : this.getImagePick(), /*#__PURE__*/_react["default"].createElement(_AiImageGenerator["default"], {
290
- onClose: function onClose() {
291
- return _this.setState({
292
- aiImageVisible: false
293
- });
294
- },
295
- onConfirm: this.onAiImageConfirm,
296
- single: true,
297
- visible: aiImageVisible
298
- }));
257
+ })))), way === 'url' ? this.getImageUrl() : this.getImagePick());
299
258
  };
300
259
 
301
260
  ImagePicker.defaultProps = {
@@ -7,7 +7,6 @@
7
7
  justify-content: space-between;
8
8
  align-items: center;
9
9
  .ai-btn {
10
- cursor: pointer;
11
10
  background: #FFFFFF;
12
11
  border: 1px solid #2F54EB;
13
12
  border-radius: 8px;
@@ -7,8 +7,7 @@ exports.urlTypeMap = exports.urlType = exports.respCodeMap = exports.quickMenuCo
7
7
  var STORAGE_KEY = {
8
8
  LOCALE: 'magicLocale',
9
9
  MAGIC_RENDER_HTML: 'MAGIC_RENDER_HTML',
10
- MAGIC_RENDER_PAGEDATA: 'MAGIC_RENDER_PAGEDATA',
11
- FONIXTREE_AI_IMG_HIS: 'fonixtree_ai_img_his'
10
+ MAGIC_RENDER_PAGEDATA: 'MAGIC_RENDER_PAGEDATA'
12
11
  };
13
12
  /** 授信状态 */
14
13
 
@@ -23,17 +23,17 @@ function GenerateSize(_a) {
23
23
  options: [{
24
24
  value: '1',
25
25
  label: '1:1'
26
+ }, {
27
+ value: '2',
28
+ label: '4:3'
29
+ }, {
30
+ value: '3',
31
+ label: '16:9'
26
32
  }]
27
33
  }), /*#__PURE__*/_react["default"].createElement(_antd.Select, {
28
34
  defaultValue: "1",
29
35
  options: [{
30
36
  value: '1',
31
- label: '256x256'
32
- }, {
33
- value: '2',
34
- label: '512x512'
35
- }, {
36
- value: '3',
37
37
  label: '1024x1024'
38
38
  }],
39
39
  style: {