Skip to content

Commit 5d3ac4d

Browse files
committed
修复切换语言时下拉框未更新
1 parent 942af98 commit 5d3ac4d

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/App.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<s-scroll-view>
1414
<VueDraggable
1515
v-model="graphData"
16-
:animation="300"
16+
:animation="200"
1717
handle=".datablock-drag"
18+
:key="draggerKey"
1819
>
1920
<DataBlock
2021
v-for="(dataItem, i) in graphData"
@@ -78,9 +79,9 @@
7879
:data="toOriginalDatum(graphData)"
7980
:width="graphWidth"
8081
:height="graphHeight"
81-
:key="key"
82+
:key="graphKey"
8283
@requireFullUpdate="fullUpdate"
83-
@requirePostUpdate="key++"
84+
@requirePostUpdate="graphKey++"
8485
v-model="fullUpdateState"
8586
/>
8687
</div>
@@ -91,15 +92,15 @@
9192

9293
<script setup lang="ts">
9394
import { useI18n } from "vue-i18n";
94-
const { t } = useI18n();
95+
const { t, locale } = useI18n();
9596
9697
import Navbar from "./components/nav.vue";
9798
import Graph from "./components/graph.vue";
9899
import DataBlock from "./components/dataBlock.vue";
99100
import CodeDisplay from "./components/codeDisplay.vue";
100101
import { VueDraggable } from "vue-draggable-plus";
101102
import type { FunctionPlotDatum } from "function-plot";
102-
import { onMounted, ref } from "vue";
103+
import { onMounted, ref, watch } from "vue";
103104
import JSON5 from "json5";
104105
import base64 from "base-64";
105106
import utf8 from "utf8";
@@ -113,7 +114,7 @@ const graphData = ref<InternalDatum[]>([
113114
const innerDrawer = ref<HTMLElementTagNameMap["s-drawer"]>();
114115
const graphWidth = ref(0),
115116
graphHeight = ref(0);
116-
const key = ref(0);
117+
const graphKey = ref(0);
117118
const fullUpdateState = ref(false);
118119
const sideRatio = ref(33);
119120
const onResize = ref(false);
@@ -131,7 +132,7 @@ onMounted(() => {
131132
132133
function fullUpdate() {
133134
fullUpdateState.value = true;
134-
key.value++;
135+
graphKey.value++;
135136
}
136137
137138
onMounted(() => {
@@ -186,6 +187,9 @@ function handleImport() {
186187
importStr.value = "";
187188
}
188189
}
190+
191+
const draggerKey = ref(0);
192+
watch(locale, () => draggerKey.value++);
189193
</script>
190194

191195
<style>

0 commit comments

Comments
 (0)