Update App.jsx via upload script - 2026-07-24 10:50:36

This commit is contained in:
mike 2026-07-24 10:51:01 +08:00
parent 22b4033253
commit e3121d945b
1 changed files with 12 additions and 2 deletions

14
App.jsx
View File

@ -3034,6 +3034,16 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage }
function updateOutputPort(t, patch) {
set({ outputPorts: (draft.outputPorts || []).map(p => (p.type === t ? { ...p, ...patch } : p)) });
}
// "5""5Vdc""2.4""2.4A"
// POE"24Vdc/48Vdc"
function normalizeOutputVoltageOnBlur(t, rawValue) {
const trimmed = (rawValue || '').trim();
if (/^\d+(\.\d+)?$/.test(trimmed)) updateOutputPort(t, { voltage: trimmed + 'Vdc' });
}
function normalizeOutputCurrentOnBlur(t, rawValue) {
const trimmed = (rawValue || '').trim();
if (/^\d+(\.\d+)?$/.test(trimmed)) updateOutputPort(t, { current: trimmed + 'A' });
}
return (
<div className="panel">
<div className="panel-header"><div className="panel-title"><Edit2 size={14} />{draft.name ? '编辑产品' : '新建产品'}</div></div>
@ -3173,8 +3183,8 @@ function ProductForm({ draft, setDraft, onSave, onCancel, categories, onManage }
{draft.outputPorts.map(p => (
<div key={p.type} style={{ display: 'flex', gap: 8, alignItems: 'center', marginBottom: 6 }}>
<div style={{ width: 90, fontSize: 12.5, fontWeight: 700, flexShrink: 0 }}>{p.type}</div>
<input className="input" style={{ flex: 1 }} placeholder="输出电压,如 5Vdc" value={p.voltage} onChange={e => updateOutputPort(p.type, { voltage: e.target.value })} />
<input className="input" style={{ flex: 1 }} placeholder="电流,如 3.0A" value={p.current} onChange={e => updateOutputPort(p.type, { current: e.target.value })} />
<input className="input" style={{ flex: 1 }} value={p.voltage} onChange={e => updateOutputPort(p.type, { voltage: e.target.value })} onBlur={e => normalizeOutputVoltageOnBlur(p.type, e.target.value)} />
<input className="input" style={{ flex: 1 }} value={p.current} onChange={e => updateOutputPort(p.type, { current: e.target.value })} onBlur={e => normalizeOutputCurrentOnBlur(p.type, e.target.value)} />
</div>
))}
</div>