commit 98746aa4b8e4159bfe2cac366d3d1cd6bccf5258 Author: baileijun <594107299@qq.com> Date: Fri Jun 28 15:13:20 2024 +0800 1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65b411d --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +.DS_Store +node_modules +node_modules/* +/dist +/lib + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +package-lock.json \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..02e20bf --- /dev/null +++ b/.npmignore @@ -0,0 +1,12 @@ +examples/ +node_modules/ +packages/ +public/ + +.browserslistrc +.editorconfig +lint-staged.config.js +package-lock.json +vue.config.js +babel.config.js +src/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..424a883 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# my-erp-element + +## Project setup +``` +npm install +``` + +### Compiles and hot-reloads for development +``` +npm run serve +``` + +### Compiles and minifies for production +``` +npm run build +``` + +### Lints and fixes files +``` +npm run lint +``` + +### Customize configuration +See [Configuration Reference](https://cli.vuejs.org/config/). diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..e955840 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,5 @@ +module.exports = { + presets: [ + '@vue/cli-plugin-babel/preset' + ] +} diff --git a/examples/index.js b/examples/index.js new file mode 100644 index 0000000..e85068d --- /dev/null +++ b/examples/index.js @@ -0,0 +1,27 @@ +// 导入button组件 +import Button from './Button' + +// 组件列表 +const components = [ + Button +] + +// 定义 install 方法,接收 Vue 作为参数(使用 use 注册插件,那么所有的组件都会被注册) +const install = function (Vue) { + // 判断是否安装 + if (install.installed) return + // 遍历注册全局组件 + components.map(component => Vue.component(component.name, component)) +} + +// 判断是否是直接引入文件 +if (typeof window !== 'undefined' && window.Vue) { + install(window.Vue) +} + +export default { + // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 + install, + // 以下是具体的组件列表 + Button +} diff --git a/examples/main.js b/examples/main.js new file mode 100644 index 0000000..42d424f --- /dev/null +++ b/examples/main.js @@ -0,0 +1,13 @@ +import Vue from 'vue' +import App from '../src/App.vue' + +// 导入组件库 +import myui from '../packages' + +Vue.config.productionTip = false + +Vue.use(myui) + +new Vue({ + render: h => h(App), +}).$mount('#app') diff --git a/package.json b/package.json new file mode 100644 index 0000000..9609e7e --- /dev/null +++ b/package.json @@ -0,0 +1,44 @@ +{ + "name": "myErpElement", + "version": "0.1.1", + "private": false, + "scripts": { + "dev": "vue-cli-service serve", + "build": "vue-cli-service build", + "lint": "vue-cli-service lint", + "lib": "vue-cli-service build --target lib packages/index.js" + }, + "main": "./dist/myErpElement.umd.min.js", + "dependencies": { + "core-js": "^3.6.5", + "vue": "^2.6.11" + }, + "devDependencies": { + "@vue/cli-plugin-babel": "~4.5.19", + "@vue/cli-plugin-eslint": "~4.5.19", + "@vue/cli-service": "~4.5.19", + "babel-eslint": "^10.1.0", + "eslint": "^6.7.2", + "eslint-plugin-vue": "^6.2.2", + "vue-template-compiler": "^2.6.11" + }, + "eslintConfig": { + "root": true, + "env": { + "node": true + }, + "extends": [ + "plugin:vue/essential", + "eslint:recommended" + ], + "parserOptions": { + "parser": "babel-eslint" + }, + "rules": {} + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not dead" + ] +} diff --git a/packages/Button/index.js b/packages/Button/index.js new file mode 100644 index 0000000..e8e4a9a --- /dev/null +++ b/packages/Button/index.js @@ -0,0 +1,9 @@ +import mButton from './src' + +// 为组件提供 install 安装方法,供按需引入 +mButton.install = function (Vue) { + Vue.component(mButton.name, mButton) +} + +// 导出组件 +export default mButton diff --git a/packages/Button/src/index.vue b/packages/Button/src/index.vue new file mode 100644 index 0000000..44a92a3 --- /dev/null +++ b/packages/Button/src/index.vue @@ -0,0 +1,38 @@ + + + + + + + \ No newline at end of file diff --git a/packages/Button1/index.js b/packages/Button1/index.js new file mode 100644 index 0000000..56c7020 --- /dev/null +++ b/packages/Button1/index.js @@ -0,0 +1,9 @@ +import mButton1 from './src' + +// 为组件提供 install 安装方法,供按需引入 +mButton1.install = function (Vue) { + Vue.component(mButton1.name, mButton1) +} + +// 导出组件 +export default mButton1 diff --git a/packages/Button1/src/index.vue b/packages/Button1/src/index.vue new file mode 100644 index 0000000..4f1972e --- /dev/null +++ b/packages/Button1/src/index.vue @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/packages/index.js b/packages/index.js new file mode 100644 index 0000000..9342a75 --- /dev/null +++ b/packages/index.js @@ -0,0 +1,29 @@ +// 导入button组件 +import mButton from './Button/src/index.vue' +import mButton1 from './Button1/src/index.vue' + +// 组件列表 +const components = [ + mButton,mButton1 +] + +// 定义 install 方法,接收 Vue 作为参数(使用 use 注册插件,那么所有的组件都会被注册) +const install = function (Vue) { + // 判断是否安装 + if (install.installed) return + // 遍历注册全局组件 + components.map(component => Vue.component(component.name, component)) +} + +// 判断是否是直接引入文件 +if (typeof window !== 'undefined' && window.Vue) { + install(window.Vue) +} + +export default { + // 导出的对象必须具有 install,才能被 Vue.use() 方法安装 + install, + // 以下是具体的组件列表 + mButton, + mButton1, +} diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..df36fcf Binary files /dev/null and b/public/favicon.ico differ diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..3e5a139 --- /dev/null +++ b/public/index.html @@ -0,0 +1,17 @@ + + + + + + + + <%= htmlWebpackPlugin.options.title %> + + + +
+ + + diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..ed239e9 --- /dev/null +++ b/src/App.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/src/assets/logo.png b/src/assets/logo.png new file mode 100644 index 0000000..f3d2503 Binary files /dev/null and b/src/assets/logo.png differ diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue new file mode 100644 index 0000000..879051a --- /dev/null +++ b/src/components/HelloWorld.vue @@ -0,0 +1,58 @@ + + + + + + diff --git a/vue.config.js b/vue.config.js new file mode 100644 index 0000000..9224b21 --- /dev/null +++ b/vue.config.js @@ -0,0 +1,20 @@ +module.exports = { + pages: { + index: { + entry: 'examples/main.js', + template: 'public/index.html', + filename: 'index.html' + } + }, + // 扩展 webpack 配置,使 packages 加入编译 + chainWebpack: config => { + config.module + .rule('js') + .include + .add('/packages') + .end() + .use('babel') + .loader('babel-loader') + } + } + \ No newline at end of file