From 7a68aee6c68beef652dcfa271cda0f4e804ae1c1 Mon Sep 17 00:00:00 2001 From: liaozan <378024053@qq.com> Date: Fri, 8 Apr 2022 22:07:01 +0800 Subject: [PATCH] feat: rewrite with vue3 --- initializer-ui/package.json | 12 ++--- initializer-ui/src/components/starter.vue | 53 +++++++++-------------- initializer-ui/src/main.ts | 4 +- initializer-ui/vite.config.ts | 44 +------------------ 4 files changed, 30 insertions(+), 83 deletions(-) diff --git a/initializer-ui/package.json b/initializer-ui/package.json index 44265fa..3b2e167 100644 --- a/initializer-ui/package.json +++ b/initializer-ui/package.json @@ -6,18 +6,14 @@ "build": "vite build --mode production" }, "dependencies": { - "@vitejs/plugin-vue": "^2.3.1", "ant-design-vue": "^3.1.1", "axios": "^0.26.1", - "consola": "^2.15.3", - "vite-plugin-style-import": "^1.4.1", "vue": "^3.2.31" }, "devDependencies": { - "@vue/compiler-sfc": "^3.2.31", - "less": "^4.1.2", - "sass": "^1.50.0", - "unplugin-vue-components": "^0.18.5", - "vite": "^2.9.1" + "@vitejs/plugin-vue": "^2.3.1", + "typescript": "^4.6.3", + "vite": "^2.9.1", + "vue-tsc": "^0.33.9" } } \ No newline at end of file diff --git a/initializer-ui/src/components/starter.vue b/initializer-ui/src/components/starter.vue index 254c009..62a8bba 100644 --- a/initializer-ui/src/components/starter.vue +++ b/initializer-ui/src/components/starter.vue @@ -2,7 +2,7 @@

项目初始代码生成

- + @@ -121,50 +121,39 @@ const createTreeData = (fileNodeList: FileNode[]): any => { return [] } return fileNodeList.map((item: FileNode) => { - // 非叶子结点 - if (item.children && item.children.length > 0) { - Object.assign(item, { - key: item.fileContent! + Math.random(), - children: createTreeData(item.children), - title: item.fileName, - selectable: false, - isLeaf: false - }) - return item - } else { - return { - key: item.fileContent! + Math.random(), - title: item.fileName, - children: [], - selectable: false, - isLeaf: true - } + return { + key: Math.random(), + title: item.fileName, + children: createTreeData(item.children), + selectable: false, + isLeaf: item.isFile } }) } - \ No newline at end of file diff --git a/initializer-ui/src/main.ts b/initializer-ui/src/main.ts index 59c1e47..2ce4d0b 100644 --- a/initializer-ui/src/main.ts +++ b/initializer-ui/src/main.ts @@ -1,5 +1,7 @@ import {createApp} from 'vue' import App from './App.vue' +import Antd from 'ant-design-vue' import './index.css' +import 'ant-design-vue/dist/antd.css'; -createApp(App).mount('#app') \ No newline at end of file +createApp(App).use(Antd).mount('#app') \ No newline at end of file diff --git a/initializer-ui/vite.config.ts b/initializer-ui/vite.config.ts index 67cd5b7..229c5a5 100644 --- a/initializer-ui/vite.config.ts +++ b/initializer-ui/vite.config.ts @@ -1,47 +1,7 @@ -import Components from 'unplugin-vue-components/vite' -import {AntDesignVueResolver} from 'unplugin-vue-components/resolvers' -import styleImport, {AndDesignVueResolve, AntdResolve} from 'vite-plugin-style-import' import {defineConfig} from 'vite' -// @ts-ignore import vue from '@vitejs/plugin-vue' +// noinspection JSUnusedGlobalSymbols export default defineConfig({ - plugins: [ - vue(), - // antd自动按需引入 - Components({ - resolvers: [ - AntDesignVueResolver(), - ] - }), - // @ts-ignore - styleImport({ - resolves: [ - AndDesignVueResolve(), - AntdResolve() - ], - // 自定义规则 - libs: [ - { - libraryName: 'ant-design-vue', - esModule: true, - resolveStyle: (name: any) => { - return `ant-design-vue/es/${name}/style/index` - } - } - ] - }) - ], - // 引用使用less的库要配置一下 - css: { - preprocessorOptions: { - less: { - javascriptEnabled: true - } - } - }, - // 让terminal显示network地址 - server: { - host: '0.0.0.0' - } + plugins: [vue()] }) \ No newline at end of file -- GitLab