refactor: convert all SFCs to script setup

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yunfei He
2026-05-24 22:39:11 +08:00
parent 9f9edcf991
commit 20b412ace1
4 changed files with 24 additions and 44 deletions
+6 -13
View File
@@ -1,21 +1,14 @@
<script lang="ts">
import { shallowRef, defineComponent } from "vue";
<script setup lang="ts">
import { shallowRef } from "vue";
import { Box, Text, useInput } from "@vue-tui/runtime";
import Counter from "./Counter.vue";
import Clock from "./Clock.vue";
export default defineComponent({
components: { Box, Text, Counter, Clock },
setup() {
const showClock = shallowRef(true);
const showClock = shallowRef(true);
useInput((input) => {
if (input === "c") showClock.value = !showClock.value;
if (input === "q") process.exit(0);
});
return { showClock };
},
useInput((input) => {
if (input === "c") showClock.value = !showClock.value;
if (input === "q") process.exit(0);
});
</script>
+11 -18
View File
@@ -1,25 +1,18 @@
<script lang="ts">
import { shallowRef, onMounted, onUnmounted, defineComponent } from "vue";
<script setup lang="ts">
import { shallowRef, onMounted, onUnmounted } from "vue";
import { Box, Text } from "@vue-tui/runtime";
export default defineComponent({
components: { Box, Text },
setup() {
const time = shallowRef(new Date().toLocaleTimeString());
let timer: ReturnType<typeof setInterval>;
const time = shallowRef(new Date().toLocaleTimeString());
let timer: ReturnType<typeof setInterval>;
onMounted(() => {
timer = setInterval(() => {
time.value = new Date().toLocaleTimeString();
}, 1000);
});
onMounted(() => {
timer = setInterval(() => {
time.value = new Date().toLocaleTimeString();
}, 1000);
});
onUnmounted(() => {
clearInterval(timer);
});
return { time };
},
onUnmounted(() => {
clearInterval(timer);
});
</script>
+6 -13
View File
@@ -1,19 +1,12 @@
<script lang="ts">
import { shallowRef, defineComponent } from "vue";
<script setup lang="ts">
import { shallowRef } from "vue";
import { Box, Text, useInput } from "@vue-tui/runtime";
export default defineComponent({
components: { Box, Text },
setup() {
const count = shallowRef(0);
const count = shallowRef(0);
useInput((input) => {
if (input === "+") count.value++;
if (input === "-") count.value--;
});
return { count };
},
useInput((input) => {
if (input === "+") count.value++;
if (input === "-") count.value--;
});
</script>