Browse Source

feat_async-theme&add:vite-plugin-monaco-editor

ananzhusen 1 year ago
parent
commit
f29b5d2c8e
3 changed files with 16 additions and 3 deletions
  1. 1 0
      package.json
  2. 4 2
      src/App.vue
  3. 11 1
      vite.config.ts

+ 1 - 0
package.json

@@ -37,6 +37,7 @@
     "postcss-nested": "^6.0.1",
     "postcss-nested": "^6.0.1",
     "typescript": "^4.7.4",
     "typescript": "^4.7.4",
     "vite": "^4.4.2",
     "vite": "^4.4.2",
+    "vite-plugin-monaco-editor": "^1.0.10",
     "vue-tsc": "^1.8.3"
     "vue-tsc": "^1.8.3"
   }
   }
 }
 }

+ 4 - 2
src/App.vue

@@ -12,8 +12,10 @@ const { getUser } = useUser();
 
 
 onBeforeMount(() => {
 onBeforeMount(() => {
   getUser();
   getUser();
-  registerTheme();
-  changeTheme('le-dark');
+  setTimeout(() => {
+    registerTheme();
+    changeTheme('le-dark');
+  }, 1000);
 });
 });
 </script>
 </script>
 <style lang="postcss" scoped></style>
 <style lang="postcss" scoped></style>

+ 11 - 1
vite.config.ts

@@ -4,11 +4,21 @@ import vueJsx from '@vitejs/plugin-vue-jsx';
 import * as path from 'path';
 import * as path from 'path';
 import * as fs from 'fs';
 import * as fs from 'fs';
 import formidable from 'formidable';
 import formidable from 'formidable';
+import monacoEditorPlugin from 'vite-plugin-monaco-editor';
 
 
 // https://vitejs.dev/config/
 // https://vitejs.dev/config/
 export default defineConfig({
 export default defineConfig({
   // assetsInclude: ['**/*.glb'],
   // assetsInclude: ['**/*.glb'],
-  plugins: [vue(), vueJsx(), fileList()],
+  plugins: [
+    vue(),
+    vueJsx(),
+    fileList(),
+    monacoEditorPlugin({
+      customDistPath: () => {
+        return 'v/monacoeditorwork';
+      },
+    }),
+  ],
   resolve: {
   resolve: {
     alias: {
     alias: {
       '@': path.resolve(__dirname, './src/'),
       '@': path.resolve(__dirname, './src/'),