alert
提示条:带图标的提示、成功、警告或错误信息,适合风控与异常提示。
示例
可用资金低于阈值时显示警告,否则显示检查通过。
javascript
function main() {
while (!exchange.IO("status")) Sleep(1000)
exchange.SetContractType("rb888")
var account = exchange.GetAccount()
if (!account) return
var alert = account.Balance < 100
? {type: "alert", level: "warning", title: "可用资金不足", text: "低于100,暂停开新仓"}
: {type: "alert", level: "success", title: "资金检查通过"}
LogStatus(alert)
}
python
def main():
while not exchange.IO("status"):
Sleep(1000)
exchange.SetContractType("rb888")
account = exchange.GetAccount()
if not account:
return
if account["Balance"] < 100:
alert = {"type": "alert", "level": "warning", "title": "可用资金不足",
"text": "低于100,暂停开新仓"}
else:
alert = {"type": "alert", "level": "success", "title": "资金检查通过"}
LogStatus(alert)
rust
fn main() {
while !exchange.IO("status").is_ok_and(|v| v.as_i64() == Some(1)) {
Sleep(1000);
}
if exchange.SetContractType("rb888").is_err() { return; }
let Ok(a) = exchange.GetAccount() else { return };
let alert = if a.Balance < 100.0 {
r#"{"type": "alert", "level": "warning",
"title": "可用资金不足", "text": "低于100,暂停开新仓"}"#
} else {
r#"{"type": "alert", "level": "success", "title": "资金检查通过"}"#
};
// 整段状态栏只有这一段 JSON,可以跨行
LogStatus!(alert);
}属性
| 名称 | 类型 | 描述 |
type | string | 必填,固定为 |
level | string | 级别: |
title | string | 标题。 |
text | string | 说明文字;只给 |
id | string | 稳定标识。组件的个数或顺序会变化时设置,状态栏刷新时组件不重建。 |
span | number | 在所在 |
参考