From be6e9eaaefd32582b1edac71ac966426e6c2bb6b Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Fri, 27 Jan 2023 11:06:31 +0800 Subject: [PATCH] fix init. --- src/learn/index.vue | 19 +++++++++++++++++-- src/main.ts | 25 ------------------------- src/oj/contest/list.vue | 3 ++- src/oj/problem/components/Editor.vue | 20 ++++++++++++++++++-- src/routes.ts | 7 +++++++ src/shared/Header.vue | 25 +++++++++++++++++++------ src/shared/Monaco.vue | 7 ++++--- src/shared/composables/chart.ts | 28 ++++++++++++++++++++++++++++ vite.config.ts | 10 ++++++++++ 9 files changed, 105 insertions(+), 39 deletions(-) create mode 100644 src/shared/composables/chart.ts diff --git a/src/learn/index.vue b/src/learn/index.vue index eccbfe3..fb83d17 100644 --- a/src/learn/index.vue +++ b/src/learn/index.vue @@ -63,10 +63,25 @@ function run() { 运行 -
-
+
+ + + + + + 上一步 + + + 下一步 + + +
+ 运行 + +
+
diff --git a/src/shared/Monaco.vue b/src/shared/Monaco.vue index 14e401c..836c276 100644 --- a/src/shared/Monaco.vue +++ b/src/shared/Monaco.vue @@ -4,7 +4,7 @@ import { LANGUAGE_VALUE } from "utils/constants" import { LANGUAGE } from "utils/types" import { isMobile } from "~/shared/composables/breakpoints" import { isDark } from "./composables/dark" -import { monaco } from "./composables/monaco" +import { init, monaco } from "./composables/monaco" interface Props { value: string @@ -29,8 +29,8 @@ const monacoEditorRef = ref() let editor: Monaco.editor.IStandaloneCodeEditor let model: Monaco.editor.ITextModel -onMounted(() => { - if (!monaco.value) return +onMounted(async () => { + if (!monaco.value) await init() model = monaco.value!.editor.createModel( props.value, LANGUAGE_VALUE[props.language] @@ -99,5 +99,6 @@ onUnmounted(() => { :class="props.class" :style="{ height: props.height }" > +
diff --git a/src/shared/composables/chart.ts b/src/shared/composables/chart.ts new file mode 100644 index 0000000..d01b8a8 --- /dev/null +++ b/src/shared/composables/chart.ts @@ -0,0 +1,28 @@ +import { + Chart as ChartJS, + Title, + Colors, + Tooltip, + Legend, + BarElement, + ArcElement, + CategoryScale, + LinearScale, +} from "chart.js" + +const [isLoaded] = useToggle() + +export function loadChart() { + if (isLoaded.value) return + ChartJS.register( + CategoryScale, + LinearScale, + BarElement, + ArcElement, + Colors, + Title, + Tooltip, + Legend + ) + isLoaded.value = true +} diff --git a/vite.config.ts b/vite.config.ts index 6811732..4fc1225 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,16 @@ const proxyConfig = { } export default defineConfig({ + build: { + rollupOptions: { + output: { + manualChunks: { + fancy: ["highlight.js", "party-js"], + chart: ["vue-chartjs", "chart.js"], + }, + }, + }, + }, resolve: { alias: { "~": path.resolve(__dirname, "./src"),