* 处理`查询`请求
()
| 219 | * 处理`查询`请求 |
| 220 | */ |
| 221 | async function handleQuery() { |
| 222 | const referer = $request.headers.referer || $request.headers.Referer |
| 223 | if (!/^https?:\/\/(.+\.)?boxjs\.(com|net)\//.test(referer)) { |
| 224 | const isMuteQueryAlert = [true, 'true'].includes( |
| 225 | $.getdata('@chavy_boxjs_userCfgs.isMuteQueryAlert') |
| 226 | ) |
| 227 | |
| 228 | if (!isMuteQueryAlert) { |
| 229 | // 关闭静默状态 |
| 230 | const _isMute = $.isMute |
| 231 | $.isMute = false |
| 232 | |
| 233 | $.msg( |
| 234 | $.name, |
| 235 | '❗️发现有脚本或人正在读取你的数据', |
| 236 | [ |
| 237 | '请注意数据安全, 你可以: ', |
| 238 | '1. 在 BoxJs 的脚本日志中查看详情', |
| 239 | '2. 在 BoxJs 的页面 (侧栏) 中 "不显示查询警告"' |
| 240 | ].join('\n') |
| 241 | ) |
| 242 | |
| 243 | // 还原静默状态 |
| 244 | $.isMute = _isMute |
| 245 | } |
| 246 | |
| 247 | $.log( |
| 248 | [ |
| 249 | '', |
| 250 | '❗️❗️❗️ 发现有脚本或人正在读取你的数据 ❗️❗️❗️', |
| 251 | JSON.stringify($request), |
| 252 | '' |
| 253 | ].join('\n') |
| 254 | ) |
| 255 | } |
| 256 | |
| 257 | const [, query] = $.path.split('/query') |
| 258 | if (/^\/boxdata/.test(query)) { |
| 259 | $.json = getBoxData() |
| 260 | } else if (/^\/baks/.test(query)) { |
| 261 | const [, backupId] = query.split('/baks/') |
| 262 | $.json = $.getjson(backupId) |
| 263 | } else if (/^\/versions$/.test(query)) { |
| 264 | await getVersions(true) |
| 265 | } else if (/^\/data/.test(query)) { |
| 266 | const [, dataKey] = query.split('/data/') |
| 267 | $.json = { |
| 268 | key: dataKey, |
| 269 | val: $.getdata(dataKey) |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * 处理 API 请求 |
no test coverage detected
searching dependent graphs…