fix: 模型下载错误一直闪烁
This commit is contained in:
parent
a91739af65
commit
9a8d61fdaa
@ -67,6 +67,7 @@ import { MsgConfirm } from '@/utils/message'
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
model: Model
|
model: Model
|
||||||
provider_list: Array<Provider>
|
provider_list: Array<Provider>
|
||||||
|
updateModelById: (model_id: string, model: Model) => void
|
||||||
}>()
|
}>()
|
||||||
const downModel = ref<Model>()
|
const downModel = ref<Model>()
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ const errMessage = computed(() => {
|
|||||||
}
|
}
|
||||||
return currentModel.value.meta.message
|
return currentModel.value.meta.message
|
||||||
}
|
}
|
||||||
return ""
|
return ''
|
||||||
})
|
})
|
||||||
const progress = computed(() => {
|
const progress = computed(() => {
|
||||||
if (currentModel.value) {
|
if (currentModel.value) {
|
||||||
@ -93,10 +94,13 @@ const progress = computed(() => {
|
|||||||
if (down_model_chunk) {
|
if (down_model_chunk) {
|
||||||
const maxObj = down_model_chunk
|
const maxObj = down_model_chunk
|
||||||
.filter((chunk: any) => chunk.index > 1)
|
.filter((chunk: any) => chunk.index > 1)
|
||||||
.reduce((prev: any, current: any) => {
|
.reduce(
|
||||||
|
(prev: any, current: any) => {
|
||||||
return (prev.index || 0) > (current.index || 0) ? prev : current
|
return (prev.index || 0) > (current.index || 0) ? prev : current
|
||||||
},{progress:0})
|
},
|
||||||
if(maxObj){
|
{ progress: 0 }
|
||||||
|
)
|
||||||
|
if (maxObj) {
|
||||||
return parseFloat(maxObj.progress?.toFixed(1))
|
return parseFloat(maxObj.progress?.toFixed(1))
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
@ -105,7 +109,7 @@ const progress = computed(() => {
|
|||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['change'])
|
const emit = defineEmits(['change', 'update:model'])
|
||||||
const eidtModelRef = ref<InstanceType<typeof EditModel>>()
|
const eidtModelRef = ref<InstanceType<typeof EditModel>>()
|
||||||
let interval: any
|
let interval: any
|
||||||
const deleteModel = () => {
|
const deleteModel = () => {
|
||||||
@ -139,11 +143,15 @@ const initInterval = () => {
|
|||||||
ModelApi.getModelMetaById(props.model.id).then((ok) => {
|
ModelApi.getModelMetaById(props.model.id).then((ok) => {
|
||||||
downModel.value = ok.data
|
downModel.value = ok.data
|
||||||
})
|
})
|
||||||
}else{
|
} else {
|
||||||
downModel.value=undefined
|
if (downModel.value) {
|
||||||
|
props.updateModelById(props.model.id, downModel.value)
|
||||||
|
downModel.value = undefined
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 6000)
|
}, 6000)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭轮询
|
* 关闭轮询
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -49,7 +49,12 @@
|
|||||||
v-for="(model, i) in row"
|
v-for="(model, i) in row"
|
||||||
:key="i"
|
:key="i"
|
||||||
>
|
>
|
||||||
<ModelCard @change="list_model" :model="model" :provider_list="provider_list">
|
<ModelCard
|
||||||
|
@change="list_model"
|
||||||
|
:updateModelById="updateModelById"
|
||||||
|
:model="model"
|
||||||
|
:provider_list="provider_list"
|
||||||
|
>
|
||||||
</ModelCard>
|
</ModelCard>
|
||||||
</el-col>
|
</el-col>
|
||||||
</template>
|
</template>
|
||||||
@ -99,6 +104,13 @@ const provider_list = ref<Array<Provider>>([])
|
|||||||
|
|
||||||
const model_list = ref<Array<Model>>([])
|
const model_list = ref<Array<Model>>([])
|
||||||
|
|
||||||
|
const updateModelById = (model_id: string, model: Model) => {
|
||||||
|
model_list.value
|
||||||
|
.filter((m) => (m.id = model_id))
|
||||||
|
.forEach((m) => {
|
||||||
|
m.status = model.status
|
||||||
|
})
|
||||||
|
}
|
||||||
const model_split_list = computed(() => {
|
const model_split_list = computed(() => {
|
||||||
return splitArray(model_list.value, 2)
|
return splitArray(model_list.value, 2)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user