<el-select v-model="threadsType"…
- User
<el-select v-model="threadsType" :placeholder="$t('set.configuration.advanced.threads.select')" @change="changeThreadsType" >
code<div v-if="threadsType === 2"> <el-input v-model.number="threadscount" type="number" style="padding-top: 5px;" :min="1" :max="8" :placeholder="$t('set.configuration.advanced.threads.placeholder')" @keydown.enter.prevent="" @change="validateThreadCount" /> </div>threadscount = 0 threadsType = 0
processCpuCounts(callback: Function) { this.cpuCounts.forEach(set => { const cpuCount = set?.eastUnit?.cpuCount || 0 callback(cpuCount) }) }
updateThreadsCount(type: number) { this.processCpuCounts((cpuCount: number) => { for (const idx in this.pairsForm) { let updatedCount = this.pairsForm[idx].threads.threadscount
codeif (type === 0) { // auto updatedCount = this.calculateAutoThreads(cpuCount) } else if (type === 1) { // max updatedCount = this.calculateMaxThreads(cpuCount) } else if (type === 2) { // num updatedCount = Math.min(this.threadscount, cpuCount) } this.pairsForm[idx].threads.threadscount = updatedCount this.threadscount = updatedCount } })}
changeThreadsType() { this.updateThreadsCount(this.threadsType) }
при threadsType = 0, то всегда вызываем calculateAutoThreads
- Assistant
In the given code, you have a
Vuecomponent that manages thread settings based on a selectedthreadsType. The component usesel-selectfor choosing thethreadsType, and for specifying the when needed. Let's break down the important parts of the logic, especially focusing on what happens when is set to 0: - User
<el-select v-model="threadsType" :placeholder="$t('set.configuration.advanced.threads.select')" @change="changeThreadsType"
code<div v-if="threadsType === 2"> <el-input v-model.number="threadscount" type="number" style="padding-top: 5px;" :min="1" :max="8" :placeholder="$t('set.configuration.advanced.threads.placeholder')" @keydown.enter.prevent="" @change="validateThreadCount" /> </div>threadscount = 0 threadsType = 0
processCpuCounts(callback: Function) { this.cpuCounts.forEach(set => { const cpuCount = set?.eastUnit?.cpuCount || 0 callback(cpuCount) }) }
updateThreadsCount(type: number) { this.processCpuCounts((cpuCount: number) => { for (const idx in this.pairsForm) { let updatedCount = this.pairsForm[idx].threads.threadscount
- Assistant