更新 lib/api.js
This commit is contained in:
parent
44233da1c0
commit
1b9ae1bf91
19
lib/api.js
19
lib/api.js
|
|
@ -115,6 +115,25 @@ export class CloudClient {
|
||||||
reportTurn(payload, token) {
|
reportTurn(payload, token) {
|
||||||
return this.request('POST', '/activity/turn', payload, token);
|
return this.request('POST', '/activity/turn', payload, token);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Read-only reachability probe: any HTTP answer (even 401 or 404) proves the
|
||||||
|
* host is up. This is what separates "服务不可达" from "令牌无效" in the card,
|
||||||
|
* and it never sends a credential.
|
||||||
|
*/
|
||||||
|
async reach() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${this.options.baseUrl()}/status`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { Accept: 'application/json' },
|
||||||
|
signal: AbortSignal.timeout(this.options.timeoutMs()),
|
||||||
|
});
|
||||||
|
return { ok: true, status: response.status, message: `服务可达(HTTP ${response.status})` };
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const reason = error instanceof Error ? error.message : String(error);
|
||||||
|
return { ok: false, status: 0, message: `服务不可达:${reason}` };
|
||||||
|
}
|
||||||
|
}
|
||||||
/** Stage one turn summary as pending proposals (summary:write token). */
|
/** Stage one turn summary as pending proposals (summary:write token). */
|
||||||
submitSummary(payload, token) {
|
submitSummary(payload, token) {
|
||||||
return this.request('POST', '/activity/summary', payload, token);
|
return this.request('POST', '/activity/summary', payload, token);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue