xt-element-ui 1.2.3 → 1.2.5
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/docs/README.md +201 -0
- package/docs/components/base/xt-button.md +114 -0
- package/docs/components/base/xt-card-item.md +104 -0
- package/docs/components/base/xt-card.md +108 -0
- package/docs/components/base/xt-config-provider.md +199 -0
- package/docs/components/base/xt-flex-box.md +115 -0
- package/docs/components/base/xt-grid-box.md +303 -0
- package/docs/components/base/xt-input.md +150 -0
- package/docs/components/base/xt-text.md +212 -0
- package/docs/components/extend/ex-bar.md +68 -0
- package/docs/components/extend/ex-button.md +62 -0
- package/docs/components/extend/ex-card.md +86 -0
- package/docs/components/extend/ex-chart.md +355 -0
- package/docs/components/extend/ex-icon.md +190 -0
- package/docs/components/extend/ex-line.md +71 -0
- package/docs/components/extend/ex-multi.md +156 -0
- package/docs/components/extend/ex-page.md +75 -0
- package/docs/components/extend/ex-pie.md +70 -0
- package/docs/components/extend/ex-select-tree.md +210 -0
- package/docs/components/extend/ex-table.md +591 -0
- package/docs/components/extend/ex-upload.md +134 -0
- package/docs/components/utils/size.md +148 -0
- package/docs/components/utils/theme.md +183 -0
- package/lib/index.common.js +449 -429
- package/lib/index.css +1 -1
- package/lib/index.umd.js +449 -429
- package/lib/index.umd.min.js +4 -4
- package/package.json +4 -2
- package/src/components/ex-chart/ExMulti.vue +44 -32
- package/src/components/ex-chart/ExPie.vue +6 -8
- package/src/components/ex-chart/index.vue +1 -4
- package/src/components/ex-chart/theme/dark.js +14 -12
- package/src/components/ex-chart/utils.js +1 -1
- package/src/components/ex-icon/index.js +2 -0
- package/src/components/ex-icon/index.vue +168 -0
- package/src/components/ex-icon/style/index.scss +7 -0
- package/src/components/ex-table/index.vue +3 -3
- package/src/components/index.scss +4 -1
- package/src/components/xt-button/index.vue +2 -2
- package/src/components/xt-button/style/index.scss +524 -614
- package/src/components/xt-card-item/images/bar.svg +1 -0
- package/src/components/xt-card-item/images/line.svg +1 -0
- package/src/components/xt-card-item/images/pie.svg +1 -0
- package/src/components/xt-card-item/index copy.vue +93 -0
- package/src/components/xt-card-item/index.vue +23 -83
- package/src/components/xt-card-item/style/index copy.scss +72 -0
- package/src/components/xt-card-item/style/index.scss +51 -40
- package/src/components/xt-config-provider/index.vue +2 -2
- package/src/components/xt-text/index.vue +58 -29
- package/src/index.js +3 -0
- package/src/components/ex-chart/ExTrend.vue +0 -124
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
## ExUpload 图片上传
|
|
2
|
+
|
|
3
|
+
基于 ElementUI `el-upload` 封装,支持图片上传、预览、删除,以及多图管理。
|
|
4
|
+
|
|
5
|
+
## 基础用法
|
|
6
|
+
|
|
7
|
+
设置 `action` 为上传接口路径,`base-url` 为图片基础地址,`v-model` 绑定逗号分隔的图片路径字符串:
|
|
8
|
+
|
|
9
|
+
::: demo 图片上传基础示例
|
|
10
|
+
```vue
|
|
11
|
+
<template>
|
|
12
|
+
<ex-upload
|
|
13
|
+
v-model="imgList"
|
|
14
|
+
action="/api/upload"
|
|
15
|
+
base-url="https://example.com"
|
|
16
|
+
/>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
data() {
|
|
22
|
+
return {
|
|
23
|
+
imgList: ''
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
```
|
|
29
|
+
:::
|
|
30
|
+
|
|
31
|
+
## 多图上传
|
|
32
|
+
|
|
33
|
+
设置 `multiple` 开启多图上传,通过 `limit` 限制最多上传数量:
|
|
34
|
+
|
|
35
|
+
::: demo 多图上传示例
|
|
36
|
+
```vue
|
|
37
|
+
<template>
|
|
38
|
+
<ex-upload
|
|
39
|
+
v-model="imgList"
|
|
40
|
+
action="/api/upload"
|
|
41
|
+
base-url="https://example.com"
|
|
42
|
+
multiple
|
|
43
|
+
:limit="5"
|
|
44
|
+
/>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script>
|
|
48
|
+
export default {
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
imgList: ''
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
:::
|
|
58
|
+
|
|
59
|
+
## 图片大小
|
|
60
|
+
|
|
61
|
+
通过 `size` 属性设置显示尺寸:
|
|
62
|
+
|
|
63
|
+
::: demo 图片尺寸示例
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<div>
|
|
67
|
+
<ex-upload v-model="img" action="/api/upload" base-url="https://example.com" />
|
|
68
|
+
<div style="margin-top: 20px">
|
|
69
|
+
<ex-upload v-model="img" action="/api/upload" base-url="https://example.com" size="big" />
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
export default {
|
|
76
|
+
data() {
|
|
77
|
+
return {
|
|
78
|
+
img: ''
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
:::
|
|
85
|
+
|
|
86
|
+
## 禁用状态
|
|
87
|
+
|
|
88
|
+
`disabled` 属性可禁用上传和删除功能:
|
|
89
|
+
|
|
90
|
+
::: demo 禁用上传示例
|
|
91
|
+
```vue
|
|
92
|
+
<template>
|
|
93
|
+
<ex-upload
|
|
94
|
+
v-model="img"
|
|
95
|
+
action="/api/upload"
|
|
96
|
+
base-url="https://example.com"
|
|
97
|
+
disabled
|
|
98
|
+
/>
|
|
99
|
+
</template>
|
|
100
|
+
|
|
101
|
+
<script>
|
|
102
|
+
export default {
|
|
103
|
+
data() {
|
|
104
|
+
return {
|
|
105
|
+
img: 'demo.jpg'
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
</script>
|
|
110
|
+
```
|
|
111
|
+
:::
|
|
112
|
+
|
|
113
|
+
## Attributes
|
|
114
|
+
|
|
115
|
+
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
116
|
+
|------|------|------|--------|--------|
|
|
117
|
+
| src | 当前图片列表,以英文逗号分隔(v-model) | string | — | '' |
|
|
118
|
+
| action | 上传接口路径,与 base-url 拼接 | string | — | '' |
|
|
119
|
+
| base-url | 图片基础地址(服务端域名) | string | — | '' |
|
|
120
|
+
| multiple | 是否支持多选 | boolean | — | false |
|
|
121
|
+
| limit | 最多上传数量 | number | — | 5 |
|
|
122
|
+
| accept | 允许的文件类型 | string | — | .jpg,.jpeg,.png |
|
|
123
|
+
| auto-upload | 是否在选取文件后立即上传 | boolean | — | true |
|
|
124
|
+
| disabled | 是否禁用 | boolean | — | false |
|
|
125
|
+
| size | 图片展示尺寸 | string | big | — |
|
|
126
|
+
| data | 上传时附带的额外参数 | object | — | {} |
|
|
127
|
+
| all-file-list | 用于图库预览的图片列表 | array | — | — |
|
|
128
|
+
| before-emit-data | 对上传结果进行处理的回调函数,返回 `false` 代表上传失败 | function(res, file, type) | — | (内部函数) |
|
|
129
|
+
|
|
130
|
+
## Events
|
|
131
|
+
|
|
132
|
+
| 事件名 | 说明 | 回调参数 |
|
|
133
|
+
|--------|------|----------|
|
|
134
|
+
| change | 图片列表变化时触发 | 以英文逗号分隔的图片路径字符串 |
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
## 字体大小配置
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
通过工具函数可以全局设置组件的字体大小,支持三种预设尺寸:`small`、`medium`、`large`。
|
|
6
|
+
|
|
7
|
+
## 方法说明
|
|
8
|
+
|
|
9
|
+
### setSize(size)
|
|
10
|
+
|
|
11
|
+
设置全局字体大小。
|
|
12
|
+
|
|
13
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
14
|
+
|------|------|------|------|
|
|
15
|
+
| `size` | String | 是 | 字体大小:`small`、`medium`、`large` |
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div>
|
|
20
|
+
<XtButton @click="setSmall">小号字体</XtButton>
|
|
21
|
+
<XtButton @click="setMedium">中号字体</XtButton>
|
|
22
|
+
<XtButton @click="setLarge">大号字体</XtButton>
|
|
23
|
+
</div>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import { setSize } from 'xt-element-ui'
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
methods: {
|
|
31
|
+
setSmall() {
|
|
32
|
+
setSize('small')
|
|
33
|
+
},
|
|
34
|
+
setMedium() {
|
|
35
|
+
setSize('medium')
|
|
36
|
+
},
|
|
37
|
+
setLarge() {
|
|
38
|
+
setSize('large')
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### getSize()
|
|
46
|
+
|
|
47
|
+
获取当前字体大小配置。
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<template>
|
|
51
|
+
<div>
|
|
52
|
+
<XtText>当前字体大小:{{ currentSize }}</XtText>
|
|
53
|
+
</div>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
import { getSize } from 'xt-element-ui'
|
|
58
|
+
|
|
59
|
+
export default {
|
|
60
|
+
computed: {
|
|
61
|
+
currentSize() {
|
|
62
|
+
return getSize()
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 字体大小对照表
|
|
70
|
+
|
|
71
|
+
| 尺寸 | 说明 |
|
|
72
|
+
|------|------|
|
|
73
|
+
| `small` | 小号字体,默认值 |
|
|
74
|
+
| `medium` | 中号字体 |
|
|
75
|
+
| `large` | 大号字体,适合大屏展示 |
|
|
76
|
+
|
|
77
|
+
## 使用示例
|
|
78
|
+
|
|
79
|
+
### 在组件安装时配置
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import XtElementUI from 'xt-element-ui'
|
|
83
|
+
|
|
84
|
+
Vue.use(XtElementUI, {
|
|
85
|
+
size: 'large' // 全局设置大号字体
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 动态切换字体大小
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<template>
|
|
93
|
+
<div>
|
|
94
|
+
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
95
|
+
<XtButton
|
|
96
|
+
v-for="size in sizes"
|
|
97
|
+
:key="size"
|
|
98
|
+
:type="currentSize === size ? 'primary' : ''"
|
|
99
|
+
@click="changeSize(size)"
|
|
100
|
+
>
|
|
101
|
+
{{ sizeLabels[size] }}
|
|
102
|
+
</XtButton>
|
|
103
|
+
</XtFlexBox>
|
|
104
|
+
|
|
105
|
+
<XtCard>
|
|
106
|
+
<XtCardItem title="当前尺寸">
|
|
107
|
+
<XtText type="primary" bold>{{ currentSize }}</XtText>
|
|
108
|
+
</XtCardItem>
|
|
109
|
+
<XtCardItem title="示例文本">
|
|
110
|
+
<XtText>这是一段示例文本,用于展示字体大小效果。</XtText>
|
|
111
|
+
</XtCardItem>
|
|
112
|
+
</XtCard>
|
|
113
|
+
</div>
|
|
114
|
+
</template>
|
|
115
|
+
|
|
116
|
+
<script>
|
|
117
|
+
import { setSize, getSize } from 'xt-element-ui'
|
|
118
|
+
|
|
119
|
+
export default {
|
|
120
|
+
data() {
|
|
121
|
+
return {
|
|
122
|
+
sizes: ['small', 'medium', 'large'],
|
|
123
|
+
sizeLabels: {
|
|
124
|
+
small: '小号',
|
|
125
|
+
medium: '中号',
|
|
126
|
+
large: '大号'
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
computed: {
|
|
131
|
+
currentSize() {
|
|
132
|
+
return getSize()
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
methods: {
|
|
136
|
+
changeSize(size) {
|
|
137
|
+
setSize(size)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
</script>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 注意事项
|
|
145
|
+
|
|
146
|
+
1. 字体大小设置会影响所有使用组件库样式的元素
|
|
147
|
+
2. 设置后会在 `html` 标签上添加 `data-size` 属性
|
|
148
|
+
3. 需要配合对应的 CSS 样式才能生效
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
## 主题配置
|
|
2
|
+
|
|
3
|
+
## 概述
|
|
4
|
+
|
|
5
|
+
通过工具函数可以全局设置主题模式,支持两种主题:`white`(亮色主题)和 `dark`(暗色主题)。
|
|
6
|
+
|
|
7
|
+
## 方法说明
|
|
8
|
+
|
|
9
|
+
### setTheme(theme)
|
|
10
|
+
|
|
11
|
+
设置全局主题。
|
|
12
|
+
|
|
13
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
14
|
+
|------|------|------|------|
|
|
15
|
+
| `theme` | String | 是 | 主题类型:`white`、`dark` |
|
|
16
|
+
|
|
17
|
+
```vue
|
|
18
|
+
<template>
|
|
19
|
+
<div>
|
|
20
|
+
<XtButton @click="setWhiteTheme">亮色主题</XtButton>
|
|
21
|
+
<XtButton @click="setDarkTheme">暗色主题</XtButton>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
import { setTheme } from 'xt-element-ui'
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
methods: {
|
|
30
|
+
setWhiteTheme() {
|
|
31
|
+
setTheme('white')
|
|
32
|
+
},
|
|
33
|
+
setDarkTheme() {
|
|
34
|
+
setTheme('dark')
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### getTheme()
|
|
42
|
+
|
|
43
|
+
获取当前主题配置。
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<template>
|
|
47
|
+
<div>
|
|
48
|
+
<XtText>当前主题:{{ currentTheme }}</XtText>
|
|
49
|
+
</div>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import { getTheme } from 'xt-element-ui'
|
|
54
|
+
|
|
55
|
+
export default {
|
|
56
|
+
computed: {
|
|
57
|
+
currentTheme() {
|
|
58
|
+
return getTheme()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 主题对照表
|
|
66
|
+
|
|
67
|
+
| 主题 | 说明 |
|
|
68
|
+
|------|------|
|
|
69
|
+
| `white` | 亮色主题,适合日间使用(默认值) |
|
|
70
|
+
| `dark` | 暗色主题,适合夜间使用 |
|
|
71
|
+
|
|
72
|
+
## 使用示例
|
|
73
|
+
|
|
74
|
+
### 在组件安装时配置
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
import XtElementUI from 'xt-element-ui'
|
|
78
|
+
|
|
79
|
+
Vue.use(XtElementUI, {
|
|
80
|
+
theme: 'dark' // 全局设置暗色主题
|
|
81
|
+
})
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 动态切换主题
|
|
85
|
+
|
|
86
|
+
```vue
|
|
87
|
+
<template>
|
|
88
|
+
<div>
|
|
89
|
+
<XtFlexBox content="center" style="gap: 16px; margin-bottom: 16px;">
|
|
90
|
+
<XtButton
|
|
91
|
+
v-for="theme in themes"
|
|
92
|
+
:key="theme"
|
|
93
|
+
:type="currentTheme === theme ? 'primary' : ''"
|
|
94
|
+
@click="changeTheme(theme)"
|
|
95
|
+
>
|
|
96
|
+
{{ themeLabels[theme] }}
|
|
97
|
+
</XtButton>
|
|
98
|
+
</XtFlexBox>
|
|
99
|
+
|
|
100
|
+
<XtCard>
|
|
101
|
+
<XtCardItem title="当前主题">
|
|
102
|
+
<XtText type="primary" bold>{{ themeLabels[currentTheme] }}</XtText>
|
|
103
|
+
</XtCardItem>
|
|
104
|
+
<XtCardItem title="主题状态">
|
|
105
|
+
<XtText :type="currentTheme === 'dark' ? 'warning' : 'success'">
|
|
106
|
+
{{ currentTheme === 'dark' ? '暗色模式已开启' : '亮色模式已开启' }}
|
|
107
|
+
</XtText>
|
|
108
|
+
</XtCardItem>
|
|
109
|
+
</XtCard>
|
|
110
|
+
</div>
|
|
111
|
+
</template>
|
|
112
|
+
|
|
113
|
+
<script>
|
|
114
|
+
import { setTheme, getTheme } from 'xt-element-ui'
|
|
115
|
+
|
|
116
|
+
export default {
|
|
117
|
+
data() {
|
|
118
|
+
return {
|
|
119
|
+
themes: ['white', 'dark'],
|
|
120
|
+
themeLabels: {
|
|
121
|
+
white: '亮色',
|
|
122
|
+
dark: '暗色'
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
computed: {
|
|
127
|
+
currentTheme() {
|
|
128
|
+
return getTheme()
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
methods: {
|
|
132
|
+
changeTheme(theme) {
|
|
133
|
+
setTheme(theme)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
</script>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 监听主题变化
|
|
141
|
+
|
|
142
|
+
```vue
|
|
143
|
+
<template>
|
|
144
|
+
<div>
|
|
145
|
+
<XtText>主题变化次数:{{ changeCount }}</XtText>
|
|
146
|
+
</div>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<script>
|
|
150
|
+
import { onConfigChange } from 'xt-element-ui'
|
|
151
|
+
|
|
152
|
+
export default {
|
|
153
|
+
data() {
|
|
154
|
+
return {
|
|
155
|
+
changeCount: 0,
|
|
156
|
+
unsubscribe: null
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
mounted() {
|
|
160
|
+
// 监听主题变化
|
|
161
|
+
this.unsubscribe = onConfigChange((key, value) => {
|
|
162
|
+
if (key === 'theme') {
|
|
163
|
+
this.changeCount++
|
|
164
|
+
console.log('主题已切换为:', value)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
},
|
|
168
|
+
beforeDestroy() {
|
|
169
|
+
// 取消监听
|
|
170
|
+
if (this.unsubscribe) {
|
|
171
|
+
this.unsubscribe()
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
</script>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 注意事项
|
|
179
|
+
|
|
180
|
+
1. 主题切换会影响所有使用组件库样式的元素
|
|
181
|
+
2. 设置后会在 `html` 标签上添加/移除 `data-theme="dark"` 属性
|
|
182
|
+
3. 需要配合对应的暗色主题 CSS 样式才能生效
|
|
183
|
+
4. 建议在应用初始化时设置主题,可以结合用户偏好存储(如 localStorage)
|