update
This commit is contained in:
@@ -2,15 +2,15 @@ import { ref } from "vue"
|
|||||||
|
|
||||||
export const insertText = ref("")
|
export const insertText = ref("")
|
||||||
|
|
||||||
export const cTexts = [
|
export const cSymbols = [
|
||||||
";",
|
";",
|
||||||
",",
|
",",
|
||||||
"&",
|
"&",
|
||||||
"{}",
|
"{}",
|
||||||
" = ",
|
"=",
|
||||||
" == ",
|
"==",
|
||||||
" > ",
|
">",
|
||||||
" < ",
|
"<",
|
||||||
" != ",
|
" != ",
|
||||||
" || ",
|
" || ",
|
||||||
" && ",
|
" && ",
|
||||||
@@ -22,27 +22,46 @@ export const cTexts = [
|
|||||||
"%d",
|
"%d",
|
||||||
"%.2f",
|
"%.2f",
|
||||||
"if () {}",
|
"if () {}",
|
||||||
" else ",
|
"else {}",
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c",
|
||||||
|
"\n",
|
||||||
]
|
]
|
||||||
|
|
||||||
export const pythonTexts = [
|
export const pythonSymbols = [
|
||||||
":",
|
":",
|
||||||
'""',
|
'""',
|
||||||
" = ",
|
",",
|
||||||
" == ",
|
"+",
|
||||||
" > ",
|
"-",
|
||||||
" < ",
|
"*",
|
||||||
|
"/",
|
||||||
|
"//",
|
||||||
|
"%",
|
||||||
|
"()",
|
||||||
|
"=",
|
||||||
|
"==",
|
||||||
|
">",
|
||||||
|
"<",
|
||||||
" != ",
|
" != ",
|
||||||
"print()",
|
"print()",
|
||||||
"input()",
|
"input()",
|
||||||
"if :",
|
"if ",
|
||||||
"else:",
|
"else:",
|
||||||
"elif :",
|
|
||||||
"for ",
|
"for ",
|
||||||
" in ",
|
" in ",
|
||||||
"range():",
|
"range():",
|
||||||
"while",
|
"while ",
|
||||||
"[]",
|
"[]",
|
||||||
"{}",
|
|
||||||
'"%.2f" % ',
|
'"%.2f" % ',
|
||||||
|
"a",
|
||||||
|
"b",
|
||||||
|
"c",
|
||||||
|
"\n",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export function getText(c: string) {
|
||||||
|
if (c === "\n") return "回车"
|
||||||
|
else return c
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from "vue"
|
import { computed } from "vue"
|
||||||
import { code } from "../composables/code"
|
import { code } from "../composables/code"
|
||||||
import { cTexts, insertText, pythonTexts } from "../composables/helper"
|
import { cSymbols, insertText, pythonSymbols, getText } from "../composables/helper"
|
||||||
|
|
||||||
function insert(text: string) {
|
function insert(text: string) {
|
||||||
insertText.value = text
|
insertText.value = text
|
||||||
}
|
}
|
||||||
|
|
||||||
const texts = computed(
|
const texts = computed(
|
||||||
() => ({ c: cTexts, python: pythonTexts })[code.language],
|
() => ({ c: cSymbols, python: pythonSymbols })[code.language],
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
@@ -21,7 +21,7 @@ const texts = computed(
|
|||||||
size="small"
|
size="small"
|
||||||
@click="insert(it)"
|
@click="insert(it)"
|
||||||
>
|
>
|
||||||
{{ it }}
|
{{ getText(it) }}
|
||||||
</n-button>
|
</n-button>
|
||||||
</n-flex>
|
</n-flex>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user