st-comp 0.0.236 → 0.0.237

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 (120) hide show
  1. package/components.d.ts +1 -0
  2. package/es/CustomFunction.cjs +1 -1
  3. package/es/CustomFunction.js +21 -21
  4. package/es/FactorWarning.cjs +1 -1
  5. package/es/FactorWarning.js +25 -25
  6. package/es/Kline.cjs +1 -1
  7. package/es/Kline.js +10 -10
  8. package/es/KlineBasic.cjs +1 -1
  9. package/es/KlineBasic.js +18 -18
  10. package/es/KlineConfig.cjs +1 -1
  11. package/es/KlineConfig.js +15 -15
  12. package/es/KlineNew.cjs +1 -1
  13. package/es/KlineNew.js +9 -9
  14. package/es/KlinePlus.cjs +1 -1
  15. package/es/KlinePlus.js +11 -11
  16. package/es/MonacoEditor.cjs +1 -1
  17. package/es/MonacoEditor.js +31 -3
  18. package/es/Pagination.cjs +1 -1
  19. package/es/Pagination.js +13 -13
  20. package/es/PasswordPrompt.cjs +1 -1
  21. package/es/PasswordPrompt.js +2 -2
  22. package/es/Table.cjs +1 -1
  23. package/es/Table.js +17 -17
  24. package/es/User.cjs +1 -1
  25. package/es/User.js +18 -18
  26. package/es/VarSelectDialog.cjs +3 -3
  27. package/es/VarSelectDialog.js +122 -178
  28. package/es/VarietyAutoComplete.cjs +1 -1
  29. package/es/VarietyAutoComplete.js +7 -7
  30. package/es/VarietySearch.cjs +18 -17
  31. package/es/VarietySearch.js +2705 -2592
  32. package/es/VarietySelect-2fd501da.cjs +1 -0
  33. package/es/VarietySelect-5a9dd50b.js +68 -0
  34. package/es/VarietyTextCopy.cjs +3 -3
  35. package/es/VarietyTextCopy.js +12 -12
  36. package/es/VirtualTable.cjs +1 -1
  37. package/es/VirtualTable.js +61 -61
  38. package/es/{_initCloneObject-52b6a510.cjs → _initCloneObject-3823a101.cjs} +1 -1
  39. package/es/{_initCloneObject-eaef9418.js → _initCloneObject-c34c65bc.js} +2 -2
  40. package/es/{config-provider-b16efd62.js → config-provider-06a63185.js} +3 -3
  41. package/es/{config-provider-a584d81e.cjs → config-provider-2182708a.cjs} +1 -1
  42. package/es/{dropdown-a59bba73.js → dropdown-302f71e7.js} +2 -2
  43. package/es/{dropdown-071c5d7e.cjs → dropdown-89b74bc9.cjs} +1 -1
  44. package/es/{el-autocomplete-a07e9439.cjs → el-autocomplete-b9a3054a.cjs} +1 -1
  45. package/es/{el-autocomplete-ba808eb6.js → el-autocomplete-ed75a659.js} +5 -5
  46. package/es/{el-button-eec58cff.cjs → el-button-68baab7b.cjs} +1 -1
  47. package/es/{el-button-c95adb85.js → el-button-d09ff85f.js} +3 -3
  48. package/es/{el-checkbox-7421ccd3.js → el-checkbox-64648e02.js} +3 -3
  49. package/es/{el-checkbox-c25236a6.cjs → el-checkbox-b982e2ef.cjs} +1 -1
  50. package/es/{el-dialog-41ab8417.js → el-dialog-6a80e3d8.js} +4 -4
  51. package/es/{el-dialog-ae86edb8.cjs → el-dialog-ad7309e9.cjs} +1 -1
  52. package/es/{el-form-item-c3fe189b.cjs → el-form-item-4076e55f.cjs} +1 -1
  53. package/es/{el-form-item-c53c374d.js → el-form-item-4eca95be.js} +5 -5
  54. package/es/{el-input-7fd293af.cjs → el-input-172c49f8.cjs} +1 -1
  55. package/es/{el-input-2f75c4ba.js → el-input-cae60510.js} +49 -49
  56. package/es/{el-input-number-5193fe6d.js → el-input-number-c2499410.js} +4 -4
  57. package/es/{el-input-number-22e21d16.cjs → el-input-number-c2e71528.cjs} +1 -1
  58. package/es/{el-loading-cfd86c15.cjs → el-loading-05826e64.cjs} +1 -1
  59. package/es/{el-loading-f6022062.js → el-loading-c738468d.js} +1 -1
  60. package/es/{el-menu-item-17dc717e.cjs → el-menu-item-7f986598.cjs} +1 -1
  61. package/es/{el-menu-item-7e881203.js → el-menu-item-f904f685.js} +4 -4
  62. package/es/{el-message-e544a8f5.js → el-message-0df23ae7.js} +5 -5
  63. package/es/{el-message-5e6a6be9.cjs → el-message-a86c0efa.cjs} +1 -1
  64. package/es/{el-message-box-a93d2f6a.js → el-message-box-05d8cf39.js} +9 -9
  65. package/es/{el-message-box-c10adb52.cjs → el-message-box-40ff2af5.cjs} +1 -1
  66. package/es/{el-overlay-09ad71cd.js → el-overlay-cc9bc792.js} +18 -18
  67. package/es/{el-overlay-9e34965f.cjs → el-overlay-d7a6e4a9.cjs} +1 -1
  68. package/es/{el-popconfirm-70a976bf.cjs → el-popconfirm-737a015b.cjs} +1 -1
  69. package/es/{el-popconfirm-81dcd202.js → el-popconfirm-a6f66a0e.js} +4 -4
  70. package/es/{el-popper-b6c99b28.cjs → el-popper-7ba87e05.cjs} +1 -1
  71. package/es/{el-popper-b4f97157.js → el-popper-a38874f4.js} +1 -1
  72. package/es/{el-segmented-f8fce9ac.cjs → el-segmented-3fd66a0e.cjs} +1 -1
  73. package/es/{el-segmented-b868d074.js → el-segmented-51b1c797.js} +2 -2
  74. package/es/{el-select-d8d91db1.cjs → el-select-12f6deb7.cjs} +1 -1
  75. package/es/{el-select-95627997.js → el-select-1b149fab.js} +8 -8
  76. package/es/{el-table-column-376cd907.js → el-table-column-3e30ebae.js} +9 -9
  77. package/es/{el-table-column-c974cb96.cjs → el-table-column-516a0ed9.cjs} +1 -1
  78. package/es/{el-tag-66cab138.js → el-tag-0a25efdf.js} +2 -2
  79. package/es/{el-tag-a33c4b22.cjs → el-tag-789f05d3.cjs} +1 -1
  80. package/es/{el-text-c20a9f48.cjs → el-text-1470de46.cjs} +1 -1
  81. package/es/{el-text-ac60d0f2.js → el-text-73d899ff.js} +1 -1
  82. package/es/{index-d725fef6.cjs → index-2375023e.cjs} +138 -137
  83. package/es/{index-f967d6c1.cjs → index-269b22da.cjs} +1 -1
  84. package/es/{index-1f7d4f70.js → index-4194c942.js} +1 -1
  85. package/es/{index-e5566b94.js → index-42e59bf5.js} +1 -1
  86. package/es/{index-c108567d.cjs → index-4f48940d.cjs} +1 -1
  87. package/es/{index-d91dc23f.js → index-54d289d1.js} +2 -2
  88. package/es/{index-844bdd85.js → index-6806997d.js} +2 -2
  89. package/es/{index-f3562b52.cjs → index-696b6a94.cjs} +1 -1
  90. package/es/{index-88546436.js → index-6e967429.js} +2 -2
  91. package/es/{index-a871c3eb.js → index-87b4bf61.js} +75 -60
  92. package/es/{index-298075cf.cjs → index-8de94a49.cjs} +1 -1
  93. package/es/{index-57672682.js → index-94e43e0d.js} +2 -2
  94. package/es/{index-bc8e277e.js → index-ac98a4d8.js} +12827 -12573
  95. package/es/{index-11547a0c.cjs → index-c04f444f.cjs} +1 -1
  96. package/es/{index-098c2447.cjs → index-cebc7160.cjs} +1 -1
  97. package/es/{index-9b9ef5dd.cjs → index-ee977f79.cjs} +1 -1
  98. package/es/{python-ecde9ff2.js → python-a914569a.js} +39 -11
  99. package/es/{python-c27ba105.cjs → python-c67c8901.cjs} +2 -2
  100. package/es/style.css +1 -1
  101. package/es/{use-form-common-props-fd9b61a0.cjs → use-form-common-props-344056f9.cjs} +1 -1
  102. package/es/{use-form-common-props-815d48a6.js → use-form-common-props-47e50c10.js} +28 -28
  103. package/es/{use-global-config-30d7d8ce.cjs → use-global-config-cf78ebac.cjs} +1 -1
  104. package/es/{use-global-config-b5e9d3d5.js → use-global-config-f52caea0.js} +4 -4
  105. package/es/{validator-1b8a6128.cjs → validator-3cad04b2.cjs} +1 -1
  106. package/es/{validator-764a9db0.js → validator-94c04152.js} +1 -1
  107. package/es/{zh-cn-e963c628.js → zh-cn-4921961d.js} +1 -1
  108. package/es/{zh-cn-90317f62.cjs → zh-cn-aabfaa94.cjs} +1 -1
  109. package/lib/bundle.js +1 -1
  110. package/lib/bundle.umd.cjs +227 -225
  111. package/lib/{index-170fa58f.js → index-c6d17ca2.js} +31989 -31621
  112. package/lib/{python-396c99dc.js → python-09a6fcf8.js} +1 -1
  113. package/lib/style.css +1 -1
  114. package/package.json +2 -1
  115. package/packages/MonacoEditor/index.vue +741 -70
  116. package/packages/VarietySearch/components/AddTag/index.vue +20 -86
  117. package/packages/VarietySearch/components/FactorScreen/index.vue +80 -12
  118. package/packages/VarietySearch/components/FactorScreen/tools.js +41 -0
  119. package/src/main.ts +16 -11
  120. package/src/pages/MonacoEditor/index.vue +1 -0
