@star-ai/star-ui 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,6 @@ star-ui-library是一个基于Uniapp和Vue2开发的移动端组件库,提供
11
11
  - 🎨 基于Uniapp和Vue2,支持多端编译
12
12
  - 📱 丰富的移动端UI组件
13
13
  - 🔧 支持按需引入
14
- - 🎯 完整的TypeScript类型支持
15
14
  - 📦 轻量、高效
16
15
 
17
16
  ## 快速开始
@@ -19,22 +18,22 @@ star-ui-library是一个基于Uniapp和Vue2开发的移动端组件库,提供
19
18
  ### 安装
20
19
 
21
20
  ```bash
22
- npm install @dengchengbo/star-ui-library
23
- pnpm add @dengchengbo/star-ui-library
21
+ npm install @star-ai/star-ui
22
+ pnpm add @star-ai/star-ui
24
23
  ```
25
24
 
26
25
  ### 使用
27
26
 
28
27
  ```javascript
29
28
  // 全局引入
30
- import StarUI from '@dengchengbo/star-ui-library'
31
- import '@dengchengbo/star-ui-library/lib/styles/index.scss'
29
+ import StarUI from '@star-ai/star-ui'
30
+ import '@star-ai/star-ui/lib/styles/index.scss'
32
31
 
33
32
  Vue.use(StarUI)
34
33
 
35
34
  // 按需引入
36
- import { Button, Input } from '@dengchengbo/star-ui-library'
37
- import '@dengchengbo/star-ui-library/lib/styles/index.scss'
35
+ import { Button, Input } from '@star-ai/star-ui'
36
+ import '@star-ai/star-ui/lib/styles/index.scss'
38
37
 
39
38
  Vue.use(Button)
40
39
  Vue.use(Input)
@@ -76,7 +75,7 @@ Vue.use(Input)
76
75
  yarn install
77
76
 
78
77
  # 启动H5开发服务器
79
- npm run serve
78
+ npm run dev:h5
80
79
 
81
80
  # 构建H5版本
82
81
  npm run build:h5
@@ -86,6 +85,9 @@ npm run build:mp-weixin
86
85
 
87
86
  # 构建App版本
88
87
  npm run build:app-plus
88
+
89
+ # 构建npm包
90
+ npm run build:lib
89
91
  ```
90
92
 
91
93
  ## npm包发布流程
@@ -144,7 +146,7 @@ npm login
144
146
  ### 6. 发布npm包
145
147
 
146
148
  ```bash
147
- npm publish --access public
149
+ npm publish --access=public
148
150
  ```
149
151
 
150
152
  ### 7. 验证发布结果
@@ -152,7 +154,7 @@ npm publish --access public
152
154
  发布成功后,可以在npm官网查看你的包:
153
155
 
154
156
  ```
155
- https://www.npmjs.com/package/@dengchengbo/star-ui-library
157
+ https://www.npmjs.com/package/@star-ai/star-ui
156
158
  ```
157
159
 
158
160
  ## 注意事项
@@ -1,8 +1,10 @@
1
1
 
2
- import Button from './Button.vue'
2
+ // Button 组件入口文件
3
+ import StarButton from './Button.vue'
3
4
 
