perf: 优化模型代码 (#461)
This commit is contained in:
parent
69f5450db2
commit
7f699c9c90
@ -134,7 +134,6 @@ import type { FormField } from '@/components/dynamics-form/type'
|
|||||||
import DynamicsForm from '@/components/dynamics-form/index.vue'
|
import DynamicsForm from '@/components/dynamics-form/index.vue'
|
||||||
import type { FormRules } from 'element-plus'
|
import type { FormRules } from 'element-plus'
|
||||||
import { MsgSuccess } from '@/utils/message'
|
import { MsgSuccess } from '@/utils/message'
|
||||||
import { QuestionFilled } from '@element-plus/icons-vue'
|
|
||||||
|
|
||||||
const providerValue = ref<Provider>()
|
const providerValue = ref<Provider>()
|
||||||
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
|
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
|
||||||
@ -214,6 +213,7 @@ const list_base_model = (model_type: any) => {
|
|||||||
const close = () => {
|
const close = () => {
|
||||||
base_form_data.value = { name: '', model_type: '', model_name: '' }
|
base_form_data.value = { name: '', model_type: '', model_name: '' }
|
||||||
credential_form_data.value = {}
|
credential_form_data.value = {}
|
||||||
|
model_form_field.value = []
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
|
|||||||
@ -128,7 +128,6 @@ import type { FormField } from '@/components/dynamics-form/type'
|
|||||||
import DynamicsForm from '@/components/dynamics-form/index.vue'
|
import DynamicsForm from '@/components/dynamics-form/index.vue'
|
||||||
import type { FormRules } from 'element-plus'
|
import type { FormRules } from 'element-plus'
|
||||||
import { MsgSuccess } from '@/utils/message'
|
import { MsgSuccess } from '@/utils/message'
|
||||||
import { QuestionFilled } from '@element-plus/icons-vue'
|
|
||||||
import AppIcon from '@/components/icons/AppIcon.vue'
|
import AppIcon from '@/components/icons/AppIcon.vue'
|
||||||
|
|
||||||
const providerValue = ref<Provider>()
|
const providerValue = ref<Provider>()
|
||||||
@ -218,6 +217,7 @@ const close = () => {
|
|||||||
base_form_data.value = { name: '', model_type: '', model_name: '' }
|
base_form_data.value = { name: '', model_type: '', model_name: '' }
|
||||||
dynamicsFormRef.value?.ruleFormRef?.resetFields()
|
dynamicsFormRef.value?.ruleFormRef?.resetFields()
|
||||||
credential_form_data.value = {}
|
credential_form_data.value = {}
|
||||||
|
model_form_field.value = []
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,6 @@
|
|||||||
ref="createModelRef"
|
ref="createModelRef"
|
||||||
@submit="list_model"
|
@submit="list_model"
|
||||||
@change="openCreateModel($event)"
|
@change="openCreateModel($event)"
|
||||||
:key="dialogState.createModelDialogKey"
|
|
||||||
></CreateModelDialog>
|
></CreateModelDialog>
|
||||||
|
|
||||||
<SelectProviderDialog
|
<SelectProviderDialog
|
||||||
@ -81,8 +80,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ElMessage } from 'element-plus'
|
import { onMounted, ref, computed } from 'vue'
|
||||||
import { onMounted, ref, computed, reactive } from 'vue'
|
|
||||||
import ModelApi from '@/api/model'
|
import ModelApi from '@/api/model'
|
||||||
import type { Provider, Model } from '@/api/type/model'
|
import type { Provider, Model } from '@/api/type/model'
|
||||||
import AppIcon from '@/components/icons/AppIcon.vue'
|
import AppIcon from '@/components/icons/AppIcon.vue'
|
||||||
@ -129,7 +127,6 @@ const openCreateModel = (provider?: Provider) => {
|
|||||||
createModelRef.value?.open(provider)
|
createModelRef.value?.open(provider)
|
||||||
} else {
|
} else {
|
||||||
selectProviderRef.value?.open()
|
selectProviderRef.value?.open()
|
||||||
refreshCreateModelDialogKey() // 更新key
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,16 +137,6 @@ const list_model = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加一个响应式的state来存储dialog的key
|
|
||||||
const dialogState = reactive({
|
|
||||||
createModelDialogKey: Date.now() // 初始值为当前的时间戳
|
|
||||||
})
|
|
||||||
|
|
||||||
// 更新dialogState.createModelDialogKey的函数
|
|
||||||
const refreshCreateModelDialogKey = () => {
|
|
||||||
dialogState.createModelDialogKey = Date.now() // 更新为新的时间戳
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
ModelApi.getProvider(loading).then((ok) => {
|
ModelApi.getProvider(loading).then((ok) => {
|
||||||
active_provider.value = allObj
|
active_provider.value = allObj
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user