Преглед изворни кода

:art: 提供消息提示推送 API 接口 https://github.com/siyuan-note/siyuan/issues/5102

Liang Ding пре 3 година
родитељ
комит
d5a2de5676
2 измењених фајлова са 117 додато и 5 уклоњено
  1. 59 2
      API.md
  2. 58 3
      API_zh_CN.md

+ 59 - 2
API.md

@@ -35,10 +35,13 @@
 * [Templates](#Templates)
     * [Render a template](#Render-a-template)
 * [File](#File)
-    * [Get File](#Get-file)
-    * [Put File](#Put-file)
+    * [Get file](#Get-file)
+    * [Put file](#Put-file)
 * [Export](#Export)
     * [Export Markdown](#Export-Markdown)
+* [Notification](#Notification)
+    * [Push message](#Push-message)
+    * [Push error message](#Push-error-message)
 * [System](#System)
     * [Get boot progress](#Get-boot-progress)
     * [Get system version](#Get-system-version)
@@ -846,6 +849,60 @@ View API token in <kbd>Settings - About</kbd>, request header: `Authorization: T
     * `hPath`: human-readable path
     * `content`: Markdown content
 
+## Notification
+
+### Push message
+
+* `/api/notification/pushMsg`
+* Parameters
+
+  ```json
+  {
+    "msg": "test",
+    "timeout": 7000
+  }
+  ```
+    * `timeout`: The duration of the message display in milliseconds. This field can be omitted, the default is 7000
+      milliseconds
+* Return value
+
+  ```json
+  {
+    "code": 0,
+    "msg": "",
+    "data": {
+        "id": "62jtmqi"
+    }
+  }
+  ```
+    * `id`: Message ID
+
+### Push error message
+
+* `/api/notification/pushErrMsg`
+* Parameters
+
+  ```json
+  {
+    "msg": "test",
+    "timeout": 7000
+  }
+  ```
+    * `timeout`: The duration of the message display in milliseconds. This field can be omitted, the default is 7000
+      milliseconds
+* Return value
+
+  ```json
+  {
+    "code": 0,
+    "msg": "",
+    "data": {
+        "id": "qc9znut"
+    }
+  }
+  ```
+    * `id`:Message ID
+
 ## System
 
 ### Get boot progress

+ 58 - 3
API_zh_CN.md

@@ -34,11 +34,14 @@
     * [执行 SQL 查询](#执行-SQL-查询)
 * [模板](#模板)
     * [渲染模板](#渲染模板)
-* [导出](#导出)
-    * [导出 Markdown 文本](#导出-markdown-文本)
 * [文件](#文件)
     * [获取文件](#获取文件)
     * [写入文件](#写入文件)
+* [导出](#导出)
+    * [导出 Markdown 文本](#导出-markdown-文本)
+* [通知](#通知)
+    * [推送消息](#推送消息)
+    * [推送报错消息](#推送报错消息)
 * [系统](#系统)
     * [获取启动进度](#获取启动进度)
     * [获取系统版本](#获取系统版本)
@@ -799,7 +802,7 @@
 * 参数为 HTTP Multipart 表单
 
     * `path`:工作空间路径下的文件路径
-    * `isDir`:是否为创建文件夹,为 `true` 时仅创建文件夹,忽略 `file` 
+    * `isDir`:是否为创建文件夹,为 `true` 时仅创建文件夹,忽略 `file`
     * `modTime`:最近访问和修改时间,Unix time
     * `file`:上传的文件
 * 返回值
@@ -842,6 +845,58 @@
     * `hPath`:人类可读的路径
     * `content`:Markdown 内容
 
+## 通知
+
+### 推送消息
+
+* `/api/notification/pushMsg`
+* 参数
+
+  ```json
+  {
+    "msg": "test",
+    "timeout": 7000
+  }
+  ```
+    * `timeout`:消息持续显示时间,单位为毫秒。可以不传入该字段,默认为 7000 毫秒
+* 返回值
+
+  ```json
+  {
+    "code": 0,
+    "msg": "",
+    "data": {
+        "id": "62jtmqi"
+    }
+  }
+  ```
+    * `id`:消息 ID
+
+### 推送报错消息
+
+* `/api/notification/pushErrMsg`
+* 参数
+
+  ```json
+  {
+    "msg": "test",
+    "timeout": 7000
+  }
+  ```
+    * `timeout`:消息持续显示时间,单位为毫秒。可以不传入该字段,默认为 7000 毫秒
+* 返回值
+
+  ```json
+  {
+    "code": 0,
+    "msg": "",
+    "data": {
+        "id": "qc9znut"
+    }
+  }
+  ```
+    * `id`:消息 ID
+
 ## 系统
 
 ### 获取启动进度