4
- Button.install = function(Vue) {
5
- Vue.component(Button.name, Button)
5
+ StarButton.install = function(Vue) {
6
+ Vue.component(StarButton.name, StarButton)
6
7
  }
7
8
 
8
- export default Button
9
+ export default StarButton
10
+ export { StarButton }
@@ -1,8 +1,10 @@
1
1
 
2
- import Input from './Input.vue'
2
+ // Input 组件入口文件
3
+ import StarInput from './Input.vue'
3
4
 
4
- Input.install = function(Vue) {
5
- Vue.component(Input.name, Input)
5
+ StarInput.install = function(Vue) {
6
+ Vue.component(StarInput.name, StarInput)
6
7
  }
7
8
 
8
- export default Input
9
+ export default StarInput
10
+ export { StarInput }
package/lib/index.js CHANGED
@@ -1,10 +1,28 @@
1
1
 
2
- // 自动导入所有组件
3
- const components = []
2
+ // star-ui 组件库主入口文件
3
+ import packageJson from '../package.json'
4
4
 
5
+ // 导入所有组件
6
+ import StarButton from './components/Button/index.js'
7
+ import StarInput from './components/Input/index.js'
8
+
9
+ // 组件列表
10
+ const components = [
11
+ StarButton,
12
+ StarInput
13
+ ]
14
+
15
+ // 安装函数
5
16
  const install = function(Vue, opts = {}) {
6
17
  components.forEach(component => {
7
- Vue.component(component.name, component)
18
+ // 如果组件有install方法,使用install方法注册
19
+ if (component.install) {
20
+ Vue.use(component)
21
+ }
22
+ // 如果组件是Vue组件对象,直接注册
23
+ else if (component.name) {
24
+ Vue.component(component.name, component)
25
+ }
8
26
  })
9
27
 
10
28
  // 挂载全局方法
@@ -19,10 +37,34 @@ if (typeof window !== 'undefined' && window.Vue) {
19
37
  install(window.Vue)
20
38
  }
21
39
 
22
- export default {
23
- version: '0.1.0',
40
+ // 创建导出对象
41
+ const StarUI = {
42
+ version: packageJson.version,
24
43
  install,
25
- // 按需导出所有组件
26
- Button: require('./components/Button').default,
27
- Input: require('./components/Input').default
44
+ // 导出所有组件
45
+ StarButton,
46
+ StarInput
28
47
  }
48
+
49
+ // 导出模块
50
+ if (typeof module !== 'undefined' && module.exports) {
51
+ // CommonJS 导出
52
+ module.exports = StarUI
53
+ module.exports.default = StarUI
54
+ // 为每个组件添加单独的导出(支持按需导入)
55
+ components.forEach(component => {
56
+ if (component.name) {
57
+ module.exports[component.name] = component
58
+ }
59
+ })
60
+ } else if (typeof define === 'function' && define.amd) {
61
+ // AMD 导出
62
+ define(() => StarUI)
63
+ } else if (typeof window !== 'undefined') {
64
+ // 浏览器全局变量导出
65
+ window.StarUI = StarUI
66
+ }
67
+
68
+ // ES模块导出
69
+ export default StarUI
70
+ export { StarButton, StarInput }
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@star-ai/star-ui",
3
+ "version": "0.0.2",
4
+ "description": "基于Uniapp的Vue2组件库",
5
+ "main": "index.js",
6
+ "files": [
7
+ "components",
8
+ "styles",
9
+ "index.js"
10
+ ],
11
+ "dependencies": {
12
+ "@vue/shared": "^3.0.0",
13
+ "core-js": "^3.8.3"
14
+ },
15
+ "keywords": [
16
+ "uniapp",
17
+ "vue2",
18
+ "component",
19
+ "ui",
20
+ "mobile"
21
+ ],
22
+ "author": "DengChengBo",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://gitee.com/chengboDeng/star-ui-library.git"
27
+ }
28
+ }
package/package.json CHANGED
@@ -1,8 +1,10 @@
1
1
  {
2
2
  "name": "@star-ai/star-ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "基于Uniapp的Vue2组件库",
5
5
  "main": "lib/index.js",
6
+ "module": "lib/index.js",
7
+ "umd:main": "lib/index.js",
6
8
  "files": [
7
9
  "lib",
8
10
  "packages"
@@ -10,6 +12,7 @@
10
12
  "scripts": {
11
13
  "serve": "npm run dev:h5",
12
14
  "build:lib": "node build/build.js",
15
+ "build:lib:prod": "cross-env BUILD_NPM_PACKAGE=true node build/build.js",
13
16
  "build": "npm run build:h5",
14
17
  "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
15
18
  "build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
@@ -55,32 +58,12 @@
55
58
  "test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
56
59
  "test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
57
60
  },
61
+ "peerDependencies": {
62
+ "vue": ">= 2.6.14 < 2.7"
63
+ },
58
64
  "dependencies": {
59
- "@dcloudio/uni-app": "^2.0.2-4080720251210002",
60
- "@dcloudio/uni-app-plus": "^2.0.2-4080720251210002",
61
- "@dcloudio/uni-h5": "^2.0.2-4080720251210002",
62
- "@dcloudio/uni-i18n": "^2.0.2-4080720251210002",
63
- "@dcloudio/uni-mp-360": "^2.0.2-4080720251210002",
64
- "@dcloudio/uni-mp-alipay": "^2.0.2-4080720251210002",
65
- "@dcloudio/uni-mp-baidu": "^2.0.2-4080720251210002",
66
- "@dcloudio/uni-mp-harmony": "^2.0.2-4080720251210002",
67
- "@dcloudio/uni-mp-jd": "^2.0.2-4080720251210002",
68
- "@dcloudio/uni-mp-kuaishou": "^2.0.2-4080720251210002",
69
- "@dcloudio/uni-mp-lark": "^2.0.2-4080720251210002",
70
- "@dcloudio/uni-mp-qq": "^2.0.2-4080720251210002",
71
- "@dcloudio/uni-mp-toutiao": "^2.0.2-4080720251210002",
72
- "@dcloudio/uni-mp-vue": "^2.0.2-4080720251210002",
73
- "@dcloudio/uni-mp-weixin": "^2.0.2-4080720251210002",
74
- "@dcloudio/uni-mp-xhs": "^2.0.2-4080720251210002",
75
- "@dcloudio/uni-quickapp-native": "^2.0.2-4080720251210002",
76
- "@dcloudio/uni-quickapp-webview": "^2.0.2-4080720251210002",
77
- "@dcloudio/uni-stacktracey": "^2.0.2-4080720251210002",
78
- "@dcloudio/uni-stat": "^2.0.2-4080720251210002",
79
65
  "@vue/shared": "^3.0.0",
80
- "core-js": "^3.8.3",
81
- "flyio": "^0.6.2",
82
- "vue": ">= 2.6.14 < 2.7",
83
- "vuex": "^3.2.0"
66
+ "core-js": "^3.8.3"
84
67
  },
85
68
  "devDependencies": {
86
69
  "@dcloudio/types": "^3.3.2",
@@ -99,6 +82,7 @@
99
82
  "@vue/cli-service": "~5.0.0",
100
83
  "babel-plugin-import": "^1.11.0",
101
84
  "cross-env": "^7.0.2",
85
+ "fs-extra": "^10.0.0",
102
86
  "jest": "^25.4.0",
103
87
  "postcss-comment": "^2.0.0",
104
88
  "sass": "^1.97.1",
@@ -129,4 +113,4 @@
129
113
  "uni-app": {
130
114
  "scripts": {}
131
115
  }
132
- }
116
+ }
package/packages/index.js CHANGED
@@ -1,17 +1,15 @@
1
- // 自动导入所有组件(使用CommonJS语法,兼容Webpack环境)
2
- const packageJson = require('../../package.json')
1
+ // 自动导入所有组件
2
+ import packageJson from '../../package.json'
3
3
 
4
- // 使用require.context自动扫描components目录下的所有组件(Webpack环境)
5
- const requireComponent = require.context('./components', true, /index\.js$/)
4
+ // 静态导入所有组件
5
+ import StarButton from './components/Button/index.js'
6
+ import StarInput from './components/Input/index.js'
6
7
 
7
8
  // 组件列表
8
- const components = requireComponent.keys().map(filePath => {
9
- // 获取组件配置
10
- const componentConfig = requireComponent(filePath)
11
-
12
- // 获取组件的默认导出
13
- return componentConfig.default || componentConfig
14
- })
9
+ const components = [
10
+ StarButton,
11
+ StarInput
12
+ ]
15
13
 
16
14
  // 安装函数
17
15
  const install = function(Vue, opts = {}) {
@@ -41,24 +39,31 @@ if (typeof window !== 'undefined' && window.Vue) {
41
39
  // 创建导出对象
42
40
  const StarUI = {
43
41
  version: packageJson.version,
44
- install
42
+ install,
43
+ // 导出所有组件
44
+ StarButton,
45
+ StarInput
45
46
  }
46
47
 
47
- // 为StarUI添加所有组件属性,并添加单独的导出
48
- components.forEach(component => {
49
- if (component.name) {
50
- StarUI[component.name] = component
51
- module.exports[component.name] = component
52
- }
53
- })
54
-
55
48
  // 导出模块
56
- module.exports = StarUI
57
-
58
- // 支持ES模块导入
59
- module.exports.default = StarUI
60
-
61
- // 支持AMD模块导入
62
- if (typeof define === 'function' && define.amd) {
49
+ if (typeof module !== 'undefined' && module.exports) {
50
+ // CommonJS 导出
51
+ module.exports = StarUI
52
+ module.exports.default = StarUI
53
+ // 为每个组件添加单独的导出(支持按需导入)
54
+ components.forEach(component => {
55
+ if (component.name) {
56
+ module.exports[component.name] = component
57
+ }
58
+ })
59
+ } else if (typeof define === 'function' && define.amd) {
60
+ // AMD 导出
63
61
  define(() => StarUI)
64
- }
62
+ } else if (typeof window !== 'undefined') {
63
+ // 浏览器全局变量导出
64
+ window.StarUI = StarUI
65
+ }
66
+
67
+ // ES模块导出
68
+ export default StarUI
69
+ export { StarButton, StarInput }