xt-element-ui 1.2.5 → 1.2.7
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/CHANGELOG.md +72 -0
- package/LICENSE +21 -0
- package/README.md +240 -104
- package/docs/README.md +67 -168
- package/docs/components/base/xt-card-item.md +1 -1
- package/docs/components/base/xt-step-price.md +280 -0
- package/docs/components/base/xt-time.md +165 -0
- package/docs/components/extend/ex-chart.md +252 -144
- package/docs/components/extend/ex-date-picker.md +0 -0
- package/docs/components/extend/ex-icon.md +1 -2
- package/docs/components/extend/ex-page.md +0 -75
- package/lib/index.common.js +1172 -586
- package/lib/index.css +1 -1
- package/lib/index.umd.js +1172 -586
- package/lib/index.umd.min.js +5 -5
- package/package.json +80 -41
- package/src/components/ex-chart/ExBar.vue +35 -29
- package/src/components/ex-chart/ExLine.vue +23 -14
- package/src/components/ex-chart/ExMulti.vue +30 -52
- package/src/components/ex-chart/ExPie.vue +23 -16
- package/src/components/ex-chart/theme/dark.js +5 -4
- package/src/components/ex-chart/theme/white.js +1 -0
- package/src/components/ex-chart/utils.js +148 -7
- package/src/components/ex-date-picker/index.js +2 -0
- package/src/components/{xt-date-picker → ex-date-picker}/index.vue +1 -1
- package/src/components/index.scss +6 -0
- package/src/components/xt-card-item/index.vue +3 -1
- package/src/components/xt-step-price/index.js +2 -0
- package/src/components/xt-step-price/index.vue +270 -0
- package/src/components/xt-step-price/style/index.scss +115 -0
- package/src/components/xt-step-price-item/index.js +2 -0
- package/src/components/xt-step-price-item/index.vue +174 -0
- package/src/components/xt-time/index.js +2 -0
- package/src/components/xt-time/index.vue +313 -0
- package/src/components/xt-time/style/index.scss +23 -0
- package/src/index.js +12 -3
- package/src/components/ex-chart/theme/blue.js +0 -91
- package/src/components/ex-chart/theme/orange.js +0 -92
- package/src/components/ex-chart/theme/starry.js +0 -106
- package/src/components/xt-date-picker/index.js +0 -2
- /package/src/components/{xt-date-picker → ex-date-picker}/SearchDate.vue +0 -0
- /package/src/components/{xt-date-picker → ex-date-picker}/quarter.vue +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
## XtTime 时间组件
|
|
2
|
+
|
|
3
|
+
集三种模式于一身的时间组件:当前时间实时显示、目标时间倒计时、日期文本格式化展示。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
### 三种显示模式
|
|
8
|
+
|
|
9
|
+
::: demo 三种显示模式
|
|
10
|
+
```vue
|
|
11
|
+
<template>
|
|
12
|
+
<div style="display: flex; flex-direction: column; gap: 12px;">
|
|
13
|
+
<div>当前时间:<XtTime type="now" /></div>
|
|
14
|
+
<div>距 2026-12-31:<XtTime type="countdown" target-time="2026-12-31 23:59:59" /></div>
|
|
15
|
+
<div>创建时间:<XtTime type="text" :value="1704067200000" /></div>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
```
|
|
19
|
+
:::
|
|
20
|
+
|
|
21
|
+
## 属性说明
|
|
22
|
+
|
|
23
|
+
### 通用属性
|
|
24
|
+
|
|
25
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
26
|
+
|------|------|--------|--------|------|
|
|
27
|
+
| `type` | String | `now` | `now`、`countdown`、`text` | 显示模式 |
|
|
28
|
+
| `format` | String | `YYYY-MM-DD HH:mm:ss` | - | `now` / `text` 模式下的日期格式 |
|
|
29
|
+
| `size` | String | base | `extra-large`、`large`、`medium`、`base`、`small`、`extra-small` | 字体大小 |
|
|
30
|
+
| `type-color` | String | - | `primary`、`success`、`warning`、`danger` | 颜色语义 |
|
|
31
|
+
| `bold` | Boolean | false | - | 是否加粗 |
|
|
32
|
+
| `prefix` | String | - | - | 前缀文本 |
|
|
33
|
+
| `suffix` | String | - | - | 后缀文本 |
|
|
34
|
+
| `empty-text` | String | `-` | - | 空值/无效值时展示的占位文本 |
|
|
35
|
+
| `hide-empty` | Boolean | false | - | 值为空时是否不渲染内容 |
|
|
36
|
+
| `interval` | Number | `1000` | `>= 100` | 刷新间隔(毫秒),仅 `now` / `countdown` 生效 |
|
|
37
|
+
|
|
38
|
+
### text 模式专属属性
|
|
39
|
+
|
|
40
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
41
|
+
|------|------|--------|------|
|
|
42
|
+
| `value` | String / Number / Date | - | 待格式化的日期值,支持时间戳(10 位秒或 13 位毫秒)、Date 对象、`2024-01-01 12:00:00` 等字符串 |
|
|
43
|
+
|
|
44
|
+
### countdown 模式专属属性
|
|
45
|
+
|
|
46
|
+
| 属性 | 类型 | 默认值 | 可选值 | 说明 |
|
|
47
|
+
|------|------|--------|--------|------|
|
|
48
|
+
| `target-time` | String / Number / Date | - | - | 目标时间,取值同 `value` |
|
|
49
|
+
| `countdown-format` | String | `DHMS` | `DHMS`、`HMS`、`MS`、`SEC` | 倒计时显示格式 |
|
|
50
|
+
| `finished-text` | String | `已结束` | - | 倒计时结束后显示的文本 |
|
|
51
|
+
|
|
52
|
+
## 事件
|
|
53
|
+
|
|
54
|
+
| 事件名 | 说明 | 参数 |
|
|
55
|
+
|--------|------|------|
|
|
56
|
+
| `finish` | 倒计时结束触发(仅 `countdown` 模式) | - |
|
|
57
|
+
| `click` | 点击组件触发 | `(event: MouseEvent)` |
|
|
58
|
+
|
|
59
|
+
## 插槽
|
|
60
|
+
|
|
61
|
+
| 插槽 | 说明 |
|
|
62
|
+
|------|------|
|
|
63
|
+
| `prefix` | 前缀插槽,优先级高于 `prefix` 属性 |
|
|
64
|
+
| `suffix` | 后缀插槽,优先级高于 `suffix` 属性 |
|
|
65
|
+
| `finished` | 倒计时结束态自定义内容(仅 `countdown` 模式) |
|
|
66
|
+
| `default` | 自定义整体内容,覆盖默认渲染 |
|
|
67
|
+
|
|
68
|
+
## 示例
|
|
69
|
+
|
|
70
|
+
### 当前时间(now 模式)
|
|
71
|
+
|
|
72
|
+
::: demo 当前时间
|
|
73
|
+
```vue
|
|
74
|
+
<template>
|
|
75
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
76
|
+
<XtTime type="now" />
|
|
77
|
+
<XtTime type="now" format="YYYY年MM月DD日 HH时mm分ss秒" type-color="primary" bold />
|
|
78
|
+
<XtTime type="now" format="HH:mm:ss" size="extra-large" type-color="danger" />
|
|
79
|
+
</div>
|
|
80
|
+
</template>
|
|
81
|
+
```
|
|
82
|
+
:::
|
|
83
|
+
|
|
84
|
+
### 日期文本(text 模式)
|
|
85
|
+
|
|
86
|
+
`value` 支持时间戳、字符串、Date 对象,自动识别并格式化:
|
|
87
|
+
|
|
88
|
+
::: demo 日期文本
|
|
89
|
+
```vue
|
|
90
|
+
<template>
|
|
91
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
92
|
+
<XtTime type="text" value="2024-01-01 12:00:00" />
|
|
93
|
+
<XtTime type="text" :value="1704067200" format="YYYY-MM-DD" />
|
|
94
|
+
<XtTime type="text" :value="new Date('2024-06-15')" format="YYYY/MM/DD" />
|
|
95
|
+
<XtTime type="text" value="无效值" />
|
|
96
|
+
<XtTime type="text" value="2024-01-01" prefix="创建于 " type-color="success" />
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
```
|
|
100
|
+
:::
|
|
101
|
+
|
|
102
|
+
### 倒计时(countdown 模式)
|
|
103
|
+
|
|
104
|
+
::: demo 倒计时
|
|
105
|
+
```vue
|
|
106
|
+
<template>
|
|
107
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
108
|
+
<XtTime type="countdown" target-time="2026-12-31 23:59:59" />
|
|
109
|
+
<XtTime type="countdown" target-time="2026-12-31 23:59:59" countdown-format="HMS" type-color="primary" />
|
|
110
|
+
<XtTime type="countdown" target-time="2026-12-31 23:59:59" countdown-format="MS" />
|
|
111
|
+
<XtTime type="countdown" target-time="2026-12-31 23:59:59" countdown-format="SEC" suffix="后结束" />
|
|
112
|
+
<XtTime
|
|
113
|
+
type="countdown"
|
|
114
|
+
:target-time="Date.now() + 5000"
|
|
115
|
+
@finish="onFinish"
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</template>
|
|
119
|
+
|
|
120
|
+
<script>
|
|
121
|
+
export default {
|
|
122
|
+
methods: {
|
|
123
|
+
onFinish() {
|
|
124
|
+
this.$message && this.$message('倒计时结束!')
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
```
|
|
130
|
+
:::
|
|
131
|
+
|
|
132
|
+
### 自定义结束态(finished 插槽)
|
|
133
|
+
|
|
134
|
+
::: demo 自定义结束态
|
|
135
|
+
```vue
|
|
136
|
+
<template>
|
|
137
|
+
<XtTime type="countdown" :target-time="Date.now() + 3000">
|
|
138
|
+
<template #finished>
|
|
139
|
+
<span style="color: #67c23a;">🎉 活动已开始,欢迎参加</span>
|
|
140
|
+
</template>
|
|
141
|
+
</XtTime>
|
|
142
|
+
</template>
|
|
143
|
+
```
|
|
144
|
+
:::
|
|
145
|
+
|
|
146
|
+
### 前缀 / 后缀
|
|
147
|
+
|
|
148
|
+
::: demo 前缀后缀
|
|
149
|
+
```vue
|
|
150
|
+
<template>
|
|
151
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
152
|
+
<XtTime type="now" prefix="当前时间:" />
|
|
153
|
+
<XtTime type="countdown" target-time="2026-12-31 23:59:59" suffix=" 后截止" type-color="warning" />
|
|
154
|
+
<XtTime type="text" value="2024-01-01 08:00:00" prefix="入职日期:" suffix="(周一)" />
|
|
155
|
+
</div>
|
|
156
|
+
</template>
|
|
157
|
+
```
|
|
158
|
+
:::
|
|
159
|
+
|
|
160
|
+
## 注意事项
|
|
161
|
+
|
|
162
|
+
- `value` / `target-time` 对**纯数字时间戳**自动识别:10 位数字视作秒级时间戳,13 位数字视作毫秒级时间戳。
|
|
163
|
+
- `countdown` 模式下组件销毁、切出 `keep-alive` 缓存时会自动清理定时器,避免内存泄漏。
|
|
164
|
+
- `type` 从 `now`/`countdown` 切换为 `text`(或反向),组件会自动重置定时器。
|
|
165
|
+
- 如需不同的时区展示,可在父组件中将 `value` 先转换为本地时区 Date 对象再传入。
|