MCPcopy Create free account
hub / github.com/Tong89/smartNode / refreshRequestList

Function refreshRequestList

frontend/app.js:470–499  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

468
469 // ── 分页请求列表 ─────────────────────────────────────────────
470 async refreshRequestList() {
471 this.reqLoading = true;
472 try {
473 const params = new URLSearchParams();
474 params.set('page', String(this.reqPage));
475 params.set('page_size', String(this.reqPageSize));
476 params.set('sort', this.reqSort);
477 if (this.reqFilterStatus) params.set('status', this.reqFilterStatus);
478 if (this.reqFilterDataType) params.set('data_type', this.reqFilterDataType);
479 if (this.reqFilterSatelliteId) params.set('satellite_id', this.reqFilterSatelliteId);
480
481 // fetchJson 对统一包络自动解包,返回 data 字段(即 items 数组)
482 // 但这里需要同时获取 meta,需要绕过自动解包
483 const url = `/api/v1/requests?${params.toString()}`;
484 const resp = await fetch(this.apiUrl(url), {
485 headers: { 'Content-Type': 'application/json' },
486 });
487 const payload = await resp.json();
488 if (payload && payload.code === 0) {
489 this.reqItems = Array.isArray(payload.data) ? payload.data : [];
490 const meta = payload.meta || {};
491 this.reqTotal = Number(meta.total || 0);
492 this.reqHasNext = Boolean(meta.has_next);
493 }
494 } catch (e) {
495 this.setNotice('请求列表加载失败: ' + (e.message || e), 'error');
496 } finally {
497 this.reqLoading = false;
498 }
499 },
500
501 async reqGoPage(page) {
502 if (page < 1 || page > this.reqTotalPages) return;

Callers

nothing calls this directly

Calls 1

setMethod · 0.80

Tested by

no test coverage detected