File size: 1,729 Bytes
ba4a662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Lifecycle

A Lifecycle component for getting the current user's environment information.

- Get the current user's language, page theme, user agent, and screen state.
- Listen to page actions and trigger corresponding events (page loading, size changes, page closing, etc.).

## How to Use

### Basic Usage

<demo name="basic"></demo>

### Automatically Adapt to User Language Environment

<demo name="language_adaptation"></demo>

### Return Different Weighted Content Based on UI Theme

<demo name="theme_adaptation"></demo>

## API and Parameter List

### Value

Interface definition:

```python
class LifecycleScreenData(GradioModel):
    width: float
    height: float
    scrollX: float
    scrollY: float


class LifecycleData(GradioModel):
    screen: LifecycleScreenData
    language: str
    theme: str
    userAgent: str
```

### Props

This component does not support passing in props.

### Event Listeners

| Event                            | Description                                                                                                             |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `mgr.Lifecycle.mount(fn,聽路路路)`   | Triggered when the user's page loads. The EventData is a dictionary type value of the current component's value.        |
| `mgr.Lifecycle.unmount(fn,聽路路路)` | Triggered when the user's page closes. The EventData is a dictionary type value of the current component's value.       |
| `mgr.Lifecycle.resize(fn,聽路路路)`  | Triggered when custom labels trigger events. The EventData is a dictionary type value of the current component's value. |