Skip to content

Commit 0e935f9

Browse files
committed
feat(info): 支持 os_categories 和 authors,以及联合筛选
close #96
1 parent 65ae29a commit 0e935f9

File tree

1 file changed

+35
-24
lines changed

1 file changed

+35
-24
lines changed

os-checks/pages/info.vue

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@
77

88
<template #header>
99
<div style="display: flex; justify-content: space-between;">
10-
<div>
10+
<div style="display: flex; gap: 20px;">
1111
<MultiSelect v-model="selectedCategories" display="chip" :options="categories" filter :maxSelectedLabels="4"
1212
placeholder="Select Categories" />
13+
14+
<MultiSelect v-model="selectedOSCategories" display="chip" :options="os_categories" filter
15+
:maxSelectedLabels="4" placeholder="Select OS Categories" />
16+
17+
<MultiSelect v-model="selectedAuthors" display="chip" :options="authors" filter :maxSelectedLabels="4"
18+
placeholder="Select Authors" />
1319
</div>
1420

15-
<div style="width: 40%">
21+
<div style="width: 30%">
1622
<IconField>
1723
<InputIcon>
1824
<i class="pi pi-search" />
1925
</InputIcon>
20-
<InputText style="width: 100%" v-model="filters['global'].value" placeholder="Global Search" />
26+
<InputText style="width: 100%" v-model="filters['global'].value"
27+
placeholder="Search in all text columns" />
2128
</IconField>
2229
</div>
2330

@@ -109,7 +116,6 @@
109116
<script setup lang="ts">
110117
import type { Pkg, PkgInfo, Test } from '~/shared/info';
111118
import { FilterMatchMode } from '@primevue/core/api';
112-
import type { Summary } from '~/shared/workflows';
113119
114120
// interactive filter/search inputs
115121
const filters = ref<any>({
@@ -124,23 +130,6 @@ githubFetch<PkgInfo[]>({
124130
summaries.value = val;
125131
});
126132
127-
const summaryColumns = [
128-
// { field: "idx", header: "Idx" },
129-
// { field: "user", header: "User" },
130-
// { field: "repo", header: "Repo" },
131-
// { field: "pkg", header: "Package" },
132-
{ field: "version", header: "Version" },
133-
{ field: "dependencies", header: "Depen-dencies" },
134-
{ field: "testcases", header: "TestCases" },
135-
{ field: "tests", header: "Tests" },
136-
{ field: "examples", header: "Examples" },
137-
{ field: "benches", header: "Benches" },
138-
// { field: "author", header: "Author" },
139-
// { field: "description", header: "Description" },
140-
// { field: "categories", header: "Categories" },
141-
// { field: "os_categories", header: "OS Categories" },
142-
];
143-
144133
const summaryTable = computed<SummaryTable[]>(() => {
145134
const value = summaries.value.map(val => {
146135
return Object.entries(val.pkgs).map(([name, pkg]) => {
@@ -195,14 +184,36 @@ const data = ref<SummaryTable[]>([]);
195184
watch(summaryTable, (val) => data.value = val);
196185
197186
const categories = computed(() => [...new Set(summaryTable.value.map(val => val.categories).flat().filter(c => c))].sort());
187+
const os_categories = computed(() => [...new Set(summaryTable.value.map(val => val.os_categories).flat().filter(c => c))].sort());
188+
const authors = computed(() => [...new Set(summaryTable.value.map(val => val.author).flat().filter(c => c))].sort());
198189
const selectedCategories = ref<string[]>([]);
199-
watch(selectedCategories, cat => {
200-
if (cat.length === 0) {
190+
const selectedOSCategories = ref<string[]>([]);
191+
const selectedAuthors = ref<string[]>([]);
192+
watchEffect(() => {
193+
const cat = selectedCategories.value;
194+
const os_cat = selectedOSCategories.value;
195+
const au = selectedAuthors.value;
196+
197+
const is_empty_cat = cat.length === 0;
198+
const is_empty_os_cat = os_cat.length === 0;
199+
const is_empty_au = au.length === 0;
200+
201+
// reset
202+
if (is_empty_cat && is_empty_os_cat && is_empty_au) {
201203
data.value = summaryTable.value;
202204
return;
203205
}
204206
205-
data.value = summaryTable.value.filter(val => cat.find(c => val.categories?.find(vc => vc === c)));
207+
data.value = summaryTable.value.filter(val => {
208+
const find_cat = cat.find(c => val.categories?.find(vc => vc === c));
209+
const find_os_cat = os_cat.find(o => val.os_categories?.find(vo => vo === o));
210+
const find_au = au.find(a => val.author?.find(va => va === a));
211+
212+
return (is_empty_cat ? true : find_cat) && (is_empty_os_cat ? true : find_os_cat) && (is_empty_au ? true : find_au)
213+
}).map((x, idx) => {
214+
x.idx = idx + 1;
215+
return x;
216+
});
206217
});
207218
208219
const dialogShow = ref(false);

0 commit comments

Comments
 (0)