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 = {
|
||||
application: "",
|
||||
category: "全部舵机",
|
||||
@@ -183,8 +189,7 @@ function getMatches(requirements: Requirements) {
|
||||
const categoryOk =
|
||||
requirements.category === "全部舵机" || requirements.category === product.category;
|
||||
const torqueOk = product.torque >= requirements.torque;
|
||||
const voltageOk =
|
||||
requirements.voltage >= product.voltageMin && requirements.voltage <= product.voltageMax;
|
||||
const voltageOk = requirements.voltage === product.ratedVoltage;
|
||||
const weightOk =
|
||||
requirements.weightLimit === 0 || product.weight === null || product.weight <= requirements.weightLimit;
|
||||
const gearOk = requirements.gear === "不限" || requirements.gear === product.gear;
|
||||
@@ -211,7 +216,7 @@ function getMatches(requirements: Requirements) {
|
||||
|
||||
if (voltageOk) {
|
||||
score += 22;
|
||||
reasons.push(`${requirements.voltage}V供电兼容`);
|
||||
reasons.push(`${requirements.voltage}V额定电压匹配`);
|
||||
} else {
|
||||
score -= 90;
|
||||
}
|
||||
@@ -413,7 +418,7 @@ export default function Home() {
|
||||
<div className="question-step">
|
||||
<p className="step-kicker">第二步 · 核心参数</p>
|
||||
<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">
|
||||
<label className="select-field">
|
||||
<span>目标产品系列</span>
|
||||
@@ -430,22 +435,15 @@ export default function Home() {
|
||||
</select>
|
||||
</label>
|
||||
<label className="select-field">
|
||||
<span>系统工作电压(0.8–30V)</span>
|
||||
<input
|
||||
className="parameter-input"
|
||||
type="number"
|
||||
min="0.8"
|
||||
max="30"
|
||||
step="0.1"
|
||||
list="voltage-values"
|
||||
<span>额定电压</span>
|
||||
<select
|
||||
value={requirements.voltage}
|
||||
onChange={(event) => update("voltage", Number(event.target.value))}
|
||||
/>
|
||||
<datalist id="voltage-values">
|
||||
{[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} />
|
||||
>
|
||||
{RATED_VOLTAGES.map((voltage) => (
|
||||
<option key={voltage} value={voltage}>{voltage.toFixed(1)}V</option>
|
||||
))}
|
||||
</datalist>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<div className="field-stack">
|
||||
@@ -650,7 +648,7 @@ export default function Home() {
|
||||
<p className="product-subtitle">{top.product.category} · {top.product.size || "尺寸待复核"}</p>
|
||||
<div className="metric-grid">
|
||||
<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.angle || "目录未标注"} />
|
||||
<Metric label="控制 / 通讯" value={top.product.control || "目录未标注"} />
|
||||
|
||||
Reference in New Issue
Block a user