gd-web-core 0.0.1
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/LICENSE +21 -0
- package/README.md +500 -0
- package/dist/components/Echarts/Echarts.vue.d.ts +23 -0
- package/dist/components/Echarts/index.d.ts +3 -0
- package/dist/components/STable/STable.vue.d.ts +102 -0
- package/dist/components/STable/index.d.ts +3 -0
- package/dist/components/ScrollContainer/ScrollContainer.vue.d.ts +42 -0
- package/dist/components/ScrollContainer/index.d.ts +3 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useLoading.d.ts +11 -0
- package/dist/hooks/useToggle.d.ts +11 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +785 -0
- package/dist/index.umd.cjs +1 -0
- package/dist/utils/async.d.ts +18 -0
- package/dist/utils/crypto.d.ts +39 -0
- package/dist/utils/dom.d.ts +21 -0
- package/dist/utils/format.d.ts +20 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/loadRemote.d.ts +14 -0
- package/dist/utils/number.d.ts +13 -0
- package/dist/utils/rowSet.d.ts +28 -0
- package/dist/utils/storage.d.ts +19 -0
- package/dist/utils/url.d.ts +11 -0
- package/dist/utils/visibility.d.ts +8 -0
- package/dist/utils/xlsx.d.ts +96 -0
- package/package.json +110 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 [Your Organization Name]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
# @gdxx/web-core
|
|
2
|
+
|
|
3
|
+
Vue 3 基座能力封装库,提供通用组件和工具函数。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @gdxx/web-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 快速开始
|
|
12
|
+
|
|
13
|
+
### 全量引入
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createApp } from 'vue'
|
|
17
|
+
import YourOrgCore from '@gdxx/web-core'
|
|
18
|
+
import '@gdxx/web-core/style.css'
|
|
19
|
+
import App from './App.vue'
|
|
20
|
+
|
|
21
|
+
const app = createApp(App)
|
|
22
|
+
app.use(YourOrgCore)
|
|
23
|
+
app.mount('#app')
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 按需引入(推荐)
|
|
27
|
+
|
|
28
|
+
本库完全支持 Tree-shaking,可以按需引入组件和工具函数,减小打包体积。
|
|
29
|
+
|
|
30
|
+
#### 方式 1: 从主入口导入(推荐)
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { Echarts, STable, formatDate, useLoading } from '@gdxx/web-core'
|
|
34
|
+
import '@gdxx/web-core/style.css'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
#### 方式 2: 从子路径导入(更语义化)
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
// 仅导入组件
|
|
41
|
+
import { Echarts, STable } from '@gdxx/web-core/components'
|
|
42
|
+
|
|
43
|
+
// 仅导入工具函数
|
|
44
|
+
import { formatDate, formatNumber } from '@gdxx/web-core/utils'
|
|
45
|
+
|
|
46
|
+
// 仅导入 Hooks
|
|
47
|
+
import { useLoading, useToggle } from '@gdxx/web-core/hooks'
|
|
48
|
+
|
|
49
|
+
// 导入样式
|
|
50
|
+
import '@gdxx/web-core/style.css'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Tree-shaking 原理
|
|
54
|
+
|
|
55
|
+
现代打包工具(Vite、Webpack 5+、Rollup)会自动移除未使用的代码:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
// 只会打包 formatDate 相关代码,其他工具函数不会被打包
|
|
59
|
+
import { formatDate } from '@gdxx/web-core'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**工作条件**:
|
|
63
|
+
- ✅ 使用 ES Module (`import`/`export`)
|
|
64
|
+
- ✅ 打包工具开启生产模式
|
|
65
|
+
- ✅ 使用命名导入(不是 `import *`)
|
|
66
|
+
|
|
67
|
+
#### 打包体积对比
|
|
68
|
+
|
|
69
|
+
| 导入方式 | 打包后体积(估算) |
|
|
70
|
+
|---------|-----------------|
|
|
71
|
+
| 全量导入 | ~200KB (gzip ~60KB) |
|
|
72
|
+
| 按需导入单个组件 | ~20KB (gzip ~6KB) |
|
|
73
|
+
| 按需导入单个工具函数 | ~2KB (gzip <1KB) |
|
|
74
|
+
|
|
75
|
+
## 验证 Tree-shaking 效果
|
|
76
|
+
|
|
77
|
+
### 使用 Rollup Plugin Visualizer
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# 安装可视化插件
|
|
81
|
+
pnpm add -D rollup-plugin-visualizer
|
|
82
|
+
|
|
83
|
+
# 在 vite.config.ts 中添加
|
|
84
|
+
import { visualizer } from 'rollup-plugin-visualizer'
|
|
85
|
+
|
|
86
|
+
export default defineConfig({
|
|
87
|
+
plugins: [
|
|
88
|
+
visualizer({ open: true })
|
|
89
|
+
]
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
# 构建后会自动打开分析报告
|
|
93
|
+
pnpm build
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 使用 Vite Build Analyzer
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# 开发时查看导入分析
|
|
100
|
+
pnpm dev
|
|
101
|
+
|
|
102
|
+
# 在浏览器控制台查看
|
|
103
|
+
import { formatDate } from '@gdxx/web-core'
|
|
104
|
+
// 只会加载 formatDate 相关模块
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 检查打包产物
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 构建生产版本
|
|
111
|
+
pnpm build
|
|
112
|
+
|
|
113
|
+
# 查看产物大小
|
|
114
|
+
ls -lh dist/
|
|
115
|
+
|
|
116
|
+
# 输出示例
|
|
117
|
+
# index.js 150KB (ES Module, 支持 tree-shaking)
|
|
118
|
+
# index.umd.cjs 180KB (UMD, 不支持 tree-shaking)
|
|
119
|
+
# index.d.ts 50KB (TypeScript 类型定义)
|
|
120
|
+
# style.css 20KB (所有组件样式)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## 组件
|
|
124
|
+
|
|
125
|
+
### Button 按钮
|
|
126
|
+
|
|
127
|
+
```vue
|
|
128
|
+
<template>
|
|
129
|
+
<Button type="primary" size="medium" @click="handleClick">
|
|
130
|
+
点击按钮
|
|
131
|
+
</Button>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<script setup lang="ts">
|
|
135
|
+
import { Button } from '@gdxx/web-core'
|
|
136
|
+
</script>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
140
|
+
|------|------|--------|------|
|
|
141
|
+
| type | `'primary' \| 'secondary' \| 'danger'` | `'primary'` | 按钮类型 |
|
|
142
|
+
| size | `'small' \| 'medium' \| 'large'` | `'medium'` | 按钮尺寸 |
|
|
143
|
+
| disabled | `boolean` | `false` | 是否禁用 |
|
|
144
|
+
| loading | `boolean` | `false` | 是否加载中 |
|
|
145
|
+
|
|
146
|
+
### Echarts 图表
|
|
147
|
+
|
|
148
|
+
需要安装 `echarts` 依赖。
|
|
149
|
+
|
|
150
|
+
```vue
|
|
151
|
+
<template>
|
|
152
|
+
<Echarts :options="chartOptions" height="400px" @click="handleClick" />
|
|
153
|
+
</template>
|
|
154
|
+
|
|
155
|
+
<script setup lang="ts">
|
|
156
|
+
import { Echarts } from '@gdxx/web-core'
|
|
157
|
+
|
|
158
|
+
const chartOptions = {
|
|
159
|
+
xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed'] },
|
|
160
|
+
yAxis: { type: 'value' },
|
|
161
|
+
series: [{ data: [120, 200, 150], type: 'bar' }]
|
|
162
|
+
}
|
|
163
|
+
</script>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
167
|
+
|------|------|--------|------|
|
|
168
|
+
| options | `EChartsOption` | 必填 | ECharts 配置项 |
|
|
169
|
+
| width | `string` | `'100%'` | 宽度 |
|
|
170
|
+
| height | `string` | `'300px'` | 高度 |
|
|
171
|
+
| theme | `string` | `''` | 主题 |
|
|
172
|
+
|
|
173
|
+
### ScrollContainer 滚动容器
|
|
174
|
+
|
|
175
|
+
自定义滚动条组件。
|
|
176
|
+
|
|
177
|
+
```vue
|
|
178
|
+
<template>
|
|
179
|
+
<ScrollContainer height="300px" direction="y">
|
|
180
|
+
<div>滚动内容...</div>
|
|
181
|
+
</ScrollContainer>
|
|
182
|
+
</template>
|
|
183
|
+
|
|
184
|
+
<script setup lang="ts">
|
|
185
|
+
import { ScrollContainer } from '@gdxx/web-core'
|
|
186
|
+
</script>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
190
|
+
|------|------|--------|------|
|
|
191
|
+
| height | `string \| number` | `'100%'` | 高度 |
|
|
192
|
+
| maxHeight | `string \| number` | - | 最大高度 |
|
|
193
|
+
| direction | `'x' \| 'y' \| 'both'` | `'y'` | 滚动方向 |
|
|
194
|
+
|
|
195
|
+
### STable 表格
|
|
196
|
+
|
|
197
|
+
需要安装 `@surely-vue/table` 和 `ant-design-vue` 依赖。
|
|
198
|
+
|
|
199
|
+
```vue
|
|
200
|
+
<template>
|
|
201
|
+
<STable :columns="columns" :data="loadData" />
|
|
202
|
+
</template>
|
|
203
|
+
|
|
204
|
+
<script setup lang="ts">
|
|
205
|
+
import { STable } from '@gdxx/web-core'
|
|
206
|
+
|
|
207
|
+
const columns = [
|
|
208
|
+
{ title: '姓名', dataIndex: 'name' },
|
|
209
|
+
{ title: '年龄', dataIndex: 'age' }
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
const loadData = async (params) => {
|
|
213
|
+
const res = await fetchData(params)
|
|
214
|
+
return { data: res.list, total: res.total }
|
|
215
|
+
}
|
|
216
|
+
</script>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Hooks
|
|
220
|
+
|
|
221
|
+
### useLoading
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { useLoading } from '@gdxx/web-core'
|
|
225
|
+
|
|
226
|
+
const { loading, startLoading, stopLoading, withLoading } = useLoading()
|
|
227
|
+
|
|
228
|
+
await withLoading(async () => {
|
|
229
|
+
await fetchData()
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### useToggle
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
import { useToggle } from '@gdxx/web-core'
|
|
237
|
+
|
|
238
|
+
const { value, toggle, setTrue, setFalse } = useToggle(false)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## 工具函数
|
|
242
|
+
|
|
243
|
+
### 日期格式化
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
import { formatDate, dateFormat } from '@gdxx/web-core'
|
|
247
|
+
|
|
248
|
+
formatDate(new Date()) // '2026-02-02 10:30:00'
|
|
249
|
+
formatDate('2026-01-01', 'YYYY/MM/DD') // '2026/01/01'
|
|
250
|
+
dateFormat('YY-mm-dd HH:MM:SS', new Date()) // '2026-02-02 10:30:00'
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### 数字处理
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
import { formatNumber, formatFileSize, toFixed, round } from '@gdxx/web-core'
|
|
257
|
+
|
|
258
|
+
formatNumber(1234567.89) // '1,234,567.89'
|
|
259
|
+
formatFileSize(1048576) // '1 MB'
|
|
260
|
+
toFixed(3.1415926, 2) // 3.14 (不四舍五入)
|
|
261
|
+
round(0.7 * 3, 2) // 2.1 (四舍五入,精度安全)
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Storage 封装
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
import { storage, createStorage } from '@gdxx/web-core'
|
|
268
|
+
|
|
269
|
+
storage.set('token', 'xxx', 3600000) // 1小时后过期
|
|
270
|
+
storage.get('token')
|
|
271
|
+
|
|
272
|
+
const myStorage = createStorage('session', { prefix: 'myapp' })
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### 防抖节流
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import { debounce, throttle, createDebounce } from '@gdxx/web-core'
|
|
279
|
+
|
|
280
|
+
// Promise 防抖
|
|
281
|
+
await debounce('search', 300)
|
|
282
|
+
|
|
283
|
+
// 节流函数
|
|
284
|
+
const throttledFn = throttle(fn, 100)
|
|
285
|
+
|
|
286
|
+
// 创建防抖函数
|
|
287
|
+
const debouncedFn = createDebounce(fn, 300)
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### URL 参数
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
import { useUrlParams, updateUrlParams } from '@gdxx/web-core'
|
|
294
|
+
|
|
295
|
+
const params = useUrlParams()
|
|
296
|
+
updateUrlParams({ page: '2' })
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### DOM 操作
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
import { scrollView, setHtmlTitle, print } from '@gdxx/web-core'
|
|
303
|
+
|
|
304
|
+
scrollView('element-id')
|
|
305
|
+
setHtmlTitle('新标题')
|
|
306
|
+
await print('#print-area')
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 加密
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
import { useRsa, useAes, disuseAes } from '@gdxx/web-core'
|
|
313
|
+
|
|
314
|
+
const encrypted = await useRsa('data', publicKey)
|
|
315
|
+
const aesEncrypted = await useAes('data', key)
|
|
316
|
+
const decrypted = await disuseAes(aesEncrypted, key)
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### 页面可见性
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
import { onVisibilityChange } from '@gdxx/web-core'
|
|
323
|
+
|
|
324
|
+
const unsubscribe = onVisibilityChange((hidden) => {
|
|
325
|
+
console.log('页面隐藏:', hidden)
|
|
326
|
+
})
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Excel 导入导出
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
import { importExcel, importExcelAll, exportJsonToExcel } from '@gdxx/web-core'
|
|
333
|
+
|
|
334
|
+
// 导入
|
|
335
|
+
const data = await importExcel(file)
|
|
336
|
+
const allSheets = await importExcelAll(file)
|
|
337
|
+
|
|
338
|
+
// 导出
|
|
339
|
+
await exportJsonToExcel(['姓名', '年龄'], [['张三', 25]], '用户列表')
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### 后端数据解析
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
import { rowSet, pageRowSet } from '@gdxx/web-core'
|
|
346
|
+
|
|
347
|
+
const { colKey, data } = rowSet(result)
|
|
348
|
+
const { colKey, data, total } = pageRowSet(pageResult)
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## 常见问题
|
|
352
|
+
|
|
353
|
+
### 为什么按需引入后打包体积还是很大?
|
|
354
|
+
|
|
355
|
+
1. **检查样式文件**:CSS 是全量加载的,确保只在入口文件导入一次
|
|
356
|
+
2. **检查导入方式**:避免使用 `import * as Core from '@gdxx/web-core'`
|
|
357
|
+
3. **检查生产模式**:确保打包工具运行在生产模式 (`NODE_ENV=production`)
|
|
358
|
+
4. **检查打包配置**:确认 Tree-shaking 已启用
|
|
359
|
+
|
|
360
|
+
### 组件依赖的第三方库会被打包吗?
|
|
361
|
+
|
|
362
|
+
不会。以下依赖被标记为 `external`,不会打包进库中:
|
|
363
|
+
- `vue` (必需)
|
|
364
|
+
- `vue-router` (可选)
|
|
365
|
+
- `echarts` (按需)
|
|
366
|
+
- `ant-design-vue` (按需)
|
|
367
|
+
- `@surely-vue/table` (按需)
|
|
368
|
+
|
|
369
|
+
用户需要在自己的项目中安装这些依赖。
|
|
370
|
+
|
|
371
|
+
### 可以只安装部分依赖吗?
|
|
372
|
+
|
|
373
|
+
可以。例如,如果不使用 `Echarts` 组件,无需安装 `echarts`:
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
# 最小安装
|
|
377
|
+
pnpm add @gdxx/web-core vue
|
|
378
|
+
|
|
379
|
+
# 使用 Echarts 组件
|
|
380
|
+
pnpm add echarts
|
|
381
|
+
|
|
382
|
+
# 使用 STable 组件
|
|
383
|
+
pnpm add ant-design-vue @surely-vue/table
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### TypeScript 类型定义支持按需引用吗?
|
|
387
|
+
|
|
388
|
+
完全支持。所有类型定义都会正确推导:
|
|
389
|
+
|
|
390
|
+
```ts
|
|
391
|
+
import { formatDate } from '@gdxx/web-core'
|
|
392
|
+
// formatDate 函数会有完整的类型提示
|
|
393
|
+
|
|
394
|
+
import type { EchartsProps } from '@gdxx/web-core'
|
|
395
|
+
// 可以单独导入类型
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## 目录结构
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
src/
|
|
402
|
+
├── components/
|
|
403
|
+
│ ├── Button/
|
|
404
|
+
│ ├── Echarts/
|
|
405
|
+
│ ├── ScrollContainer/
|
|
406
|
+
│ └── STable/
|
|
407
|
+
├── hooks/
|
|
408
|
+
│ ├── useLoading.ts
|
|
409
|
+
│ └── useToggle.ts
|
|
410
|
+
├── utils/
|
|
411
|
+
│ ├── format.ts
|
|
412
|
+
│ ├── storage.ts
|
|
413
|
+
│ ├── loadRemote.ts
|
|
414
|
+
│ ├── dom.ts
|
|
415
|
+
│ ├── url.ts
|
|
416
|
+
│ ├── number.ts
|
|
417
|
+
│ ├── async.ts
|
|
418
|
+
│ ├── crypto.ts
|
|
419
|
+
│ ├── visibility.ts
|
|
420
|
+
│ ├── rowSet.ts
|
|
421
|
+
│ └── xlsx.ts
|
|
422
|
+
├── assets/
|
|
423
|
+
└── index.ts
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
## 📚 文档
|
|
427
|
+
|
|
428
|
+
完整文档请查看 [docs/](./docs/) 目录:
|
|
429
|
+
|
|
430
|
+
- **快速开始**
|
|
431
|
+
- [安装指南](./docs/getting-started/installation.md)
|
|
432
|
+
- [快速上手](./docs/getting-started/quick-start.md)
|
|
433
|
+
|
|
434
|
+
- **进阶指南**
|
|
435
|
+
- [按需引用](./docs/guides/tree-shaking.md) - Tree-shaking 优化
|
|
436
|
+
- [TypeScript 支持](./docs/guides/typescript.md)
|
|
437
|
+
- [最佳实践](./docs/guides/best-practices.md)
|
|
438
|
+
|
|
439
|
+
- **发布和部署** ⭐
|
|
440
|
+
- [发布流程完整指南](./docs/deployment/publishing.md)
|
|
441
|
+
- [版本管理规范](./docs/deployment/versioning.md)
|
|
442
|
+
- [发布检查清单](./docs/deployment/checklist.md)
|
|
443
|
+
- [CI/CD 集成](./docs/deployment/ci-cd.md)
|
|
444
|
+
|
|
445
|
+
- **开发指南**
|
|
446
|
+
- [开发环境搭建](./docs/development/setup.md)
|
|
447
|
+
- [贡献指南](./docs/development/contributing.md)
|
|
448
|
+
|
|
449
|
+
## 🚀 开发
|
|
450
|
+
|
|
451
|
+
### 快速开始
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# 安装依赖
|
|
455
|
+
pnpm install
|
|
456
|
+
|
|
457
|
+
# 启动开发服务器(带 playground 预览)
|
|
458
|
+
pnpm dev
|
|
459
|
+
|
|
460
|
+
# 运行测试
|
|
461
|
+
pnpm test
|
|
462
|
+
|
|
463
|
+
# 构建库
|
|
464
|
+
pnpm build
|
|
465
|
+
|
|
466
|
+
# 发布到 npm
|
|
467
|
+
pnpm release:patch # 或 minor、major
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### 发布流程
|
|
471
|
+
|
|
472
|
+
详细的发布指南请查看 [发布流程文档](./docs/deployment/publishing.md)
|
|
473
|
+
|
|
474
|
+
**快速发布**:
|
|
475
|
+
```bash
|
|
476
|
+
# 1. 确保测试通过
|
|
477
|
+
pnpm test:run
|
|
478
|
+
|
|
479
|
+
# 2. 构建
|
|
480
|
+
pnpm build
|
|
481
|
+
|
|
482
|
+
# 3. 发布(自动更新版本号)
|
|
483
|
+
pnpm release:patch # Bug 修复 (0.0.1 -> 0.0.2)
|
|
484
|
+
pnpm release:minor # 新功能 (0.0.2 -> 0.1.0)
|
|
485
|
+
pnpm release:major # 破坏性变更 (0.1.0 -> 1.0.0)
|
|
486
|
+
|
|
487
|
+
# 4. 推送 tag
|
|
488
|
+
git push origin main --tags
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### 目录说明
|
|
492
|
+
|
|
493
|
+
- `src/` - 库源代码
|
|
494
|
+
- `playground/` - 开发预览应用
|
|
495
|
+
- `test/` - 测试文件
|
|
496
|
+
- `dist/` - 构建输出
|
|
497
|
+
|
|
498
|
+
## License
|
|
499
|
+
|
|
500
|
+
MIT
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ECharts, EChartsOption } from 'echarts';
|
|
2
|
+
export interface EchartsProps {
|
|
3
|
+
options: EChartsOption;
|
|
4
|
+
width?: string;
|
|
5
|
+
height?: string;
|
|
6
|
+
theme?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import('vue').DefineComponent<EchartsProps, {
|
|
9
|
+
chartInstance: import('vue').ShallowRef<ECharts | null, ECharts | null>;
|
|
10
|
+
resize: () => void;
|
|
11
|
+
setOption: (option: EChartsOption) => void;
|
|
12
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
13
|
+
click: (params: unknown) => any;
|
|
14
|
+
}, string, import('vue').PublicProps, Readonly<EchartsProps> & Readonly<{
|
|
15
|
+
onClick?: ((params: unknown) => any) | undefined;
|
|
16
|
+
}>, {
|
|
17
|
+
width: string;
|
|
18
|
+
height: string;
|
|
19
|
+
theme: string;
|
|
20
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
21
|
+
chartRef: HTMLDivElement;
|
|
22
|
+
}, HTMLDivElement>;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export interface ColumnItem {
|
|
2
|
+
title?: string;
|
|
3
|
+
dataIndex?: string;
|
|
4
|
+
key?: string;
|
|
5
|
+
align?: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
wch?: number;
|
|
8
|
+
children?: ColumnItem[];
|
|
9
|
+
noExp?: boolean;
|
|
10
|
+
autoHeight?: boolean;
|
|
11
|
+
expRender?: (params: RenderParams) => unknown;
|
|
12
|
+
customRender?: (params: RenderParams) => unknown;
|
|
13
|
+
customRenderExport?: (params: RenderParams) => unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface RenderParams {
|
|
16
|
+
column: ColumnItem;
|
|
17
|
+
index: number;
|
|
18
|
+
record: Record<string, unknown>;
|
|
19
|
+
text: unknown;
|
|
20
|
+
value: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface STableProps {
|
|
23
|
+
columns: ColumnItem[];
|
|
24
|
+
data: (params: DataParams) => Promise<DataResult>;
|
|
25
|
+
pageNum?: number;
|
|
26
|
+
pageSize?: number;
|
|
27
|
+
showPagination?: string | boolean;
|
|
28
|
+
pageSizeOptions?: string[];
|
|
29
|
+
rowAutoHeight?: boolean;
|
|
30
|
+
exportName?: string | number;
|
|
31
|
+
showIndex?: boolean;
|
|
32
|
+
enableContextExport?: boolean;
|
|
33
|
+
rowKey?: string | ((record: Record<string, unknown>) => string);
|
|
34
|
+
}
|
|
35
|
+
export interface DataParams {
|
|
36
|
+
pageNo: number;
|
|
37
|
+
pageSize: number;
|
|
38
|
+
export?: boolean;
|
|
39
|
+
sortField?: string;
|
|
40
|
+
sortOrder?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
export interface DataResult {
|
|
44
|
+
data?: Record<string, unknown>[];
|
|
45
|
+
rows?: Record<string, unknown>[];
|
|
46
|
+
total?: number;
|
|
47
|
+
totalCount?: number;
|
|
48
|
+
}
|
|
49
|
+
interface Pagination {
|
|
50
|
+
current: number;
|
|
51
|
+
pageSize: number;
|
|
52
|
+
}
|
|
53
|
+
interface Sorter {
|
|
54
|
+
field?: string;
|
|
55
|
+
order?: string;
|
|
56
|
+
}
|
|
57
|
+
declare function __VLS_template(): {
|
|
58
|
+
attrs: Partial<{}>;
|
|
59
|
+
slots: any;
|
|
60
|
+
refs: {};
|
|
61
|
+
rootEl: any;
|
|
62
|
+
};
|
|
63
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
64
|
+
declare const __VLS_component: import('vue').DefineComponent<STableProps, {
|
|
65
|
+
_columns: ColumnItem[];
|
|
66
|
+
getEl: () => Promise<HTMLElement>;
|
|
67
|
+
getData: () => Record<string, unknown>[];
|
|
68
|
+
getPageData: (num?: number) => Record<string, unknown>[];
|
|
69
|
+
refresh: (bool?: boolean) => void;
|
|
70
|
+
loadData: (pagination?: Partial<Pagination & {
|
|
71
|
+
export?: boolean;
|
|
72
|
+
}>, filters?: Record<string, unknown>, sorter?: Sorter) => Promise<DataResult | undefined>;
|
|
73
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
74
|
+
change: (pagination: Pagination, filters: unknown, sorter: Sorter, ...rest: unknown[]) => any;
|
|
75
|
+
"update:pageNum": (value: number) => any;
|
|
76
|
+
"update:pageSize": (value: number) => any;
|
|
77
|
+
"export-page": () => any;
|
|
78
|
+
"export-all": () => any;
|
|
79
|
+
}, string, import('vue').PublicProps, Readonly<STableProps> & Readonly<{
|
|
80
|
+
onChange?: ((pagination: Pagination, filters: unknown, sorter: Sorter, ...rest: unknown[]) => any) | undefined;
|
|
81
|
+
"onUpdate:pageNum"?: ((value: number) => any) | undefined;
|
|
82
|
+
"onUpdate:pageSize"?: ((value: number) => any) | undefined;
|
|
83
|
+
"onExport-page"?: (() => any) | undefined;
|
|
84
|
+
"onExport-all"?: (() => any) | undefined;
|
|
85
|
+
}>, {
|
|
86
|
+
pageSize: number;
|
|
87
|
+
rowKey: string | ((record: Record<string, unknown>) => string);
|
|
88
|
+
pageNum: number;
|
|
89
|
+
showPagination: string | boolean;
|
|
90
|
+
pageSizeOptions: string[];
|
|
91
|
+
rowAutoHeight: boolean;
|
|
92
|
+
exportName: string | number;
|
|
93
|
+
showIndex: boolean;
|
|
94
|
+
enableContextExport: boolean;
|
|
95
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
96
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
97
|
+
export default _default;
|
|
98
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
99
|
+
new (): {
|
|
100
|
+
$slots: S;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface ScrollContainerProps {
|
|
2
|
+
height?: string | number;
|
|
3
|
+
maxHeight?: string | number;
|
|
4
|
+
direction?: 'x' | 'y' | 'both';
|
|
5
|
+
wrapClass?: string;
|
|
6
|
+
viewClass?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function __VLS_template(): {
|
|
9
|
+
attrs: Partial<{}>;
|
|
10
|
+
slots: {
|
|
11
|
+
default?(_: {}): any;
|
|
12
|
+
};
|
|
13
|
+
refs: {
|
|
14
|
+
wrapRef: HTMLDivElement;
|
|
15
|
+
viewRef: HTMLDivElement;
|
|
16
|
+
};
|
|
17
|
+
rootEl: HTMLDivElement;
|
|
18
|
+
};
|
|
19
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
20
|
+
declare const __VLS_component: import('vue').DefineComponent<ScrollContainerProps, {
|
|
21
|
+
update: () => void;
|
|
22
|
+
scrollTo: (options: ScrollToOptions) => void;
|
|
23
|
+
setScrollTop: (top: number) => void;
|
|
24
|
+
setScrollLeft: (left: number) => void;
|
|
25
|
+
getScrollWrap: () => HTMLDivElement | null;
|
|
26
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ScrollContainerProps> & Readonly<{}>, {
|
|
27
|
+
height: string | number;
|
|
28
|
+
maxHeight: string | number;
|
|
29
|
+
direction: "x" | "y" | "both";
|
|
30
|
+
wrapClass: string;
|
|
31
|
+
viewClass: string;
|
|
32
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
33
|
+
wrapRef: HTMLDivElement;
|
|
34
|
+
viewRef: HTMLDivElement;
|
|
35
|
+
}, HTMLDivElement>;
|
|
36
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
37
|
+
export default _default;
|
|
38
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
39
|
+
new (): {
|
|
40
|
+
$slots: S;
|
|
41
|
+
};
|
|
42
|
+
};
|