@star-ai/star-ui 0.0.2

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 ADDED
@@ -0,0 +1,167 @@
1
+ # star-ui-library
2
+
3
+ 基于Uniapp的Vue2组件库
4
+
5
+ ## 项目介绍
6
+
7
+ star-ui-library是一个基于Uniapp和Vue2开发的移动端组件库,提供了丰富的UI组件,帮助开发者快速构建美观、易用的移动应用。
8
+
9
+ ## 特性
10
+
11
+ - 🎨 基于Uniapp和Vue2,支持多端编译
12
+ - 📱 丰富的移动端UI组件
13
+ - 🔧 支持按需引入
14
+ - 🎯 完整的TypeScript类型支持
15
+ - 📦 轻量、高效
16
+
17
+ ## 快速开始
18
+
19
+ ### 安装
20
+
21
+ ```bash
22
+ npm install @dengchengbo/star-ui-library
23
+ pnpm add @dengchengbo/star-ui-library
24
+ ```
25
+
26
+ ### 使用
27
+
28
+ ```javascript
29
+ // 全局引入
30
+ import StarUI from '@dengchengbo/star-ui-library'
31
+ import '@dengchengbo/star-ui-library/lib/styles/index.scss'
32
+
33
+ Vue.use(StarUI)
34
+
35
+ // 按需引入
36
+ import { Button, Input } from '@dengchengbo/star-ui-library'
37
+ import '@dengchengbo/star-ui-library/lib/styles/index.scss'
38
+
39
+ Vue.use(Button)
40
+ Vue.use(Input)
41
+ ```
42
+
43
+ ## 组件文档
44
+
45
+ ### Button 按钮
46
+
47
+ ```vue
48
+ <my-button type="primary">主要按钮</my-button>
49
+ ```
50
+
51
+ ### Input 输入框
52
+
53
+ ```vue
54
+ <my-input v-model="value" placeholder="请输入内容"></my-input>
55
+ ```
56
+
57
+ ## 开发指南
58
+
59
+ ### 项目结构
60
+
61
+ ```
62
+ ├── packages/ # 组件源码
63
+ │ ├── components/ # 组件目录
64
+ │ ├── styles/ # 样式文件
65
+ │ └── index.js # 入口文件
66
+ ├── lib/ # 构建后的npm包
67
+ ├── examples/ # 示例代码
68
+ ├── build/ # 构建脚本
69
+ └── docs/ # 文档
70
+ ```
71
+
72
+ ### 开发命令
73
+
74
+ ```bash
75
+ # 安装依赖
76
+ yarn install
77
+
78
+ # 启动H5开发服务器
79
+ npm run serve
80
+
81
+ # 构建H5版本
82
+ npm run build:h5
83
+
84
+ # 构建小程序版本
85
+ npm run build:mp-weixin
86
+
87
+ # 构建App版本
88
+ npm run build:app-plus
89
+ ```
90
+
91
+ ## npm包发布流程
92
+
93
+ ### 1. 准备工作
94
+
95
+ 确保你已经:
96
+ - 拥有npm账号并已登录
97
+ - 确保package.json中的配置正确
98
+ - 已完成代码开发和测试
99
+
100
+ ### 2. 构建npm包
101
+
102
+ ```bash
103
+ # 执行构建脚本
104
+ npm run build:lib
105
+ ```
106
+
107
+ 此命令会执行以下操作:
108
+ - 清空lib目录
109
+ - 复制所有组件到lib/components
110
+ - 为每个组件创建单独的index.js入口文件
111
+ - 复制样式文件到lib/styles
112
+ - 创建主入口文件lib/index.js
113
+
114
+ ### 3. 检查构建结果
115
+
116
+ 构建完成后,检查lib目录是否包含以下内容:
117
+ - lib/index.js # 主入口文件
118
+ - lib/components/ # 组件目录
119
+ - lib/styles/ # 样式文件
120
+
121
+ ### 4. 更新版本号
122
+
123
+ 根据语义化版本规则更新package.json中的version字段:
124
+
125
+ ```bash
126
+ # 补丁版本(修复bug)
127
+ npm version patch
128
+
129
+ # 小版本(新增功能)
130
+ npm version minor
131
+
132
+ # 大版本(不兼容更改)
133
+ npm version major
134
+ ```
135
+
136
+ ### 5. 登录npm账号
137
+
138
+ 如果尚未登录npm账号,执行以下命令登录:
139
+
140
+ ```bash
141
+ npm login
142
+ ```
143
+
144
+ ### 6. 发布npm包
145
+
146
+ ```bash
147
+ npm publish --access public
148
+ ```
149
+
150
+ ### 7. 验证发布结果
151
+
152
+ 发布成功后,可以在npm官网查看你的包:
153
+
154
+ ```
155
+ https://www.npmjs.com/package/@dengchengbo/star-ui-library
156
+ ```
157
+
158
+ ## 注意事项
159
+
160
+ - 发布前请确保所有测试通过
161
+ - 发布前请检查package.json中的配置是否正确
162
+ - 每次发布请更新版本号
163
+ - 如果是私有包,请移除--access public参数
164
+
165
+ ## License
166
+
167
+ MIT
@@ -0,0 +1,325 @@
1
+ <template>
2
+ <view
3
+ class="star-button"
4
+ :class="[
5
+ `star-button--${type}`,
6
+ `star-button--${size}`,
7
+ {
8
+ 'star-button--disabled': disabled,
9
+ 'star-button--loading': loading,
10
+ 'star-button--block': block,
11
+ 'star-button--plain': plain
12
+ }
13
+ ]"
14
+ :style="[customStyle]"
15
+ @click="handleClick"
16
+ >
17
+ <!-- 加载状态 -->
18
+ <view v-if="loading" class="star-button__loading">
19
+ <view class="star-button__loading-spinner"></view>
20
+ </view>
21
+
22
+ <!-- 图标 -->
23
+ <text
24
+ v-if="icon && !loading"
25
+ class="star-button__icon"
26
+ :class="icon"
27
+ ></text>
28
+
29
+ <!-- 文字内容 -->
30
+ <text class="star-button__text">
31
+ <slot></slot>
32
+ </text>
33
+
34
+ <!-- 右侧图标 -->
35
+ <text
36
+ v-if="rightIcon && !loading"
37
+ class="star-button__right-icon"
38
+ :class="rightIcon"
39
+ ></text>
40
+ </view>
41
+ </template>
42
+
43
+ <script>
44
+ export default {
45
+ name: 'StarButton',
46
+
47
+ // 组件属性定义
48
+ props: {
49
+ // 按钮类型
50
+ type: {
51
+ type: String,
52
+ default: 'default',
53
+ validator: (value) => {
54
+ return ['default', 'primary', 'success', 'warning', 'error', 'info'].includes(value)
55
+ }
56
+ },
57
+
58
+ // 按钮大小
59
+ size: {
60
+ type: String,
61
+ default: 'medium',
62
+ validator: (value) => {
63
+ return ['mini', 'small', 'medium', 'large'].includes(value)
64
+ }
65
+ },
66
+
67
+ // 是否禁用
68
+ disabled: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+
73
+ // 是否加载中
74
+ loading: {
75
+ type: Boolean,
76
+ default: false
77
+ },
78
+
79
+ // 是否为朴素按钮
80
+ plain: {
81
+ type: Boolean,
82
+ default: false
83
+ },
84
+
85
+ // 是否为块级按钮
86
+ block: {
87
+ type: Boolean,
88
+ default: false
89
+ },
90
+
91
+ // 左侧图标
92
+ icon: {
93
+ type: String,
94
+ default: ''
95
+ },
96
+
97
+ // 右侧图标
98
+ rightIcon: {
99
+ type: String,
100
+ default: ''
101
+ },
102
+
103
+ // 自定义样式
104
+ customStyle: {
105
+ type: Object,
106
+ default: () => ({})
107
+ },
108
+
109
+ // 点击防抖时间(毫秒)
110
+ debounce: {
111
+ type: Number,
112
+ default: 0
113
+ }
114
+ },
115
+
116
+ data() {
117
+ return {
118
+ canClick: true
119
+ }
120
+ },
121
+
122
+ methods: {
123
+ handleClick(event) {
124
+ // 防抖处理
125
+ if (!this.canClick) return
126
+
127
+ if (this.debounce > 0) {
128
+ this.canClick = false
129
+ setTimeout(() => {
130
+ this.canClick = true
131
+ }, this.debounce)
132
+ }
133
+
134
+ // 触发点击事件
135
+ if (!this.disabled && !this.loading) {
136
+ this.$emit('click', event)
137
+ }
138
+ }
139
+ }
140
+ }
141
+ </script>
142
+
143
+ <style lang="scss" scoped>
144
+ // 引入样式变量
145
+ @import "../../styles/variables.scss";
146
+
147
+ .star-button {
148
+ display: inline-flex;
149
+ align-items: center;
150
+ justify-content: center;
151
+ position: relative;
152
+ box-sizing: border-box;
153
+ padding: 0 16px;
154
+ height: 44px;
155
+ line-height: 44px;
156
+ border-radius: $border-radius-base;
157
+ font-size: $font-size-base;
158
+ font-weight: 500;
159
+ text-align: center;
160
+ vertical-align: middle;
161
+ transition: all 0.3s;
162
+ cursor: pointer;
163
+ user-select: none;
164
+
165
+ // 块级按钮
166
+ &--block {
167
+ display: flex;
168
+ width: 100%;
169
+ }
170
+
171
+ // 禁用状态
172
+ &--disabled {
173
+ opacity: 0.6;
174
+ cursor: not-allowed;
175
+ }
176
+
177
+ // 大小
178
+ &--mini {
179
+ padding: 0 8px;
180
+ height: 24px;
181
+ line-height: 24px;
182
+ font-size: $font-size-sm;
183
+ border-radius: $border-radius-sm;
184
+ }
185
+
186
+ &--small {
187
+ padding: 0 12px;
188
+ height: 32px;
189
+ line-height: 32px;
190
+ font-size: $font-size-sm;
191
+ border-radius: $border-radius-sm;
192
+ }
193
+
194
+ &--large {
195
+ padding: 0 20px;
196
+ height: 48px;
197
+ line-height: 48px;
198
+ font-size: $font-size-lg;
199
+ border-radius: $border-radius-lg;
200
+ }
201
+
202
+ // 类型 - 默认
203
+ &--default {
204
+ color: $text-color;
205
+ background-color: $bg-color;
206
+ border: 1px solid $border-color;
207
+
208
+ &:not(.star-button--disabled):not(.star-button--loading):active {
209
+ background-color: darken($bg-color, 5%);
210
+ }
211
+ }
212
+
213
+ // 类型 - 主要
214
+ &--primary {
215
+ color: $white;
216
+ background-color: $primary-color;
217
+ border: 1px solid $primary-color;
218
+
219
+ &.star-button--plain {
220
+ color: $primary-color;
221
+ background-color: transparent;
222
+ }
223
+
224
+ &:not(.star-button--disabled):not(.star-button--loading):active {
225
+ background-color: darken($primary-color, 10%);
226
+ border-color: darken($primary-color, 10%);
227
+ }
228
+ }
229
+
230
+ // 类型 - 成功
231
+ &--success {
232
+ color: $white;
233
+ background-color: $success-color;
234
+ border: 1px solid $success-color;
235
+
236
+ &.star-button--plain {
237
+ color: $success-color;
238
+ background-color: transparent;
239
+ }
240
+ }
241
+
242
+ // 类型 - 警告
243
+ &--warning {
244
+ color: $white;
245
+ background-color: $warning-color;
246
+ border: 1px solid $warning-color;
247
+
248
+ &.star-button--plain {
249
+ color: $warning-color;
250
+ background-color: transparent;
251
+ }
252
+ }
253
+
254
+ // 类型 - 错误
255
+ &--error {
256
+ color: $white;
257
+ background-color: $error-color;
258
+ border: 1px solid $error-color;
259
+
260
+ &.star-button--plain {
261
+ color: $error-color;
262
+ background-color: transparent;
263
+ }
264
+ }
265
+
266
+ // 类型 - 信息
267
+ &--info {
268
+ color: $white;
269
+ background-color: $info-color;
270
+ border: 1px solid $info-color;
271
+
272
+ &.star-button--plain {
273
+ color: $info-color;
274
+ background-color: transparent;
275
+ }
276
+ }
277
+
278
+ // 加载中
279
+ &--loading {
280
+ cursor: not-allowed;
281
+ }
282
+
283
+ // 图标
284
+ &__icon,
285
+ &__right-icon {
286
+ font-family: "star-icon-font" !important; // 使用你自己的图标字体
287
+ margin-right: 4px;
288
+ font-size: inherit;
289
+ }
290
+
291
+ &__right-icon {
292
+ margin-right: 0;
293
+ margin-left: 4px;
294
+ }
295
+
296
+ &__text {
297
+ display: inline-block;
298
+ vertical-align: middle;
299
+ }
300
+
301
+ // 加载动画
302
+ &__loading {
303
+ margin-right: 4px;
304
+ }
305
+
306
+ &__loading-spinner {
307
+ display: inline-block;
308
+ width: 14px;
309
+ height: 14px;
310
+ border: 2px solid;
311
+ border-color: currentColor transparent transparent transparent;
312
+ border-radius: 50%;
313
+ animation: star-button-spin 1s linear infinite;
314
+ }
315
+ }
316
+
317
+ @keyframes star-button-spin {
318
+ 0% {
319
+ transform: rotate(0deg);
320
+ }
321
+ 100% {
322
+ transform: rotate(360deg);
323
+ }
324
+ }
325
+ </style>
@@ -0,0 +1,8 @@
1
+
2
+ import Button from './Button.vue'
3
+
4
+ Button.install = function(Vue) {
5
+ Vue.component(Button.name, Button)
6
+ }
7
+
8
+ export default Button