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 当前接受的应用数据 key,值结构来自现有客户端用途,并非服务端强制校验的 JSON 结构。ID 不能为空。数据持久保存,同一设备的客户端共用,与偏好设置无关。不存在的值返回 null;value 为非 null JSON,不能用 null 删除 key。此处仅说明数据结构,不展示实际保存的用户内容。
| 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
持久保存指定 Key Value key 的 JSON 数据,编码后不得超过 65,536 字节。值发生变化返回 true,相同值重复写入返回 false;value 不能为 null,也不会修改偏好设置。
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。当前支持的 key 及数据结构见上方可折叠列表;此接口不读取偏好设置。
graphql
# Read JSON application data by key; returns null when absent and does not read preferences.
query keyValue($key: String!) {
keyValue(key: $key)
}