1010 <ShadcnTab v-model =" activeTab" :key =" `tab-${configureTabs.length}`" @on-change =" onChangeTab" >
1111 <ShadcnTabItem value =" source" :label =" $t('source.common.source')" :key =" 'source-tab'" >
1212 <ShadcnFormItem name =" type" :label =" $t('source.common.type')" :rules =" [{ required: true, message: $t('function.tip.selectPluginHolder') }]" >
13- <ShadcnToggleGroup v-model =" formState.type" class =" flex flex-wrap gap-3" name =" plugin" >
14- <ShadcnToggle v-for =" plugin in plugins" class =" p-1"
15- :key =" plugin.name"
16- :value =" plugin.name" >
13+ <ShadcnToggleGroup v-model =" formState.type" class =" flex flex-wrap gap-3" name =" plugin" :disabled =" !hasJsonConvert" >
14+ <ShadcnToggle v-for =" plugin in plugins" class =" p-1" :key =" plugin.name" :value =" plugin.name" >
1715 <ShadcnTooltip :content =" plugin.name" class =" p-1" >
1816 <img class =" h-16 w-16 object-contain" :src =" '/static/images/plugin/' + plugin.name.toLowerCase() + '.svg'" :alt =" plugin.name" >
1917 </ShadcnTooltip >
2624 class =" space-y-4"
2725 :key =" tab"
2826 :value =" tab"
27+ :disabled =" !hasJsonConvert"
2928 :label =" $t(`source.common.${ tab }`)" >
3029 <ShadcnFormItem v-for =" configure in pluginTabConfigure"
3130 :name =" configure.field"
@@ -119,6 +118,7 @@ import { defineComponent } from 'vue'
119118import { SourceModel , SourceRequest } from ' @/model/source'
120119import { cloneDeep , pick } from ' lodash'
121120import SourceService from ' @/services/source'
121+ import PluginService from ' @/services/plugin'
122122import { TokenUtils } from ' @/utils/token'
123123import { ResponseModel } from ' @/model/response'
124124
@@ -172,7 +172,8 @@ export default defineComponent({
172172 pluginConfigure: null as unknown as any ,
173173 pluginTabConfigure: null as unknown as any ,
174174 applyConfigure: null as unknown as any ,
175- originalSchema: null as unknown as any
175+ originalSchema: null as unknown as any ,
176+ hasJsonConvert: false
176177 }
177178 },
178179 created()
@@ -246,23 +247,30 @@ export default defineComponent({
246247
247248 // 获取插件列表的 Promise
248249 // Get plugins promise
249- const getPluginsPromise = SourceService .getPlugins ()
250+ const getPluginsPromise = PluginService .getPlugins (true )
251+
252+ const pluginsResponse = await getPluginsPromise
253+ this .hasJsonConvert = pluginsResponse .data .some (value =>
254+ value .type ?.toLowerCase () === ' convert' &&
255+ value .name === ' JsonConvert'
256+ )
257+
258+ if (! this .hasJsonConvert ) {
259+ this .testInfo .message = this .$t (' plugin.text.requiredJsonConvert' )
260+ }
261+
262+ if (pluginsResponse .status ) {
263+ this .plugins = pluginsResponse .data .filter ((plugin : { type: string }) =>
264+ plugin .type ?.toLowerCase () === ' connector'
265+ )
266+ }
250267
251268 if (this .info ) {
252- this .title = ` ${ this .$t (' source.common.modify' ).replace (' $NAME' , String (this .info .name )) } `
269+ this .title = ` ${ this .$t (' source.common.modify' ).replace (' $NAME' , String (this .info .name || ' ... ' )) } `
253270
254271 // 同时执行获取插件列表和源代码信息的请求
255272 // Simultaneously execute requests to get plugin list and source code
256- const [pluginsResponse, sourceResponse] = await Promise .all ([
257- getPluginsPromise ,
258- SourceService .getByCode (this .info .code )
259- ])
260-
261- // 处理插件列表响应
262- // Handle plugin list response
263- if (pluginsResponse .status ) {
264- this .plugins = pluginsResponse .data
265- }
273+ const sourceResponse = await SourceService .getByCode (this .info .code )
266274
267275 // 处理源代码信息响应
268276 // Handle source code response
@@ -280,19 +288,10 @@ export default defineComponent({
280288 this .updatePluginTabConfigure (' source' )
281289 }
282290 }
291+
292+ console .log (this .plugins )
283293 }
284294 else {
285- // 如果没有 info,只需要获取插件列表
286- // If there is no info, only get plugin list
287- const pluginsResponse = await getPluginsPromise
288- if (pluginsResponse .status ) {
289- this .plugins = pluginsResponse .data
290-
291- const hasJsonConvert = this .plugins .filter (value => value .type === ' Convert' && value .name === ' JsonConvert' ).length > 0
292- if (! hasJsonConvert ) {
293- this .testInfo .message = ' JsonConvert plugin is required'
294- }
295- }
296295 this .formState = SourceRequest .of ()
297296 }
298297 }
0 commit comments