refactor: convert all SFCs to script setup
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user