API 參考
鍵值儲存
與偏好設定分開、無須開發者模式的裝置級 JSON 應用程式資料。允許的 key:last_file_path、quick_note_draft、recent_searches、recent_save_dirs、chat_input_text:peer:ID 與 chat_input_text:channel:ID(ID 不得為空)。同一裝置的用戶端共用這些值。
Key Value 目前儲存的資料
下表列出 keyValue 與 setKeyValue 目前接受的應用程式資料索引鍵。值結構反映目前用戶端的用途,不是伺服器強制執行的 JSON 結構。ID 不得為空。資料會永久儲存,並由同一裝置的用戶端共用;不是偏好設定。不存在的值回傳 null。value 引數為非 null JSON,不能以 null 刪除索引鍵。範例描述資料結構,不是實際儲存的使用者內容。
| Key | JSON 值結構 | 用途 |
|---|---|---|
| last_file_path | { rootPath: string, fullPath: string, selectedPath: string } | 上次檔案瀏覽位置:根目錄、完整路徑與選取路徑。 |
| quick_note_draft | string | 尚未傳送的快速筆記文字。 |
| recent_searches | string[] | 最近搜尋詞,最新在前;清單裁剪由用戶端執行。 |
| recent_save_dirs | string[] | 最近選取的儲存或上傳目錄,最新在前;清單裁剪由用戶端執行。 |
| chat_input_text:peer:ID | string | ID 指定的對端裝置尚未傳送的聊天文字。 |
| chat_input_text:channel:ID | string | ID 指定的頻道尚未傳送的聊天文字。 |
型別定義
graphql
type Mutation {
setKeyValue(key: String!, value: JSON!): Boolean!
}
type Query {
keyValue(key: String!): JSON
}
scalar JSON操作
mutation
setKeyValue
將 JSON 應用程式資料永久儲存至允許的 Key Value key,編碼後不得超過 65536 位元組。值變更時回傳 true,值相同時回傳 false;此 API 不會修改偏好設定。
graphql
# Save JSON application data up to 65,536 encoded bytes; returns whether the stored value changed.
mutation setKeyValue($key: String!, $value: JSON!) {
setKeyValue(key: $key, value: $value)
}query
keyValue
讀取允許的 Key Value key 所儲存的 JSON 應用程式資料;不存在時回傳 null。此 API 不會讀取偏好設定。
graphql
# Read JSON application data by key; returns null when absent and does not read preferences.
query keyValue($key: String!) {
keyValue(key: $key)
}