x-next 1.13.0 → 1.15.0
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/AI_CODING.md +6 -5
- package/AI_USAGE/catalog.md +108 -105
- package/AI_USAGE/components/alert-api.md +48 -0
- package/AI_USAGE/components/alert.md +222 -3
- package/AI_USAGE/components/bar-chart-api.md +177 -0
- package/AI_USAGE/components/bar-chart.md +297 -3
- package/AI_USAGE/components/boxicons.md +147 -0
- package/AI_USAGE/components/button-api.md +144 -0
- package/AI_USAGE/components/button.md +447 -3
- package/AI_USAGE/components/charts.md +81 -0
- package/AI_USAGE/components/checkbox-api.md +145 -0
- package/AI_USAGE/components/checkbox.md +365 -3
- package/AI_USAGE/components/color-picker-api.md +52 -0
- package/AI_USAGE/components/color-picker.md +211 -3
- package/AI_USAGE/components/config-provider-api.md +38 -0
- package/AI_USAGE/components/config-provider.md +250 -3
- package/AI_USAGE/components/date-picker-api.md +1114 -0
- package/AI_USAGE/components/date-picker.md +378 -3
- package/AI_USAGE/components/dialog-api.md +142 -0
- package/AI_USAGE/components/dialog.md +284 -3
- package/AI_USAGE/components/draggable-api.md +146 -0
- package/AI_USAGE/components/draggable.md +259 -0
- package/AI_USAGE/components/drawer-api.md +78 -0
- package/AI_USAGE/components/drawer.md +256 -0
- package/AI_USAGE/components/dropdown-api.md +529 -0
- package/AI_USAGE/components/dropdown.md +392 -3
- package/AI_USAGE/components/empty-api.md +36 -0
- package/AI_USAGE/components/empty.md +227 -3
- package/AI_USAGE/components/finicon.md +88 -0
- package/AI_USAGE/components/form-api.md +524 -0
- package/AI_USAGE/components/form.md +454 -0
- package/AI_USAGE/components/grid-api.md +527 -0
- package/AI_USAGE/components/grid.md +224 -0
- package/AI_USAGE/components/heatmap-api.md +122 -0
- package/AI_USAGE/components/heatmap.md +220 -0
- package/AI_USAGE/components/icon-api.md +4707 -0
- package/AI_USAGE/components/icon.md +257 -0
- package/AI_USAGE/components/image-api.md +440 -0
- package/AI_USAGE/components/image.md +465 -0
- package/AI_USAGE/components/input-api.md +184 -0
- package/AI_USAGE/components/input-number-api.md +66 -0
- package/AI_USAGE/components/input-number.md +294 -0
- package/AI_USAGE/components/input-tag-api.md +114 -0
- package/AI_USAGE/components/input-tag.md +482 -0
- package/AI_USAGE/components/input.md +293 -3
- package/AI_USAGE/components/layout-api.md +147 -0
- package/AI_USAGE/components/layout.md +230 -0
- package/AI_USAGE/components/line-chart-api.md +197 -0
- package/AI_USAGE/components/line-chart.md +306 -3
- package/AI_USAGE/components/link-api.md +42 -0
- package/AI_USAGE/components/link.md +197 -0
- package/AI_USAGE/components/menu-api.md +516 -0
- package/AI_USAGE/components/menu.md +268 -0
- package/AI_USAGE/components/message-api.md +215 -0
- package/AI_USAGE/components/message-box-api.md +108 -0
- package/AI_USAGE/components/message-box.md +268 -3
- package/AI_USAGE/components/message.md +231 -3
- package/AI_USAGE/components/network-api.md +91 -0
- package/AI_USAGE/components/network.md +378 -0
- package/AI_USAGE/components/notification-api.md +236 -0
- package/AI_USAGE/components/notification.md +275 -3
- package/AI_USAGE/components/pagination-api.md +62 -0
- package/AI_USAGE/components/pagination.md +380 -3
- package/AI_USAGE/components/pie-chart-api.md +109 -0
- package/AI_USAGE/components/pie-chart.md +245 -3
- package/AI_USAGE/components/popconfirm-api.md +75 -0
- package/AI_USAGE/components/popconfirm.md +231 -3
- package/AI_USAGE/components/popover-api.md +75 -0
- package/AI_USAGE/components/popover.md +208 -3
- package/AI_USAGE/components/popup-api.md +75 -0
- package/AI_USAGE/components/popup.md +52 -0
- package/AI_USAGE/components/progress-api.md +44 -0
- package/AI_USAGE/components/progress.md +248 -3
- package/AI_USAGE/components/radio-api.md +165 -0
- package/AI_USAGE/components/radio.md +259 -3
- package/AI_USAGE/components/rate-api.md +54 -0
- package/AI_USAGE/components/rate.md +233 -3
- package/AI_USAGE/components/resize-box-api.md +56 -0
- package/AI_USAGE/components/resize-box.md +231 -0
- package/AI_USAGE/components/scrollbar-api.md +77 -0
- package/AI_USAGE/components/scrollbar.md +218 -0
- package/AI_USAGE/components/select-api.md +758 -0
- package/AI_USAGE/components/select.md +640 -3
- package/AI_USAGE/components/skeleton-api.md +85 -0
- package/AI_USAGE/components/skeleton.md +150 -0
- package/AI_USAGE/components/slider-api.md +51 -0
- package/AI_USAGE/components/slider.md +233 -3
- package/AI_USAGE/components/space-api.md +38 -0
- package/AI_USAGE/components/space.md +145 -0
- package/AI_USAGE/components/spin-api.md +43 -0
- package/AI_USAGE/components/spin.md +205 -0
- package/AI_USAGE/components/steps-api.md +111 -0
- package/AI_USAGE/components/steps.md +201 -3
- package/AI_USAGE/components/switch-api.md +58 -0
- package/AI_USAGE/components/switch.md +290 -3
- package/AI_USAGE/components/table-api.md +2919 -0
- package/AI_USAGE/components/table.md +1457 -0
- package/AI_USAGE/components/tabs-api.md +135 -0
- package/AI_USAGE/components/tabs.md +308 -3
- package/AI_USAGE/components/tag-api.md +124 -0
- package/AI_USAGE/components/tag.md +292 -0
- package/AI_USAGE/components/textarea-api.md +55 -0
- package/AI_USAGE/components/textarea.md +326 -3
- package/AI_USAGE/components/time-picker-api.md +137 -0
- package/AI_USAGE/components/time-picker.md +271 -3
- package/AI_USAGE/components/time-range-selector-api.md +44 -0
- package/AI_USAGE/components/time-range-selector.md +355 -0
- package/AI_USAGE/components/timeline-api.md +93 -0
- package/AI_USAGE/components/timeline.md +312 -0
- package/AI_USAGE/components/tooltip-api.md +77 -0
- package/AI_USAGE/components/tooltip.md +182 -0
- package/AI_USAGE/components/tree-select-api.md +498 -0
- package/AI_USAGE/components/tree-select.md +744 -0
- package/AI_USAGE/components/trend-chart-api.md +119 -0
- package/AI_USAGE/components/trend-chart.md +335 -0
- package/AI_USAGE/components/trigger-api.md +124 -0
- package/AI_USAGE/components/trigger.md +185 -0
- package/AI_USAGE/components/upload-api.md +200 -0
- package/AI_USAGE/components/upload.md +711 -3
- package/AI_USAGE/components/watermark-api.md +87 -0
- package/AI_USAGE/components/watermark.md +200 -0
- package/AI_USAGE/core.md +1 -1
- package/AI_USAGE/index.md +36 -7
- package/AI_USAGE/recipes/form-on-demand.md +1 -1
- package/AI_USAGE.md +34972 -5
- package/CHANGELOG.md +39 -0
- package/dist/_props/css.d.ts +2 -1
- package/dist/_utils/inherit-component-type.d.ts +11 -0
- package/dist/components/bar-chart/BarChart.d.ts +1 -1
- package/dist/components/bar-chart/index.d.ts +3 -3
- package/dist/components/date-picker/index.d.ts +420 -5
- package/dist/components/form-input/index.d.ts +617 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/layout/index.d.ts +689 -1
- package/dist/components/line-chart/LineChart.d.ts +1 -1
- package/dist/components/line-chart/index.d.ts +3 -3
- package/dist/components/line-chart/interface.d.ts +2 -2
- package/dist/components/menu/index.d.ts +786 -1
- package/dist/components/tree-select/TreeNode.vue.d.ts +478 -0
- package/dist/components/tree-select/TreeSelect.d.ts +1549 -0
- package/dist/components/tree-select/TreeSelectDropdown.vue.d.ts +569 -0
- package/dist/components/tree-select/hooks/use-tree-select.d.ts +92 -0
- package/dist/components/tree-select/index.d.ts +3321 -0
- package/dist/components/tree-select/interface.d.ts +203 -0
- package/dist/components/tree-select/utils.d.ts +64 -0
- package/dist/es/_styles/palette-aliases.js +3 -0
- package/dist/es/_utils/inherit-component-type.js +6 -0
- package/dist/es/components/_components/feedback-icon/index.vue2.js +10 -10
- package/dist/es/components/button/Button.js +9 -9
- package/dist/es/components/date-picker/index.js +18 -17
- package/dist/es/components/drawer/src/Drawer.vue.js +6 -6
- package/dist/es/components/form-input/index.js +12 -11
- package/dist/es/components/form-switch/Switch.vue2.js +18 -18
- package/dist/es/components/image/Image.vue2.js +13 -13
- package/dist/es/components/image/ImagePreview.vue2.js +33 -33
- package/dist/es/components/index.js +55 -52
- package/dist/es/components/layout/index.js +10 -9
- package/dist/es/components/link/Link.vue2.js +12 -12
- package/dist/es/components/menu/hooks/use-level.js +5 -5
- package/dist/es/components/menu/index.js +13 -10
- package/dist/es/components/message/message.vue2.js +13 -13
- package/dist/es/components/spin/Spin.js +28 -28
- package/dist/es/components/tag/Tag.vue2.js +22 -22
- package/dist/es/components/timeline/src/Timeline.js +7 -7
- package/dist/es/components/tree-select/TreeNode.vue.js +91 -0
- package/dist/es/components/tree-select/TreeNode.vue2.js +162 -0
- package/dist/es/components/tree-select/TreeSelect.js +865 -0
- package/dist/es/components/tree-select/TreeSelectDropdown.vue.js +57 -0
- package/dist/es/components/tree-select/TreeSelectDropdown.vue2.js +79 -0
- package/dist/es/components/tree-select/hooks/use-tree-select.js +376 -0
- package/dist/es/components/tree-select/index.js +13 -0
- package/dist/es/components/tree-select/utils.js +181 -0
- package/dist/es/icons/animation/animation-loading.js +2 -2
- package/dist/es/index.js +71 -68
- package/dist/es/style.css +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.umd.js +3 -3
- package/dist/style/base.css +1 -1
- package/dist/style/dependencies.json +10 -0
- package/dist/style/drawer.css +1 -1
- package/dist/style/table.css +1 -1
- package/dist/style/tree-select.css +1 -0
- package/dist/style/tree-select.js +8 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +11 -5
- package/volar.d.ts +2 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
2
|
# MessageBox AI 使用
|
|
3
3
|
|
|
4
|
-
适用版本:x-next@1.
|
|
4
|
+
适用版本:x-next@1.15.0;来源指纹:`47ea153587c8d0b3bf318977b10bde9f8dd4acff90c5818541ba6513252ad362`。
|
|
5
5
|
|
|
6
|
-
先读 [通用接入](../core.md)。公开导出:`MessageBox
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`MessageBox`;主要模型:无。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./message-box-api.md),包含本组件族全部子组件和别名。
|
|
7
7
|
|
|
8
8
|
按需样式:`x-next/style/message-box`(包含 base.css、button.css、dialog.css、message-box.css、space.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
9
|
|
|
10
|
+
## 已核验行为与示例
|
|
11
|
+
|
|
10
12
|
[组件文档与 live demo](https://x-next.yjmf.com/components/message-box)。调用 `MessageBox(options)`,默认类型为 `'success'`、宽度 `360`、居中、显示遮罩和关闭按钮、点击遮罩不关闭。`title` / `content` 支持文字、VNode 或渲染函数;`footer=false` 隐藏页脚。
|
|
11
13
|
|
|
12
14
|
返回 `close()` / `update(options)` 句柄,结果通过 `onOk(event)` / `onCancel(event)` 回调处理。`beforeOnOk` / `beforeOnCancel` 返回 `boolean | Promise<boolean>`,必须返回 `true` 才放行;异步业务放在前置钩子。它不是 Promise,没有 `confirm()`;`.warning(title, content)` 等返回的 `.ok()` / `.cancel()` 用于注册链式回调。
|
|
@@ -36,4 +38,267 @@ onBeforeUnmount(() => handle?.close());
|
|
|
36
38
|
</template>
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
## 场景用法
|
|
42
|
+
|
|
43
|
+
以下示例从本地 `src/docs/components/message-box.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./message-box-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
44
|
+
|
|
45
|
+
### 用途与选型
|
|
46
|
+
|
|
47
|
+
用于确认、警告等阻塞式反馈。
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### 基础用法
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
import 'x-next/style.css';
|
|
55
|
+
import { Space, Button } from 'x-next';
|
|
56
|
+
import { MessageBox } from 'x-next';
|
|
57
|
+
|
|
58
|
+
const openConfirm = () => {
|
|
59
|
+
MessageBox.warning('确认删除吗?', '删除后数据不可恢复')
|
|
60
|
+
.ok(() => console.log('ok'))
|
|
61
|
+
.cancel(() => console.log('cancel'));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const openInfo = () => {
|
|
65
|
+
MessageBox.info('更新说明', '本次操作不会影响已有数据');
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
68
|
+
<template>
|
|
69
|
+
<Space>
|
|
70
|
+
<Button status="warning" @click="openConfirm">删除确认</Button>
|
|
71
|
+
<Button @click="openInfo">信息提示</Button>
|
|
72
|
+
</Space>
|
|
73
|
+
</template>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 消息类型
|
|
77
|
+
|
|
78
|
+
```vue
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
import 'x-next/style.css';
|
|
81
|
+
import { Button } from 'x-next';
|
|
82
|
+
import { MessageBox } from 'x-next';
|
|
83
|
+
import type { MessageBoxStaticMethod } from 'x-next';
|
|
84
|
+
|
|
85
|
+
const openType = (type: MessageBoxStaticMethod) => {
|
|
86
|
+
MessageBox[type](`${type} 标题`, `${type} 内容`);
|
|
87
|
+
};
|
|
88
|
+
</script>
|
|
89
|
+
<template>
|
|
90
|
+
<div class="demo-inline-group">
|
|
91
|
+
<Button @click="openType('info')">Info</Button>
|
|
92
|
+
<Button status="success" @click="openType('success')">Success</Button>
|
|
93
|
+
<Button status="warning" @click="openType('warning')">Warning</Button>
|
|
94
|
+
<Button status="strong" @click="openType('strong')">Strong</Button>
|
|
95
|
+
<Button status="danger" @click="openType('error')">Error</Button>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 异步关闭
|
|
101
|
+
|
|
102
|
+
```vue
|
|
103
|
+
<script setup lang="ts">
|
|
104
|
+
import 'x-next/style.css';
|
|
105
|
+
import { Space, Button } from 'x-next';
|
|
106
|
+
import { MessageBox } from 'x-next';
|
|
107
|
+
|
|
108
|
+
const openAsyncOk = () => {
|
|
109
|
+
MessageBox({
|
|
110
|
+
title: '提交确认',
|
|
111
|
+
content: '确认提交当前表单吗?',
|
|
112
|
+
type: 'info',
|
|
113
|
+
okText: '提交',
|
|
114
|
+
beforeOnOk: async () => {
|
|
115
|
+
await new Promise((resolve) => window.setTimeout(resolve, 1200));
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const openBlockedCancel = () => {
|
|
122
|
+
MessageBox({
|
|
123
|
+
title: '当前不能取消',
|
|
124
|
+
content: 'beforeOnCancel 返回 false 时弹窗会保持打开',
|
|
125
|
+
type: 'warning',
|
|
126
|
+
beforeOnCancel: () => false,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
</script>
|
|
130
|
+
<template>
|
|
131
|
+
<Space>
|
|
132
|
+
<Button type="primary" @click="openAsyncOk">异步确认</Button>
|
|
133
|
+
<Button @click="openBlockedCancel">阻止取消</Button>
|
|
134
|
+
</Space>
|
|
135
|
+
</template>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 手动控制
|
|
139
|
+
|
|
140
|
+
```vue
|
|
141
|
+
<script setup lang="ts">
|
|
142
|
+
import 'x-next/style.css';
|
|
143
|
+
import { Space, Button } from 'x-next';
|
|
144
|
+
import { MessageBox } from 'x-next';
|
|
145
|
+
|
|
146
|
+
const openManualClose = () => {
|
|
147
|
+
const instance = MessageBox({
|
|
148
|
+
title: '手动关闭',
|
|
149
|
+
content: '这个消息框会在 2 秒后关闭',
|
|
150
|
+
type: 'success',
|
|
151
|
+
});
|
|
152
|
+
window.setTimeout(() => instance.close(), 2000);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const openManualUpdate = () => {
|
|
156
|
+
let seconds = 3;
|
|
157
|
+
const instance = MessageBox.success('倒计时', `还有 ${seconds} 秒关闭`);
|
|
158
|
+
const timer = window.setInterval(() => {
|
|
159
|
+
seconds -= 1;
|
|
160
|
+
instance.update({ content: `还有 ${seconds} 秒关闭` });
|
|
161
|
+
if (seconds <= 0) {
|
|
162
|
+
window.clearInterval(timer);
|
|
163
|
+
instance.close();
|
|
164
|
+
}
|
|
165
|
+
}, 1000);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const closeAll = () => MessageBox.destroyAll();
|
|
169
|
+
</script>
|
|
170
|
+
<template>
|
|
171
|
+
<Space>
|
|
172
|
+
<Button @click="openManualClose">2 秒后关闭</Button>
|
|
173
|
+
<Button @click="openManualUpdate">倒计时更新</Button>
|
|
174
|
+
<Button @click="closeAll">关闭全部</Button>
|
|
175
|
+
</Space>
|
|
176
|
+
</template>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 页脚和按钮
|
|
180
|
+
|
|
181
|
+
```vue
|
|
182
|
+
<script setup lang="ts">
|
|
183
|
+
import 'x-next/style.css';
|
|
184
|
+
import { Space, Button } from 'x-next';
|
|
185
|
+
import { h } from 'vue';
|
|
186
|
+
import { MessageBox } from 'x-next';
|
|
187
|
+
|
|
188
|
+
const openNoFooter = () => {
|
|
189
|
+
MessageBox({
|
|
190
|
+
title: '无底部区域',
|
|
191
|
+
content: 'footer=false 时不会显示底部按钮',
|
|
192
|
+
type: 'info',
|
|
193
|
+
footer: false,
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const openOnlyOk = () => {
|
|
198
|
+
MessageBox.success('保存成功', '只展示确认按钮').update({ hideCancel: true });
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const openCustomFooter = () => {
|
|
202
|
+
MessageBox({
|
|
203
|
+
title: '自定义底部',
|
|
204
|
+
content: 'footer 可以接收渲染函数',
|
|
205
|
+
type: 'strong',
|
|
206
|
+
footer: ({ cancel, ok }) =>
|
|
207
|
+
h('div', { style: 'display:flex;gap:8px;justify-content:flex-end;' }, [
|
|
208
|
+
h('button', { onClick: cancel }, '稍后'),
|
|
209
|
+
h('button', { onClick: ok }, '立即处理'),
|
|
210
|
+
]),
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
</script>
|
|
214
|
+
<template>
|
|
215
|
+
<Space>
|
|
216
|
+
<Button @click="openNoFooter">隐藏底部</Button>
|
|
217
|
+
<Button @click="openOnlyOk">只保留确认</Button>
|
|
218
|
+
<Button @click="openCustomFooter">自定义底部</Button>
|
|
219
|
+
</Space>
|
|
220
|
+
</template>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 自定义位置和容器
|
|
224
|
+
|
|
225
|
+
```vue
|
|
226
|
+
<script setup lang="ts">
|
|
227
|
+
import 'x-next/style.css';
|
|
228
|
+
import { Space, Button } from 'x-next';
|
|
229
|
+
import { MessageBox } from 'x-next';
|
|
230
|
+
|
|
231
|
+
const openTopMessageBox = () => {
|
|
232
|
+
MessageBox({
|
|
233
|
+
title: '自定义位置',
|
|
234
|
+
content: '设置 top 后不再垂直居中',
|
|
235
|
+
type: 'info',
|
|
236
|
+
top: 80,
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const openLocalMessageBox = () => {
|
|
241
|
+
MessageBox({
|
|
242
|
+
title: '局部容器',
|
|
243
|
+
content: '挂载到指定容器',
|
|
244
|
+
type: 'success',
|
|
245
|
+
renderTo: '#message-box-local-container',
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
</script>
|
|
249
|
+
<template>
|
|
250
|
+
<Space>
|
|
251
|
+
<Button @click="openTopMessageBox">距离顶部</Button>
|
|
252
|
+
<Button @click="openLocalMessageBox">局部容器</Button>
|
|
253
|
+
</Space>
|
|
254
|
+
<div id="message-box-local-container" class="message-box-local-container"></div>
|
|
255
|
+
</template>
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### MessageBoxOptions
|
|
259
|
+
|
|
260
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
261
|
+
| --- | --- | --- | --- |
|
|
262
|
+
| `title` | 标题 | `MessageBoxContent` | `-` |
|
|
263
|
+
| `type` | 消息类型 | `'info' \| 'success' \| 'warning' \| 'strong' \| 'error'` | `'success'` |
|
|
264
|
+
| `content` | 正文内容 | `MessageBoxContent` | `-` |
|
|
265
|
+
| `footer` | 自定义底部;`false` 时隐藏底部 | `boolean \| VNode \| (scoped) => MessageBoxRenderResult` | 默认按钮 |
|
|
266
|
+
| `okText` | 确认按钮文案 | `string` | `'确认'` |
|
|
267
|
+
| `cancelText` | 取消按钮文案 | `string` | `'取消'` |
|
|
268
|
+
| `mask` | 是否显示遮罩 | `boolean` | `true` |
|
|
269
|
+
| `maskToClose` | 点击遮罩是否关闭 | `boolean` | `false` |
|
|
270
|
+
| `onOk` | 点击确认回调 | `(event: Event) => void` | `-` |
|
|
271
|
+
| `beforeOnOk` | 确认前拦截 | `() => boolean \| Promise<boolean>` | `-` |
|
|
272
|
+
| `onCancel` | 点击取消回调 | `(event: Event) => void` | `-` |
|
|
273
|
+
| `beforeOnCancel` | 取消前拦截 | `() => boolean \| Promise<boolean>` | `-` |
|
|
274
|
+
| `width` | 宽度 | `string \| number` | `360` |
|
|
275
|
+
| `height` | 高度 | `string \| number` | `'auto'` |
|
|
276
|
+
| `top` | 距离顶部位置 | `string \| number` | `0` |
|
|
277
|
+
| `center` | 是否居中 | `boolean` | `true` |
|
|
278
|
+
| `renderTo` | 挂载容器,找不到时回退到 body | `string \| HTMLElement` | `'body'` |
|
|
279
|
+
| `hideCancel` | 是否隐藏取消按钮 | `boolean` | `false` |
|
|
280
|
+
| `hideOk` | 是否隐藏确认按钮 | `boolean` | `false` |
|
|
281
|
+
| `closable` | 是否显示右上角关闭按钮 | `boolean` | `true` |
|
|
282
|
+
| `popupClass` | 弹层自定义类名 | `string` | `-` |
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
### 返回值
|
|
286
|
+
|
|
287
|
+
| 方法 | 说明 | 参数 |
|
|
288
|
+
| --- | --- | --- |
|
|
289
|
+
| `close()` | 关闭当前消息框 | `-` |
|
|
290
|
+
| `update(options)` | 更新当前消息框配置 | `Partial<MessageBoxOptions>` |
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
### 链式回调
|
|
294
|
+
|
|
295
|
+
| 方法 | 说明 | 参数 |
|
|
296
|
+
| --- | --- | --- |
|
|
297
|
+
| `ok(callback)` | 注册确认回调 | `() => void` |
|
|
298
|
+
| `ok(before, callback)` | 注册确认前拦截与确认回调 | `() => boolean \| Promise<boolean>, () => void` |
|
|
299
|
+
| `cancel(callback)` | 注册取消回调 | `() => void` |
|
|
300
|
+
| `cancel(before, callback)` | 注册取消前拦截与取消回调 | `() => boolean \| Promise<boolean>, () => void` |
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./message-box-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
2
|
# Message AI 使用
|
|
3
3
|
|
|
4
|
-
适用版本:x-next@1.
|
|
4
|
+
适用版本:x-next@1.15.0;来源指纹:`47ea153587c8d0b3bf318977b10bde9f8dd4acff90c5818541ba6513252ad362`。
|
|
5
5
|
|
|
6
|
-
先读 [通用接入](../core.md)。公开导出:`Message, MessageComponent
|
|
6
|
+
先读 [通用接入](../core.md)。公开导出:`Message, MessageComponent`;主要模型:无。完整 Props、Events、Slots、实例方法与服务签名见 [本地 API](./message-api.md),包含本组件族全部子组件和别名。
|
|
7
7
|
|
|
8
8
|
按需样式:`x-next/style/message`(包含 base.css、message.css)。代码块未单独引样式时在应用入口加载全量样式,或按实际所有组件加载 JS 入口;不要仅因复制一个组件页就漏掉其中的 Button 等组合依赖。
|
|
9
9
|
|
|
10
|
+
## 已核验行为与示例
|
|
11
|
+
|
|
10
12
|
[组件文档与 live demo](https://x-next.yjmf.com/components/message)。`Message(options)` 或 `.success()` / `.error()` / `.loading()` 等显示提示。服务默认 `type='info'`、`duration=3000` 毫秒、`position='top'`、`showClose=false`;`duration=0` 持续显示,内容用 `message` 或 `content`。根入口的 `MessageComponent` 是模板组件,默认 `type='success'`,不要把服务默认值套给组件;需要统一效果时显式传 `type`。
|
|
11
13
|
|
|
12
14
|
返回句柄只有 `close()`;同一容器和位置下再次传相同 `id` 更新消息,没有句柄 `update()`。`onClose(id?)` 在自动或手动关闭时触发;自定义内容可用 VNode / 渲染函数。页面只清理自己持有的句柄。
|
|
@@ -33,4 +35,230 @@ onBeforeUnmount(() => handle?.close());
|
|
|
33
35
|
</template>
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
## 场景用法
|
|
39
|
+
|
|
40
|
+
以下示例从本地 `src/docs/components/message.md` 显式导入到独立 AI 源,补齐局部注册、状态和样式后进行严格模板检查。上方已核验行为优先;原始 prop 默认值、包装透传和示例业务适配分别查 [完整 API](./message-api.md) 与场景说明。类型通过不代表所有散文和交互已验证。
|
|
41
|
+
|
|
42
|
+
### 用途与选型
|
|
43
|
+
|
|
44
|
+
用于轻量级即时反馈,通常由命令式方法触发。
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### 基础用法
|
|
48
|
+
|
|
49
|
+
```vue
|
|
50
|
+
<script setup lang="ts">
|
|
51
|
+
import 'x-next/style.css';
|
|
52
|
+
import { Space, Button } from 'x-next';
|
|
53
|
+
import { Message } from 'x-next';
|
|
54
|
+
|
|
55
|
+
const showBasicMessage = () => Message.success('保存成功');
|
|
56
|
+
const showInfoMessage = () => Message.info('这是一条信息提示');
|
|
57
|
+
</script>
|
|
58
|
+
<template>
|
|
59
|
+
<Space>
|
|
60
|
+
<Button type="primary" @click="showBasicMessage">成功提示</Button>
|
|
61
|
+
<Button @click="showInfoMessage">信息提示</Button>
|
|
62
|
+
</Space>
|
|
63
|
+
</template>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 消息类型
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
import 'x-next/style.css';
|
|
71
|
+
import { Button } from 'x-next';
|
|
72
|
+
import { Message } from 'x-next';
|
|
73
|
+
type IMessageType = 'success' | 'info' | 'warning' | 'error' | 'loading' | 'strong' | 'normal';
|
|
74
|
+
|
|
75
|
+
const showTypedMessage = (type: IMessageType) => {
|
|
76
|
+
Message[type]({
|
|
77
|
+
message: `${type} message`,
|
|
78
|
+
duration: type === 'loading' ? 0 : 3000,
|
|
79
|
+
showClose: type === 'loading',
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
</script>
|
|
83
|
+
<template>
|
|
84
|
+
<div class="demo-inline-group">
|
|
85
|
+
<Button @click="showTypedMessage('info')">Info</Button>
|
|
86
|
+
<Button status="success" @click="showTypedMessage('success')">Success</Button>
|
|
87
|
+
<Button status="warning" @click="showTypedMessage('warning')">Warning</Button>
|
|
88
|
+
<Button status="danger" @click="showTypedMessage('error')">Error</Button>
|
|
89
|
+
<Button status="strong" @click="showTypedMessage('strong')">Strong</Button>
|
|
90
|
+
<Button @click="showTypedMessage('normal')">Normal</Button>
|
|
91
|
+
<Button type="primary" @click="showTypedMessage('loading')">Loading</Button>
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 可关闭和手动关闭
|
|
97
|
+
|
|
98
|
+
```vue
|
|
99
|
+
<script setup lang="ts">
|
|
100
|
+
import 'x-next/style.css';
|
|
101
|
+
import { Space, Button } from 'x-next';
|
|
102
|
+
import { Message } from 'x-next';
|
|
103
|
+
|
|
104
|
+
const showCloseableMessage = () => {
|
|
105
|
+
Message.info({
|
|
106
|
+
message: '点击右侧按钮关闭',
|
|
107
|
+
showClose: true,
|
|
108
|
+
duration: 0,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const showManualMessage = () => {
|
|
113
|
+
const handler = Message.loading({
|
|
114
|
+
message: '2 秒后手动关闭',
|
|
115
|
+
duration: 0,
|
|
116
|
+
});
|
|
117
|
+
window.setTimeout(() => handler.close(), 2000);
|
|
118
|
+
};
|
|
119
|
+
</script>
|
|
120
|
+
<template>
|
|
121
|
+
<Space>
|
|
122
|
+
<Button @click="showCloseableMessage">可关闭</Button>
|
|
123
|
+
<Button @click="showManualMessage">手动关闭</Button>
|
|
124
|
+
</Space>
|
|
125
|
+
</template>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 更新内容
|
|
129
|
+
|
|
130
|
+
```vue
|
|
131
|
+
<script setup lang="ts">
|
|
132
|
+
import 'x-next/style.css';
|
|
133
|
+
import { Space, Button } from 'x-next';
|
|
134
|
+
import { ref } from 'vue';
|
|
135
|
+
import { Message } from 'x-next';
|
|
136
|
+
|
|
137
|
+
const count = ref(1);
|
|
138
|
+
|
|
139
|
+
const showUpdatedMessage = () => {
|
|
140
|
+
Message.info({
|
|
141
|
+
id: 'message-update-demo',
|
|
142
|
+
message: `当前进度 ${count.value++}`,
|
|
143
|
+
duration: 3000,
|
|
144
|
+
showClose: true,
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const clearMessages = () => Message.clear();
|
|
149
|
+
</script>
|
|
150
|
+
<template>
|
|
151
|
+
<Space>
|
|
152
|
+
<Button type="primary" @click="showUpdatedMessage">更新同一条消息</Button>
|
|
153
|
+
<Button @click="clearMessages">清空消息</Button>
|
|
154
|
+
</Space>
|
|
155
|
+
</template>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### 位置和悬停
|
|
159
|
+
|
|
160
|
+
```vue
|
|
161
|
+
<script setup lang="ts">
|
|
162
|
+
import 'x-next/style.css';
|
|
163
|
+
import { Space, Button } from 'x-next';
|
|
164
|
+
import { Message } from 'x-next';
|
|
165
|
+
|
|
166
|
+
const showTopMessage = () => Message.info({ message: '顶部提示', position: 'top' });
|
|
167
|
+
const showBottomMessage = () => Message.success({ message: '底部提示', position: 'bottom' });
|
|
168
|
+
const showHoverMessage = () => {
|
|
169
|
+
Message.warning({
|
|
170
|
+
message: '鼠标移入时暂停自动关闭',
|
|
171
|
+
resetOnHover: true,
|
|
172
|
+
duration: 4000,
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
</script>
|
|
176
|
+
<template>
|
|
177
|
+
<Space>
|
|
178
|
+
<Button @click="showTopMessage">顶部</Button>
|
|
179
|
+
<Button @click="showBottomMessage">底部</Button>
|
|
180
|
+
<Button @click="showHoverMessage">悬停暂停</Button>
|
|
181
|
+
</Space>
|
|
182
|
+
</template>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### 自定义内容
|
|
186
|
+
|
|
187
|
+
`useHTML` 会直接渲染 HTML 字符串。只应传入可信内容,用户输入或后端返回内容需要先自行消毒。
|
|
188
|
+
|
|
189
|
+
```vue
|
|
190
|
+
<script setup lang="ts">
|
|
191
|
+
import 'x-next/style.css';
|
|
192
|
+
import { Space, Button } from 'x-next';
|
|
193
|
+
import { h } from 'vue';
|
|
194
|
+
import { Message } from 'x-next';
|
|
195
|
+
|
|
196
|
+
const showCustomIconMessage = () => {
|
|
197
|
+
Message.info({
|
|
198
|
+
message: '自定义图标提示',
|
|
199
|
+
icon: () => h('span', { style: 'color: #ff7125;' }, '★'),
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const showHtmlMessage = () => {
|
|
204
|
+
Message.warning({
|
|
205
|
+
message: '<strong>仅用于可信 HTML</strong>',
|
|
206
|
+
useHTML: true,
|
|
207
|
+
showClose: true,
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
</script>
|
|
211
|
+
<template>
|
|
212
|
+
<Space>
|
|
213
|
+
<Button @click="showCustomIconMessage">自定义图标</Button>
|
|
214
|
+
<Button @click="showHtmlMessage">HTML 内容</Button>
|
|
215
|
+
</Space>
|
|
216
|
+
</template>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 局部容器
|
|
220
|
+
|
|
221
|
+
```vue
|
|
222
|
+
<script setup lang="ts">
|
|
223
|
+
import 'x-next/style.css';
|
|
224
|
+
import { Button } from 'x-next';
|
|
225
|
+
import { Message } from 'x-next';
|
|
226
|
+
|
|
227
|
+
const showContainerMessage = () => {
|
|
228
|
+
Message.success({
|
|
229
|
+
message: '局部容器中的提示',
|
|
230
|
+
renderTo: '#message-local-container',
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
</script>
|
|
234
|
+
<template>
|
|
235
|
+
<Button @click="showContainerMessage">显示到局部容器</Button>
|
|
236
|
+
<div id="message-local-container" class="message-local-container"></div>
|
|
237
|
+
</template>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### IMessageOptions
|
|
241
|
+
|
|
242
|
+
| 参数 | 说明 | 类型 | 默认值 |
|
|
243
|
+
| --- | --- | --- | --- |
|
|
244
|
+
| `id` | 提示唯一标识,相同 id 会更新已有消息 | `string \| number` | `-` |
|
|
245
|
+
| `message` | 提示内容 | `string \| number \| VNode \| RenderFunction` | `-` |
|
|
246
|
+
| `content` | `message` 的别名 | `string \| number \| VNode \| RenderFunction` | `-` |
|
|
247
|
+
| `type` | 提示类型 | `'success' \| 'warning' \| 'error' \| 'strong' \| 'info' \| 'loading' \| 'normal'` | `'info'` |
|
|
248
|
+
| `duration` | 自动关闭时间,单位毫秒,`0` 表示不自动关闭 | `number` | `3000` |
|
|
249
|
+
| `center` | 内容是否居中 | `boolean` | `false` |
|
|
250
|
+
| `onClose` | 关闭回调 | `(id?: string \| number) => void` | `-` |
|
|
251
|
+
| `offset` | 与容器顶部或底部的初始偏移 | `number` | `20` |
|
|
252
|
+
| `renderTo` | 挂载容器 | `string \| HTMLElement` | `'body'` |
|
|
253
|
+
| `showClose` | 是否显示关闭按钮 | `boolean` | `false` |
|
|
254
|
+
| `closable` | `showClose` 的别名 | `boolean` | `false` |
|
|
255
|
+
| `showIcon` | 是否显示图标 | `boolean` | `type !== 'normal'` |
|
|
256
|
+
| `icon` | 自定义图标 | `RenderFunction` | `-` |
|
|
257
|
+
| `useHTML` | 是否按 HTML 渲染字符串内容 | `boolean` | `false` |
|
|
258
|
+
| `popupClass` | 自定义类名 | `string` | `-` |
|
|
259
|
+
| `position` | 展示位置 | `'top' \| 'bottom'` | `'top'` |
|
|
260
|
+
| `resetOnHover` | 鼠标悬停时暂停自动关闭 | `boolean` | `false` |
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
返回 [AI 索引](../index.md)。先查本页与 [本地 API](./message-api.md);需要更深类型时查 [公开组件导航](../catalog.md),不默认上网查找本包用法。
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<!-- Generated by pnpm generate:ai-usage. Edit script/ai-usage/content.md and script/ai-usage/. -->
|
|
2
|
+
# Network 完整公开 API
|
|
3
|
+
|
|
4
|
+
适用版本:x-next@1.15.0;来源指纹:`47ea153587c8d0b3bf318977b10bde9f8dd4acff90c5818541ba6513252ad362`。
|
|
5
|
+
|
|
6
|
+
从同版本构建的公开声明、运行时 props/emits 和显式 expose 生成。运行时导入始终使用 `x-next`,声明路径仅作定位。插槽类型未细化时,具体槽名与作用域见本地用法示例。
|
|
7
|
+
|
|
8
|
+
## Network API
|
|
9
|
+
|
|
10
|
+
公开声明:`dist/components/network/index.d.ts`。 类型中的 undefined 表示可省略;原始 prop 默认值不等于继承配置或服务默认值。
|
|
11
|
+
|
|
12
|
+
### Props
|
|
13
|
+
|
|
14
|
+
| 名称 | 用途 | 公开类型 | 必填 | 声明默认值 |
|
|
15
|
+
| --- | --- | --- | --- | --- |
|
|
16
|
+
| size | 信号图标尺寸 | undefined | "mini" | "small" | "medium" | "large" | 否 | "medium" |
|
|
17
|
+
| signalStrengthColor | 兼容的 good / poor 颜色 | undefined | [string, string] | 否 | 工厂函数(每个实例初始化;有效值见行为说明) |
|
|
18
|
+
| statusColors | 各状态颜色,优先于兼容颜色 | undefined | { medium?: string | undefined; unknown?: string | undefined; good?: string | undefined; poor?: string | undefined; offline?: string | undefined; } | 否 | {} |
|
|
19
|
+
| status | 受控质量;传入后停止自动检测 | undefined | "medium" | "unknown" | "good" | "poor" | "offline" | 否 | 未声明 |
|
|
20
|
+
| ping | 同源或允许 CORS 的主动探测 URL | undefined | string | 否 | 未声明 |
|
|
21
|
+
| interval | 每次轮询完成后的等待毫秒数;有限正数启用,其他值关闭 | undefined | number | 否 | 未声明 |
|
|
22
|
+
| timeout | 请求及响应体总超时毫秒数;非有限或非正数回退 5000 | undefined | number | 否 | 5000 |
|
|
23
|
+
| showMetrics | 显示延迟和下载估算,无数据时显示占位 | undefined | false | true | 否 | false(Vue Boolean 转换) |
|
|
24
|
+
| showTooltip | 将状态文案写入原生 title | undefined | false | true | 否 | false |
|
|
25
|
+
| ariaLabel | 自定义无障碍名称 | undefined | string | 否 | 未声明 |
|
|
26
|
+
| ariaLive | 状态变化播报策略 | undefined | "off" | "polite" | "assertive" | 否 | "polite" |
|
|
27
|
+
|
|
28
|
+
### Events
|
|
29
|
+
|
|
30
|
+
| 事件 | 用途 | 监听器签名(即事件参数) |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| change | 自动模式首次检测和语义字段变化;受控模式手动 refresh 每次触发 | undefined | (status: NetworkStatus) => any |
|
|
33
|
+
| online | 自动模式从浏览器离线恢复 | undefined | (status: NetworkStatus) => any |
|
|
34
|
+
| offline | 自动模式从非离线进入浏览器离线 | undefined | (status: NetworkStatus) => any |
|
|
35
|
+
| probe | 当前有效轮次主动探测完成(成功、失败、超时均含);被状态变化或卸载取消的旧轮次不发 | undefined | (status: NetworkStatus) => any |
|
|
36
|
+
|
|
37
|
+
### Slots
|
|
38
|
+
|
|
39
|
+
| 名称 | 用途 | 公开类型 |
|
|
40
|
+
| --- | --- | --- |
|
|
41
|
+
| default | 完全自定义展示,替换默认图标和指标 | (args_0: NetworkSlotProps) => VNode[] |
|
|
42
|
+
|
|
43
|
+
### 实例方法 / 暴露值
|
|
44
|
+
|
|
45
|
+
| 名称 | 公开类型 |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| refresh | () => Promise<NetworkStatus> |
|
|
48
|
+
|
|
49
|
+
### 关联类型定义
|
|
50
|
+
|
|
51
|
+
以下摘自本组件族声明,供查阅嵌套配置;运行时和值类型均以根入口可导出项为准。
|
|
52
|
+
|
|
53
|
+
```typescript-reference
|
|
54
|
+
type NetworkQuality = 'unknown' | 'good' | 'medium' | 'poor' | 'offline';
|
|
55
|
+
|
|
56
|
+
type NetworkStatusSource = 'navigator' | 'connection' | 'probe' | 'manual';
|
|
57
|
+
|
|
58
|
+
type NetworkStatusReason = 'initial' | 'browser-offline' | 'connection-change' | 'probe-timeout' | 'probe-error' | 'http-error' | 'unsupported';
|
|
59
|
+
|
|
60
|
+
interface NetworkStatus {
|
|
61
|
+
online: boolean;
|
|
62
|
+
quality: NetworkQuality;
|
|
63
|
+
latency?: number;
|
|
64
|
+
downloadSpeed?: number;
|
|
65
|
+
speedSource?: 'probe';
|
|
66
|
+
downlink?: number;
|
|
67
|
+
rtt?: number;
|
|
68
|
+
effectiveType?: string;
|
|
69
|
+
source: NetworkStatusSource;
|
|
70
|
+
reason?: NetworkStatusReason;
|
|
71
|
+
lastCheckedAt: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
type NetworkEventListenerCallback = (status: NetworkStatus) => void;
|
|
75
|
+
|
|
76
|
+
type NetworkOptions = {
|
|
77
|
+
interval?: number;
|
|
78
|
+
ping?: `https://${string}` | `http://${string}` | string;
|
|
79
|
+
timeout?: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type NetworkSize = 'mini' | 'small' | 'medium' | 'large';
|
|
83
|
+
|
|
84
|
+
interface NetworkSlotProps extends Pick<NetworkStatus, 'quality' | 'online' | 'latency' | 'downloadSpeed' | 'speedSource' | 'source' | 'reason'> {
|
|
85
|
+
status: NetworkStatus;
|
|
86
|
+
refresh: () => Promise<NetworkStatus>;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
返回 [Network 用法](./network.md)。
|