@@ -23,12 +23,13 @@
23
23
  <!-- 添加标签弹窗 -->
24
24
  <el-dialog
25
25
  v-model="visible"
26
+ title="Tips"
26
27
  width="1000"
27
28
  >
28
29
  <template #header>
29
30
  <div>
30
31
  添加标签
31
- <el-radio-group v-model="tagType" size="small" style="margin-left: 8px; vertical-align: 5px;">
32
+ <el-radio-group v-model="tagType" size="small" style="margin-left: 8px; vertical-align: 5px;" v-if="0">
32
33
  <el-radio-button label="个人" value="person" />
33
34
  <el-radio-button label="系统" value="system" />
34
35
  </el-radio-group>
@@ -40,8 +41,8 @@
40
41
  <el-checkbox :checked="isCheck(item)" @change="changeCheckBox(item)">
41
42
  <div style="display: flex; width: 280px;">
42
43
  <div style="flex: 1;line-height: 24px;">{{ item.name }}</div>
43
- <el-button size="small" :icon="Edit" @click="editTag(item)" v-if="tagType === 'person'"></el-button>
44
- <el-button size="small" :icon="Delete" @click="deleteTag(item)" v-if="tagType === 'person'"></el-button>
44
+ <el-button size="small" :icon="Edit" v-if="0"></el-button>
45
+ <el-button size="small" :icon="Delete" @click="deleteTag(item)"></el-button>
45
46
  </div>
