Skip to content

Commit b3a8705

Browse files
committed
优化切割线面板指示器逻辑
1 parent d67de16 commit b3a8705

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/editor/inputs/subblocks/derivatePane.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@
55
<div slot="text" class="tab-text">
66
{{ t("data.derivate.title") }}
77
<Transition name="badge">
8-
<s-badge class="tab-badge" v-if="derivateEnabled"></s-badge>
8+
<s-badge
9+
class="tab-badge"
10+
v-if="derivateEnabled"
11+
:class="{ error: derivateReady === undefined }"
12+
></s-badge>
913
</Transition>
1014
</div>
1115
</s-tab-item>
1216
<s-tab-item value="secant">
1317
<div slot="text" class="tab-text">
1418
{{ t("data.secant.title") }}
1519
<Transition name="badge">
16-
<s-badge class="tab-badge" v-if="secantEnabled"></s-badge>
20+
<s-badge
21+
class="tab-badge"
22+
v-if="secantEnabled"
23+
:class="{ error: secantReady.length === 0 }"
24+
></s-badge>
1725
</Transition>
1826
</div>
1927
</s-tab-item>
@@ -154,16 +162,17 @@ const derivFollowMouse = computed(
154162
const derivateX = ref<number | "">(initDerivate.x0 ?? "");
155163
const derivateReady = computed(
156164
(): undefined | PrivateDataTypes.LinearPart.Derivative => {
157-
if (!derivateEnabled.value) return undefined;
165+
if (!derivateEnabled.value || !derivateFn.value) return undefined;
158166
if (derivFollowMouse.value)
159167
return {
160168
fn: derivateFn.value,
161169
updateOnMouseMove: true,
162170
};
171+
if (derivateX.value === "") return undefined;
163172
return {
164173
fn: derivateFn.value,
165174
updateOnMouseMove: false,
166-
x0: derivateX.value || 0,
175+
x0: derivateX.value,
167176
};
168177
}
169178
);
@@ -227,6 +236,9 @@ watchEffect(() => {
227236
background-color: var(--s-color-success);
228237
color: var(--s-color-on-success);
229238
margin-left: 0.8em;
239+
&.error {
240+
background-color: var(--s-color-error);
241+
}
230242
}
231243
.badge {
232244
&-enter-active,

0 commit comments

Comments
 (0)