This commit is contained in:
feie9456 2025-09-13 09:54:54 +08:00
parent bf7f5ec32e
commit 2d08c9f2d0
2 changed files with 55 additions and 51 deletions

View File

@ -1073,7 +1073,8 @@ function editTextBox(inst: Instance) {
:class="{ selected: selectedId === inst.id }"
:style="{ left: inst.x + 'px', top: inst.y + 'px', transform: 'translate(-50%, -50%) rotate(' + (inst.rotation || 0) + 'deg)' }"
@pointerdown="(e) => onInstanceMouseDown(e, inst)"
@click.stop="() => selectInstance(inst.id)" :title="(elements.find(e => e.key === inst.key)?.name || inst.key)">
@click.stop="() => selectInstance(inst.id)"
:title="(elements.find(e => e.key === inst.key)?.name || inst.key)">
<div class="inst-box"
:style="{ width: inst.size > 0 ? inst.size + 'px' : 'auto', height: inst.size > 0 ? inst.size + 'px' : 'auto' }">
<img v-if="inst.key !== 'text_box'" :src="(elements.find(e => e.key === inst.key)?.stateImages
@ -1093,13 +1094,10 @@ function editTextBox(inst: Instance) {
}" />
<!-- 文本框渲染层不参与电路仅显示可编辑文本 -->
<div v-if="inst.key === 'text_box'" class="text-box"
:style="{
<div v-if="inst.key === 'text_box'" class="text-box" :style="{
fontSize: (Number(inst.props?.['fontSize'] ?? 24)) + 'px',
color: String(inst.props?.['color'] ?? '#111827'),
}"
@dblclick.stop="editTextBox(inst)"
title="双击编辑文本">
}" @dblclick.stop="editTextBox(inst)" title="双击编辑文本">
{{ String(inst.props?.['text'] ?? '') }}
</div>
@ -1185,7 +1183,9 @@ function editTextBox(inst: Instance) {
<div class="panel-inner">
<div class="prop-title">{{ selectedInst.key }} 属性</div>
<!-- 预设按钮区域显示当前元件的预设点击一键应用当未隐藏属性时 -->
<div v-if="selectedMeta?.preset?.length && String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'" class="presets">
<div
v-if="selectedMeta?.preset?.length && String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'"
class="presets">
<span class="preset-label">预设</span>
<button v-for="p in selectedMeta!.preset" :key="p.name"
class="preset-btn" @click.stop="applyPreset(p)">{{
@ -1194,18 +1194,21 @@ function editTextBox(inst: Instance) {
</div>
<div class="props">
<!-- 实时电学量在隐藏属性=on时不显示 -->
<label class="prop-row" v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'">
<label class="prop-row"
v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'">
<span class="label">电压</span>
<span>{{ formatValue(instLive[selectedInst!.id]?.v ?? null, 'V')
}}</span>
</label>
<label class="prop-row" v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'">
<label class="prop-row"
v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'">
<span class="label">电流</span>
<span>{{ formatValue(instLive[selectedInst!.id]?.i ?? null, 'A')
}}</span>
</label>
<!-- 旋转控制在隐藏属性=on时不显示 -->
<label class="prop-row" v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'">
<label class="prop-row"
v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'">
<span class="label">旋转</span>
<input type="range" min="-180" max="180" step="1"
v-model.number="selectedInst!.rotation" />
@ -1226,7 +1229,8 @@ function editTextBox(inst: Instance) {
</select>
</label>
<!-- 业务属性编辑当未隐藏属性时显示 -->
<template v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'"
<template
v-if="String(selectedInst!.props['hideProps'] ?? 'off') !== 'on'"
v-for="schema in (elements.find(e => e.key === selectedInst!.key)?.propertySchemas || [])"
:key="schema.key">
<label class="prop-row" v-if="schema.key !== 'hideProps'">

View File

@ -150,10 +150,10 @@ export const elements: CircuitElement[] = [
pinUrl: slidingRheostatPin,
defaultSize: 180,
connectionPoints: [
{ x: 0.15, y: 0.28, name: '部左侧' },
{ x: 0.85, y: 0.28, name: '部右侧' },
{ x: 0.15, y: 0.76, name: '部左侧' },
{ x: 0.85, y: 0.76, name: '部右侧' },
{ x: 0.15, y: 0.28, name: '部左侧' },
{ x: 0.85, y: 0.28, name: '部右侧' },
{ x: 0.15, y: 0.76, name: '部左侧' },
{ x: 0.85, y: 0.76, name: '部右侧' },
],
propertySchemas: [
{ key: 'maxResistance', label: '最大电阻', type: 'number', unit: 'Ω', default: 100 },