@deppon/deppon-template 2.2.1 → 2.2.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
@@ -1,330 +1,330 @@
1
- # `@deppon/deppon-template`
2
-
3
- 业务组件库(Vue 3)
4
-
5
- ## 安装
6
-
7
- ```bash
8
- npm install @deppon/deppon-template
9
- ```
10
-
11
- ## 配置
12
-
13
- 由于组件库使用 Less 编写样式,你需要在项目中配置 Less 支持。
14
-
15
- > 📖 **详细使用指南:**
16
- >
17
- > - [Vite 项目使用指南](./VITE_USAGE.md) - 完整的 Vite + Vue 3 使用示例
18
- > - [通用使用示例](./USAGE.md) - 包含常见问题和解决方案
19
-
20
- ### Vite 项目
21
-
22
- Vite 默认支持 Less,无需额外配置。如果遇到问题,确保已安装 `less`:
23
-
24
- ```bash
25
- npm install -D less
26
- ```
27
-
28
- **快速开始:**
29
-
30
- ```vue
31
- <template>
32
- <ProLayout :menu-items="menuItems" :active-menu="activeMenu" title="我的应用">
33
- <router-view />
34
- </ProLayout>
35
- </template>
36
-
37
- <script setup>
38
- import { ref } from 'vue';
39
- import { ProLayout } from '@deppon/deppon-template';
40
- // ✅ Less 文件会自动导入并编译
41
-
42
- const activeMenu = ref('/home');
43
- const menuItems = ref([
44
- { path: '/home', title: '首页' },
45
- { path: '/about', title: '关于' },
46
- ]);
47
- </script>
48
- ```
49
-
50
- 查看 [VITE_USAGE.md](./VITE_USAGE.md) 获取完整示例。
51
-
52
- ### Webpack 项目
53
-
54
- 需要安装并配置 Less 加载器:
55
-
56
- ```bash
57
- npm install -D less less-loader
58
- ```
59
-
60
- 在 `webpack.config.js` 或 `vue.config.js` 中配置:
61
-
62
- ```javascript
63
- module.exports = {
64
- module: {
65
- rules: [
66
- {
67
- test: /\.less$/,
68
- use: ['style-loader', 'css-loader', 'less-loader'],
69
- },
70
- ],
71
- },
72
- };
73
- ```
74
-
75
- ## 使用
76
-
77
- ### 完整引入
78
-
79
- ```vue
80
- <template>
81
- <ProLayout :menu-items="menuItems" :active-menu="activeMenu" title="我的应用">
82
- <router-view />
83
- </ProLayout>
84
- </template>
85
-
86
- <script setup>
87
- import { ProLayout } from '@deppon/deppon-template';
88
- // 样式会自动导入(Less 文件会被自动处理)
89
-
90
- const menuItems = [
91
- {
92
- path: '/home',
93
- title: '首页',
94
- icon: HomeFilled,
95
- },
96
- {
97
- path: '/about',
98
- title: '关于',
99
- icon: Document,
100
- },
101
- ];
102
-
103
- const activeMenu = '/home';
104
- </script>
105
- ```
106
-
107
- ### 按需引入
108
-
109
- ```vue
110
- <template>
111
- <div>
112
- <ProLayout :menu-items="menuItems" />
113
- <ProForm :form-items="formItems" />
114
- <ProTable :columns="columns" :data="tableData" />
115
- </div>
116
- </template>
117
-
118
- <script setup>
119
- // 按需导入组件,样式会自动导入
120
- import { ProLayout, ProForm, ProTable } from '@deppon/deppon-template';
121
-
122
- const menuItems = [];
123
- const formItems = [];
124
- const columns = [];
125
- const tableData = [];
126
- </script>
127
- ```
128
-
129
- ### 单独导入组件
130
-
131
- ```vue
132
- <template>
133
- <ProLayout :menu-items="menuItems" />
134
- </template>
135
-
136
- <script setup>
137
- // 从子路径导入,样式会自动导入
138
- import ProLayout from '@deppon/deppon-template/pro-layout';
139
- // 或者
140
- import { ProLayout } from '@deppon/deppon-template';
141
- </script>
142
- ```
143
-
144
- ### 样式说明
145
-
146
- - **自动导入**:当你导入组件时,对应的 Less 文件会自动被导入
147
- - **Less 编译**:Less 文件会被你的构建工具(Vite/Webpack)自动编译为 CSS
148
- - **:deep() 支持**:Less 文件中的 `:deep()` 语法会被正确处理
149
- - **无需手动导入样式**:不需要手动 `import '@deppon/deppon-template/es/pro-layout/ProLayout.vue.less'`
150
-
151
- ### 完整示例(Vite + Vue 3)
152
-
153
- ```vue
154
- <!-- App.vue -->
155
- <template>
156
- <ProLayout
157
- :menu-items="menuItems"
158
- :active-menu="activeMenu"
159
- title="管理系统"
160
- :show-logo="true"
161
- :show-header="true"
162
- :fixed-header="true"
163
- @collapse-change="handleCollapseChange"
164
- >
165
- <template #header-right>
166
- <el-button>用户中心</el-button>
167
- </template>
168
-
169
- <router-view />
170
- </ProLayout>
171
- </template>
172
-
173
- <script setup>
174
- import { ref } from 'vue';
175
- import { ProLayout } from '@deppon/deppon-template';
176
- import { HomeFilled, Document, Setting } from '@deppon/deppon-ui/icons-vue';
177
-
178
- const activeMenu = ref('/home');
179
- const collapsed = ref(false);
180
-
181
- const menuItems = ref([
182
- {
183
- path: '/home',
184
- title: '首页',
185
- icon: HomeFilled,
186
- },
187
- {
188
- path: '/documents',
189
- title: '文档',
190
- icon: Document,
191
- children: [
192
- {
193
- path: '/documents/list',
194
- title: '文档列表',
195
- },
196
- ],
197
- },
198
- {
199
- path: '/settings',
200
- title: '设置',
201
- icon: Setting,
202
- },
203
- ]);
204
-
205
- const handleCollapseChange = val => {
206
- console.log('侧边栏折叠状态:', val);
207
- };
208
- </script>
209
- ```
210
-
211
- ### 完整示例(Webpack + Vue 3)
212
-
213
- ```vue
214
- <!-- App.vue -->
215
- <template>
216
- <ProLayout :menu-items="menuItems" :active-menu="activeMenu">
217
- <router-view />
218
- </ProLayout>
219
- </template>
220
-
221
- <script>
222
- import { ref } from 'vue';
223
- import { ProLayout } from '@deppon/deppon-template';
224
-
225
- export default {
226
- name: 'App',
227
- components: {
228
- ProLayout,
229
- },
230
- setup() {
231
- const activeMenu = ref('/home');
232
- const menuItems = ref([
233
- { path: '/home', title: '首页' },
234
- { path: '/about', title: '关于' },
235
- ]);
236
-
237
- return {
238
- activeMenu,
239
- menuItems,
240
- };
241
- },
242
- };
243
- </script>
244
- ```
245
-
246
- ## 使用
247
-
248
- ### useScrollEnd Composable
249
-
250
- 监听滚动到底部的事件。
251
-
252
- ```vue
253
- <template>
254
- <div class="scroll-container" ref="scrollContainer">
255
- <!-- 内容 -->
256
- </div>
257
- </template>
258
-
259
- <script setup>
260
- import { ref } from 'vue';
261
- import { useScrollEnd } from '@deppon/deppon-template';
262
-
263
- const scrollContainer = ref(null);
264
-
265
- // 监听滚动到底部
266
- useScrollEnd(
267
- () => {
268
- console.log('滚动到底部了');
269
- // 加载更多数据
270
- loadMore();
271
- },
272
- 50, // 距离底部的阈值(像素)
273
- '.scroll-container', // 滚动容器的选择器,可选
274
- );
275
-
276
- const loadMore = () => {
277
- // 加载更多逻辑
278
- };
279
- </script>
280
- ```
281
-
282
- #### 参数
283
-
284
- | 参数 | 说明 | 类型 | 默认值 |
285
- | --------------------- | -------------------------- | ---------- | ---------------------------------------- |
286
- | callback | 滚动到底部时触发的回调函数 | `function` | 必填 |
287
- | thresholds | 距离底部的阈值(像素) | `number` | `0` |
288
- | scrollElementSelector | 滚动容器的选择器 | `string` | `null`(使用 document.scrollingElement) |
289
-
290
- ### Events
291
-
292
- 事件总线,用于组件间通信。基于 [mitt](https://github.com/developit/mitt) 实现,轻量级且专为浏览器设计。
293
-
294
- ```vue
295
- <script setup>
296
- import { events } from '@deppon/deppon-template';
297
-
298
- // 监听事件
299
- events.on('some-event', data => {
300
- console.log('收到事件:', data);
301
- });
302
-
303
- // 触发事件
304
- events.emit('some-event', { key: 'value' });
305
-
306
- // 移除监听
307
- events.off('some-event');
308
- </script>
309
- ```
310
-
311
- ### Track
312
-
313
- 埋点工具函数。
314
-
315
- ```vue
316
- <script setup>
317
- import { gt } from '@deppon/deppon-template';
318
-
319
- // 使用埋点
320
- const handleClick = () => {
321
- const trackData = gt('gbdetail_buy_nk_pv');
322
- // trackData 包含埋点所需的数据
323
- console.log(trackData);
324
- };
325
- </script>
326
- ```
327
-
328
- ## License
329
-
330
- MIT
1
+ # `@deppon/deppon-template`
2
+
3
+ 业务组件库(Vue 3)
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @deppon/deppon-template
9
+ ```
10
+
11
+ ## 配置
12
+
13
+ 由于组件库使用 Less 编写样式,你需要在项目中配置 Less 支持。
14
+
15
+ > 📖 **详细使用指南:**
16
+ >
17
+ > - [Vite 项目使用指南](./VITE_USAGE.md) - 完整的 Vite + Vue 3 使用示例
18
+ > - [通用使用示例](./USAGE.md) - 包含常见问题和解决方案
19
+
20
+ ### Vite 项目
21
+
22
+ Vite 默认支持 Less,无需额外配置。如果遇到问题,确保已安装 `less`:
23
+
24
+ ```bash
25
+ npm install -D less
26
+ ```
27
+
28
+ **快速开始:**
29
+
30
+ ```vue
31
+ <template>
32
+ <ProLayout :menu-items="menuItems" :active-menu="activeMenu" title="我的应用">
33
+ <router-view />
34
+ </ProLayout>
35
+ </template>
36
+
37
+ <script setup>
38
+ import { ref } from 'vue';
39
+ import { ProLayout } from '@deppon/deppon-template';
40
+ // ✅ Less 文件会自动导入并编译
41
+
42
+ const activeMenu = ref('/home');
43
+ const menuItems = ref([
44
+ { path: '/home', title: '首页' },
45
+ { path: '/about', title: '关于' },
46
+ ]);
47
+ </script>
48
+ ```
49
+
50
+ 查看 [VITE_USAGE.md](./VITE_USAGE.md) 获取完整示例。
51
+
52
+ ### Webpack 项目
53
+
54
+ 需要安装并配置 Less 加载器:
55
+
56
+ ```bash
57
+ npm install -D less less-loader
58
+ ```
59
+
60
+ 在 `webpack.config.js` 或 `vue.config.js` 中配置:
61
+
62
+ ```javascript
63
+ module.exports = {
64
+ module: {
65
+ rules: [
66
+ {
67
+ test: /\.less$/,
68
+ use: ['style-loader', 'css-loader', 'less-loader'],
69
+ },
70
+ ],
71
+ },
72
+ };
73
+ ```
74
+
75
+ ## 使用
76
+
77
+ ### 完整引入
78
+
79
+ ```vue
80
+ <template>
81
+ <ProLayout :menu-items="menuItems" :active-menu="activeMenu" title="我的应用">
82
+ <router-view />
83
+ </ProLayout>
84
+ </template>
85
+
86
+ <script setup>
87
+ import { ProLayout } from '@deppon/deppon-template';
88
+ // 样式会自动导入(Less 文件会被自动处理)
89
+
90
+ const menuItems = [
91
+ {
92
+ path: '/home',
93
+ title: '首页',
94
+ icon: HomeFilled,
95
+ },
96
+ {
97
+ path: '/about',
98
+ title: '关于',
99
+ icon: Document,
100
+ },
101
+ ];
102
+
103
+ const activeMenu = '/home';
104
+ </script>
105
+ ```
106
+
107
+ ### 按需引入
108
+
109
+ ```vue
110
+ <template>
111
+ <div>
112
+ <ProLayout :menu-items="menuItems" />
113
+ <ProForm :form-items="formItems" />
114
+ <ProTable :columns="columns" :data="tableData" />
115
+ </div>
116
+ </template>
117
+
118
+ <script setup>
119
+ // 按需导入组件,样式会自动导入
120
+ import { ProLayout, ProForm, ProTable } from '@deppon/deppon-template';
121
+
122
+ const menuItems = [];
123
+ const formItems = [];
124
+ const columns = [];
125
+ const tableData = [];
126
+ </script>
127
+ ```
128
+
129
+ ### 单独导入组件
130
+
131
+ ```vue
132
+ <template>
133
+ <ProLayout :menu-items="menuItems" />
134
+ </template>
135
+
136
+ <script setup>
137
+ // 从子路径导入,样式会自动导入
138
+ import ProLayout from '@deppon/deppon-template/pro-layout';
139
+ // 或者
140
+ import { ProLayout } from '@deppon/deppon-template';
141
+ </script>
142
+ ```
143
+
144
+ ### 样式说明
145
+
146
+ - **自动导入**:当你导入组件时,对应的 Less 文件会自动被导入
147
+ - **Less 编译**:Less 文件会被你的构建工具(Vite/Webpack)自动编译为 CSS
148
+ - **:deep() 支持**:Less 文件中的 `:deep()` 语法会被正确处理
149
+ - **无需手动导入样式**:不需要手动 `import '@deppon/deppon-template/es/pro-layout/ProLayout.vue.less'`
150
+
151
+ ### 完整示例(Vite + Vue 3)
152
+
153
+ ```vue
154
+ <!-- App.vue -->
155
+ <template>
156
+ <ProLayout
157
+ :menu-items="menuItems"
158
+ :active-menu="activeMenu"
159
+ title="管理系统"
160
+ :show-logo="true"
161
+ :show-header="true"
162
+ :fixed-header="true"
163
+ @collapse-change="handleCollapseChange"
164
+ >
165
+ <template #header-right>
166
+ <el-button>用户中心</el-button>
167
+ </template>
168
+
169
+ <router-view />
170
+ </ProLayout>
171
+ </template>
172
+
173
+ <script setup>
174
+ import { ref } from 'vue';
175
+ import { ProLayout } from '@deppon/deppon-template';
176
+ import { HomeFilled, Document, Setting } from '@deppon/deppon-ui/icons-vue';
177
+
178
+ const activeMenu = ref('/home');
179
+ const collapsed = ref(false);
180
+
181
+ const menuItems = ref([
182
+ {
183
+ path: '/home',
184
+ title: '首页',
185
+ icon: HomeFilled,
186
+ },
187
+ {
188
+ path: '/documents',
189
+ title: '文档',
190
+ icon: Document,
191
+ children: [
192
+ {
193
+ path: '/documents/list',
194
+ title: '文档列表',
195
+ },
196
+ ],
197
+ },
198
+ {
199
+ path: '/settings',
200
+ title: '设置',
201
+ icon: Setting,
202
+ },
203
+ ]);
204
+
205
+ const handleCollapseChange = val => {
206
+ console.log('侧边栏折叠状态:', val);
207
+ };
208
+ </script>
209
+ ```
210
+
211
+ ### 完整示例(Webpack + Vue 3)
212
+
213
+ ```vue
214
+ <!-- App.vue -->
215
+ <template>
216
+ <ProLayout :menu-items="menuItems" :active-menu="activeMenu">
217
+ <router-view />
218
+ </ProLayout>
219
+ </template>
220
+
221
+ <script>
222
+ import { ref } from 'vue';
223
+ import { ProLayout } from '@deppon/deppon-template';
224
+
225
+ export default {
226
+ name: 'App',
227
+ components: {
228
+ ProLayout,
229
+ },
230
+ setup() {
231
+ const activeMenu = ref('/home');
232
+ const menuItems = ref([
233
+ { path: '/home', title: '首页' },
234
+ { path: '/about', title: '关于' },
235
+ ]);
236
+
237
+ return {
238
+ activeMenu,
239
+ menuItems,
240
+ };
241
+ },
242
+ };
243
+ </script>
244
+ ```
245
+
246
+ ## 使用
247
+
248
+ ### useScrollEnd Composable
249
+
250
+ 监听滚动到底部的事件。
251
+
252
+ ```vue
253
+ <template>
254
+ <div class="scroll-container" ref="scrollContainer">
255
+ <!-- 内容 -->
256
+ </div>
257
+ </template>
258
+
259
+ <script setup>
260
+ import { ref } from 'vue';
261
+ import { useScrollEnd } from '@deppon/deppon-template';
262
+
263
+ const scrollContainer = ref(null);
264
+
265
+ // 监听滚动到底部
266
+ useScrollEnd(
267
+ () => {
268
+ console.log('滚动到底部了');
269
+ // 加载更多数据
270
+ loadMore();
271
+ },
272
+ 50, // 距离底部的阈值(像素)
273
+ '.scroll-container', // 滚动容器的选择器,可选
274
+ );
275
+
276
+ const loadMore = () => {
277
+ // 加载更多逻辑
278
+ };
279
+ </script>
280
+ ```
281
+
282
+ #### 参数
283
+
284
+ | 参数 | 说明 | 类型 | 默认值 |
285
+ | --------------------- | -------------------------- | ---------- | ---------------------------------------- |
286
+ | callback | 滚动到底部时触发的回调函数 | `function` | 必填 |
287
+ | thresholds | 距离底部的阈值(像素) | `number` | `0` |
288
+ | scrollElementSelector | 滚动容器的选择器 | `string` | `null`(使用 document.scrollingElement) |
289
+
290
+ ### Events
291
+
292
+ 事件总线,用于组件间通信。基于 [mitt](https://github.com/developit/mitt) 实现,轻量级且专为浏览器设计。
293
+
294
+ ```vue
295
+ <script setup>
296
+ import { events } from '@deppon/deppon-template';
297
+
298
+ // 监听事件
299
+ events.on('some-event', data => {
300
+ console.log('收到事件:', data);
301
+ });
302
+
303
+ // 触发事件
304
+ events.emit('some-event', { key: 'value' });
305
+
306
+ // 移除监听
307
+ events.off('some-event');
308
+ </script>
309
+ ```
310
+
311
+ ### Track
312
+
313
+ 埋点工具函数。
314
+
315
+ ```vue
316
+ <script setup>
317
+ import { gt } from '@deppon/deppon-template';
318
+
319
+ // 使用埋点
320
+ const handleClick = () => {
321
+ const trackData = gt('gbdetail_buy_nk_pv');
322
+ // trackData 包含埋点所需的数据
323
+ console.log(trackData);
324
+ };
325
+ </script>
326
+ ```
327
+
328
+ ## License
329
+
330
+ MIT
package/es/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { ProField, ProFieldText, ProFieldSelect, ProFieldDatePicker } from './pro-field';
2
- export { default as ProForm } from './pro-form';
3
- export { default as ProTable } from './pro-table';
4
- export { default as ProLayout } from './pro-layout';
5
- export { default as ProDialog } from './pro-dialog';
1
+ export { ProField, ProFieldText, ProFieldSelect, ProFieldDatePicker } from './pro-field';
2
+ export { default as ProForm } from './pro-form';
3
+ export { default as ProTable } from './pro-table';
4
+ export { default as ProLayout } from './pro-layout';
5
+ export { default as ProDialog } from './pro-dialog';
@@ -1,5 +1,5 @@
1
- import type { DefineComponent } from 'vue';
2
-
3
- declare const ProDialog: DefineComponent<Record<string, never>, Record<string, never>, any>;
4
- export { ProDialog };
5
- export default ProDialog;
1
+ import type { DefineComponent } from 'vue';
2
+
3
+ declare const ProDialog: DefineComponent<Record<string, never>, Record<string, never>, any>;
4
+ export { ProDialog };
5
+ export default ProDialog;