|
15 | 15 | </style>
|
16 | 16 | </head>
|
17 | 17 | <body>
|
18 |
| - <h1 id="welcome">Welcome</h1> |
| 18 | + <h1 id="toolapi">toolapi</h1> |
19 | 19 | <h1 id="section">这是什么?</h1>
|
20 | 20 | <p>一个简单的工具API
|
21 | 21 | 项目仓库<a href="https://github.com/AragonSnow/toolapi">https://github.com/AragonSnow/toolapi</a><br>
|
| 22 | +博客:<a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/">简单工具api</a><br> |
22 | 23 | 如果有更多api需求,可以留言给我添加</p>
|
23 | 24 | <h1 id="section-1">功能</h1>
|
24 |
| -<h2 id="timestamp">1 时间戳转换(/timestamp)</h2> |
25 |
| -<p>目前仅支持GMT+8 北京时间</p> |
26 |
| -<h3 id="section-2">1.1 参数</h3> |
27 |
| -<table> |
28 |
| -<thead> |
29 |
| -<tr> |
30 |
| -<th style="text-align: center;">参数</th> |
31 |
| -<th style="text-align: center;">默认值</th> |
32 |
| -<th style="text-align: left;">是否必要参数</th> |
33 |
| -<th style="text-align: left;">解释</th> |
34 |
| -</tr> |
35 |
| -</thead> |
36 |
| -<tbody> |
37 |
| -<tr> |
38 |
| -<td style="text-align: center;">t</td> |
39 |
| -<td style="text-align: center;">now</td> |
40 |
| -<td style="text-align: left;">是</td> |
41 |
| -<td style="text-align: left;">要转换成时间戳的北京时间</td> |
42 |
| -</tr> |
43 |
| -<tr> |
44 |
| -<td style="text-align: center;">ts</td> |
45 |
| -<td style="text-align: center;">null</td> |
46 |
| -<td style="text-align: left;">是</td> |
47 |
| -<td style="text-align: left;">要转换成北京时间的时间戳</td> |
48 |
| -</tr> |
49 |
| -<tr> |
50 |
| -<td style="text-align: center;">form</td> |
51 |
| -<td style="text-align: center;">%Y-%m-%d %H:%M:%S</td> |
52 |
| -<td style="text-align: left;">否</td> |
53 |
| -<td style="text-align: left;">输出的时间格式</td> |
54 |
| -</tr> |
55 |
| -</tbody> |
56 |
| -</table> |
57 |
| -<h3 id="section-3">1.2 返回值</h3> |
58 |
| -<table> |
59 |
| -<thead> |
60 |
| -<tr> |
61 |
| -<th style="text-align: center;">参数</th> |
62 |
| -<th style="text-align: left;">解释</th> |
63 |
| -</tr> |
64 |
| -</thead> |
65 |
| -<tbody> |
66 |
| -<tr> |
67 |
| -<td style="text-align: center;">时间戳</td> |
68 |
| -<td style="text-align: left;">转换的时间戳</td> |
69 |
| -</tr> |
70 |
| -<tr> |
71 |
| -<td style="text-align: center;">时间</td> |
72 |
| -<td style="text-align: left;">格式化输出的北京时间</td> |
73 |
| -</tr> |
74 |
| -<tr> |
75 |
| -<td style="text-align: center;">状态</td> |
76 |
| -<td style="text-align: left;">运行的状态, 非OK都是异常</td> |
77 |
| -</tr> |
78 |
| -</tbody> |
79 |
| -</table> |
80 |
| -<h3 id="section-4">1.3 用例</h3> |
81 |
| -<pre><code>https://toolapi.us-south.cf.appdomain.cloud/timestamp |
82 |
| -返回现在北京时间 |
83 |
| -{ |
84 |
| - "时间戳": 1586917839, |
85 |
| - "时间": "2020-04-15 10:30:39", |
86 |
| - "状态": "OK" |
87 |
| -} |
88 |
| -</code></pre> |
89 |
| -<pre><code>https://toolapi.us-south.cf.appdomain.cloud/timestamp?ts=1586921249 |
90 |
| -如果参数带时间戳,会忽略其他参数转换成北京时间 |
91 |
| -{ |
92 |
| - "时间戳": "1586921249", |
93 |
| - "时间": "2020-04-15 11:27:29", |
94 |
| - "状态": "OK" |
95 |
| -} |
96 |
| -</code></pre> |
97 |
| -<pre><code>https://toolapi.us-south.cf.appdomain.cloud/timestamp?t=2020-04-15+11%3a00%3a09 |
98 |
| -北京时间返回时间戳 |
99 |
| -{ |
100 |
| - "时间戳": 1586919609, |
101 |
| - "时间": "2020-04-15 11:00:09", |
102 |
| - "状态": "OK" |
103 |
| -} |
104 |
| -</code></pre> |
105 |
| -<h2 id="regex">2. 正则表达是(/regex)</h2> |
106 |
| -<p>正则匹配参数并返回匹配结果</p> |
107 |
| -<h3 id="section-5">2.1 参数</h3> |
108 |
| -<table> |
109 |
| -<thead> |
110 |
| -<tr> |
111 |
| -<th style="text-align: center;">参数</th> |
112 |
| -<th style="text-align: center;">默认值</th> |
113 |
| -<th style="text-align: left;">是否必要参数</th> |
114 |
| -<th style="text-align: left;">解释</th> |
115 |
| -</tr> |
116 |
| -</thead> |
117 |
| -<tbody> |
118 |
| -<tr> |
119 |
| -<td style="text-align: center;">data</td> |
120 |
| -<td style="text-align: center;">""</td> |
121 |
| -<td style="text-align: left;">是</td> |
122 |
| -<td style="text-align: left;">要匹配的数据</td> |
123 |
| -</tr> |
124 |
| -<tr> |
125 |
| -<td style="text-align: center;">p</td> |
126 |
| -<td style="text-align: center;">""</td> |
127 |
| -<td style="text-align: left;">是</td> |
128 |
| -<td style="text-align: left;">正则表达式</td> |
129 |
| -</tr> |
130 |
| -</tbody> |
131 |
| -</table> |
132 |
| -<h3 id="section-6">2.2 返回值</h3> |
133 |
| -<table> |
134 |
| -<thead> |
135 |
| -<tr> |
136 |
| -<th style="text-align: center;">参数</th> |
137 |
| -<th style="text-align: left;">解释</th> |
138 |
| -</tr> |
139 |
| -</thead> |
140 |
| -<tbody> |
141 |
| -<tr> |
142 |
| -<td style="text-align: center;">数据</td> |
143 |
| -<td style="text-align: left;">匹配的结果</td> |
144 |
| -</tr> |
145 |
| -<tr> |
146 |
| -<td style="text-align: center;">状态</td> |
147 |
| -<td style="text-align: left;">运行的状态, 非OK都是异常</td> |
148 |
| -</tr> |
149 |
| -</tbody> |
150 |
| -</table> |
151 |
| -<h3 id="section-7">2.3 用例</h3> |
152 |
| -<pre><code>https://toolapi.us-south.cf.appdomain.cloud/regex?data=%7b"code"%3a0%2c"msg"%3a"成功"%2c"data"%3a%7b"users"%3a%5b%7b"name"%3a"张三"%2c"gender"%3a"male"%2c"age"%3a12%7d%2c%7b"name"%3a"李四"%2c"gender"%3a"female"%2c"age"%3a15%7d%2c%7b"name"%3a"王五"%2c"gender"%3a"male"%2c"age"%3a22%7d%2c%7b"name"%3a"赵六"%2c"gender"%3a"male"%2c"age"%3a24%7d%5d%2c"goods"%3a%5b%7b"name"%3a"apple"%2c"price"%3a15%2c"num"%3a200%7d%2c%7b"name"%3a"pear"%2c"price"%3a18%2c"num"%3a100%7d%2c%7b"name"%3a"banana"%2c"price"%3a16%2c"num"%3a210%7d%5d%7d%7d&p=name"%3a"(.%2b%3f)" |
153 |
| - |
154 |
| -测试数据: |
155 |
| -{"code":0,"msg":"成功","data":{"users":[{"name":"张三","gender":"male","age":12},{"name":"李四","gender":"female","age":15},{"name":"王五","gender":"male","age":22},{"name":"赵六","gender":"male","age":24}],"goods":[{"name":"apple","price":15,"num":200},{"name":"pear","price":18,"num":100},{"name":"banana","price":16,"num":210}]}} |
156 |
| - |
157 |
| -正则表达式: name":"(.+?)" |
158 |
| - |
159 |
| -返回结果: |
160 |
| -{ |
161 |
| - "数据": { |
162 |
| - "1": "张三", |
163 |
| - "2": "李四", |
164 |
| - "3": "王五", |
165 |
| - "4": "赵六", |
166 |
| - "5": "apple", |
167 |
| - "6": "pear", |
168 |
| - "7": "banana" |
169 |
| - }, |
170 |
| - "状态": "OK" |
171 |
| -} |
172 |
| -</code></pre> |
173 |
| -<h2 id="string">3 字符串处理(string)</h2> |
174 |
| -<p>目前实现字符串替换功能</p> |
175 |
| -<h3 id="replace">3.1 字符串替换(replace)</h3> |
176 |
| -<table> |
177 |
| -<thead> |
178 |
| -<tr> |
179 |
| -<th style="text-align: center;">参数</th> |
180 |
| -<th style="text-align: center;">默认值</th> |
181 |
| -<th style="text-align: left;">是否必要参数</th> |
182 |
| -<th style="text-align: left;">解释</th> |
183 |
| -</tr> |
184 |
| -</thead> |
185 |
| -<tbody> |
186 |
| -<tr> |
187 |
| -<td style="text-align: center;">s</td> |
188 |
| -<td style="text-align: center;">""</td> |
189 |
| -<td style="text-align: left;">是</td> |
190 |
| -<td style="text-align: left;">要替换的数据</td> |
191 |
| -</tr> |
192 |
| -<tr> |
193 |
| -<td style="text-align: center;">f</td> |
194 |
| -<td style="text-align: center;">""</td> |
195 |
| -<td style="text-align: left;">是</td> |
196 |
| -<td style="text-align: left;">必须是replace</td> |
197 |
| -</tr> |
198 |
| -<tr> |
199 |
| -<td style="text-align: center;">p</td> |
200 |
| -<td style="text-align: center;">""</td> |
201 |
| -<td style="text-align: left;">是</td> |
202 |
| -<td style="text-align: left;">要替换的关键词,支持正则</td> |
203 |
| -</tr> |
204 |
| -<tr> |
205 |
| -<td style="text-align: center;">t</td> |
206 |
| -<td style="text-align: center;">""</td> |
207 |
| -<td style="text-align: left;">是</td> |
208 |
| -<td style="text-align: left;">替换后的内容</td> |
209 |
| -</tr> |
210 |
| -<tr> |
211 |
| -<td style="text-align: center;">r</td> |
212 |
| -<td style="text-align: center;">""</td> |
213 |
| -<td style="text-align: left;">否</td> |
214 |
| -<td style="text-align: left;">返回的内容选择是json和纯文本, 默认是返回json,json会先显示转义字符,纯文本不会</td> |
215 |
| -</tr> |
216 |
| -</tbody> |
217 |
| -</table> |
218 |
| -<h3 id="replace-1">3.2 字符串替换(replace)</h3> |
219 |
| -<p>| 参数 | 解释 | |
220 |
| -| :----: | :---- | |
221 |
| -| 原始字符串 | 输入的内容 | |
222 |
| -| 处理后字符串 | 替换后的字符串 | |
223 |
| -| 状态 | 运行的状态, 非OK都是异常 | |
224 |
| -text |
225 |
| -直接返回替换后的字符串</p> |
226 |
| -<h3 id="section-8">3.1.3 用例</h3> |
227 |
| -<pre><code>返回json |
228 |
| -https://toolapi.us-south.cf.appdomain.cloud/string?p=%E4%BA%BA&t=%E5%AD%97%E7%AC%A6%E4%B8%B2&f=replace&r=json&s={"text":"我是人"} |
229 |
| -s = {"text":"我是人"} |
230 |
| -f = replace |
231 |
| -p = 人 |
232 |
| -t = 字符串 |
233 |
| -r = json (可不用,默认) |
234 |
| -返回 |
235 |
| -{ |
236 |
| - "原始字符串": "{\"text\":\"我是人\"}", |
237 |
| - "处理后字符串": "{\"text\":\"我是字符串\"}", |
238 |
| - "状态": "OK" |
239 |
| -} |
240 |
| -</code></pre> |
241 |
| -<pre><code>返回文本 |
242 |
| -https://toolapi.us-south.cf.appdomain.cloud/string?p=%E4%BA%BA&t=%E5%AD%97%E7%AC%A6%E4%B8%B2&f=replace&r=text&s={"text":"我是人"} |
243 |
| -s = {"text":"我是人"} |
244 |
| -f = replace |
245 |
| -p = 人 |
246 |
| -t = 字符串 |
247 |
| -r = text |
248 |
| -返回 |
249 |
| -{"text":"我是字符串"} |
250 |
| -</code></pre> |
| 25 | +<h2 id="timestamp"><a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/#1-%E6%97%B6%E9%97%B4%E6%88%B3%E8%BD%AC%E6%8D%A2%EF%BC%88-timestamp%EF%BC%89">1 时间戳转换(/timestamp)</a></h2> |
| 26 | +<h2 id="regex"><a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/#2-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E6%98%AF%EF%BC%88-regex%EF%BC%89">2. 正则表达是(/regex)</a></h2> |
| 27 | +<h2 id="string"><a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/#3-%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%A4%84%E7%90%86-string">3 字符串处理(string)</a></h2> |
| 28 | +<h3 id="replace"><a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/#3-1-%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%9B%BF%E6%8D%A2-replace">3.1 字符串替换(replace)</a></h3> |
| 29 | +<h2 id="condition"><a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/#4-%E6%9D%A1%E4%BB%B6-condition">4 条件(condition)</a></h2> |
| 30 | +<h3 id="judge"><a href="https://hexo.aragon.wang/2020/04/16/%E7%AE%80%E5%8D%95%E5%B7%A5%E5%85%B7api/#4-1-%E5%88%A4%E6%96%AD-judge">4.1 判断(judge)</a></h3> |
251 | 31 |
|
252 | 32 | </body>
|
253 | 33 | </html>
|
|
0 commit comments