markdown State(状态图)
Last updated on November 22, 2024 pm
🧙 Questions
状态图: 用于描述节点的状态变化
☄️ Ideas
内部子状态变化
stateDiagram-v2
[*] --> First
state First {
[*] --> Second
state Second {
[*] --> second
second --> Third
state Third {
[*] --> third
third --> [*]
}
}
}
stateDiagram-v2
[*] --> First
First --> Second
First --> Third
state First {
[*] --> fir
fir --> [*]
}
state Second {
[*] --> sec
sec --> [*]
}
state Third {
[*] --> thi
thi --> [*]
}
逻辑判断
stateDiagram-v2
state if_state <<choice>>
[*] --> IsPositive
IsPositive --> if_state
if_state --> False: if n < 0
if_state --> True : if n >= 0
拉取逻辑
stateDiagram-v2
state fork_state <<fork>>
[*] --> fork_state
fork_state --> State2
fork_state --> State3
state join_state <<join>>
State2 --> join_state
State3 --> join_state
join_state --> State4
State4 --> [*]
并发逻辑
stateDiagram-v2
[*] --> Active
state Active {
[*] --> NumLockOff
NumLockOff --> NumLockOn : EvNumLockPressed
NumLockOn --> NumLockOff : EvNumLockPressed
--
[*] --> CapsLockOff
CapsLockOff --> CapsLockOn : EvCapsLockPressed
CapsLockOn --> CapsLockOff : EvCapsLockPressed
--
[*] --> ScrollLockOff
ScrollLockOff --> ScrollLockOn : EvScrollLockPressed
ScrollLockOn --> ScrollLockOff : EvScrollLockPressed
}
基础语法
stateDiagram-v2
%% 从左向右
direction LR
%% 全局变量
state "运行中" as r
%% 起始
[*] --> Initiative
Initiative --> Created
Created --> r
%% 添加文本
note right of Created
right note content
end note
%% 线上备注
r --> Finished : 运行结束
r --> Failing
r --> Restarting
r --> Suspended
%% 内部逻辑
r --> 取消中
state 取消中 {
[*] --> Canceling
Canceling --> Canceled
Canceled --> [*]
}
取消中 --> [*]
Restarting --> r
Suspended --> r
Restarting --> Failed
Failing --> Failed
Finished --> [*]
Failed --> [*]
stateDiagram-v2
%% 从左向右
direction LR
%% 全局变量
state "运行中" as r
%% 起始
[*] --> Initiative
Initiative --> Created
Created --> r
%% 添加文本
note right of Created
right note content
end note
%% 线上备注
r --> Finished : 运行结束
r --> Failing
r --> Restarting
r --> Suspended
%% 内部逻辑
r --> 取消中
state 取消中 {
[*] --> Canceling
Canceling --> Canceled
Canceled --> [*]
}
取消中 --> [*]
Restarting --> r
Suspended --> r
Restarting --> Failed
Failing --> Failed
Finished --> [*]
Failed --> [*]
注意事项
- 中文不需要加双引号
🔗 Links
markdown State(状态图)
https://ispong.isxcode.com/github/markdown/markdown State(状态图)/