(url)
| 396 | } |
| 397 | |
| 398 | function parseQueryString(url) { |
| 399 | const queryString = url.split('?')[1] // 获取查询字符串部分 |
| 400 | const regex = /([^=&]+)=([^&]*)/g // 匹配键值对的正则表达式 |
| 401 | const params = {} |
| 402 | let match |
| 403 | |
| 404 | while ((match = regex.exec(queryString))) { |
| 405 | const key = decodeURIComponent(match[1]) // 解码键 |
| 406 | const value = decodeURIComponent(match[2]) // 解码值 |
| 407 | params[key] = value // 将键值对添加到对象中 |
| 408 | } |
| 409 | |
| 410 | return params |
| 411 | } |
| 412 | |
| 413 | // 请求 |
| 414 | async function http(url, opts = {}) { |