This commit is contained in:
2024-01-24 12:05:58 +08:00
parent 98fd6081a0
commit e1c01fdf21

View File

@@ -1,21 +1,42 @@
<script lang="ts" setup>
import { insertText } from "../composables/helper"
import { code } from "../composables/code"
import { computed } from "vue"
function insert(text: string) {
insertText.value = text
}
const texts = computed(() => {
if (code.language === "c") return [",", ";", "printf();", "{\n}", "int", "%d"]
else
return [
":",
"=",
"==",
"print()",
"input()",
"if",
"else",
"elif",
"for",
"in",
"range",
"while",
]
})
</script>
<template>
<n-flex align="center" class="container">
<n-flex align="center" class="container" wrap>
<span>编程助手</span>
<n-button size="small" @click="insert(':')">:</n-button>
<n-button size="small" @click="insert('=')">=</n-button>
<n-button size="small" @click="insert('print')">print</n-button>
<n-button size="small" @click="insert('input')">input</n-button>
<n-button v-for="it in texts" :key="it" size="small" @click="insert(it)">
{{ it }}
</n-button>
</n-flex>
</template>
<style scoped>
.container {
padding: 0 10px;
margin-bottom: 10px;
}
</style>