Skip to content

Commit 7f699c9

Browse files
authored
perf: 优化模型代码 (#461)
1 parent 69f5450 commit 7f699c9

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

ui/src/views/template/component/CreateModelDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ import type { FormField } from '@/components/dynamics-form/type'
134134
import DynamicsForm from '@/components/dynamics-form/index.vue'
135135
import type { FormRules } from 'element-plus'
136136
import { MsgSuccess } from '@/utils/message'
137-
import { QuestionFilled } from '@element-plus/icons-vue'
138137
139138
const providerValue = ref<Provider>()
140139
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
@@ -214,6 +213,7 @@ const list_base_model = (model_type: any) => {
214213
const close = () => {
215214
base_form_data.value = { name: '', model_type: '', model_name: '' }
216215
credential_form_data.value = {}
216+
model_form_field.value = []
217217
dialogVisible.value = false
218218
}
219219
const submit = () => {

ui/src/views/template/component/EditModel.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ import type { FormField } from '@/components/dynamics-form/type'
128128
import DynamicsForm from '@/components/dynamics-form/index.vue'
129129
import type { FormRules } from 'element-plus'
130130
import { MsgSuccess } from '@/utils/message'
131-
import { QuestionFilled } from '@element-plus/icons-vue'
132131
import AppIcon from '@/components/icons/AppIcon.vue'
133132
134133
const providerValue = ref<Provider>()
@@ -218,6 +217,7 @@ const close = () => {
218217
base_form_data.value = { name: '', model_type: '', model_name: '' }
219218
dynamicsFormRef.value?.ruleFormRef?.resetFields()
220219
credential_form_data.value = {}
220+
model_form_field.value = []
221221
dialogVisible.value = false
222222
}
223223

ui/src/views/template/index.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
ref="createModelRef"
7171
@submit="list_model"
7272
@change="openCreateModel($event)"
73-
:key="dialogState.createModelDialogKey"
7473
></CreateModelDialog>
7574

7675
<SelectProviderDialog
@@ -81,8 +80,7 @@
8180
</template>
8281

8382
<script lang="ts" setup>
84-
import { ElMessage } from 'element-plus'
85-
import { onMounted, ref, computed, reactive } from 'vue'
83+
import { onMounted, ref, computed } from 'vue'
8684
import ModelApi from '@/api/model'
8785
import type { Provider, Model } from '@/api/type/model'
8886
import AppIcon from '@/components/icons/AppIcon.vue'
@@ -129,7 +127,6 @@ const openCreateModel = (provider?: Provider) => {
129127
createModelRef.value?.open(provider)
130128
} else {
131129
selectProviderRef.value?.open()
132-
refreshCreateModelDialogKey() // 更新key
133130
}
134131
}
135132
@@ -140,16 +137,6 @@ const list_model = () => {
140137
})
141138
}
142139
143-
// 添加一个响应式的state来存储dialog的key
144-
const dialogState = reactive({
145-
createModelDialogKey: Date.now() // 初始值为当前的时间戳
146-
})
147-
148-
// 更新dialogState.createModelDialogKey的函数
149-
const refreshCreateModelDialogKey = () => {
150-
dialogState.createModelDialogKey = Date.now() // 更新为新的时间戳
151-
}
152-
153140
onMounted(() => {
154141
ModelApi.getProvider(loading).then((ok) => {
155142
active_provider.value = allObj

0 commit comments

Comments
 (0)