46
47
  </el-checkbox>
47
48
  </div>
@@ -54,21 +55,6 @@
54
55
  </template>
55
56
  </el-dialog>
56
57
  <!-- 编辑标签弹窗 -->
57
- <el-dialog
58
- v-model="editVisible"
59
- title="编辑标签"
60
- top="20vh"
61
- width="600"
62
- >
63
- <div style="margin-bottom: 12px;">原名称:{{ editItem?.name }}</div>
64
- <el-input v-model="editValue" />
65
- <template #footer>
66
- <div class="dialog-footer">
67
- <el-button @click="editVisible = false">取消</el-button>
68
- <el-button type="primary" @click="changeTag()">确定</el-button>
69
- </div>
70
- </template>
71
- </el-dialog>
72
58
  </template>
73
59
 
74
60
  <script setup>
@@ -83,17 +69,14 @@ const data = defineModel("data", { default: [] });
83
69
  const visible = ref(false);
84
70
  const tagType = ref('person'); // 标签类型
85
71
  const searchValue = ref(''); // 搜索值
86
- const tagMap = ref({}); // 全部标签映射
72
+ const totalTagList = ref([]); // 全部标签列表
87
73
  const tagList = ref([]); // 标签列表
88
74
  const checkList = ref([]); // 勾选列表
