@glodon-aiot/dataset-annotation 3.14.0-alpha.33 → 3.15.0-alpha.2

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 (119) hide show
  1. package/dist/es/DatasetContext/index.mjs +3 -6
  2. package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +91 -94
  3. package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +28 -37
  4. package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +101 -145
  5. package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +195 -256
  6. package/dist/es/components/DetectionAnnotation/index.mjs +424 -456
  7. package/dist/es/components/Iconfont/index.mjs +2 -2
  8. package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +1 -1
  9. package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +1 -1
  10. package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +45 -43
  11. package/dist/es/components/PicZipImportModal/index.mjs +293 -308
  12. package/dist/es/components/PreLabelOCR/index.mjs +1 -1
  13. package/dist/es/constant.mjs +3 -3
  14. package/dist/es/featuresConfig.mjs +9 -13
  15. package/dist/es/index.mjs +7 -11
  16. package/dist/lib/index.js +3 -4
  17. package/dist/src/DatasetContext/index.d.ts +0 -2
  18. package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +0 -1
  19. package/dist/src/constant.d.ts +1 -1
  20. package/dist/src/featuresConfig.d.ts +0 -4
  21. package/dist/src/index.d.ts +0 -3
  22. package/package.json +2 -2
  23. package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +0 -129
  24. package/dist/es/components/DetectionAnnotation/components/ImageModal/style.less.mjs +0 -4
  25. package/dist/es/components/PicZipImportModal/config.mjs +0 -47
  26. package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +0 -4
  27. package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +0 -4
  28. package/dist/es/components/VLMAnnotation/RegionItem.mjs +0 -170
  29. package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +0 -94
  30. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useAIButtonHover.mjs +0 -193
  31. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +0 -116
  32. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +0 -115
  33. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +0 -42
  34. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +0 -55
  35. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +0 -51
  36. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +0 -62
  37. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +0 -484
  38. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +0 -100
  39. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +0 -106
  40. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +0 -101
  41. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +0 -103
  42. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +0 -38
  43. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +0 -173
  44. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +0 -72
  45. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +0 -218
  46. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +0 -98
  47. package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +0 -156
  48. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +0 -4
  49. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +0 -4
  50. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +0 -4
  51. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +0 -4
  52. package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +0 -4
  53. package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +0 -678
  54. package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +0 -4
  55. package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +0 -33
  56. package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/AIErrorTooltip.less.mjs +0 -4
  57. package/dist/es/components/VLMAnnotation/components/AIErrorTooltip/index.mjs +0 -24
  58. package/dist/es/components/VLMAnnotation/components/DragButton.mjs +0 -18
  59. package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +0 -16
  60. package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +0 -30
  61. package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +0 -40
  62. package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +0 -44
  63. package/dist/es/components/VLMAnnotation/constants.mjs +0 -57
  64. package/dist/es/components/VLMAnnotation/index.mjs +0 -279
  65. package/dist/es/components/VLMAnnotation/style.less.mjs +0 -4
  66. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +0 -343
  67. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +0 -4
  68. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +0 -240
  69. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +0 -201
  70. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +0 -4
  71. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
  72. package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +0 -4
  73. package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +0 -149
  74. package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +0 -4
  75. package/dist/es/components/VLMAnnotationDetail/index.mjs +0 -449
  76. package/dist/es/components/VLMAnnotationDetail/style.less.mjs +0 -4
  77. package/dist/es/createVlmtasetAnnotation/index.mjs +0 -131
  78. package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +0 -34
  79. package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
  80. package/dist/src/components/PicZipImportModal/config.d.ts +0 -23
  81. package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +0 -4
  82. package/dist/src/components/VLMAnnotation/RegionItem.d.ts +0 -4
  83. package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +0 -4
  84. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useAIButtonHover.d.ts +0 -16
  85. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +0 -13
  86. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +0 -38
  87. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +0 -18
  88. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +0 -7
  89. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +0 -13
  90. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +0 -22
  91. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +0 -35
  92. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +0 -16
  93. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +0 -11
  94. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +0 -29
  95. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +0 -31
  96. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +0 -13
  97. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +0 -41
  98. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +0 -12
  99. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +0 -16
  100. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +0 -32
  101. package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +0 -25
  102. package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +0 -4
  103. package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +0 -32
  104. package/dist/src/components/VLMAnnotation/components/AIErrorTooltip/index.d.ts +0 -8
  105. package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +0 -7
  106. package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +0 -6
  107. package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +0 -7
  108. package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +0 -4
  109. package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +0 -4
  110. package/dist/src/components/VLMAnnotation/constants.d.ts +0 -113
  111. package/dist/src/components/VLMAnnotation/index.d.ts +0 -6
  112. package/dist/src/components/VLMAnnotation/types.d.ts +0 -187
  113. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +0 -14
  114. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +0 -12
  115. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +0 -12
  116. package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +0 -12
  117. package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +0 -17
  118. package/dist/src/components/VLMAnnotationDetail/index.d.ts +0 -6
  119. package/dist/src/createVlmtasetAnnotation/index.d.ts +0 -16
