From a9b6e87249b0543b6f1be807716050244919382d Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 9 Feb 2021 17:19:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8C=89=E9=9C=80=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/certd-ui/babel.config.js | 6 +- packages/ui/certd-ui/package-lock.json | 10 +++ packages/ui/certd-ui/package.json | 1 + packages/ui/certd-ui/src/antdv.js | 90 ++++++++++++++++++++++++++ packages/ui/certd-ui/src/main.js | 8 +-- packages/ui/certd-ui/vue.config.js | 8 +++ 6 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 packages/ui/certd-ui/src/antdv.js diff --git a/packages/ui/certd-ui/babel.config.js b/packages/ui/certd-ui/babel.config.js index e9558405..ce5a9140 100644 --- a/packages/ui/certd-ui/babel.config.js +++ b/packages/ui/certd-ui/babel.config.js @@ -1,5 +1,9 @@ module.exports = { presets: [ '@vue/cli-plugin-babel/preset' - ] + ], + plugins: [['import', { + libraryName: 'ant-design-vue', + style: true // or 'css' + }]] } diff --git a/packages/ui/certd-ui/package-lock.json b/packages/ui/certd-ui/package-lock.json index 46e00f67..43f916fa 100644 --- a/packages/ui/certd-ui/package-lock.json +++ b/packages/ui/certd-ui/package-lock.json @@ -4106,6 +4106,16 @@ "object.assign": "^4.1.0" } }, + "babel-plugin-import": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/babel-plugin-import/-/babel-plugin-import-1.13.3.tgz", + "integrity": "sha512-1qCWdljJOrDRH/ybaCZuDgySii4yYrtQ8OJQwrcDqdt0y67N30ng3X3nABg6j7gR7qUJgcMa9OMhc4AGViDwWw==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/runtime": "^7.0.0" + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", diff --git a/packages/ui/certd-ui/package.json b/packages/ui/certd-ui/package.json index 947be088..30d95123 100644 --- a/packages/ui/certd-ui/package.json +++ b/packages/ui/certd-ui/package.json @@ -31,6 +31,7 @@ "@vue/eslint-config-standard": "^6.0.0", "@vue/test-utils": "^2.0.0-0", "babel-eslint": "^10.1.0", + "babel-plugin-import": "^1.13.3", "chai": "^4.2.0", "eslint": "^7.15.0", "eslint-plugin-import": "^2.20.2", diff --git a/packages/ui/certd-ui/src/antdv.js b/packages/ui/certd-ui/src/antdv.js new file mode 100644 index 00000000..9ad2c6f9 --- /dev/null +++ b/packages/ui/certd-ui/src/antdv.js @@ -0,0 +1,90 @@ +import _ from 'lodash' +import { + AutoComplete, + Alert, + Avatar, + Badge, + Button, + Calendar, + Card, + Cascader, + Checkbox, + Col, + DatePicker, + Divider, + Dropdown, + Form, + Icon, + Input, + InputNumber, + Layout, + List, + LocaleProvider, + Modal, + Radio, + Rate, + Row, + Select, + Switch, + Tabs, + Tag, + TimePicker, + Tooltip, + Drawer, + // ColorPicker, + ConfigProvider, + Descriptions, + Space +} from 'ant-design-vue' + +const list = { + AutoComplete, + Alert, + Avatar, + Badge, + Button, + Calendar, + Card, + Cascader, + Checkbox, + Col, + DatePicker, + Divider, + Dropdown, + Form, + Icon, + Input, + InputNumber, + Layout, + List, + LocaleProvider, + TimePicker, + Modal, + Radio, + Rate, + Row, + Select, + Switch, + Tabs, + Tag, + Tooltip, + Drawer, + // ColorPicker, + ConfigProvider, + Descriptions, + Space +} +export default function (app) { + _.forEach(list, item => { + app.use(item) + + // app.config.globalProperties.$message = message + // app.config.globalProperties.$notification = notification + app.config.globalProperties.$info = Modal.info + app.config.globalProperties.$success = Modal.success + app.config.globalProperties.$error = Modal.error + app.config.globalProperties.$warning = Modal.warning + app.config.globalProperties.$confirm = Modal.confirm + app.config.globalProperties.$destroyAll = Modal.destroyAll + }) +} diff --git a/packages/ui/certd-ui/src/main.js b/packages/ui/certd-ui/src/main.js index 1607d0e0..7157ff1f 100644 --- a/packages/ui/certd-ui/src/main.js +++ b/packages/ui/certd-ui/src/main.js @@ -1,16 +1,16 @@ import { createApp } from 'vue' import router from './router' import App from './App.vue' -import Antd from 'ant-design-vue' -import 'ant-design-vue/dist/antd.css' -import './style/common.less' import { i18n } from './i18n' import icons from './icons' +import antdv from './antdv' import components from './components' const app = createApp(App) app.config.productionTip = false app.use(i18n) -app.use(Antd) icons(app) +antdv(app) +// eslint-disable-next-line +import './style/common.less' app.use(components) app.use(router).mount('#app') diff --git a/packages/ui/certd-ui/vue.config.js b/packages/ui/certd-ui/vue.config.js index f20c98a6..9bc7c351 100644 --- a/packages/ui/certd-ui/vue.config.js +++ b/packages/ui/certd-ui/vue.config.js @@ -1,6 +1,7 @@ module.exports = { pages: { index: { + entry: 'src/main.js', // template 中的 title 标签需要是 <%= htmlWebpackPlugin.options.title %> title: 'Cert-D' } @@ -11,5 +12,12 @@ module.exports = { target: 'http://localhost:3000/' } } + }, + css: { + loaderOptions: { + less: { + javascriptEnabled: true + } + } } }