sun-form-v3 1.0.65 → 1.0.67

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. package/package.json +8 -5
  2. package/src/App.vue +9 -0
  3. package/src/assets/font/YouSheBiaoTiHei-2.ttf +0 -0
  4. package/src/assets/font/demo.css +539 -0
  5. package/src/assets/font/demo_index.html +1200 -0
  6. package/src/assets/font/iconfont.css +191 -0
  7. package/src/assets/font/iconfont.js +1 -0
  8. package/src/assets/font/iconfont.json +317 -0
  9. package/src/assets/font/iconfont.ttf +0 -0
  10. package/src/assets/font/iconfont.woff +0 -0
  11. package/src/assets/font/iconfont.woff2 +0 -0
  12. package/src/assets/img/bg_footer.png +0 -0
  13. package/src/assets/img/bg_title.png +0 -0
  14. package/src/assets/img/file.png +0 -0
  15. package/src/assets/img/logo.png +0 -0
  16. package/src/assets/img/logo2.png +0 -0
  17. package/src/assets/img/logo22.png +0 -0
  18. package/src/assets/img/logo23.png +0 -0
  19. package/src/assets/img/logo3.png +0 -0
  20. package/src/assets/img//347/237/251/345/275/242@2x.png +0 -0
  21. package/src/assets/logo.svg +1 -0
  22. package/src/assets/styles/element/index.scss +15 -0
  23. package/src/assets/styles/index.css +3 -0
  24. package/src/components/a.js +14 -0
  25. package/src/components/aDesigner/config.vue +127 -0
  26. package/src/components/aDesigner/design.vue +20 -0
  27. package/src/components/aDesigner/designer.js +342 -0
  28. package/src/components/aDesigner/http.js +292 -0
  29. package/src/components/aDesigner/index.vue +144 -0
  30. package/src/components/aDesigner/panel.vue +144 -0
  31. package/src/components/aDesigner/show.vue +24 -0
  32. package/src/components/widgetCommonComps/commonApiConfig/index.vue +194 -0
  33. package/src/components/widgetCommonComps/commonCard/index.vue +36 -0
  34. package/src/components/widgetCommonComps/commonCodeEditor/editor.vue +219 -0
  35. package/src/components/widgetCommonComps/commonCodeEditor/modalEditor.vue +68 -0
  36. package/src/components/widgetCommonComps/commonCollapseCard/index.vue +10 -0
  37. package/src/components/widgetCommonComps/commonContainer/index.vue +95 -0
  38. package/src/components/widgetCommonComps/commonJsonInput/index.vue +59 -0
  39. package/src/components/widgetCommonComps/commonLabelContainer/index.vue +39 -0
  40. package/src/components/widgetCommonComps/commonSidetree/index.vue +61 -0
  41. package/src/components/widgetCommonComps/commonTypeInput/index.vue +75 -0
  42. package/src/components/widgetCommonComps/commonWidgetLabelContainer/index.vue +55 -0
  43. package/src/components/widgetCommonComps/index copy.js +17 -0
  44. package/src/components/widgetCommonComps/index.js +17 -0
  45. package/src/components/widgetConfigComps/config-input/index.vue +60 -0
  46. package/src/components/widgetConfigComps/index copy.js +13 -0
  47. package/src/components/widgetConfigComps/index.js +17 -0
  48. package/src/components/widgetShowComps/index.js +29 -0
  49. package/src/components/widgetShowComps/widget-form/index.vue +43 -0
  50. package/src/components/widgetShowComps/widget-homepage/index.vue +41 -0
  51. package/src/components/widgetShowComps/widget-input/index.vue +85 -0
  52. package/src/components/widgetShowComps/widget-select/index.vue +31 -0
  53. package/src/designer.js +342 -0
  54. package/src/http.js +292 -0
  55. package/src/index.js +24 -0
  56. package/src/index2.js +23 -0
  57. package/src/main.js +19 -0
  58. package/src/remark.js +708 -0
  59. package/src/testBtn.vue +11 -0
  60. package/src/testInput.vue +12 -0
  61. package/src/util/jsformat.js +568 -0
  62. package/src/widgetConfig.js +1112 -0
  63. package/dist/abap-DfvySaIJ.js +0 -1404
  64. package/dist/apex-B__0irD3.js +0 -332
  65. package/dist/assets/css.worker-OK053IOu.js +0 -84
  66. package/dist/assets/editor.worker-D9iUZyMP.js +0 -11
  67. package/dist/assets/html.worker-CL40hqKM.js +0 -458
  68. package/dist/assets/json.worker-6f9bhSHY.js +0 -42
  69. package/dist/assets/ts.worker-B6g3wjaE.js +0 -37021
  70. package/dist/azcli-CDMGhRmx.js +0 -74
  71. package/dist/bat-0Mk8aqzx.js +0 -106
  72. package/dist/bicep-BBi_I06Z.js +0 -108
  73. package/dist/cameligo-D0G_Zm6X.js +0 -180
  74. package/dist/clojure-o2ZKLeMp.js +0 -767
  75. package/dist/coffee-DOQff5VC.js +0 -238
  76. package/dist/cpp-CQGJnWhD.js +0 -395
  77. package/dist/csharp-C1jLsHl8.js +0 -332
  78. package/dist/csp-C_ttMQaW.js +0 -59
  79. package/dist/css-BC202kVV.js +0 -193
  80. package/dist/cssMode-B2c4O0YS.js +0 -1541
  81. package/dist/cypher-DwtEH7Fi.js +0 -269
  82. package/dist/dart-D9XknsP2.js +0 -287
  83. package/dist/dockerfile-DgsNjqqa.js +0 -136
  84. package/dist/ecl-BAMCHBl6.js +0 -462
  85. package/dist/elixir-CegIttP8.js +0 -575
  86. package/dist/favicon.ico +0 -0
  87. package/dist/flow9-9608t7UV.js +0 -148
  88. package/dist/freemarker2-C0V-2C6A.js +0 -995
  89. package/dist/fsharp-CCtt9-1_.js +0 -223
  90. package/dist/go-CGUIPbct.js +0 -224
  91. package/dist/graphql-BNRIFFIn.js +0 -157
  92. package/dist/handlebars-Dq-D2gGP.js +0 -425
  93. package/dist/hcl-C__KLIXe.js +0 -189
  94. package/dist/html-CHe4dRTt.js +0 -314
  95. package/dist/htmlMode-DmZav6BJ.js +0 -1551
  96. package/dist/index2-CDdAhO0H.js +0 -124690
  97. package/dist/ini-CeKYn_zA.js +0 -77
  98. package/dist/java-Dm24deQl.js +0 -238
  99. package/dist/javascript-e6NjSQC6.js +0 -76
  100. package/dist/jsonMode-pOauncTt.js +0 -1957
  101. package/dist/julia-BImNW7VE.js +0 -517
  102. package/dist/kotlin-BfE79GEb.js +0 -259
  103. package/dist/less-DglNOcaC.js +0 -168
  104. package/dist/lexon-BA0dRz9Q.js +0 -163
  105. package/dist/liquid-DGCC4WOg.js +0 -246
  106. package/dist/lua-DMkWzJcm.js +0 -168
  107. package/dist/m3-sA-5shO8.js +0 -216
  108. package/dist/markdown-OYRB1igA.js +0 -235
  109. package/dist/mdx-GitjX2xy.js +0 -171
  110. package/dist/mips-rRzkJ_7G.js +0 -204
  111. package/dist/msdax-DoVJdUhd.js +0 -381
  112. package/dist/mysql-Ty44IHXo.js +0 -884
  113. package/dist/objective-c-VUfyhYrA.js +0 -189
  114. package/dist/pascal-DkASiYyw.js +0 -257
  115. package/dist/pascaligo-p-ELPlVO.js +0 -170
  116. package/dist/perl-Cjl1FxLZ.js +0 -632
  117. package/dist/pgsql-DjVenF7s.js +0 -857
  118. package/dist/php-CwvGzZOO.js +0 -506
  119. package/dist/pla-Br1iaBIV.js +0 -143
  120. package/dist/postiats-BaeP8zZY.js +0 -913
  121. package/dist/powerquery-CLCshuo8.js +0 -896
  122. package/dist/powershell-CZV50w5N.js +0 -245
  123. package/dist/protobuf-MV3XTewJ.js +0 -426
  124. package/dist/pug-DkDg4c4l.js +0 -408
  125. package/dist/python-BxUPejAm.js +0 -282
  126. package/dist/qsharp-BAtiKA97.js +0 -291
  127. package/dist/r-8ocrd-h-.js +0 -249
  128. package/dist/razor-B0zHeS7k.js +0 -556
  129. package/dist/redis-9sZiddxc.js +0 -308
  130. package/dist/redshift-DQfTOGC0.js +0 -815
  131. package/dist/restructuredtext-DXU-vkgr.js +0 -180
  132. package/dist/ruby-DotfqwMf.js +0 -517
  133. package/dist/rust-BIauJ5KN.js +0 -349
  134. package/dist/sb-CmWMvDEV.js +0 -121
  135. package/dist/scala-C81brEbk.js +0 -376
  136. package/dist/scheme-D0pcFz2x.js +0 -114
  137. package/dist/scss-BOdN2fGG.js +0 -268
  138. package/dist/shell-6E09eAkU.js +0 -227
  139. package/dist/solidity-CWStzA1K.js +0 -1373
  140. package/dist/sophia-76Sb6CWe.js +0 -205
  141. package/dist/sparql-BmZTkOWT.js +0 -207
  142. package/dist/sql-Cs9TBAW5.js +0 -859
  143. package/dist/st-B-rqE1Bu.js +0 -422
  144. package/dist/style.css +0 -1
  145. package/dist/sun-form-v3.es.js +0 -4
  146. package/dist/sun-form-v3.umd.js +0 -1908
  147. package/dist/swift-Btsj6YxQ.js +0 -318
  148. package/dist/systemverilog-B3RHBRa2.js +0 -582
  149. package/dist/tcl-Dpj776pn.js +0 -238
  150. package/dist/tsMode-AhR0apFR.js +0 -886
  151. package/dist/twig-Bb9JmBsE.js +0 -398
  152. package/dist/typescript-DW_IjlW5.js +0 -349
  153. package/dist/typespec-CDWeg3SU.js +0 -123
  154. package/dist/vb-DEXnYwEI.js +0 -378
  155. package/dist/wgsl-D602c1lx.js +0 -445
  156. package/dist/xml-CraN90Vi.js +0 -101
  157. package/dist/yaml-D6yA8dTm.js +0 -212
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <el-button plain :type="props.modelValue.apiurl ? 'primary' : ''" icon="Setting" @click="openEvent">
3
+ {{ props.buttonName }}
4
+ </el-button>
5
+ <vxe-modal transfer v-model="showModal" width="600px" height="600px" show-footer @close="closeHandle">
6
+ <template #title>
7
+ <span>{{ props.title }}</span>
8
+ </template>
9
+ <template #default>
10
+ <div class="item">
11
+ <div class="lab">发送方式</div>
12
+ <div class="con">
13
+ <el-radio-group v-model="data.method">
14
+ <el-radio-button value="get" label="GET"></el-radio-button>
15
+ <el-radio-button value="post" label="POST"></el-radio-button>
16
+ <el-radio-button value="put" label="PUT"></el-radio-button>
17
+ <el-radio-button value="patch" label="PATCH"></el-radio-button>
18
+ <el-radio-button value="delete" label="DELETE"></el-radio-button>
19
+ </el-radio-group>
20
+ </div>
21
+ </div>
22
+ <div class="item">
23
+ <div class="lab">数据格式</div>
24
+ <div class="con">
25
+ <el-radio-group v-model="data.contentType">
26
+ <el-radio-button value="JSON" label="JSON"></el-radio-button>
27
+ <el-radio-button value="FormData" label="FormData"></el-radio-button>
28
+ </el-radio-group>
29
+ </div>
30
+ </div>
31
+ <div class="item">
32
+ <div class="lab">接口地址</div>
33
+ <div class="con">
34
+ <el-input v-model="data.apiurl" placeholder="例:/api/getData"></el-input>
35
+ </div>
36
+ </div>
37
+ <div class="item">
38
+ <div class="lab">参数数据</div>
39
+ <div class="con">
40
+ <common-json-input v-model="data.params"></common-json-input>
41
+ </div>
42
+ </div>
43
+ <div class="item">
44
+ <div class="lab">参数适配器</div>
45
+ <div class="con">
46
+ <modal-editor :designer="designer" v-model="data.paramsFormat" :params="['params', 'widget', 'app']"></modal-editor>
47
+ <el-popover placement="top-start" title="示例" :width="150" trigger="hover">
48
+ <slot>
49
+ return
50
+ &nbsp;{<br>
51
+ &nbsp;&nbsp;&nbsp;"name":'张三',<br>
52
+ &nbsp;&nbsp;&nbsp;"age":22<br>
53
+ &nbsp;},<br>
54
+ </slot>
55
+ <template #reference>
56
+ <el-icon class="ml-2 cursor-pointer">
57
+ <WarningFilled />
58
+ </el-icon>
59
+ </template>
60
+ </el-popover>
61
+ <!-- <common-code-editor v-model="data.beforeSend" height="300px"></common-code-editor> -->
62
+ </div>
63
+ </div>
64
+ <div class="item">
65
+ <div class="lab">请求头数据</div>
66
+ <div class="con">
67
+ <common-json-input v-model="data.headers"></common-json-input>
68
+ </div>
69
+ </div>
70
+
71
+ <div class="item">
72
+ <div class="lab">请求头适配器</div>
73
+ <div class="con">
74
+ <modal-editor :designer="designer" v-model="data.headersFormat" :params="['headers', 'widget', 'app']"></modal-editor>
75
+ <el-popover placement="top-start" title="示例" :width="150" trigger="hover">
76
+ <slot>
77
+ return
78
+ &nbsp;{<br>
79
+ &nbsp;&nbsp;&nbsp;"token":'abc',<br>
80
+ &nbsp;&nbsp;&nbsp;"serial-no":22<br>
81
+ &nbsp;},<br>
82
+ </slot>
83
+ <template #reference>
84
+ <el-icon class="ml-2 cursor-pointer">
85
+ <WarningFilled />
86
+ </el-icon>
87
+ </template>
88
+ </el-popover>
89
+ <!-- <common-code-editor v-model="data.beforeSend" height="300px"></common-code-editor> -->
90
+ </div>
91
+ </div>
92
+ <div class="item">
93
+ <div class="lab">请求成功适配器</div>
94
+ <div class="con">
95
+ <modal-editor :designer="designer" v-model="data.successFormat" :params="['res', 'widget', 'app']"></modal-editor>
96
+ <el-popover placement="top-start" title="注意" :width="200" trigger="hover">
97
+ <slot>
98
+ 请求成功是指数据上的请求成功,不代表业务上的请求成功,axios中进入的是then回调
99
+ </slot>
100
+ <template #reference>
101
+ <el-icon class="ml-2 cursor-pointer">
102
+ <WarningFilled />
103
+ </el-icon>
104
+ </template>
105
+ </el-popover>
106
+ </div>
107
+ </div>
108
+ <div class="item">
109
+ <div class="lab">请求失败适配器</div>
110
+ <div class="con">
111
+ <modal-editor :designer="designer" v-model="data.errorFormat" :params="['error', 'widget', 'app']"></modal-editor>
112
+ <el-popover placement="top-start" title="注意" :width="200" trigger="hover">
113
+ <slot>
114
+ 请求失败是指数据上的请求成功,不代表业务上的请求成功,axios中进入的是catch回调
115
+ </slot>
116
+ <template #reference>
117
+ <el-icon class="ml-2 cursor-pointer">
118
+ <WarningFilled />
119
+ </el-icon>
120
+ </template>
121
+ </el-popover>
122
+ </div>
123
+ </div>
124
+ </template>
125
+ <template #footer>
126
+ <el-button icon="Promotion" size="small" @click="testHandle">测试请求</el-button>
127
+ <el-button icon="Close" size="small" @click="closeHandle">关闭</el-button>
128
+ <el-button icon="Check" type="primary" size="small" @click="confirmHandle">确认</el-button>
129
+ </template>
130
+ </vxe-modal>
131
+ </template>
132
+
133
+ <script setup>
134
+ import { ref, reactive, computed } from 'vue';
135
+ import commonCodeEditor from '../commonCodeEditor/editor.vue'
136
+ import modalEditor from '../commonCodeEditor/modalEditor.vue'
137
+
138
+ defineOptions({ name: "commonApiConfig" })
139
+ const emit = defineEmits(['update:modelValue'])
140
+ let props = defineProps({
141
+ modelValue: [Object, null],
142
+ designer: {
143
+ type: Object
144
+ },
145
+ buttonName: {
146
+ type: [String],
147
+ default: '接口配置'
148
+ }, title: {
149
+ type: [String],
150
+ default: '请求配置'
151
+ },
152
+ })
153
+ let designer = props.designer
154
+ // let data = computed({
155
+ // set(value) {
156
+ // emit('update:modelValue', value)
157
+ // },
158
+ // get() {
159
+ // return props.modelValue
160
+ // }
161
+ // })
162
+ let data = ref(null)
163
+ let showModal = ref(false)
164
+ const openEvent = () => {
165
+ data.value = designer.$utils.clone(props.modelValue, true)
166
+ // data.apiSet = props.modelValue
167
+ showModal.value = true;
168
+ }
169
+ const closeHandle = () => {
170
+ showModal.value = false
171
+ }
172
+ const testHandle = () => {
173
+ emit('update:modelValue', data.value)
174
+ designer.requestByApisetConfig(designer.chosenWidget)
175
+ }
176
+ const confirmHandle = () => {
177
+ emit('update:modelValue', data.value)
178
+ showModal.value = false
179
+ }
180
+ </script>
181
+
182
+ <style scoped lang="scss">
183
+ .item {
184
+ @apply flex my-4 items-center;
185
+
186
+ .lab {
187
+ @apply flex-none w-32 flex justify-end pr-4;
188
+ }
189
+
190
+ .con {
191
+ @apply flex-1;
192
+ }
193
+ }
194
+ </style>
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div class="border-gray-200 border-t border-b">
3
+ <!-- 卡片头 -->
4
+ <div class="flex items-center justify-between p-2 bg-gray-100 cursor-pointer text-sm" @click="toggle = !toggle">
5
+ <span class="select-none">
6
+ {{ props.title }}
7
+ </span>
8
+ <span>
9
+ <el-icon v-if="toggle">
10
+ <ArrowUp />
11
+ </el-icon>
12
+ <el-icon v-else>
13
+ <ArrowDown />
14
+ </el-icon>
15
+ </span>
16
+ </div>
17
+ <!-- 卡片内容 -->
18
+ <div class="px-3 py-2 bg-white" v-if="toggle">
19
+ <slot></slot>
20
+ </div>
21
+ </div>
22
+ </template>
23
+
24
+ <script setup>
25
+ import { ref, reactive } from 'vue';
26
+ let props = defineProps({
27
+ title: {
28
+ type: String,
29
+ default: "标题"
30
+ }
31
+ })
32
+ defineOptions({ name: "commonCard" })
33
+ let toggle = ref(true);
34
+ </script>
35
+
36
+ <style scoped lang="scss"></style>
@@ -0,0 +1,219 @@
1
+ <template>
2
+ <div class="flex w-full h-full">
3
+ <div class="tree_wrap flex-none w-[320px] border" v-if="!props.pure">
4
+ <common-sidetree :designer="designer" :canAddApi="true" @addApi="addApiHandle"></common-sidetree>
5
+ </div>
6
+ <div class="h-full w-full flex flex-col flex-1">
7
+ <div class="head py-2 px-2 box-border bg-[#191c20]" v-if="!props.pure">
8
+ <span class="text-[#569cd6]">function</span>
9
+ <span class="text-[#ffd700]">( </span>
10
+ <span v-for="(item, index) in props.params" class="text-[#d4d4d4]">
11
+ {{ item }}
12
+ {{ index == props.params.length - 1 ? '' : ' , ' }}
13
+ </span>
14
+ <span class="text-[#ffd700]"> ) {</span>
15
+ </div>
16
+ <div class="flex-1 h-full" ref="container" :style="{ width: props.width, height: props.height }">
17
+ </div>
18
+ <div v-if="!props.pure" class="footer text-[#ffd700] bg-[#2f3129] py-2 px-2">}</div>
19
+ </div>
20
+ </div>
21
+ </template>
22
+
23
+ <script setup>
24
+ import { ref, onMounted, onUnmounted, watch } from 'vue';
25
+ import * as monaco from 'monaco-editor';
26
+ import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
27
+ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
28
+ import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker';
29
+ import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker';
30
+ import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker';
31
+ import "monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution"; // 代码高亮&提示
32
+ import "monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution"; // 代码高亮&提示
33
+ import "monaco-editor/esm/vs/language/typescript/monaco.contribution"; // 代码高亮&提示
34
+ import 'monaco-editor/esm/vs/editor/contrib/contextmenu/browser/contextmenu.js'; // 右键显示菜单
35
+ import 'monaco-editor/esm/vs/editor/contrib/folding/browser/folding.js'; // 折叠
36
+ import 'monaco-editor/esm/vs/editor/contrib/format/browser/formatActions.js'; // 格式化代码
37
+ import 'monaco-editor/esm/vs/editor/contrib/suggest/browser/suggestController.js'; // 代码联想提示
38
+ import 'monaco-editor/esm/vs/editor/contrib/tokenization/browser/tokenization.js'; // 代码联想提示
39
+ import 'monaco-editor/esm/vs/editor/contrib/snippet/browser/snippetController2.js'; //代码片段支持
40
+
41
+ defineOptions({ name: "commonCodeEditor" });
42
+ const props = defineProps({
43
+ modelValue: [String, null],
44
+ designer: {
45
+ type: Object,
46
+ default: {}
47
+ },
48
+ width: {
49
+ type: [String],
50
+ default: '100%'
51
+ },
52
+ height: {
53
+ type: [String],
54
+ default: '100%'
55
+ },
56
+ language: {
57
+ type: [String],
58
+ default: 'javascript'
59
+ },
60
+ theme: {
61
+ type: [String],
62
+ default: 'vs-dark'
63
+ // default: 'vs'
64
+ },
65
+ params: {
66
+ type: [Array],
67
+ default: []
68
+ },
69
+ minimap: {
70
+ type: [Boolean],
71
+ default: true,
72
+ },
73
+ pure: {
74
+ type: [Boolean],
75
+ default: false,
76
+ },
77
+ tabSize: {
78
+ type: [Number],
79
+ default: 4,
80
+ }
81
+ })
82
+ const emit = defineEmits(['update:modelValue'])
83
+ const container = ref(null);
84
+ let editor = null
85
+ onMounted(() => {
86
+ // 设置 Monaco 编辑器的基础路径
87
+ window.MonacoEnvironment = {
88
+ getWorker(_, label) {
89
+ if (label === 'json') {
90
+ return new jsonWorker();
91
+ }
92
+ if (label === 'css' || label === 'scss' || label === 'less') {
93
+ return new cssWorker();
94
+ }
95
+ if (label === 'html' || label === 'handlebars' || label === 'razor') {
96
+ return new htmlWorker();
97
+ }
98
+ if (label === 'typescript' || label === 'javascript') {
99
+ return new tsWorker();
100
+ }
101
+ return new editorWorker();
102
+ }
103
+ };
104
+
105
+ // 确保容器元素存在且尺寸正确
106
+ if (container.value) {
107
+ editor = monaco.editor.create(container.value, {
108
+ value: props.modelValue || "",
109
+ language: props.language,
110
+ theme: props.theme, // 可选:使用暗色主题 默认
111
+ automaticLayout: true, // 自动调整布局以适应容器大小变化
112
+ minimap: { enabled: props.minimap }, // 启用小地图
113
+ folding: true, // 启用代码折叠
114
+ foldingStrategy: 'auto', // 自动折叠策略
115
+ renderLineHighlight: 'all', // 高亮当前行
116
+ scrollBeyondLastLine: false, // 禁止滚动超过最后一行
117
+ quickSuggestions: true, // 快速建议
118
+ suggestOnTriggerCharacters: true, // 在触发字符时提供建议
119
+ parameterHints: { enabled: true }, // 启用参数提示
120
+ autoClosingBrackets: 'always', // 自动闭合括号
121
+ autoClosingQuotes: 'always', // 自动闭合引号
122
+ guides: { indentation: true }, // 缩进指南
123
+ autoIndent: 'full', // 自动缩进
124
+ formatOnType: true, // 在输入时格式化
125
+ formatOnPaste: true, // 在粘贴时格式化
126
+ wordWrap: 'wordWrapColumn',// 自动换行
127
+ tabSize: props.tabSize,// 缩进大小
128
+ });
129
+ // monaco.languages.registerHoverProvider('javascript', {
130
+ // provideHover: function (model, position) {
131
+ // const word = model.getWordAtPosition(position);
132
+ // if (word.word.startsWith('btn_')) {
133
+ // return {
134
+ // contents: [
135
+ // { value: '按钮组件: 提交表单' },
136
+ // { value: '属性: label="提交", type="primary"' },
137
+ // { value: '方法: onClick="submitForm()"' }
138
+ // ]
139
+ // };
140
+ // }
141
+ // // 处理其他组件类型...
142
+ // }
143
+ // });
144
+
145
+ editor.addAction({
146
+ id: 'show-component-info',
147
+ label: '显示组件信息',
148
+ keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.I],
149
+ contextMenuGroupId: 'operation',
150
+ contextMenuOrder: 1.5,
151
+ run: function (ed) {
152
+ const model = ed.getModel();
153
+ const selection = ed.getSelection();
154
+ const word = model.getWordAtPosition(selection.getStartPosition());
155
+ if (word && word.word.startsWith('grid_')) {
156
+ console.log('组件名称:', word.word);
157
+ showComponentInfo(word.word); // 自定义函数,显示组件信息
158
+ }
159
+ }
160
+ });
161
+ editor.onDidChangeModelContent((event) => {
162
+ emit('update:modelValue', editor.getValue());
163
+ });
164
+ setTimeout(() => {
165
+ formatCode();
166
+ }, 20);
167
+ // watch(() => props.modelValue, (val) => {
168
+ // console.log(val);
169
+ // setValue(val)
170
+ // setTimeout(() => {
171
+ // formatCode();
172
+ // }, 20);
173
+ // }, {
174
+ // deep: true,
175
+ // immediate: true
176
+ // })
177
+ // 可选:在组件卸载时销毁编辑器
178
+ onUnmounted(() => {
179
+ editor.dispose();
180
+ });
181
+ } else {
182
+ console.error('编辑器容器元素不存在');
183
+ }
184
+ });
185
+ const getValue = () => {
186
+ console.log(editor.getValue());
187
+ }
188
+ const setValue = (val) => {
189
+ editor.setValue(val);
190
+ }
191
+ const formatCode = () => {
192
+ editor.trigger('keyboard', 'editor.action.formatDocument', null);
193
+ }
194
+ const setPositionValue = (val) => {
195
+ const position = editor.getPosition();
196
+ editor.executeEdits('', [{
197
+ range: new monaco.Range(
198
+ position.lineNumber,
199
+ position.column,
200
+ position.lineNumber,
201
+ position.column
202
+ ),
203
+ text: val,
204
+ forceMoveMarkers: true
205
+ }]);
206
+ }
207
+ const addApiHandle = (row) => {
208
+ console.log(row);
209
+ }
210
+
211
+ defineExpose({
212
+ getValue,
213
+ setValue,
214
+ setPositionValue,
215
+ formatCode
216
+ })
217
+ </script>
218
+
219
+ <style scoped lang="scss"></style>
@@ -0,0 +1,68 @@
1
+ <template>
2
+ <el-button plain :type="props.modelValue ? 'primary' : ''" icon="Edit" @click="openEvent">
3
+ {{ props.buttonName }}
4
+ </el-button>
5
+ <vxe-modal transfer v-model="showModal" width="80%" height="80%" show-footer @close="closeHandle">
6
+ <template #title>
7
+ <span>{{ props.title }}</span>
8
+ </template>
9
+ <template #default>
10
+ <commonCodeEditor :designer="designer" :params="props.params" v-if="showModal" v-model="codeString">
11
+ </commonCodeEditor>
12
+ </template>
13
+ <template #footer>
14
+ <el-button icon="Close" size="small" @click="closeHandle">关闭</el-button>
15
+ <el-button icon="Check" size="small" type="primary" @click="confirmHandle">确认</el-button>
16
+ </template>
17
+ </vxe-modal>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { ref, reactive, computed } from 'vue';
22
+ import commonCodeEditor from './editor.vue'
23
+
24
+ let props = defineProps({
25
+ modelValue: [String, null],
26
+ params: {
27
+ type: [Array],
28
+ default: []
29
+ },
30
+ designer: {
31
+ type: Object,
32
+ default: {}
33
+ },
34
+ buttonName: {
35
+ type: [String],
36
+ default: '编辑代码'
37
+ }, title: {
38
+ type: [String],
39
+ default: '代码编辑器'
40
+ },
41
+ })
42
+ const emit = defineEmits(['update:modelValue'])
43
+
44
+ let showModal = ref(false)
45
+ // let codeString = computed({
46
+ // get() {
47
+ // return props.modelValue
48
+ // },
49
+ // set(value) {
50
+ // emit('update:modelValue', value);
51
+ // }
52
+ // })
53
+ let codeString = ref(null)
54
+ const openEvent = () => {
55
+ codeString.value = props.modelValue
56
+ showModal.value = true;
57
+ }
58
+ const closeHandle = () => {
59
+ showModal.value = false
60
+ }
61
+ const confirmHandle = () => {
62
+ emit('update:modelValue', codeString.value);
63
+ showModal.value = false
64
+ }
65
+ defineOptions({ name: "modalEditor" })
66
+ </script>
67
+
68
+ <style scoped lang="scss"></style>
@@ -0,0 +1,10 @@
1
+ <template>
2
+ </template>
3
+
4
+ <script setup>
5
+ import { ref,reactive } from 'vue';
6
+ defineOptions({name:"commonCollapseCard"})
7
+ </script>
8
+
9
+ <style scoped lang="scss">
10
+ </style>
@@ -0,0 +1,95 @@
1
+ <template>
2
+ <div @click.stop="activeWidget" class="box-border relative "
3
+ v-if="!(designer.showMode&&props.widget.props.hide)"
4
+ :style="{width: 100/24 * props.widget.props.width + '%'}"
5
+ :class="designer.showMode||(widget.id == designer.widgetConfig.chosenId ? 'border-blue-700 border-2' : 'border-2 border-gray-100 ') + ' ' + (designer.showMode||(props.widget.type == 'homepage' ? 'overflow-y-auto py-5 ' : ''))">
6
+ <slot></slot>
7
+ <div v-if="widget.id == designer.widgetConfig.chosenId && widget.type != 'homepage'&&!designer.showMode"
8
+ class="absolute right-[-2px] top-[-22px] h-[20px] bg-blue-700">
9
+ <el-tooltip class="box-item" effect="dark" content="父级" placement="top">
10
+ <el-icon size="22" color="#ffffff" class="icon_item" @click.stop="gotoParent">
11
+ <Top />
12
+ </el-icon>
13
+ </el-tooltip>
14
+ <el-tooltip class="box-item" effect="dark" content="复制" placement="top">
15
+ <el-icon size="22" color="#ffffff" class="icon_item" @click.stop="copyWidget">
16
+ <CopyDocument />
17
+ </el-icon>
18
+ </el-tooltip>
19
+ <el-tooltip class="box-item" effect="dark" content="删除" placement="top">
20
+ <el-icon @click.stop="deleteWidget" size="22" color="#ffffff" class="icon_item">
21
+ <Delete />
22
+ </el-icon>
23
+ </el-tooltip>
24
+ </div>
25
+ <div v-if="props.widget.id == designer.widgetConfig.chosenId && props.widget.type != 'homepage'&&!designer.showMode"
26
+ class="handle absolute top-[-22px] h-[20px] bg-blue-700 text-gray-50 text-xs px-1 flex items-center justify-center cursor-pointer"
27
+ :class="(widget.type == 'homepage') ? 'right-[-2px]' : 'right-[68px]'">
28
+ <el-icon v-if="widget.type != 'homepage'" size="12" color="#ffffff" class="mr-1">
29
+ <Rank />
30
+ </el-icon>
31
+ {{ props.widget.displayName }}
32
+ </div>
33
+ </div>
34
+ </template>
35
+
36
+ <script setup>
37
+ import widgetConfig from '../../../widgetConfig';
38
+ import { ref, reactive, watch } from 'vue';
39
+ defineOptions({ name: "commonContainer" })
40
+ let props = defineProps({
41
+ designer: {
42
+ type: Object,
43
+ default: {}
44
+ },
45
+ widget: {
46
+ type: Object,
47
+ default: {}
48
+ },
49
+ parentWidget: {
50
+ type: Object,
51
+ default: {}
52
+ }
53
+ })
54
+ let widget = reactive(props.widget)
55
+ let designer = props.designer
56
+ let parentWidget = reactive(props.parentWidget)
57
+
58
+ let activeWidget = () => {
59
+ if(!designer.showMode){
60
+ designer.setChosenId(widget.id)
61
+ }
62
+ }
63
+ let deleteWidget = () => {
64
+ let widgetList = parentWidget.widgetList
65
+ let index = widgetList.findIndex(item => item.id == widget.id);
66
+ widgetList.splice(index, 1);
67
+ if (widgetList.length) {
68
+ if (index == 0) {
69
+ designer.setChosenId(widgetList[0].id)
70
+ } else {
71
+ designer.setChosenId(widgetList[index - 1].id)
72
+ }
73
+ } else {
74
+ designer.setChosenId(parentWidget.id)
75
+ }
76
+ }
77
+ let gotoParent = () => {
78
+ designer.setChosenId(parentWidget.id)
79
+ }
80
+ let copyWidget = () => {
81
+ let widgetList = parentWidget.widgetList
82
+ let index = widgetList.findIndex(item => item.id == widget.id);
83
+ let obj = widgetConfig[widget.type]
84
+ let newWidget = designer.getChosenInitData(obj)
85
+ widgetList.splice(index + 1, 0, newWidget);
86
+ }
87
+ </script>
88
+
89
+ <style scoped lang="scss">
90
+ @import url("../../../assets/font/iconfont.css");
91
+
92
+ .icon_item {
93
+ @apply px-1 cursor-pointer;
94
+ }
95
+ </style>