Skip to content

Commit cbbb7d3

Browse files
committed
fix: update json view rendering in JsProcessor component TAP-6812
- Replaced the inline jsonView definition with a function to enhance readability and maintainability. - Commented out unused tab change logic for clarity. - Ensured jsonView is called as a function in the render method for proper rendering.
1 parent 73acfc4 commit cbbb7d3

File tree

1 file changed

+53
-54
lines changed
  • packages/dag/src/components/form/js-processor

1 file changed

+53
-54
lines changed

packages/dag/src/components/form/js-processor/index.jsx

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,14 @@ export const JsProcessor = observer(
305305
loadFunction()
306306

307307
const onTabChange = (current) => {
308-
if (current == '1') {
309-
beforeJsonRef.value.editor.resize(true)
310-
afterJsonRef.value.editor.resize(true)
311-
312-
setTimeout(() => {
313-
beforeJsonRef.value.editor.resize(true)
314-
afterJsonRef.value.editor.resize(true)
315-
}, 300)
316-
}
308+
// if (current == '1') {
309+
// beforeJsonRef.value.editor.resize(true)
310+
// afterJsonRef.value.editor.resize(true)
311+
// setTimeout(() => {
312+
// beforeJsonRef.value.editor.resize(true)
313+
// afterJsonRef.value.editor.resize(true)
314+
// }, 300)
315+
// }
317316
}
318317

319318
function getPrefix(line, index) {
@@ -455,6 +454,49 @@ export const JsProcessor = observer(
455454
</div>
456455
)
457456

457+
const jsonView = () => (
458+
<div
459+
class="flex json-view-wrap"
460+
v-loading={running.value}
461+
element-loading-text={runningText.value}
462+
>
463+
<div class="json-view flex-1 mr-4 border rounded-2 overflow-hidden">
464+
<div class="json-view-header">
465+
{i18n.t('packages_form_js_processor_index_tiaoshishuru')}
466+
</div>
467+
<VCodeEditor
468+
ref={beforeJsonRef}
469+
class="py-0 json-view-editor flex-1"
470+
value={inputRef.value}
471+
lang="json"
472+
options={{
473+
readOnly: true,
474+
highlightActiveLine: false,
475+
highlightGutterLine: false,
476+
}}
477+
theme="chrome"
478+
></VCodeEditor>
479+
</div>
480+
<div class="json-view flex-1 border rounded-2 overflow-hidden">
481+
<div class="json-view-header">
482+
{i18n.t('packages_form_js_processor_index_jieguoshuchu')}
483+
</div>
484+
<VCodeEditor
485+
ref={afterJsonRef}
486+
class="py-0 json-view-editor flex-1"
487+
value={outputRef.value}
488+
lang="json"
489+
options={{
490+
readOnly: true,
491+
highlightActiveLine: false,
492+
highlightGutterLine: false,
493+
}}
494+
theme="chrome"
495+
></VCodeEditor>
496+
</div>
497+
</div>
498+
)
499+
458500
return () => {
459501
const editorProps = { ...attrs }
460502
editorProps.options.readOnly = props.disabled
@@ -490,49 +532,6 @@ export const JsProcessor = observer(
490532
</div>
491533
)
492534

493-
const jsonView = (
494-
<div
495-
class="flex json-view-wrap"
496-
v-loading={running.value}
497-
element-loading-text={runningText.value}
498-
>
499-
<div class="json-view flex-1 mr-4 border rounded-2 overflow-hidden">
500-
<div class="json-view-header">
501-
{i18n.t('packages_form_js_processor_index_tiaoshishuru')}
502-
</div>
503-
<VCodeEditor
504-
ref={beforeJsonRef}
505-
class="py-0 json-view-editor flex-1"
506-
value={inputRef.value}
507-
lang="json"
508-
options={{
509-
readOnly: true,
510-
highlightActiveLine: false,
511-
highlightGutterLine: false,
512-
}}
513-
theme="chrome"
514-
></VCodeEditor>
515-
</div>
516-
<div class="json-view flex-1 border rounded-2 overflow-hidden">
517-
<div class="json-view-header">
518-
{i18n.t('packages_form_js_processor_index_jieguoshuchu')}
519-
</div>
520-
<VCodeEditor
521-
ref={afterJsonRef}
522-
class="py-0 json-view-editor flex-1"
523-
value={outputRef.value}
524-
lang="json"
525-
options={{
526-
readOnly: true,
527-
highlightActiveLine: false,
528-
highlightGutterLine: false,
529-
}}
530-
theme="chrome"
531-
></VCodeEditor>
532-
</div>
533-
</div>
534-
)
535-
536535
return (
537536
<div class="js-processor font-color-light">
538537
<ElDrawer
@@ -690,7 +689,7 @@ export const JsProcessor = observer(
690689
display: fullscreen.value ? 'contents' : 'none',
691690
}}
692691
>
693-
{jsonView}
692+
{jsonView()}
694693
</div>
695694
</ElTabPane>
696695
</ElTabs>
@@ -713,7 +712,7 @@ export const JsProcessor = observer(
713712
{renderTool()}
714713
</div>
715714
{showJsonArea.value && (
716-
<div class="mt-4 json-view-area">{jsonView}</div>
715+
<div class="mt-4 json-view-area">{jsonView()}</div>
717716
)}
718717
</div>
719718
</div>

0 commit comments

Comments
 (0)