Skip to content

Commit f4f6d84

Browse files
committed
标线动画问题修复
1 parent afd78d0 commit f4f6d84

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

src/consts.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import type {
2-
FunctionPlotAnnotation,
3-
FunctionPlotDatum,
4-
} from "function-plot";
1+
import type { FunctionPlotAnnotation, FunctionPlotDatum } from "function-plot";
52
import { cloneDeep } from "lodash-es";
63

74
export type ValueLabel = { value: string; label: string; default?: boolean };
@@ -399,6 +396,7 @@ export type InternalAnnotation = {
399396
axis: "x" | "y";
400397
value: string;
401398
text: string;
399+
key: number;
402400
};
403401

404402
export function toOriginalAnnotation(items: InternalAnnotation[]) {
@@ -419,6 +417,7 @@ export function toInternalAnnotation(items: FunctionPlotAnnotation[]) {
419417
axis,
420418
value,
421419
text: item.text ?? "",
420+
key: Math.random(),
422421
});
423422
});
424423
return cloned;

src/editor/annotation.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
{{ t("annotation.vertical") }}
99
</s-segmented-button-item>
1010
</s-segmented-button>
11+
12+
<s-tooltip>
13+
<s-icon-button
14+
slot="trigger"
15+
@click="deleteAnnotation"
16+
style="color: var(--s-color-error)"
17+
>
18+
<SIconDelete />
19+
</s-icon-button>
20+
{{ t("buttons.del") }}
21+
</s-tooltip>
22+
1123
<s-text-field
1224
class="styled"
1325
type="number"
@@ -35,4 +47,11 @@ import { watch } from "vue";
3547
watch([() => props.annotation.axis, () => props.annotation.text], () =>
3648
emitter.emit("require-post-update", "anntaions axis change")
3749
);
50+
51+
import SIconDelete from "@/ui/icons/delete.vue";
52+
import { useProfile } from "@/states";
53+
const profile = useProfile();
54+
function deleteAnnotation() {
55+
profile.annotations.splice(props.index, 1);
56+
}
3857
</script>

src/editor/annotationList.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
<template>
22
<s-scroll-view>
33
<AnimatedList>
4-
<AnimatedListItem v-for="(item, index) in profile.annotations">
5-
<Annotation :index="index" :annotation="item" class="datumFolder" />
4+
<AnimatedListItem
5+
v-for="(item, index) in profile.annotations"
6+
:key="item.key"
7+
>
8+
<Annotation
9+
:index="index"
10+
:annotation="item"
11+
class="datumFolder"
12+
:key="item.key"
13+
/>
614
</AnimatedListItem>
715
</AnimatedList>
816
<div class="plot-data add-data" @click="profile.addAnnotation">

src/states.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const useProfile = defineStore("profile", () => {
4848
axis: "y",
4949
value: "0",
5050
text: "",
51+
key: Math.random(),
5152
});
5253

5354
return {

0 commit comments

Comments
 (0)