欢乐时光卡

每周欢乐时光窗口及倒计时:欢乐价特惠期间及下一次开始时间。

直播卡片

此卡由浏览器绘制,使用与播放器相同的代码,带示例数据。

类别:食品和饮料。标签:酒吧和酒馆,餐厅和咖啡馆,价格和费率,倒计时和计时器。

布局

此全屏卡在横屏或竖屏时填满整个屏幕,不作为角落、芯片或条带放置。

布局:全屏。表单:横向,纵向。

卡片布局、主题和发布。浏览卡片。

数据与隐私

此卡使用其配置的属性和实时卡数据。

属性

有关主题、背景、强调色和位置,请参见通用属性。

创建卡片时,在卡片的params中设置静态属性。其数据文档仅包含动态属性。嵌套行描述其父属性的内容。

静态属性

名称类型默认数值和限制描述
titlestring"Happy hour"maxLength:30
currencystring"$"maxLength:3
decimals数字,字符串"auto""auto", 0, 1, 2
hour12booleantrue
pageSecondsnumber10最小值:5;最大值:120
footnotestring""maxLength:120底部一行,例如“仅限堂食”。
timeZone字符串,空值null
backgroundColor字符串,空值null模式:"^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$"用纯色 CSS 顺序覆盖卡片背景和底板。#RRGGBBAA 提供透明度。背景无则优先。
textColor字符串,空值null模式:"^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$"覆盖主文本和次要文本颜色。强调色和语义状态色保持原有功能。

动态属性

名称类型默认数值和限制描述
windowsarray[{"days":["weekdays"],"start":"16:00","end":"18:00"},{"days":["fri","sat"],"start":"22:00","end":"00:00","label":"Late"}]maxItems:8每周时间窗口。
windows[].daysarraymaxItems:7周一至周日,或工作日、周末、每日。
windows[].startstringmaxLength:5;必填屏幕所在时区的 HH:MM,24 小时制。
windows[].endstringmaxLength:5;必填HH:MM;结束时间早于开始时间时,跨越午夜。
windows[].labelstringmaxLength:24
specialsarray[{"name":"House lager, pint","price":5,"was":8,"note":"Draught, 20 oz"},{"name":"Well cocktails","price":7,"was":11,"note":"Rum, vodka, gin or whisky"},{"name":"Glass of house red or white","price":6,"was":10},{"name":"Chicken wings, six","price":9,"was":14,"note":"Hot, honey garlic or dry rub","badge":"Popular"},{"name":"Loaded nachos","price":10,"was":15,"note":"Share between two"}]maxItems:24特价内容,欢乐价。
specials[].namestringminLength:1;maxLength:120;必填
specials[].notestringmaxLength:160
specials[].badgestringmaxLength:16
specials[].price数字,空值最小值:0欢乐时光价格。
specials[].was数字,空值最小值:0划去的原价。
specials[].priceLabelstringmaxLength:16替换价格,例如2件10元。

画布示例

将静态属性保存为 params.json 并创建卡片。结果中包含它的 crd_ ID。

{
  "theme": "neomustard"
}
screenrig card create --type happy-hour --major 1 --file params.json

将此项目添加到播放列表页面的primitives中,并用该 ID 替换示例中的 ID。发布播放列表并分配屏幕。

{
  "id": "happy-hour",
  "primitive": "card",
  "card": "crd_01EXAMPLECARD000000000",
  "layout": "full",
  "content_fit": "fill"
}

写入实时数据

创建卡片后向其写入文档,之后替换该文档即可更新屏幕,无需重新发布。卡片会按其动态属性检查每次写入,并拒绝它不接受的文档。请使用与播放列表相同的项目。

将文档保存为card-data.json。CLI直接读取文档,无需包装:

{
  "windows": [
    {
      "days": [
        "weekdays"
      ],
      "start": "16:00",
      "end": "18:00"
    },
    {
      "days": [
        "fri",
        "sat"
      ],
      "start": "22:00",
      "end": "00:00",
      "label": "Late"
    }
  ],
  "specials": [
    {
      "name": "House lager, pint",
      "price": 5,
      "was": 8,
      "note": "Draught, 20 oz"
    },
    {
      "name": "Well cocktails",
      "price": 7,
      "was": 11,
      "note": "Rum, vodka, gin or whisky"
    },
    {
      "name": "Glass of house red or white",
      "price": 6,
      "was": 10
    },
    {
      "name": "Chicken wings, six",
      "price": 9,
      "was": 14,
      "note": "Hot, honey garlic or dry rub",
      "badge": "Popular"
    },
    {
      "name": "Loaded nachos",
      "price": 10,
      "was": 15,
      "note": "Share between two"
    }
  ]
}
screenrig card data put crd_01EXAMPLECARD000000000 --file card-data.json

或直接调用 API。API 将相同文档包装在 document 字段中。智能体令牌已指定其项目,因此不发送项目头;若发送 ScreenRig-Project,必须与令牌项目匹配。通过环境提供 API 授权;详见 API 认证。

curl --request PUT "https://api.screenrig.ai/api/cards/crd_01EXAMPLECARD000000000/data" \
  --header "Authorization: Bearer $SCREENRIG_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"document":{"windows":[{"days":["weekdays"],"start":"16:00","end":"18:00"},{"days":["fri","sat"],"start":"22:00","end":"00:00","label":"Late"}],"specials":[{"name":"House lager, pint","price":5,"was":8,"note":"Draught, 20 oz"},{"name":"Well cocktails","price":7,"was":11,"note":"Rum, vodka, gin or whisky"},{"name":"Glass of house red or white","price":6,"was":10},{"name":"Chicken wings, six","price":9,"was":14,"note":"Hot, honey garlic or dry rub","badge":"Popular"},{"name":"Loaded nachos","price":10,"was":15,"note":"Share between two"}]}}'