Skip to content

Commit c206f62

Browse files
committed
部分选项触发强制刷新
1 parent 0efb42f commit c206f62

File tree

4 files changed

+58
-19
lines changed

4 files changed

+58
-19
lines changed

src/editor/annotationList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ const profile = useProfile();
3737
3838
import emitter from "@/mitt";
3939
const afterDragged = () =>
40-
emitter.emit("require-post-update", "annotations order change");
40+
emitter.emit("require-full-update", "annotations order change");
4141
</script>

src/editor/options.vue

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,65 @@
1111
></s-switch>
1212
</div>
1313
<div class="option">
14-
<span class="label">{{ t("inputs.caption") }}</span>
14+
<span class="label">{{ t("inputs.title") }}</span>
1515
<s-text-field
16-
:label="t('inputs.caption')"
16+
:label="t('inputs.title')"
1717
v-model="profile.options.title"
1818
></s-text-field>
1919
</div>
2020

2121
<s-divider>{{ t("title.horizontalAxis") }}</s-divider>
2222
<div class="option">
2323
<span class="label">{{ t("inputs.reverse") }}</span>
24-
<s-switch></s-switch>
24+
<s-switch
25+
v-model.lazy="profile.options.xAxis.invert"
26+
type="checkbox"
27+
></s-switch>
2528
</div>
2629
<div class="option">
2730
<span class="label">{{ t("inputs.grow") }}</span>
28-
<s-segmented-button>
29-
<s-segmented-button-item value="y">{{
31+
<s-segmented-button v-model.lazy="profile.options.xAxis.type">
32+
<s-segmented-button-item value="linear">{{
3033
t("inputs.linear")
3134
}}</s-segmented-button-item>
32-
<s-segmented-button-item value="x">
35+
<s-segmented-button-item value="log">
3336
{{ t("inputs.log") }}
3437
</s-segmented-button-item>
3538
</s-segmented-button>
3639
</div>
3740
<div class="option">
3841
<span class="label">{{ t("inputs.caption") }}</span>
39-
<s-text-field :label="t('inputs.caption')"></s-text-field>
42+
<s-text-field
43+
:label="t('inputs.caption')"
44+
v-model="profile.options.xAxis.label"
45+
></s-text-field>
4046
</div>
4147

4248
<s-divider>{{ t("title.verticalAxis") }}</s-divider>
4349
<div class="option">
4450
<span class="label">{{ t("inputs.reverse") }}</span>
45-
<s-switch></s-switch>
51+
<s-switch
52+
v-model.lazy="profile.options.yAxis.invert"
53+
type="checkbox"
54+
></s-switch>
4655
</div>
4756
<div class="option">
4857
<span class="label">{{ t("inputs.grow") }}</span>
49-
<s-segmented-button>
50-
<s-segmented-button-item value="y">{{
58+
<s-segmented-button v-model.lazy="profile.options.yAxis.type">
59+
<s-segmented-button-item value="linear">{{
5160
t("inputs.linear")
5261
}}</s-segmented-button-item>
53-
<s-segmented-button-item value="x">
62+
<s-segmented-button-item value="log">
5463
{{ t("inputs.log") }}
5564
</s-segmented-button-item>
5665
</s-segmented-button>
5766
</div>
5867
<div class="option">
5968
<span class="label">{{ t("inputs.caption") }}</span>
60-
<s-text-field :label="t('inputs.caption')"></s-text-field>
69+
<s-text-field
70+
:label="t('inputs.caption')"
71+
v-model="profile.options.yAxis.label"
72+
></s-text-field>
6173
</div>
6274
</div>
6375
</s-scroll-view>
@@ -69,6 +81,20 @@ const { t } = useI18n();
6981
7082
import { useProfile } from "@/states";
7183
const profile = useProfile();
84+
85+
import { watch } from "vue";
86+
import emitter from "@/mitt";
87+
watch(
88+
[
89+
() => profile.options.xAxis.type,
90+
() => profile.options.yAxis.type,
91+
() => profile.options.xAxis.invert,
92+
() => profile.options.yAxis.invert,
93+
],
94+
() => {
95+
emitter.emit("require-full-update", "axis type change");
96+
}
97+
);
7298
</script>
7399

74100
<style>
@@ -84,8 +110,15 @@ const profile = useProfile();
84110
}
85111
.option {
86112
display: flex;
113+
flex-wrap: wrap;
87114
align-items: center;
88115
justify-content: space-between;
89116
margin: 0 30px;
90117
}
118+
.option span{
119+
line-height: 2em;
120+
}
121+
.option s-text-field {
122+
max-width: 100%;
123+
}
91124
</style>

src/graph/graph.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function findError(graphData: FunctionPlotDatum[]) {
5555
}
5656
5757
let unwatchHandler: WatchHandle | null = null;
58-
58+
const emit = defineEmits(["require-post-update"]);
5959
onMounted(async () => {
6060
const functionPlot = (await import("function-plot")).default;
6161
const handleUpdate = throttle(() => {
@@ -78,7 +78,7 @@ onMounted(async () => {
7878
});
7979
if (fullUpdateState.value) {
8080
fullUpdateState.value = false;
81-
emitter.emit("require-post-update", "once after error");
81+
emit("require-post-update", "once after error");
8282
} else errorMsg.value = undefined;
8383
} catch (e) {
8484
// console.log(e);
@@ -152,8 +152,13 @@ s-page.dark #graphRender {
152152
font-size: 18px;
153153
font-family: var(--font-mono);
154154
}
155-
.annotations,
156-
.fn-text {
155+
#graphRender .annotations,
156+
#graphRender .fn-text,
157+
#graphRender .axis-label {
157158
font-size: 20px;
158159
}
160+
161+
#graphRender .title {
162+
font-weight: bold;
163+
}
159164
</style>

src/graph/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:height="graphHeight"
66
:key="graphKey"
77
v-model="fullUpdateState"
8+
@require-post-update="handlePostUpdate"
89
/>
910
</div>
1011
</template>
@@ -38,10 +39,10 @@ emitter.on("require-full-update", (str) => {
3839
if (import.meta.env.DEV)
3940
console.log(`fullUpdateState: ${fullUpdateState.value}, ${str}`);
4041
});
41-
emitter.on("require-post-update", (str) => {
42+
const handlePostUpdate = (str: string) => {
4243
fullUpdateState.value = false;
4344
graphKey.value++;
4445
if (import.meta.env.DEV)
4546
console.log(`postUpdateState: ${fullUpdateState.value}, ${str}`);
46-
});
47+
};
4748
</script>

0 commit comments

Comments
 (0)