react-modal-navigation 1.1.2 → 1.1.4
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 +5 -0
- package/README.md +114 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +436 -425
- package/dist/style.css +7 -1
- package/docs/API.md +305 -16
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}
|
|
16
16
|
.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}
|
|
17
17
|
.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:white}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}
|
|
18
|
-
.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:
|
|
18
|
+
.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.72);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}
|
|
19
|
+
.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:rgba(15,23,42,.72)}
|
|
20
|
+
.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}
|
|
21
|
+
.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}
|
|
22
|
+
.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}
|
|
23
|
+
@keyframes pmn-spin{to{transform:rotate(360deg)}}
|
|
24
|
+
@media (prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}
|
|
19
25
|
.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}
|
|
20
26
|
.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}
|
|
21
27
|
|
package/docs/API.md
CHANGED
|
@@ -145,22 +145,217 @@ modal.update({ placement: 'right', width: 520, viewportGap: 5 });
|
|
|
145
145
|
|
|
146
146
|
**左右抽屉:** `placement: 'left'/'right'` 时,宽度仍按 `width/size` 配置,但高度由视口自动计算,四周默认 5px 间隙;内部内容过长时滚动。设置 `viewportGap: 0` 可取消缝隙。
|
|
147
147
|
|
|
148
|
-
## 5.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
148
|
+
## 5. 页面导航 API(完整指南)
|
|
149
|
+
|
|
150
|
+
弹窗导航与弹窗本身的打开/关闭是两层概念:`modal.open({ name, screen, params })` 创建弹窗并选择初始页面;`navigation` 管理**当前弹窗内部**的页面栈。
|
|
151
|
+
|
|
152
|
+
### 5.1 注册页面、指定初始页面
|
|
153
|
+
|
|
154
|
+
```jsx
|
|
155
|
+
const registry = {
|
|
156
|
+
userModal: {
|
|
157
|
+
initialRoute: 'UserList',
|
|
158
|
+
modalOptions: { placement: 'right', width: 520 },
|
|
159
|
+
screens: {
|
|
160
|
+
UserList: { title: '用户列表', component: UserList },
|
|
161
|
+
UserDetail: { title: '用户详情', component: UserDetail },
|
|
162
|
+
UserEdit: { title: '编辑用户', component: UserEdit },
|
|
163
|
+
SaveSuccess: { title: '保存成功', component: SaveSuccess },
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// 默认进入 UserList,初始栈:[UserList]
|
|
169
|
+
modal.open({ name: 'userModal' });
|
|
170
|
+
|
|
171
|
+
// 直接进入 UserEdit,初始栈:[UserEdit],不会先创建 UserList
|
|
172
|
+
modal.open({
|
|
173
|
+
name: 'userModal',
|
|
174
|
+
screen: 'UserEdit',
|
|
175
|
+
params: { userId: 1001 },
|
|
176
|
+
placement: 'right',
|
|
177
|
+
width: 600,
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`screen` 仅在**打开时**指定初始页面;打开后的页面切换使用 `navigation`。目标页面必须存在于对应弹窗的 `screens`,否则抛出错误。
|
|
182
|
+
|
|
183
|
+
### 5.2 获取导航对象和当前页面参数
|
|
184
|
+
|
|
185
|
+
```jsx
|
|
186
|
+
import { useModal } from 'react-modal-navigation';
|
|
187
|
+
|
|
188
|
+
function UserDetail({ route, navigation }) {
|
|
189
|
+
// 两种获取方式:Screen props 或 useModal() 返回的 navigation
|
|
190
|
+
const { navigation: hookNavigation } = useModal();
|
|
191
|
+
const userId = route.params?.userId;
|
|
192
|
+
const currentName = navigation.currentRoute.name;
|
|
193
|
+
const currentParams = hookNavigation.currentRoute.params;
|
|
194
|
+
|
|
195
|
+
return <div>页面:{currentName},用户:{userId}</div>;
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
`route` 对象包含 `{ key, name, params }`;`key` 标识页面实例。`navigation.currentRoute` 指向当前栈顶页面;`navigation.stack` 为从根页面到当前页面的路由数组。
|
|
200
|
+
|
|
201
|
+
### 5.3 所有导航方法速查
|
|
202
|
+
|
|
203
|
+
| API | 参数 | 返回值 | 栈变化 / 说明 |
|
|
204
|
+
|---|---|---|---|
|
|
205
|
+
| `navigation.navigate(name, params?)` | 已注册页面名、页面参数 | `void` | 不存在则压栈;已存在则回到该页面,截断其后路由,并以新参数替换原参数(省略时变成 `{}`) |
|
|
206
|
+
| `navigation.goBack(result?)` | 可选返回数据 | `boolean` | 移除栈顶并返回上一页;根页面或重复返回时为 `false` |
|
|
207
|
+
| `navigation.replace(name, params?)` | 已注册页面名、页面参数 | `void` | 以**新页面实例**替换栈顶,栈长度不变 |
|
|
208
|
+
| `navigation.reset(name, params?)` | 已注册页面名、页面参数 | `void` | 清空整个栈,创建一个新的根页面 |
|
|
209
|
+
| `navigation.setParams(partial)` | 非数组对象 | `void` | 浅合并当前路由参数,不新增页面、不改变 `route.key` |
|
|
210
|
+
| `navigation.close(result?)` | 可选业务结果 | `Promise<boolean>` | 请求关闭**整个弹窗**,不是返回上一页;可能被关闭守卫阻止 |
|
|
211
|
+
| `navigation.setLoading(visible, text?)` | 布尔值、可选文案 | `void` | 控制弹窗全局 Loading,与页面导航无关 |
|
|
212
|
+
| `navigation.canGoBack` | — | `boolean` | `stack.length > 1` 时为 `true` |
|
|
213
|
+
| `navigation.stack` | — | `Array<{key,name,params}>` | 当前导航栈(只读使用) |
|
|
214
|
+
| `navigation.currentRoute` | — | `{key,name,params}` | 当前页面路由 |
|
|
215
|
+
|
|
216
|
+
### 5.4 navigate:前进或返回已有页面
|
|
217
|
+
|
|
218
|
+
```jsx
|
|
219
|
+
navigation.navigate('UserDetail', { userId: 1001 });
|
|
220
|
+
navigation.navigate('UserEdit', { userId: 1001, mode: 'edit' });
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
例如 `[UserList] → navigate('UserDetail') → [UserList, UserDetail]`。再次 `navigate('UserList')` 会变成 `[UserList]`,**不会产生第二个 UserList**。如果已存在 `UserDetail`,再次跳转会复用原有 `route.key`,但更新其 `params`,并移除它后面的页面。这是本库的特定行为,不要假设它与 React Navigation 完全相同。
|
|
224
|
+
|
|
225
|
+
### 5.5 goBack:返回并向上一页传值
|
|
226
|
+
|
|
227
|
+
```jsx
|
|
228
|
+
// UserDetail.jsx
|
|
229
|
+
function UserDetail({ navigation }) {
|
|
230
|
+
return (
|
|
231
|
+
<button onClick={() => navigation.goBack({ refreshed: true, userId: 1001 })}>
|
|
232
|
+
保存并返回列表
|
|
233
|
+
</button>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// UserList.jsx
|
|
238
|
+
import { useNavigationResult } from 'react-modal-navigation';
|
|
239
|
+
|
|
240
|
+
function UserList({ navigation }) {
|
|
241
|
+
useNavigationResult(result => {
|
|
242
|
+
if (result?.refreshed) {
|
|
243
|
+
// 在这里重新获取列表数据
|
|
244
|
+
console.log('需要刷新用户:', result.userId);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
return <button onClick={() => navigation.navigate('UserDetail', { userId: 1001 })}>查看详情</button>;
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
`goBack(result)` 仅在有上一页时生效;根页面调用返回 `false`,**不会自动关闭弹窗**。返回数据通过上一页的 `useNavigationResult()` 接收;不传 `result` 不会产生新的结果事件。
|
|
252
|
+
|
|
253
|
+
### 5.6 replace:替换当前页面
|
|
254
|
+
|
|
255
|
+
```jsx
|
|
256
|
+
// [UserList, UserEdit] → [UserList, SaveSuccess]
|
|
257
|
+
navigation.replace('SaveSuccess', { userId: 1001 });
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
适用于提交完成后的成功页、登录流程步骤替换。被替换页面的组件会卸载;返回时不会再回到被替换的页面。
|
|
261
|
+
|
|
262
|
+
### 5.7 reset:重置导航栈
|
|
263
|
+
|
|
264
|
+
```jsx
|
|
265
|
+
// [UserList, UserDetail, UserEdit] → [UserList]
|
|
266
|
+
navigation.reset('UserList', { filter: 'active' });
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
适用于完成多步骤操作后返回流程起点。`reset()` 会创建新的根页面实例并清除旧的页面栈与页面返回事件。
|
|
270
|
+
|
|
271
|
+
### 5.8 setParams:更新当前页面参数
|
|
272
|
+
|
|
273
|
+
```jsx
|
|
274
|
+
// 当前参数 { userId: 1001, tab: 'overview' }
|
|
275
|
+
navigation.setParams({ tab: 'settings' });
|
|
276
|
+
// 更新后 { userId: 1001, tab: 'settings' }
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
这是**浅合并**,不会合并嵌套对象;不改变路由实例的 `key`。参数必须是非数组对象。`modal.update()` 更新弹窗布局等配置,不能替代 `navigation.setParams()`。
|
|
280
|
+
|
|
281
|
+
### 5.9 close、confirm、dismiss:结束整个弹窗
|
|
282
|
+
|
|
283
|
+
```jsx
|
|
284
|
+
const { modal, navigation } = useModal();
|
|
285
|
+
|
|
286
|
+
await navigation.close({ userId: 1001 }); // 关闭整个弹窗,并返回业务结果
|
|
287
|
+
await modal.confirm({ userId: 1001 }); // 明确标记为确认
|
|
288
|
+
await modal.dismiss('cancel'); // 明确标记为取消
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
`navigation.close()` 与 `navigation.goBack()` 不同:前者关闭弹窗,后者仅返回上一 Screen。需要明确确认/取消语义时优先使用 `modal.confirm()` / `modal.dismiss()`。外部可通过 `modal.openAsync()` 获取最终结果。
|
|
292
|
+
|
|
293
|
+
### 5.10 canGoBack、stack、currentRoute:自定义返回按钮与面包屑
|
|
294
|
+
|
|
295
|
+
```jsx
|
|
296
|
+
function NavigationToolbar({ navigation }) {
|
|
297
|
+
return (
|
|
298
|
+
<nav>
|
|
299
|
+
<button disabled={!navigation.canGoBack} onClick={() => navigation.goBack()}>
|
|
300
|
+
返回上一页
|
|
301
|
+
</button>
|
|
302
|
+
<span>当前:{navigation.currentRoute.name}</span>
|
|
303
|
+
<span>深度:{navigation.stack.length}</span>
|
|
304
|
+
</nav>
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### 5.11 KeepAlive 页面聚焦:useIsFocused / useFocusEffect
|
|
310
|
+
|
|
311
|
+
```jsx
|
|
312
|
+
import { useCallback } from 'react';
|
|
313
|
+
import { useIsFocused, useFocusEffect } from 'react-modal-navigation';
|
|
314
|
+
|
|
315
|
+
function UserList() {
|
|
316
|
+
const focused = useIsFocused();
|
|
317
|
+
|
|
318
|
+
useFocusEffect(useCallback(() => {
|
|
319
|
+
const id = setInterval(() => console.log('列表轮询'), 5000);
|
|
320
|
+
return () => clearInterval(id);
|
|
321
|
+
}, []));
|
|
322
|
+
|
|
323
|
+
return <p>{focused ? '当前页面' : '后台保留页面'}</p>;
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
本库在 `navigate()` 前进时保留先前页面的组件状态;隐藏页面不等于卸载。使用 `useFocusEffect()` 在失焦时停止订阅、轮询或定时器。传入 `useCallback` 稳定的回调,避免不必要的重新订阅。
|
|
328
|
+
|
|
329
|
+
### 5.12 导航流程示例
|
|
330
|
+
|
|
331
|
+
```text
|
|
332
|
+
打开 modal.open({ name: 'userModal', screen: 'UserList' })
|
|
333
|
+
[UserList]
|
|
334
|
+
│ navigate('UserDetail', { userId: 1001 })
|
|
335
|
+
▼
|
|
336
|
+
[UserList, UserDetail]
|
|
337
|
+
│ navigate('UserEdit', { userId: 1001 })
|
|
338
|
+
▼
|
|
339
|
+
[UserList, UserDetail, UserEdit]
|
|
340
|
+
│ goBack({ saved: true })
|
|
341
|
+
▼
|
|
342
|
+
[UserList, UserDetail] ← UserDetail 使用 useNavigationResult 接收结果
|
|
343
|
+
│ replace('SaveSuccess')
|
|
344
|
+
▼
|
|
345
|
+
[UserList, SaveSuccess]
|
|
346
|
+
│ reset('UserList')
|
|
347
|
+
▼
|
|
348
|
+
[UserList]
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### 5.13 常见问题与限制
|
|
352
|
+
|
|
353
|
+
1. `navigate/replace/reset` 的目标必须在当前弹窗 `screens` 中注册;否则抛出错误。
|
|
354
|
+
2. `navigate` 到已有页面会截断其后的栈,并替换该页面的参数;如果希望创建新实例,当前 API 不支持强制重复压入同名页面。
|
|
355
|
+
3. `goBack` 在根页面返回 `false`,如需关闭弹窗请使用 `modal.dismiss()`、`modal.confirm()` 或 `navigation.close()`。
|
|
356
|
+
4. `goBack(result)` 的结果由**返回到的上一页面**通过 `useNavigationResult` 接收,不等同于 `modal.openAsync()` 的弹窗最终结果。
|
|
357
|
+
5. `useModalUnsavedChanges()` 当前拦截弹窗关闭和弹窗替换,**不会自动拦截内部** `navigate/goBack/replace/reset`;表单内部路由跳转前需要自行处理未保存状态。
|
|
358
|
+
6. `navigation` 仅在弹窗 Screen 上下文中可用;外部页面负责 `modal.open()`,不要在普通页面中直接调用 `navigation.navigate()`。
|
|
164
359
|
|
|
165
360
|
## 6. 异步业务任务
|
|
166
361
|
|
|
@@ -227,3 +422,97 @@ modal.openAsync({
|
|
|
227
422
|
| animationDuration | number | 220 | 毫秒,关闭等待最多 1000ms |
|
|
228
423
|
|
|
229
424
|
动画位置自动匹配 `placement`,左右 Drawer 保持 5px 缝隙,使用 transform 动画以避免布局抖动。遵循系统减少动态效果设置。
|
|
425
|
+
|
|
426
|
+
## `screen`:指定打开时的初始页面
|
|
427
|
+
|
|
428
|
+
`modal.open({ name, screen?, params?, options?, ...modalOptions })`
|
|
429
|
+
|
|
430
|
+
| 字段 | 类型 | 默认值 | 说明 |
|
|
431
|
+
| --- | --- | --- | --- |
|
|
432
|
+
| `name` | `string` | 必填 | Registry 中的弹窗名称 |
|
|
433
|
+
| `screen` | `string` | `registry[name].initialRoute` | 此次打开时的初始页面名称 |
|
|
434
|
+
| `params` | `unknown` | `{}` | 传给此次选中初始页面的参数 |
|
|
435
|
+
| `options` | `ModalOptions` | `{}` | 弹窗配置,优先于同名顶层选项 |
|
|
436
|
+
|
|
437
|
+
```tsx
|
|
438
|
+
modal.open({ name: 'userModal', screen: 'UserDetail', params: { userId: 1 } });
|
|
439
|
+
await modal.openAsync({ name: 'userModal', screen: 'UserEdit', params: { userId: 1 } });
|
|
440
|
+
await modal.enqueue({ name: 'userModal', screen: 'UserDetail' });
|
|
441
|
+
await modal.enqueueAsync({ name: 'userModal', screen: 'UserEdit' });
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
`screen` 不属于 `ModalOptions`,不会传入 CSS/布局配置;不存在的页面抛出 Error。
|
|
445
|
+
`open` 和 `openAsync` 的字符串签名保持兼容。
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
## navigation.setOptions(options) — 动态设置当前页面选项
|
|
449
|
+
|
|
450
|
+
**签名**:`setOptions(options: ModalScreenOptions): void`。参数必须为非空对象(允许 `{}`),数组与 `null` 会抛出 `TypeError`。更新采用浅合并;只影响当前路由实例,切换到其他路由时使用该路由自己的配置。
|
|
451
|
+
|
|
452
|
+
优先级:`screens[route.name]` 的页面默认配置 < 当前路由 `setOptions()` 覆盖配置。`setOptions` 可动态修改 `title`、`showTitle`、`showBackButton`、`renderHeader`、`renderHeaderRight`、`renderFooter`、`showFooter` 等页面级选项;弹窗尺寸与位置应使用 `modal.update()`。
|
|
453
|
+
|
|
454
|
+
```jsx
|
|
455
|
+
function UserDetail({ route, navigation }) {
|
|
456
|
+
const userId = route.params?.userId;
|
|
457
|
+
React.useEffect(() => {
|
|
458
|
+
navigation.setOptions({
|
|
459
|
+
title: `用户详情 ${userId}`,
|
|
460
|
+
showBackButton: true,
|
|
461
|
+
renderHeaderRight: () => <button onClick={() => console.log(userId)}>刷新</button>,
|
|
462
|
+
});
|
|
463
|
+
}, [navigation.setOptions, userId]);
|
|
464
|
+
return <div>{userId}</div>;
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
**获取参数的三种方式:**
|
|
469
|
+
|
|
470
|
+
```jsx
|
|
471
|
+
// 方式一:页面组件的 route 属性(推荐)
|
|
472
|
+
function EditUser({ route }) { const userId = route.params?.userId; return <div>{userId}</div>; }
|
|
473
|
+
|
|
474
|
+
// 方式二:从 useModal 获取当前路由
|
|
475
|
+
function EditUser() {
|
|
476
|
+
const { navigation } = useModal();
|
|
477
|
+
const userId = navigation.currentRoute?.params?.userId;
|
|
478
|
+
return <div>{userId}</div>;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// 方式三:useModalNavigation
|
|
482
|
+
function EditUser() {
|
|
483
|
+
const navigation = useModalNavigation();
|
|
484
|
+
const userId = navigation.currentRoute?.params?.userId;
|
|
485
|
+
return <div>{userId}</div>;
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**参数来源:** `modal.open({ name, screen, params })` 初始化首屏参数;`navigation.navigate(name, params)` / `replace(name, params)` / `reset(name, params)` 传递目标页面参数;`navigation.setParams({ field: value })` 浅合并当前页面参数。
|
|
490
|
+
|
|
491
|
+
**注意:** `setOptions()` 不会更改 `route.params`,`setParams()` 也不会直接修改 `title`。当 `title` 是基于参数的函数时,`setParams()` 更新参数后会触发重新渲染。动态覆盖选项在对应路由被移除后清除。
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
## Footer 异步操作与整窗 Loading
|
|
495
|
+
|
|
496
|
+
默认 Footer 的 `done` / `cancel` 返回 Promise 时,执行期间自动展示 `ModalLoading` 蒙层,覆盖整个弹窗并阻止交互,结束时自动撤销。显示文本为 `loadingText ?? translate('modal.processing')`。
|
|
497
|
+
|
|
498
|
+
```jsx
|
|
499
|
+
useModalFooter({
|
|
500
|
+
doneText: t('common.save'),
|
|
501
|
+
loadingText: t('common.saving'),
|
|
502
|
+
done: async () => await save(),
|
|
503
|
+
});
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
页面手动控制 Loading 仍可使用 `useModalLoading()` 和 `modal.setLoading()`。
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
### 整窗 Loading 蒙层
|
|
510
|
+
|
|
511
|
+
`useModalLoading()` / `modal.setLoading()` 触发的 Loading 覆盖整个弹窗(Header、页面内容和 Footer),居中展示无卡片、无阴影的旋转圆圈及可国际化文案。背景使用半透明蒙层,弹窗内的操作在加载期间被遮挡。
|
|
512
|
+
|
|
513
|
+
```jsx
|
|
514
|
+
modal.setLoading(true, { text: t("common.loading") });
|
|
515
|
+
// 请求结束后
|
|
516
|
+
modal.setLoading(false);
|
|
517
|
+
```
|
|
518
|
+
|