Use rated voltage options in selector
This commit is contained in:
34
app/page.tsx
34
app/page.tsx
@@ -160,6 +160,12 @@ const SELECTOR_PRODUCTS = CATALOG_PRODUCTS.filter((product) =>
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const RATED_VOLTAGES = [...new Set(
|
||||||
|
SELECTOR_PRODUCTS
|
||||||
|
.map((product) => product.ratedVoltage)
|
||||||
|
.filter((voltage): voltage is number => voltage !== null),
|
||||||
|
)].sort((a, b) => a - b);
|
||||||
|
|
||||||
const DEFAULT_REQUIREMENTS: Requirements = {
|
const DEFAULT_REQUIREMENTS: Requirements = {
|
||||||
application: "",
|
application: "",
|
||||||
category: "全部舵机",
|
category: "全部舵机",
|
||||||
@@ -183,8 +189,7 @@ function getMatches(requirements: Requirements) {
|
|||||||
const categoryOk =
|
const categoryOk =
|
||||||
requirements.category === "全部舵机" || requirements.category === product.category;
|
requirements.category === "全部舵机" || requirements.category === product.category;
|
||||||
const torqueOk = product.torque >= requirements.torque;
|
const torqueOk = product.torque >= requirements.torque;
|
||||||
const voltageOk =
|
const voltageOk = requirements.voltage === product.ratedVoltage;
|
||||||
requirements.voltage >= product.voltageMin && requirements.voltage <= product.voltageMax;
|
|
||||||
const weightOk =
|
const weightOk =
|
||||||
requirements.weightLimit === 0 || product.weight === null || product.weight <= requirements.weightLimit;
|
requirements.weightLimit === 0 || product.weight === null || product.weight <= requirements.weightLimit;
|
||||||
const gearOk = requirements.gear === "不限" || requirements.gear === product.gear;
|
const gearOk = requirements.gear === "不限" || requirements.gear === product.gear;
|
||||||
@@ -211,7 +216,7 @@ function getMatches(requirements: Requirements) {
|
|||||||
|
|
||||||
if (voltageOk) {
|
if (voltageOk) {
|
||||||
score += 22;
|
score += 22;
|
||||||
reasons.push(`${requirements.voltage}V供电兼容`);
|
reasons.push(`${requirements.voltage}V额定电压匹配`);
|
||||||
} else {
|
} else {
|
||||||
score -= 90;
|
score -= 90;
|
||||||
}
|
}
|
||||||
@@ -413,7 +418,7 @@ export default function Home() {
|
|||||||
<div className="question-step">
|
<div className="question-step">
|
||||||
<p className="step-kicker">第二步 · 核心参数</p>
|
<p className="step-kicker">第二步 · 核心参数</p>
|
||||||
<h2>输入舵机的关键技术要求</h2>
|
<h2>输入舵机的关键技术要求</h2>
|
||||||
<p className="step-help">已覆盖243款舵机:0.09–920 kgf·cm、0.8–30V;不确定的项目可选“不限”。</p>
|
<p className="step-help">已覆盖243款舵机:0.09–920 kgf·cm,并按官方目录额定电压精确筛选。</p>
|
||||||
<div className="two-fields compact-fields">
|
<div className="two-fields compact-fields">
|
||||||
<label className="select-field">
|
<label className="select-field">
|
||||||
<span>目标产品系列</span>
|
<span>目标产品系列</span>
|
||||||
@@ -430,22 +435,15 @@ export default function Home() {
|
|||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
<label className="select-field">
|
<label className="select-field">
|
||||||
<span>系统工作电压(0.8–30V)</span>
|
<span>额定电压</span>
|
||||||
<input
|
<select
|
||||||
className="parameter-input"
|
|
||||||
type="number"
|
|
||||||
min="0.8"
|
|
||||||
max="30"
|
|
||||||
step="0.1"
|
|
||||||
list="voltage-values"
|
|
||||||
value={requirements.voltage}
|
value={requirements.voltage}
|
||||||
onChange={(event) => update("voltage", Number(event.target.value))}
|
onChange={(event) => update("voltage", Number(event.target.value))}
|
||||||
/>
|
>
|
||||||
<datalist id="voltage-values">
|
{RATED_VOLTAGES.map((voltage) => (
|
||||||
{[1.2, 2.7, 3.7, 4.2, 5, 6, 7.4, 8.4, 9, 12, 16.8, 24, 28, 30].map((voltage) => (
|
<option key={voltage} value={voltage}>{voltage.toFixed(1)}V</option>
|
||||||
<option key={voltage} value={voltage} />
|
|
||||||
))}
|
))}
|
||||||
</datalist>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="field-stack">
|
<div className="field-stack">
|
||||||
@@ -650,7 +648,7 @@ export default function Home() {
|
|||||||
<p className="product-subtitle">{top.product.category} · {top.product.size || "尺寸待复核"}</p>
|
<p className="product-subtitle">{top.product.category} · {top.product.size || "尺寸待复核"}</p>
|
||||||
<div className="metric-grid">
|
<div className="metric-grid">
|
||||||
<Metric label="堵转扭矩" value={`${formatTorque(top.product.torque)} kgf·cm`} />
|
<Metric label="堵转扭矩" value={`${formatTorque(top.product.torque)} kgf·cm`} />
|
||||||
<Metric label="工作电压" value={`${top.product.voltageMin}–${top.product.voltageMax}V`} />
|
<Metric label="电压范围" value={`${top.product.voltageMin}–${top.product.voltageMax}V`} />
|
||||||
<Metric label="空载速度" value={top.product.speed || "目录未标注"} />
|
<Metric label="空载速度" value={top.product.speed || "目录未标注"} />
|
||||||
<Metric label="操作角度" value={top.product.angle || "目录未标注"} />
|
<Metric label="操作角度" value={top.product.angle || "目录未标注"} />
|
||||||
<Metric label="控制 / 通讯" value={top.product.control || "目录未标注"} />
|
<Metric label="控制 / 通讯" value={top.product.control || "目录未标注"} />
|
||||||
|
|||||||
Reference in New Issue
Block a user