Skip to content

Commit 72e511a

Browse files
committed
refactor: update schemaFormInstance to use computed property
1 parent 7cd0922 commit 72e511a

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

packages/business/src/views/connections/DatabaseForm.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919
getProxyId,
2020
subscribeProxy,
2121
} from '@tap/api/src/core/proxy'
22-
2322
import resize from '@tap/component/src/directives/resize'
2423
import SchemaToForm from '@tap/form/src/SchemaToForm.vue'
24+
2525
import i18n from '@tap/i18n'
2626
import { checkConnectionName, submitForm, uuid } from '@tap/shared'
2727
import { isEmpty } from 'lodash-es'
@@ -123,7 +123,6 @@ export default {
123123
total: 0,
124124
},
125125
showAgentIpAlert: false,
126-
schemaFormInstance: null,
127126
}
128127
},
129128
computed: {
@@ -140,6 +139,12 @@ export default {
140139
: 'net'
141140
}/prerequisites/allow-access-network`
142141
},
142+
143+
schemaFormInstance: {
144+
get() {
145+
return this.$refs.schemaToForm?.form
146+
},
147+
},
143148
},
144149
async created() {
145150
if (!this.isDaas) {
@@ -160,8 +165,6 @@ export default {
160165
}
161166
},
162167
mounted() {
163-
// this.schemaFormInstance = markRaw(this.$refs.schemaToForm?.form) // 获取表单的 form
164-
this.schemaFormInstance = this.$refs.schemaToForm?.form // 获取表单的 form
165168
this.id = this.$route.params.id || ''
166169
const { fromPath } = this.$route.query
167170
if (fromPath) {
@@ -898,7 +901,7 @@ export default {
898901
properties: {
899902
heartbeatEnable: {
900903
type: 'boolean',
901-
default: true,
904+
default: false,
902905
'x-component': 'Switch',
903906
},
904907
},
@@ -1587,7 +1590,7 @@ export default {
15871590
},
15881591
15891592
getForm() {
1590-
return this.schemaFormInstance
1593+
return this.$refs.schemaToForm?.form
15911594
},
15921595
15931596
handleDebug() {

packages/form/src/SchemaToForm.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
setValidateLanguage,
66
} from '@formily/core'
77
import { getCurrentLanguage } from '@tap/i18n/src/shared/util'
8+
import { shallowRef } from 'vue'
89
import { Form } from './components'
910
import { SchemaField } from './shared'
1011
@@ -43,13 +44,15 @@ export default {
4344
},
4445
data() {
4546
return {
46-
form: createForm(
47-
this.value
48-
? {
49-
values: this.value,
50-
effects: this.useEffects,
51-
}
52-
: {},
47+
form: shallowRef(
48+
createForm(
49+
this.value
50+
? {
51+
values: this.value,
52+
effects: this.useEffects,
53+
}
54+
: {},
55+
),
5356
),
5457
objData: null,
5558
}

0 commit comments

Comments
 (0)