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"),