cy-element-ui 1.1.4 → 1.1.6

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
@@ -1,148 +1,354 @@
1
- <p align="center">
2
- <img src="https://cdn.rawgit.com/ElemeFE/element/dev/element_logo.svg">
3
- </p>
4
-
5
- <p align="center">
6
- <a href="https://travis-ci.org/ElemeFE/element">
7
- <img src="https://travis-ci.org/ElemeFE/element.svg?branch=master">
8
- </a>
9
- <a href="https://coveralls.io/github/ElemeFE/element?branch=master">
10
- <img src="https://coveralls.io/repos/github/ElemeFE/element/badge.svg?branch=master">
11
- </a>
12
- <a href="https://cdnjs.com/libraries/element-ui">
13
- <img src="https://img.shields.io/cdnjs/v/element-ui.svg">
14
- </a>
15
- <a href="https://www.npmjs.org/package/element-ui">
16
- <img src="https://img.shields.io/npm/v/element-ui.svg">
17
- </a>
18
- <a href="https://npmcharts.com/compare/element-ui?minimal=true">
19
- <img src="http://img.shields.io/npm/dm/element-ui.svg">
20
- </a>
21
- <br>
22
- <a href="http://img.badgesize.io/https://unpkg.com/element-ui/lib/index.js?compression=gzip&label=gzip%20size:%20JS">
23
- <img src="http://img.badgesize.io/https://unpkg.com/element-ui/lib/index.js?compression=gzip&label=gzip%20size:%20JS">
24
- </a>
25
- <a href="http://img.badgesize.io/https://unpkg.com/element-ui/lib/theme-chalk/index.css?compression=gzip&label=gzip%20size:%20CSS">
26
- <img src="http://img.badgesize.io/https://unpkg.com/element-ui/lib/theme-chalk/index.css?compression=gzip&label=gzip%20size:%20CSS">
27
- </a>
28
- <a href="#backers">
29
- <img src="https://opencollective.com/element/backers/badge.svg">
30
- </a>
31
- <a href="#sponsors">
32
- <img src="https://opencollective.com/element/sponsors/badge.svg">
33
- </a>
34
- <a href="LICENSE">
35
- <img src="https://img.shields.io/badge/License-MIT-yellow.svg">
36
- </a>
37
- </p>
38
-
39
- > A Vue.js 2.0 UI Toolkit for Web.
40
-
41
- Element will stay with Vue 2.x
42
-
43
- For Vue 3.0, we recommend using [Element Plus](https://github.com/element-plus/element-plus)(Element Plus is a community develop project)
44
-
45
- For MiniProgram development, we recommend using [MorJS](https://github.com/eleme/morjs)
46
-
47
- ## Links
48
- - Homepage and documentation
49
- - [International users](http://element.eleme.io/#/en-US)
50
- - [Chinese users](http://element.eleme.io/#/zh-CN)
51
- - [Spanish users](http://element.eleme.io/#/es)
52
- - [French users](http://element.eleme.io/#/fr-FR)
53
- - [awesome-element](https://github.com/ElementUI/awesome-element)
54
- - [FAQ](./FAQ.md)
55
- - [Vue.js 3.0 migration](https://github.com/element-plus/element-plus)
56
- - [Customize theme](http://element.eleme.io/#/en-US/component/custom-theme)
57
- - [Preview and generate theme online](https://elementui.github.io/theme-chalk-preview)
58
- - [Element for React](https://github.com/elemefe/element-react)
59
- - [Element for Angular](https://github.com/ElemeFE/element-angular)
60
- - [Atom helper](https://github.com/ElemeFE/element-helper)
61
- - [Visual Studio Code helper](https://github.com/ElemeFE/vscode-element-helper)
62
- - Starter kit
63
- - [element-starter](https://github.com/ElementUI/element-starter)
64
- - [element-in-laravel-starter](https://github.com/ElementUI/element-in-laravel-starter)
65
- - [Design resources](https://github.com/ElementUI/Resources)
66
- - Gitter
67
- - [International users](https://gitter.im/element-en/Lobby)
68
- - [Chinese users](https://gitter.im/ElemeFE/element)
69
-
70
- ## Install
71
- ```shell
72
- npm install element-ui -S
73
- ```
74
-
75
- ## Quick Start
76
- ``` javascript
1
+ # cy-element-ui 组件开发指南
2
+
3
+ ## 概述
4
+
5
+ 本文档详细介绍如何在 cy-element-ui 项目中创建新组件,并将其打包发布到 npm 仓库。
6
+
7
+ ---
8
+
9
+ ## 一、创建新组件
10
+
11
+ ### 1. 自动创建组件模板
12
+
13
+ 使用项目提供的脚本自动生成组件基础结构:
14
+
15
+ ```bash
16
+ npm run new:cy <component-name>
17
+ ```
18
+
19
+ **示例:**
20
+ ```bash
21
+ npm run new:cy test
22
+ ```
23
+
24
+ **执行结果:**
25
+ - 创建 `packages/cy-test/` 目录
26
+ - 创建 `packages/cy-test/index.js` - 组件导出文件
27
+ - 创建 `packages/cy-test/src/main.vue` - 组件实现文件
28
+
29
+ ### 2. 手动创建组件(可选)
30
+
31
+ 如果需要自定义结构,可以手动创建以下文件:
32
+
33
+ **文件结构:**
34
+ ```
35
+ packages/
36
+ └── cy-test/
37
+ ├── index.js # 组件导出
38
+ └── src/
39
+ └── main.vue # 组件实现
40
+ ```
41
+
42
+ **`packages/cy-test/index.js` 内容:**
43
+ ```javascript
44
+ import CyTest from './src/main';
45
+
46
+ CyTest.install = function(Vue) {
47
+ Vue.component(CyTest.name, CyTest);
48
+ };
49
+
50
+ export default CyTest;
51
+ ```
52
+
53
+ **`packages/cy-test/src/main.vue` 内容:**
54
+ ```vue
55
+ <template>
56
+ <div class="cy-test">
57
+ <slot></slot>
58
+ </div>
59
+ </template>
60
+
61
+ <script>
62
+ export default {
63
+ name: 'CyTest',
64
+ props: {
65
+ // 定义组件属性
66
+ }
67
+ };
68
+ </script>
69
+ ```
70
+
71
+ ---
72
+
73
+ ## 二、添加组件样式
74
+
75
+ ### 1. 创建样式文件
76
+
77
+ 在主题样式目录中创建组件样式:
78
+
79
+ ```bash
80
+ touch packages/theme-chalk/src/cy-test.scss
81
+ ```
82
+
83
+ **`packages/theme-chalk/src/cy-test.scss` 内容示例:**
84
+ ```scss
85
+ .cy-test {
86
+ display: inline-block;
87
+ padding: 20px 24px;
88
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
89
+ border-radius: 8px;
90
+ transition: all 0.3s ease;
91
+ }
92
+ ```
93
+
94
+ ### 2. 导入样式到主题入口
95
+
96
+ 修改 `packages/theme-chalk/src/index.scss`,添加样式导入:
97
+
98
+ ```scss
99
+ // 在文件末尾添加
100
+ @import "./cy-test.scss";
101
+ ```
102
+
103
+ ---
104
+
105
+ ## 三、注册组件到组件库
106
+
107
+ ### 1. 更新组件配置文件
108
+
109
+ 修改 `components.json`,添加新组件:
110
+
111
+ ```json
112
+ {
113
+ "cy-test": "./packages/cy-test/index.js"
114
+ }
115
+ ```
116
+
117
+ ### 2. 重新生成入口文件
118
+
119
+ 运行以下命令自动更新 `src/index.js`:
120
+
121
+ ```bash
122
+ npm run build:file
123
+ ```
124
+
125
+ **验证:**
126
+ 检查 `src/index.js` 是否包含:
127
+ ```javascript
128
+ import CyTest from '../packages/cy-test/index.js';
129
+ ```
130
+
131
+ ---
132
+
133
+ ## 四、添加组件文档(可选)
134
+
135
+ ### 1. 创建示例页面
136
+
137
+ 在示例目录中创建组件展示页面:
138
+
139
+ ```
140
+ examples/
141
+ └── pages/
142
+ ├── zh-CN/
143
+ │ └── cy-test.md # 中文文档
144
+ └── en-US/
145
+ └── cy-test.md # 英文文档
146
+ ```
147
+
148
+ ### 2. 配置导航
149
+
150
+ 修改 `examples/nav.config.json`,添加导航项:
151
+
152
+ ```json
153
+ {
154
+ "chanchan": {
155
+ "name": "产研模块",
156
+ "children": [
157
+ {
158
+ "path": "/cy-test",
159
+ "name": "CyTest 测试组件"
160
+ }
161
+ ]
162
+ }
163
+ }
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 五、打包构建
169
+
170
+ ### 1. 完整构建
171
+
172
+ 运行完整构建命令,生成 `lib/` 目录:
173
+
174
+ ```bash
175
+ npm run dist
176
+ ```
177
+
178
+ **构建内容:**
179
+ - `lib/index.js` - 主入口文件(包含所有组件)
180
+ - `lib/theme-chalk/` - 主题样式文件
181
+
182
+ ### 2. 单独构建主题样式(可选)
183
+
184
+ 如果只修改了样式,可以单独构建主题:
185
+
186
+ ```bash
187
+ npm run build:theme
188
+ ```
189
+
190
+ ### 3. 验证打包结果
191
+
192
+ 检查 `lib/index.js` 是否包含新组件:
193
+
194
+ ```bash
195
+ grep "CyTest" lib/index.js
196
+ ```
197
+
198
+ ---
199
+
200
+ ## 六、发布到 npm
201
+
202
+ ### 1. 更新版本号
203
+
204
+ 修改 `package.json` 中的版本号:
205
+
206
+ ```json
207
+ {
208
+ "version": "1.1.4"
209
+ }
210
+ ```
211
+
212
+ **版本号规则:**
213
+ - `MAJOR.MINOR.PATCH`
214
+ - 修复bug:增加 PATCH
215
+ - 新增功能:增加 MINOR
216
+ - 重大变更:增加 MAJOR
217
+
218
+ ### 2. 登录 npm
219
+
220
+ 确保已登录 npm 账号:
221
+
222
+ ```bash
223
+ npm login
224
+ ```
225
+
226
+ ### 3. 发布到 npm
227
+
228
+ 执行发布命令:
229
+
230
+ ```bash
231
+ npm publish
232
+ ```
233
+
234
+ **注意事项:**
235
+ - 确保版本号未被使用过
236
+ - 确保 `lib/` 目录已正确生成
237
+ - 确保 `package.json` 中的 `main` 字段指向正确
238
+
239
+ ---
240
+
241
+ ## 七、在项目中使用
242
+
243
+ ### 1. 安装依赖
244
+
245
+ ```bash
246
+ npm install cy-element-ui --save
247
+ ```
248
+
249
+ ### 2. 全局引入
250
+
251
+ ```javascript
252
+ // main.js
77
253
  import Vue from 'vue'
78
- import Element from 'element-ui'
254
+ import CyElementUI from 'cy-element-ui'
255
+ import 'cy-element-ui/lib/theme-chalk/index.css'
256
+
257
+ Vue.use(CyElementUI)
258
+ ```
259
+
260
+ ### 3. 使用组件
261
+
262
+ ```vue
263
+ <template>
264
+ <cy-test title="测试">
265
+ 这是测试内容
266
+ </cy-test>
267
+ </template>
268
+ ```
269
+
270
+ ---
271
+
272
+ ## 八、文件变更汇总
273
+
274
+ ### 创建的文件
275
+
276
+ | 文件路径 | 说明 |
277
+ |---------|------|
278
+ | `packages/cy-test/index.js` | 组件导出文件 |
279
+ | `packages/cy-test/src/main.vue` | 组件实现文件 |
280
+ | `packages/theme-chalk/src/cy-test.scss` | 组件样式文件 |
281
+
282
+ ### 修改的文件
283
+
284
+ | 文件路径 | 修改内容 |
285
+ |---------|---------|
286
+ | `components.json` | 添加组件配置 |
287
+ | `packages/theme-chalk/src/index.scss` | 导入组件样式 |
288
+ | `src/index.js` | 自动生成组件注册 |
289
+ | `package.json` | 更新版本号 |
79
290
 
80
- Vue.use(Element)
291
+ ### 生成的文件(构建后)
81
292
 
82
- // or
83
- import {
84
- Select,
85
- Button
86
- // ...
87
- } from 'element-ui'
293
+ | 文件路径 | 说明 |
294
+ |---------|------|
295
+ | `lib/index.js` | 打包后的主入口 |
296
+ | `lib/theme-chalk/cy-test.css` | 组件样式 |
297
+ | `lib/theme-chalk/index.css` | 完整主题样式 |
88
298
 
89
- Vue.component(Select.name, Select)
90
- Vue.component(Button.name, Button)
299
+ ---
300
+
301
+ ## 九、常见问题
302
+
303
+ ### Q1: 组件未被打包进 lib/index.js
304
+
305
+ **原因:** `components.json` 未添加组件配置
306
+
307
+ **解决:**
308
+ ```bash
309
+ npm run build:file
91
310
  ```
92
- For more information, please refer to [Quick Start](http://element.eleme.io/#/en-US/component/quickstart) in our documentation.
93
311
 
94
- ## Browser Support
95
- Modern browsers and Internet Explorer 10+.
312
+ ### Q2: 样式未生效
96
313
 
97
- ## Development
98
- Skip this part if you just want to use Element.
314
+ **原因:** 样式未导入到主题入口
99
315
 
100
- For those who are interested in contributing to Element, please refer to our contributing guide ([中文](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.zh-CN.md) | [English](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.en-US.md) | [Español](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.es.md) | [Français](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.fr-FR.md)) to see how to run this project.
316
+ **解决:**
317
+ 检查 `packages/theme-chalk/src/index.scss` 是否包含:
318
+ ```scss
319
+ @import "./cy-test.scss";
320
+ ```
321
+
322
+ ### Q3: 发布时版本冲突
101
323
 
102
- ## Changelog
103
- Detailed changes for each release are documented in the [release notes](https://github.com/ElemeFE/element/releases).
324
+ **原因:** 版本号已存在
104
325
 
105
- ## FAQ
106
- We have collected some [frequently asked questions](https://github.com/ElemeFE/element/blob/master/FAQ.md). Before reporting an issue, please search if the FAQ has the answer to your problem.
326
+ **解决:**
327
+ 更新 `package.json` 中的版本号
107
328
 
108
- ## Contribution
109
- Please make sure to read the contributing guide ([中文](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.zh-CN.md) | [English](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.en-US.md) | [Español](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.es.md) | [Français](https://github.com/ElemeFE/element/blob/master/.github/CONTRIBUTING.fr-FR.md)) before making a pull request.
329
+ ### Q4: npm 发布失败
110
330
 
111
- ## Special Thanks
112
- English documentation is brought to you by SwiftGG Translation Team:
113
- - [raychenfj](https://github.com/raychenfj)
114
- - [kevin](http://thekevin.cn/)
115
- - [曾小涛](https://github.com/zengxiaotao)
116
- - [湾仔王二](https://github.com/wanzaiwanger)
117
- - [BlooDLine](http://www.ibloodline.com/)
118
- - [陈铭嘉](https://chenmingjia.github.io/)
119
- - [千叶知风](http://mpc6.com/)
120
- - [梁杰](http://numbbbbb.com)
121
- - [Changing](https://github.com/sunzhuo11)
122
- - [mmoaay](https://github.com/mmoaay)
331
+ **原因:** 未登录或权限不足
123
332
 
124
- Spanish documentation is made possible by these community developers:
125
- - [adavie1](https://github.com/adavie1)
126
- - [carmencitaqiu](https://github.com/carmencitaqiu)
127
- - [coderdiaz](https://github.com/coderdiaz)
128
- - [fedegar33](https://github.com/fedegar33)
129
- - [Gonzalo2310](https://github.com/Gonzalo2310)
130
- - [lesterbx](https://github.com/lesterbx)
131
- - [ProgramerGuy](https://github.com/ProgramerGuy)
132
- - [SantiagoGdaR](https://github.com/SantiagoGdaR)
133
- - [sigfriedCub1990](https://github.com/sigfriedCub1990)
134
- - [thechosenjuan](https://github.com/thechosenjuan)
333
+ **解决:**
334
+ ```bash
335
+ npm login
336
+ ```
135
337
 
136
- French documentation is made possible by these community developers:
137
- - [smalesys](https://github.com/smalesys)
138
- - [blombard](https://github.com/blombard)
338
+ ---
139
339
 
140
- ## Join Discussion Group
340
+ ## 十、开发流程建议
141
341
 
142
- Scan the QR code using [Dingtalk App](https://www.dingtalk.com/) to join in discussion group :
342
+ 1. **创建组件** `npm run new:cy <name>`
343
+ 2. **编写代码** → 修改 `packages/<name>/src/main.vue`
344
+ 3. **添加样式** → 创建 `packages/theme-chalk/src/<name>.scss`
345
+ 4. **注册组件** → `npm run build:file`
346
+ 5. **测试预览** → `npm run dev`
347
+ 6. **打包构建** → `npm run dist`
348
+ 7. **发布 npm** → `npm version patch && npm publish`
143
349
 
144
- <img alt="Join Discusion Group" src="https://user-images.githubusercontent.com/17680888/93177882-0ae92d80-f766-11ea-870d-3fa2d7f06454.png" width="300">
350
+ ---
145
351
 
352
+ ## License
146
353
 
147
- ## LICENSE
148
- [MIT](LICENSE)
354
+ MIT