PlainApp
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

向裝置剪貼簿寫入文字,並將此次寫入記錄到剪貼簿歷史。

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 }
}