API 参考
剪贴板
通过 app.capabilities 判断功能支持,通过 app.access 和宿主权限判断访问授权。示例使用合成数据,调用前请替换路径、ID、输入和筛选条件。
类型定义
graphql
type Mutation {
deleteClipboardItems(query: String!): ActionResult!
setClipboard(text: String!, label: String! = "", sensitive: Boolean! = false): Boolean!
}
type Query {
clipboardItemCount(query: String!): Int!
clipboardItems(query: String!, offset: Int!, limit: Int!): [ClipboardItem!]!
}
type Subscription {
clipboardChanged: ClipboardChange!
}
type ActionResult {
affectedCount: Int!
}
type ClipboardChange {
text: String!
sensitive: Boolean!
time: Instant!
}
type ClipboardItem {
id: ID!
text: String!
source: String!
label: String!
sensitive: Boolean!
createdAt: Instant!
}
scalar Instant操作
mutation
deleteClipboardItems
删除匹配的剪贴板历史记录;删除全部记录时必须显式使用 all:true 查询。
graphql
# Delete clipboard history entries matching the query DSL (`ids:` /
# `text:`; a bare word is a text LIKE). A blank query is rejected —
# send `all:true` to target everything.
mutation deleteClipboardItems($query: String!) {
deleteClipboardItems(query: $query) { affectedCount }
}mutation
setClipboard
将文本写入设备剪贴板;系统确认成功后才记录历史。返回 false 或系统报错时历史不变;若之后保存历史失败,会在系统已写入的情况下报错。
graphql
# Record caller-attributed history only after a successful system write; suppress watcher echoes.
mutation setClipboard($text: String!, $label: String!, $sensitive: Boolean!) {
setClipboard(text: $text, label: $label, sensitive: $sensitive)
}query
clipboardItemCount
统计符合查询条件的剪贴板历史记录数。
graphql
query clipboardItemCount($query: String!) {
clipboardItemCount(query: $query)
}query
clipboardItems
分页读取匹配的剪贴板历史记录,最新记录在前。
graphql
# Paged clipboard history, newest first.
query clipboardItems($query: String!, $offset: Int!, $limit: Int!) {
clipboardItems(query: $query, offset: $offset, limit: $limit) { id text source label sensitive createdAt }
}subscription
clipboardChanged
接收剪贴板变更信息。
graphql
subscription clipboardChanged {
clipboardChanged { text sensitive time }
}