89
- const editVisible = ref(false); // 编辑标签弹窗
90
- const editItem = ref(null); // 编辑标签对象
91
- const editValue = ref(''); // 编辑标签值
92
75
 
93
76
  const showCheckTagList = computed(() => {
94
77
  return data.value.map(id => {
95
78
  return {
96
- name: tagMap.value[id],
79
+ name: totalTagList.value?.find(i => i.id === id)?.tagName,
97
80
  id,
98
81
  }
99
82
  })
@@ -101,7 +84,6 @@ const showCheckTagList = computed(() => {
101
84
 
102
85
  watch(() => tagType.value, () => {
103
86
  searchValue.value = ''
104
- getTagList()
105
87
  })
106
88
 
107
89
  watch(() => searchValue.value, () => {
@@ -124,7 +106,6 @@ const changeCheckBox = (item) => {
124
106
  }
125
107
  }
126
108
 
127
- // 标签相关操作
128
109
  const handleAction = (action, index) => {
129
110
  switch (action) {
130
111
  // 新增
@@ -136,6 +117,13 @@ const handleAction = (action, index) => {
136
117
  getTagList()
137
118
  break;
138
119
  }
120
+ // 编辑
121
+ case "edit": {
122
+ const item = data.value[index];
123
+ compositeOrderForm.value = { ...item };
124
+ visible.value = true;
125
+ break;
126
+ }
139
127
  // 窗口确认
140
128
  case "submit": {
141
129
  visible.value = false;
@@ -150,7 +138,6 @@ const handleAction = (action, index) => {
150
138
  }
151
139
  };
152
140
 
153
- // 删除个人标签
154
141
  const deleteTag = (item) => {
155
142
  ElMessageBox.alert(`确认删除标签“${item.name}”吗?`, '删除标签', {
156
143
  confirmButtonText: 'OK',
@@ -158,41 +145,13 @@ const deleteTag = (item) => {
158
145
  if (action === 'confirm') {
159
146
  await request.post('/alarm/deliversign/deleteTag', { tagId: item.id })
160
147
  getTagList()
161
- ElMessage.success('删除成功!')
148
+ Elmessage.success('删除成功!')
162
149
  }
163
150
  },
164
151
  })
165
152
  }
166
153
 
167
- // 打开编辑标签弹窗
168
- const editTag = (item) => {
169
- editItem.value = item
170
- editValue.value = item.name
171
- editVisible.value = true
172
- }
173
-
174
- // 修改标签
175
- const changeTag = async () => {
176
- await request.post('/alarm/deliversign/addOrUpdateFeatureTag', { tagName: editValue.value, tagId: editItem.value.id })
177
- tagMap.value = {
178
- ...tagMap.value,
179
- [editItem.value.id]: editValue.value
180
- }
181
- tagList.value = tagList.value.map(item => {
182
- if (item.id === editItem.value.id) {
183
- return {
184
- ...item,
185
- name: editValue.value
186
- }
187
- }
188
- return item
189
- })
190
- editVisible.value = false
191
- ElMessage.success('修改成功!')
192
- }
193
-
194
- // 获取标签列表
195
- const getTagList = async () => {
154
+ const getTagList = async (isTotal = false) => {
196
155
  if (tagType.value === 'person') {
197
156
  // 个人标签
198
157
  const res = await request.post('/alarm/deliversign/findTagsByUserId', { tagName: searchValue.value })
@@ -203,44 +162,19 @@ const getTagList = async () => {
203
162
  id: item.id
204
163
  }))
205
164
  })
165
+ if (isTotal) {
166
+ totalTagList.value = res.body
167
+ }
206
168
  } else {
207
169
  // 系统标签
208
- const res = await request.post('/alarm/deliversign/findSystemTagsByTagName', { tagName: searchValue.value })
209
- tagList.value = []
210
- nextTick(() => {
211
- tagList.value = res.body?.map(item => ({
212
- name: item.tagName,
213
- id: item.id
214
- }))
215
- })
216
170
  }
217
171
  }
218
172
 
219
- // 获取全部标签
220
- const getTotalTagMap = async () => {
221
- const res = await Promise.all([
222
- request.post('/alarm/deliversign/findTagsByUserId'),
223
- request.post('/alarm/deliversign/findSystemTagsByTagName')
224
- ])
225
- tagMap.value = res.reduce((r, i) => {
226
- return {
227
- ...r,
228
- ...i.body?.reduce((bodyR, bodyI) => {
229
- return {
230
- ...bodyR,
231
- [bodyI.id]: bodyI.tagName
232
- }
233
- }, {})
234
- }
235
- }, {})
236
- Elmessage.success('删除成功!')
237
- }
238
-
239
- getTotalTagMap()
173
+ getTagList(true)
240
174
 
241
175
  defineExpose({
242
176
  updateTag: () => {
243
- getTotalTagMap()
177
+ getTagList(true)
244
178
  }
245
179
  })
246
180
  </script>
@@ -2,7 +2,7 @@
2
2
  <script setup name="FactorScreen">
3
3
  import { nextTick, ref, watch, inject, reactive } from "vue";
4
4
  import { Close, Plus, CircleCloseFilled, InfoFilled, Document } from "@element-plus/icons-vue";
5
- import { handleVerifyScore, extractConditionDetails, extractVariables } from "./tools.js";
5
+ import { handleVerifyScore, extractConditionDetails, extractVariables, sendToAi } from "./tools.js";
6
6
  import FactorDescription from "./FactorDescription.vue";
7
7
  import MonacoEditor from "../../../MonacoEditor/index.vue";
8
8
 
@@ -38,6 +38,7 @@ const visibleDescriptions = ref(false);
38
38
  const factorType = ref("脚本");
39
39
  const scriptTestLoading = ref(false);
40
40
  const scriptCopyLoading = ref(false);
41
+ const scriptAILoading = ref(false);
41
42
  const testVariety = ref("");
42
43
  const testVarietyVisible = ref(false);
43
44
  const scriptTestLogVisible = ref(false);
@@ -45,6 +46,7 @@ const scriptTestResult = reactive({
45
46
  result: null,
46
47
  detail: "",
47
48
  code: "",
49
+ ai: "",
48
50
  });
49
51
 
50
52
  // 弹窗表单
@@ -322,6 +324,16 @@ const handleScriptCopy = async () => {
322
324
  scriptCopyLoading.value = false;
323
325
  }
324
326
  };
327
+ // 测试: 复制
328
+ const handleTestCodeCopy = () => {
329
+ let txa = document.createElement("textarea");
330
+ txa.value = scriptTestResult.code;
331
+ document.body.appendChild(txa);
332
+ txa.select();
333
+ document.execCommand("copy");
334
+ document.body.removeChild(txa);
335
+ ElMessage.success("测试代码已经成功复制到粘贴板");
336
+ };
325
337
  // 测试: 打开/确认/日志
326
338
  const extractCodesFromString = (str) => {
327
339
  if (!str) return [];
@@ -351,7 +363,7 @@ const handleScriptTest = async (action) => {
351
363
  };
352
364
  const testRes = await request.post("/common/qt/testFactorSelect", params);
353
365
  const { result, detail } = testRes.body;
354
- Object.assign(scriptTestResult, { result, detail, code: body });
366
+ Object.assign(scriptTestResult, { result, detail, code: body, ai: "" });
355
367
  if (result === 1) {
356
368
  ElMessage.success("测试通过");
357
369
  } else {
@@ -372,6 +384,21 @@ const handleScriptTest = async (action) => {
372
384
  }
373
385
  }
374
386
  };
387
+ // 测试: AI分析
388
+ const handleTestAi = () => {
389
+ const appId = "87be17ecc84d4d2ea3108d7155bec2ac";
390
+ const apiKey = "sk-d995eb26a4334bdeb2ccb4cbfaf51de8";
391
+ scriptAILoading.value = true;
392
+ scriptTestResult.ai = "";
393
+ sendToAi(appId, apiKey, scriptTestResult.code, (type, res) => {
394
+ if (type === "finish") {
395
+ scriptAILoading.value = false;
396
+ return;
397
+ }
398
+ scriptTestResult.ai = scriptTestResult.ai + res;
399
+ console.log(scriptTestResult.ai);
400
+ });
401
+ };
375
402
 
376
403
  // 监控: 窗口开关
377
404
  watch(
@@ -396,6 +423,8 @@ watch(
396
423
  Object.assign(scriptTestResult, {
397
424
  result: null,
398
425
  detail: "",
426
+ code: "",
427
+ ai: "",
399
428
  });
400
429
  break;
401
430
  }
@@ -818,6 +847,7 @@ watch(
818
847
  ref="monacoEditorRef"
819
848
  :language="'lua'"
820
849
  :suggestionEnable="true"
850
+ :variableEnable="true"
821
851
  />
822
852
  </div>
823
853
  <template #footer>
@@ -890,7 +920,7 @@ watch(
890
920
  <el-dialog
891
921
  modal-class="log-dialog"
892
922
  v-model="scriptTestLogVisible"
893
- width="830"
923
+ width="80vw"
894
924
  align-center
895
925
  append-to-body
896
926
  draggable
@@ -923,17 +953,53 @@ watch(
923
953
  >
924
954
  <pre>{{ scriptTestResult.code }}</pre>
925
955
  </el-scrollbar>
926
- <!-- 分割线 -->
927
- <el-divider direction="vertical" />
928
956
  <!-- 日志 -->
929
- <el-scrollbar height="600px">
957
+ <el-scrollbar
958
+ class="log"
959
+ height="600px"
960
+ >
930
961
  <pre :class="scriptTestResult.result === 1 ? 'success-log' : 'error-log'">{{ scriptTestResult.result === 1 ? `✅️ 测试通过\n${scriptTestResult.detail}` : scriptTestResult.detail }}</pre>
931
962
  </el-scrollbar>
963
+ <!-- AI分析结果 -->
964
+ <el-scrollbar
965
+ class="ai"
966
+ height="600px"
967
+ >
968
+ <v-md-editor
969
+ v-if="scriptTestResult.ai"
970
+ mode="preview"
971
+ :model-value="scriptTestResult.ai"
972
+ />
973
+ <!-- 正在进行AI分析, 并且没有返回结果时, 展示骨架屏 -->
974
+ <el-skeleton
975
+ v-else-if="scriptAILoading"
976
+ :rows="5"
977
+ animated
978
+ />
979
+ <!-- 未进行AI分析, 并且没有返回结果时, 展示文案 -->
980
+ <el-empty
981
+ v-else-if="!scriptAILoading"
982
+ description="点击下方按钮: AI分析, 分析结果将会展示在此处"
983
+ />
984
+ </el-scrollbar>
932
985
  </div>
933
986
  <!-- 底部 -->
934
987
  <template #footer>
935
988
  <div class="dialog-footer">
936
- <el-button @click="scriptTestLogVisible = false"> 关闭 </el-button>
989
+ <el-button
990
+ type="primary"
991
+ :loading="scriptAILoading"
992
+ @click="handleTestAi"
993
+ >
994
+ AI分析
995
+ </el-button>
996
+ <el-button
997
+ type="primary"
998
+ @click="handleTestCodeCopy"
999
+ >
1000
+ 复制
1001
+ </el-button>
1002
+ <el-button @click="scriptTestLogVisible = false">关闭</el-button>
937
1003
  </div>
938
1004
  </template>
939
1005
  </el-dialog>
@@ -1028,15 +1094,13 @@ watch(
1028
1094
  }
1029
1095
  .content {
1030
1096
  display: flex;
1031
- background-color: var(--el-color-black);
1097
+ gap: 1px;
1032
1098
  .el-scrollbar {
1099
+ background-color: var(--el-color-black);
1033
1100
  flex: 1;
1034
1101
  box-sizing: border-box;
1035
1102
  padding: 8px;
1036
- }
1037
- .el-divider {
1038
- margin: 0;
1039
- height: 616px;
1103
+ border: var(--el-border);
1040
1104
  }
1041
1105
  .code {
1042
1106
  color: var(--el-color-info);
@@ -1054,6 +1118,10 @@ watch(
1054
1118
  word-break: break-all;
1055
1119
  word-wrap: break-word;
1056
1120
  }
1121
+ .ai {
1122
+ flex: 2;
1123
+ background-color: white;
1124
+ }
1057
1125
  }
1058
1126
  }
1059
1127
  </style>
@@ -32,3 +32,44 @@ export const extractVariables = (content) => {
32
32
 
33
33
  return [...new Set(variables)]; // 去重
34
34
  };
35
+
36
+ // 发送AI
37
+ export const sendToAi = async (appId, apiKey, value, callback) => {
38
+ try {
39
+ const res = await fetch(`https://dashscope.aliyuncs.com/api/v1/apps/${appId}/completion`, {
40
+ method: "POST",
41
+ body: JSON.stringify({
42
+ input: { prompt: value },
43
+ parameters: {
44
+ incremental_output: "true", // 流式返回
45
+ },
46
+ debug: {},
47
+ }),
48
+ headers: {
49
+ Authorization: `Bearer ${apiKey}`,
50
+ "Content-Type": "application/json",
51
+ "X-DashScope-SSE": "enable", // 流式输出
52
+ },
53
+ });
54
+ if (!res.ok || !res.body) throw new Error("请求失败");
55
+
56
+ const reader = res.body.getReader();
57
+ const decoder = new TextDecoder();
58
+
59
+ while (true) {
60
+ const { done, value } = await reader.read();
61
+ if (done && callback) {
62
+ callback("finish", "");
63
+ break;
64
+ }
65
+ try {
66
+ const data = decoder.decode(value, { stream: true });
67
+ const resData = JSON.parse(data.split("\n")[3].substr(5));
68
+ const resText = resData?.output?.text;
69
+ if (resText && callback) callback("message", resText);
70
+ } catch (error) {}
71
+ }
72
+ } catch (error) {
73
+ console.error(error);
74
+ }
75
+ };
package/src/main.ts CHANGED
@@ -1,12 +1,17 @@
1
- import { createApp } from 'vue'
2
- import './style.css'
3
- import App from './App.vue'
4
- import router from './router'
5
- import stComp from '../packages/index.ts'
6
- import { createPinia } from 'pinia'
1
+ import { createApp } from "vue";
2
+ import "./style.css";
3
+ import App from "./App.vue";
4
+ import router from "./router";
5
+ import stComp from "../packages/index.ts";
6
+ import { createPinia } from "pinia";
7
7
 
8
- createApp(App)
9
- .use(router)
10
- .use(stComp)
11
- .use(createPinia())
12
- .mount('#app')
8
+ // markdown编辑预览组件
9
+ import "@kangc/v-md-editor/lib/style/base-editor.css";
10
+ import "@kangc/v-md-editor/lib/theme/style/vuepress.css";
11
+ import Prism from "prismjs";
12
+ import vuepressTheme from "@kangc/v-md-editor/lib/theme/vuepress.js";
13
+ import VueMarkdownEditor from "@kangc/v-md-editor";
14
+
15
+ VueMarkdownEditor.use(vuepressTheme, { Prism });
16
+
17
+ createApp(App).use(router).use(stComp).use(createPinia()).use(VueMarkdownEditor).mount("#app");
@@ -8,6 +8,7 @@
8
8
  ref="monacoEditorRef"
9
9
  :defaultValue="value"
10
10
  :suggestionEnable="true"
11
+ :variableEnable="true"
11
12
  @change="changeCode"
12
13
  />
13
14
  </div>