From d940c684ad2a5ac6f5383753dfd53882aacbe863 Mon Sep 17 00:00:00 2001
From: yuetsh <517252939@qq.com>
Date: Sun, 21 Jan 2024 21:41:31 +0800
Subject: [PATCH] update
---
src/App.vue | 11 +++++++----
src/components/CodeEditor.vue | 8 ++++----
src/composables/code.ts | 7 ++++++-
src/desktop/Header.vue | 30 +++++++++++++++++++++++-------
src/main.ts | 2 ++
vite.config.ts | 14 ++++++++++++++
6 files changed, 56 insertions(+), 16 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index b1c45cc..c25bfd2 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -14,9 +14,12 @@ const isDark = useDark()
:date-locale="dateZhCN"
:theme="isDark ? darkTheme : null"
>
-
-
-
-
+
+
+
+
+
+
+./themes/breakpoints
diff --git a/src/components/CodeEditor.vue b/src/components/CodeEditor.vue
index 245367f..dd0574b 100644
--- a/src/components/CodeEditor.vue
+++ b/src/components/CodeEditor.vue
@@ -19,7 +19,7 @@ interface Props {
}
const props = withDefaults(defineProps(), {
- language: "c",
+ language: "python",
fontSize: 24,
readonly: false,
placeholder: "",
@@ -45,10 +45,10 @@ watch(
)
const lang = computed(() => {
- if (props.language === "c") {
- return cpp()
+ if (props.language === "python") {
+ return python()
}
- return python()
+ return cpp()
})
function onChange(v: string) {
diff --git a/src/composables/code.ts b/src/composables/code.ts
index 35ba8b7..1f5dff5 100644
--- a/src/composables/code.ts
+++ b/src/composables/code.ts
@@ -1,6 +1,6 @@
import { ref } from "vue"
import copyTextToClipboard from "copy-text-to-clipboard"
-import { Code } from "../types"
+import { Code, LANGUAGE } from "../types"
import { sources } from "../templates"
import { submit } from "../api"
@@ -21,6 +21,11 @@ export function reset() {
output.value = ""
}
+export function changeLanguage(language: LANGUAGE) {
+ code.value.value = sources[language]
+ output.value = ""
+}
+
export async function run() {
loading.value = true
const cleanCode = code.value.value.trim()
diff --git a/src/desktop/Header.vue b/src/desktop/Header.vue
index 1284692..fb09d88 100644
--- a/src/desktop/Header.vue
+++ b/src/desktop/Header.vue
@@ -1,18 +1,29 @@
@@ -24,8 +35,13 @@ const languages: SelectOption[] = [
{{ isDark ? "浅色" : "深色" }}
重置
- 复制
-
+ 复制
+
diff --git a/src/main.ts b/src/main.ts
index e1e48df..be3e017 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -12,6 +12,7 @@ import {
NSplit,
NFlex,
NIcon,
+ NMessageProvider,
} from "naive-ui"
import App from "./App.vue"
import "normalize.css"
@@ -20,6 +21,7 @@ const naive = create({
components: [
NButton,
NConfigProvider,
+ NMessageProvider,
NLayout,
NLayoutHeader,
NLayoutContent,
diff --git a/vite.config.ts b/vite.config.ts
index bde757c..a22762b 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -3,5 +3,19 @@ import vue from "@vitejs/plugin-vue"
import legacy from "@vitejs/plugin-legacy"
export default defineConfig({
+ build: {
+ rollupOptions: {
+ output: {
+ manualChunks: {
+ editor: [
+ "vue-codemirror",
+ "codemirror",
+ "@codemirror/lang-cpp",
+ "@codemirror/lang-python",
+ ],
+ },
+ },
+ },
+ },
plugins: [vue(), legacy({ targets: ["chrome 66", "not IE 11"] })],
})