@@ -1,343 +0,0 @@
1
- var X = Object.defineProperty, Y = Object.defineProperties;
2
- var Z = Object.getOwnPropertyDescriptors;
3
- var j = Object.getOwnPropertySymbols;
4
- var ee = Object.prototype.hasOwnProperty, te = Object.prototype.propertyIsEnumerable;
5
- var M = (o, s, n) => s in o ? X(o, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[s] = n, x = (o, s) => {
6
- for (var n in s || (s = {}))
7
- ee.call(s, n) && M(o, n, s[n]);
8
- if (j)
9
- for (var n of j(s))
10
- te.call(s, n) && M(o, n, s[n]);
11
- return o;
12
- }, A = (o, s) => Y(o, Z(s));
13
- var E = (o, s, n) => new Promise((m, h) => {
14
- var l = (c) => {
15
- try {
16
- a(n.next(c));
17
- } catch (p) {
18
- h(p);
19
- }
20
- }, f = (c) => {
21
- try {
22
- a(n.throw(c));
23
- } catch (p) {
24
- h(p);
25
- }
26
- }, a = (c) => c.done ? m(c.value) : Promise.resolve(c.value).then(l, f);
27
- a((n = n.apply(o, s)).next());
28
- });
29
- import { jsxs as u, jsx as i } from "react/jsx-runtime";
30
- import { forwardRef as ie, useContext as ne, useState as b, useRef as re, useImperativeHandle as se, useEffect as q } from "react";
31
- import { Row as ae, Col as F, Input as P, Select as k, Space as T, Button as v, Table as le, Modal as ce, message as C } from "antd";
32
- import oe from "../../../../DatasetContext/index.mjs";
33
- import "./style.less.mjs";
34
- import B from "../../../Iconfont/index.mjs";
35
- const de = ie((o, s) => {
36
- const {
37
- datasetId: n,
38
- versionId: m,
39
- onAttributesChange: h,
40
- onLoadingChange: l
41
- } = o, {
42
- services: {
43
- cvforceDatahub: f
44
- }
45
- } = ne(oe), [a, c] = b([]), [p, N] = b(!1), [D, g] = b(""), [w, O] = b(!1), [R, y] = b(null), I = re(""), S = (e) => {
46
- const t = [...e].sort((r, d) => r.id.localeCompare(d.id));
47
- return JSON.stringify(t);
48
- }, U = () => S(a) !== I.current, z = () => new Promise((e) => {
49
- if (!U()) {
50
- e(!0);
51
- return;
52
- }
53
- ce.confirm({
54
- title: "提示",
55
- content: "属性列表有未保存的更改,确定要离开吗?",
56
- okText: "确定",
57
- cancelText: "取消",
58
- onOk: () => {
59
- e(!0);
60
- },
61
- onCancel: () => {
62
- e(!1);
63
- }
64
- });
65
- });
66
- se(s, () => ({
67
- hasUnsavedChanges: U,
68
- checkDirtyAndConfirm: z
69
- }));
70
- const V = () => E(void 0, null, function* () {
71
- N(!0), l == null || l(!0);
72
- try {
73
- if (n && m && f) {
74
- const t = (yield f.getDatasetsIdVersionsVidConfigs(n, m)) || [];
75
- return c(t), I.current = S(t), t;
76
- }
77
- } catch (e) {
78
- console.error("获取属性列表失败:", e);
79
- } finally {
80
- N(!1), l == null || l(!1);
81
- }
82
- });
83
- q(() => {
84
- V();
85
- }, []), q(() => {
86
- const e = (t) => {
87
- if (S(a) !== I.current)
88
- return t.preventDefault(), t.returnValue = "", "";
89
- };
90
- return window.addEventListener("beforeunload", e), () => {
91
- window.removeEventListener("beforeunload", e);
92
- };
93
- }, [a]);
94
- const _ = () => {
95
- if (!D.trim()) {
96
- C.error("属性名称不能为空");
97
- return;
98
- }
99
- const e = {
100
- id: `attr-${Date.now()}`,
101
- name: D.trim(),
102
- type: "text"
103
- }, t = [...a, e];
104
- c(t), g("");
105
- }, H = () => {
106
- g("");
107
- }, J = (e) => {
108
- const t = a.filter((r) => r.id !== e);
109
- c(t);
110
- }, K = () => {
111
- c([]), O(!1), y(null);
112
- }, W = () => {
113
- if (a.filter((t) => !t.name || !t.name.trim()).length > 0) {
114
- C.error("属性名称不能为空");
115
- return;
116
- }
117
- O(!w), y(null);
118
- }, $ = (e, t) => {
119
- const r = a.map((d) => d.id === e ? A(x({}, d), {
120
- name: t
121
- }) : d);
122
- c(r);
123
- }, G = (e, t) => {
124
- const r = a.map((d) => d.id === e ? A(x({}, d), {
125
- type: t
126
- }) : d);
127
- c(r);
128
- }, L = () => E(void 0, null, function* () {
129
- if (!(!n || !m || !f)) {
130
- N(!0), l == null || l(!0);
131
- try {
132
- const e = a.map((r) => {
133
- var d;
134
- return A(x({}, r), {
135
- id: (d = r.id) != null && d.startsWith("attr-") ? "" : r.id
136
- });
137
- });
138
- console.log("attributes", a), yield f.saveVisionLabelConfigs(n, m, {
139
- data: e
140
- });
141
- const t = yield V();
142
- C.success("保存成功"), h == null || h(t || a);
143
- } catch (e) {
144
- throw console.error("保存属性列表失败:", e), C.error("保存失败"), e;
145
- } finally {
146
- N(!1), l == null || l(!1);
147
- }
148
- }
149
- }), Q = [{
150
- title: "序号",
151
- key: "index",
152
- width: 80,
153
- render: (e, t, r) => r + 1
154
- }, {
155
- title: "属性名称",
156
- dataIndex: "name",
157
- key: "name",
158
- render: (e, t) => w ? /* @__PURE__ */ i(P, {
159
- value: e,
160
- showCount: !0,
161
- maxLength: 32,
162
- onChange: (r) => {
163
- $(t.id, r.target.value);
164
- },
165
- onBlur: () => {
166
- R === t.id && y(null);
167
- },
168
- onFocus: () => {
169
- y(t.id);
170
- }
171
- }) : /* @__PURE__ */ i("span", {
172
- children: e
173
- })
174
- }, {
175
- title: "属性类型",
176
- dataIndex: "type",
177
- key: "type",
178
- render: (e, t) => w ? /* @__PURE__ */ i(k, {
179
- value: e || "text",
180
- onChange: (r) => {
181
- G(t.id, r);
182
- },
183
- style: {
184
- width: "100%"
185
- },
186
- onBlur: () => {
187
- R === t.id && y(null);
188
- },
189
- onFocus: () => {
190
- y(t.id);
191
- },
192
- disabled: !0,
193
- children: /* @__PURE__ */ i(k.Option, {
194
- value: "text",
195
- children: "文本"
196
- })
197
- }) : /* @__PURE__ */ i("span", {
198
- children: "文本"
199
- })
200
- }, {
201
- title: "操作",
202
- key: "action",
203
- width: 100,
204
- render: (e, t) => /* @__PURE__ */ i(v, {
205
- type: "link",
206
- onClick: () => J(t.id),
207
- children: "删除"
208
- })
209
- }];
210
- return /* @__PURE__ */ u("div", {
211
- className: "attribute-detail",
212
- children: [/* @__PURE__ */ i("div", {
213
- className: "use-tips",
214
- children: /* @__PURE__ */ i("div", {
215
- children: "使用须知:用户需清楚能从图纸中提取出所有类型的信息,图片中的标注信息(如“零件名称”、“规格型号”),属性定义对应全局"
216
- })
217
- }), /* @__PURE__ */ u("div", {
218
- className: "lists",
219
- children: [/* @__PURE__ */ u(ae, {
220
- className: "lists-content",
221
- gutter: 48,
222
- children: [/* @__PURE__ */ i(F, {
223
- span: 12,
224
- children: /* @__PURE__ */ u("div", {
225
- className: "list-item",
226
- children: [/* @__PURE__ */ i("div", {
227
- className: "list-item-header",
228
- children: /* @__PURE__ */ i("div", {
229
- className: "list-item-title",
230
- children: "新增属性"
231
- })
232
- }), /* @__PURE__ */ u("div", {
233
- className: "list-item-content",
234
- children: [/* @__PURE__ */ u("div", {
235
- className: "form-item",
236
- children: [/* @__PURE__ */ i("div", {
237
- className: "form-label",
238
- children: "属性名称"
239
- }), /* @__PURE__ */ i(P, {
240
- showCount: !0,
241
- maxLength: 32,
242
- value: D,
243
- onChange: (e) => g(e.target.value),
244
- placeholder: "请输入属性名称",
245
- onPressEnter: _
246
- })]
247
- }), /* @__PURE__ */ u("div", {
248
- className: "form-item",
249
- children: [/* @__PURE__ */ i("div", {
250
- className: "form-label",
251
- children: "属性类型"
252
- }), /* @__PURE__ */ i(k, {
253
- value: "text",
254
- disabled: !0,
255
- style: {
256
- width: "100%"
257
- },
258
- children: /* @__PURE__ */ i(k.Option, {
259
- value: "text",
260
- children: "文本"
261
- })
262
- })]
263
- }), /* @__PURE__ */ i("div", {
264
- className: "form-actions",
265
- children: /* @__PURE__ */ u(T, {
266
- children: [/* @__PURE__ */ i(v, {
267
- type: "primary",
268
- onClick: _,
269
- children: "添加属性"
270
- }), /* @__PURE__ */ i(v, {
271
- onClick: H,
272
- children: "取消"
273
- })]
274
- })
275
- })]
276
- })]
277
- })
278
- }), /* @__PURE__ */ i(F, {
279
- span: 12,
280
- children: /* @__PURE__ */ u("div", {
281
- className: "list-item",
282
- children: [/* @__PURE__ */ u("div", {
283
- className: "list-item-header",
284
- children: [/* @__PURE__ */ i("div", {
285
- className: "list-item-title",
286
- children: "属性列表"
287
- }), /* @__PURE__ */ u(T, {
288
- style: {
289
- height: 32
290
- },
291
- children: [/* @__PURE__ */ i(v, {
292
- type: "text",
293
- icon: w ? /* @__PURE__ */ i(B, {
294
- type: "icon-queding",
295
- className: "self-icon"
296
- }) : /* @__PURE__ */ i(B, {
297
- type: "icon-editing",
298
- className: "self-icon"
299
- }),
300
- onClick: W
301
- }), /* @__PURE__ */ i(v, {
302
- type: "text",
303
- icon: /* @__PURE__ */ i(B, {
304
- type: "icon-qingchujiyi",
305
- className: "self-icon"
306
- }),
307
- onClick: K
308
- })]
309
- })]
310
- }), /* @__PURE__ */ i("div", {
311
- className: "list-item-content table-wrapper",
312
- children: /* @__PURE__ */ i(le, {
313
- columns: Q,
314
- dataSource: a,
315
- rowKey: "id",
316
- pagination: !1,
317
- size: "small",
318
- scroll: {
319
- y: "100%"
320
- }
321
- })
322
- })]
323
- })
324
- })]
325
- }), /* @__PURE__ */ i("div", {
326
- className: "attribute-detail-footer",
327
- children: /* @__PURE__ */ i(T, {
328
- children: /* @__PURE__ */ i(v, {
329
- type: "primary",
330
- loading: p,
331
- disabled: p,
332
- onClick: L,
333
- children: "保存"
334
- })
335
- })
336
- })]
337
- })]
338
- });
339
- });
340
- de.displayName = "AttributeDetail";
341
- export {
342
- de as default
343
- };
@@ -1,4 +0,0 @@
1
- const t = "";
2
- export {
3
- t as default
4
- };
@@ -1,240 +0,0 @@
1
- var R = Object.defineProperty, G = Object.defineProperties;
2
- var O = Object.getOwnPropertyDescriptors;
3
- var A = Object.getOwnPropertySymbols;
4
- var $ = Object.prototype.hasOwnProperty, H = Object.prototype.propertyIsEnumerable;
5
- var D = (d, r, a) => r in d ? R(d, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : d[r] = a, v = (d, r) => {
6
- for (var a in r || (r = {}))
7
- $.call(r, a) && D(d, a, r[a]);
8
- if (A)
9
- for (var a of A(r))
10
- H.call(r, a) && D(d, a, r[a]);
11
- return d;
12
- }, N = (d, r) => G(d, O(r));
13
- var y = (d, r, a) => new Promise((f, h) => {
14
- var c = (l) => {
15
- try {
16
- n(a.next(l));
17
- } catch (m) {
18
- h(m);
19
- }
20
- }, p = (l) => {
21
- try {
22
- n(a.throw(l));
23
- } catch (m) {
24
- h(m);
25
- }
26
- }, n = (l) => l.done ? f(l.value) : Promise.resolve(l.value).then(c, p);
27
- n((a = a.apply(d, r)).next());
28
- });
29
- import { jsxs as u, jsx as o } from "react/jsx-runtime";
30
- import { Space as J, Button as x, Input as b, Modal as P, message as q } from "antd";
31
- import { forwardRef as z, useState as Q, useContext as F, useRef as K, useImperativeHandle as W, useEffect as k } from "react";
32
- import T from "../../../Iconfont/index.mjs";
33
- import X from "../../../../DatasetContext/index.mjs";
34
- const Y = z((d, r) => {
35
- const {
36
- visionId: a,
37
- afterChangeTemplates: f,
38
- datasetId: h
39
- } = d, [c, p] = Q(!1), [n, l] = Q([]), {
40
- services: {
41
- cvforceDatahub: m
42
- }
43
- } = F(X), I = () => y(void 0, null, function* () {
44
- if (!h || !a)
45
- return;
46
- const e = yield m == null ? void 0 : m.getDatasetsIdVersionsVid(h, a), t = (e == null ? void 0 : e.qaTemplate) || [];
47
- return l(t), w.current = C(t), t;
48
- }), w = K(""), C = (e) => {
49
- const t = [...e].sort((s, i) => {
50
- const g = String(s.id), B = String(i.id);
51
- return g.localeCompare(B);
52
- });
53
- return JSON.stringify(t);
54
- }, S = () => C(n) !== w.current, E = () => new Promise((e) => {
55
- if (!S()) {
56
- e(!0);
57
- return;
58
- }
59
- P.confirm({
60
- title: "提示",
61
- content: "QA生成配置有未保存的更改,确定要离开吗?",
62
- okText: "确定",
63
- cancelText: "取消",
64
- onOk: () => {
65
- e(!0);
66
- },
67
- onCancel: () => {
68
- e(!1);
69
- }
70
- });
71
- });
72
- W(r, () => ({
73
- hasUnsavedChanges: S,
74
- checkDirtyAndConfirm: E
75
- })), k(() => {
76
- I();
77
- }, [h, a]), k(() => {
78
- const e = (t) => {
79
- if (C(n) !== w.current)
80
- return t.preventDefault(), t.returnValue = "", "";
81
- };
82
- return window.addEventListener("beforeunload", e), () => {
83
- window.removeEventListener("beforeunload", e);
84
- };
85
- }, [n]);
86
- const L = () => {
87
- l([...n, {
88
- id: Date.now(),
89
- name: "",
90
- q: "",
91
- a: ""
92
- }]), p(!0);
93
- }, M = (e) => {
94
- l(n.filter((t) => t.id !== e));
95
- }, U = (e, t) => {
96
- const s = n.map((i) => i.id === e ? N(v({}, i), {
97
- name: t
98
- }) : i);
99
- l(s);
100
- }, V = (e, t) => {
101
- const s = n.map((i) => i.id === e ? N(v({}, i), {
102
- q: t
103
- }) : i);
104
- l(s);
105
- }, j = (e, t) => {
106
- const s = n.map((i) => i.id === e ? N(v({}, i), {
107
- a: t
108
- }) : i);
109
- l(s);
110
- };
111
- return /* @__PURE__ */ u("div", {
112
- className: "info-item",
113
- children: [/* @__PURE__ */ u("div", {
114
- className: "info-item-header",
115
- children: [/* @__PURE__ */ o("div", {
116
- className: "info-item-title",
117
- children: "QA生成配置"
118
- }), /* @__PURE__ */ u(J, {
119
- style: {
120
- height: 32
121
- },
122
- children: [/* @__PURE__ */ o(x, {
123
- type: "text",
124
- icon: c ? /* @__PURE__ */ o(T, {
125
- type: "icon-queding",
126
- className: "self-icon"
127
- }) : /* @__PURE__ */ o(T, {
128
- type: "icon-editing",
129
- className: "self-icon"
130
- }),
131
- onClick: () => y(void 0, null, function* () {
132
- if (c) {
133
- if (n.filter((t) => {
134
- var s, i, g;
135
- return !((s = t.name) != null && s.trim()) || !((i = t.q) != null && i.trim()) || !((g = t.a) != null && g.trim());
136
- }).length > 0) {
137
- q.error("模版名称、问题模版、回答模版均不能为空");
138
- return;
139
- }
140
- if (console.log("生成问题和答案", n), !h || !a)
141
- return;
142
- try {
143
- const t = n == null ? void 0 : n.map((s) => ({
144
- id: s.id,
145
- name: s.name,
146
- q: s.q,
147
- a: s.a
148
- }));
149
- yield m == null ? void 0 : m.patchDatasetsIdVersionsVid(h, a, {
150
- qaTemplate: t
151
- }), yield I();
152
- } catch (t) {
153
- q.error("保存失败");
154
- return;
155
- }
156
- f && f();
157
- }
158
- p(!c);
159
- })
160
- }), /* @__PURE__ */ o(x, {
161
- type: "text",
162
- disabled: n.length >= 2,
163
- icon: /* @__PURE__ */ o(T, {
164
- type: "icon-tianjia",
165
- className: `self-icon ${n.length >= 2 ? "disabled" : ""}`
166
- }),
167
- onClick: L
168
- })]
169
- })]
170
- }), /* @__PURE__ */ o("div", {
171
- className: "template-tips",
172
- children: "*此配置对应全局,每个数据集/版本下都可自定义设置"
173
- }), /* @__PURE__ */ o("div", {
174
- className: "template-content",
175
- children: n.map((e) => /* @__PURE__ */ u("div", {
176
- className: "form-item-container " + (c ? "active" : ""),
177
- children: [/* @__PURE__ */ u("div", {
178
- className: "form-item",
179
- children: [/* @__PURE__ */ u("div", {
180
- className: "form-item-header",
181
- children: [/* @__PURE__ */ o("div", {
182
- className: "form-label",
183
- children: "模版名称"
184
- }), /* @__PURE__ */ o(x, {
185
- type: "text",
186
- icon: /* @__PURE__ */ o(T, {
187
- type: "icon-shanchu",
188
- className: `delete-btn ${!c || n.length <= 1 ? "disabled" : ""}`
189
- }),
190
- disabled: !c || n.length <= 1,
191
- onClick: () => M(e.id)
192
- })]
193
- }), /* @__PURE__ */ o(b, {
194
- showCount: !0,
195
- maxLength: 32,
196
- value: e.name,
197
- onChange: (t) => U(e.id, t.target.value),
198
- placeholder: "请输入模版名称",
199
- disabled: !c,
200
- style: {
201
- marginBottom: 20
202
- }
203
- })]
204
- }), /* @__PURE__ */ u("div", {
205
- className: "form-item",
206
- children: [/* @__PURE__ */ o("div", {
207
- className: "form-label",
208
- children: "问题模版"
209
- }), /* @__PURE__ */ o(b.TextArea, {
210
- showCount: !0,
211
- maxLength: 2e3,
212
- value: e.q,
213
- onChange: (t) => V(e.id, t.target.value),
214
- placeholder: "请输入问题模版",
215
- disabled: !c,
216
- rows: 2
217
- })]
218
- }), /* @__PURE__ */ u("div", {
219
- className: "form-item",
220
- children: [/* @__PURE__ */ o("div", {
221
- className: "form-label",
222
- children: "回答模版"
223
- }), /* @__PURE__ */ o(b.TextArea, {
224
- showCount: !0,
225
- maxLength: 2e3,
226
- value: e.a,
227
- onChange: (t) => j(e.id, t.target.value),
228
- placeholder: "请输入回答模版",
229
- disabled: !c,
230
- rows: 2
231
- })]
232
- })]
233
- }, e.id))
234
- })]
235
- });
236
- });
237
- Y.displayName = "QAGenerationConfig";
238
- export {
239
- Y as default
240
- };