Spaces:
Running
Running
Upload app.js
Browse files- static/app.js +19 -0
static/app.js
CHANGED
|
@@ -1065,6 +1065,25 @@ function toggleResultFilter(kind, value) {
|
|
| 1065 |
STATE.page = 1;
|
| 1066 |
renderFilterOptions({ preserveScroll: true });
|
| 1067 |
doSearch();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1068 |
}
|
| 1069 |
|
| 1070 |
function toggleResultDateTerm(value) {
|
|
|
|
| 1065 |
STATE.page = 1;
|
| 1066 |
renderFilterOptions({ preserveScroll: true });
|
| 1067 |
doSearch();
|
| 1068 |
+
refreshSelectedFacetItem(kind, value);
|
| 1069 |
+
}
|
| 1070 |
+
|
| 1071 |
+
async function refreshSelectedFacetItem(kind, value) {
|
| 1072 |
+
const dataKey = kind === "source" ? "sources" : kind === "author" ? "authors" : "tags";
|
| 1073 |
+
const keys = filterKeys(kind);
|
| 1074 |
+
try {
|
| 1075 |
+
const data = await apiWithTimeout(`/api/facet/${kind}?page=1&page_size=500&q=${encodeURIComponent(value)}`);
|
| 1076 |
+
if (!STATE[keys.include].includes(value) && !STATE[keys.exclude].includes(value)) return;
|
| 1077 |
+
const item = (data.items || []).find((candidate) => String(candidate.name) === value);
|
| 1078 |
+
if (!item) return;
|
| 1079 |
+
STATE.facets[dataKey] = sortFacetItems([
|
| 1080 |
+
...STATE.facets[dataKey].filter((candidate) => String(candidate.name) !== value),
|
| 1081 |
+
item,
|
| 1082 |
+
]);
|
| 1083 |
+
renderFacetFilter(kind);
|
| 1084 |
+
} catch (error) {
|
| 1085 |
+
if (error.name !== "AbortError") console.warn("筛选数量加载失败", error);
|
| 1086 |
+
}
|
| 1087 |
}
|
| 1088 |
|
| 1089 |
function toggleResultDateTerm(value) {
|