Skip to content

Commit 3a76ea6

Browse files
committed
- ref selectedPostTypes? and its <AMenu>
* now longer setting defualt value of `selectedPage` to the first page * change the height of `.pev2` from dynamicly `40vh` to determined `53rem` @ `<PostQueryPlanVisualizer>` * rename prop `ApiPosts.response.queries` to `query` as it only contains a single query after union @ api/types.ts @ fe
1 parent f22754d commit 3a76ea6

2 files changed

Lines changed: 6 additions & 17 deletions

File tree

fe/src/api/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type ApiPosts = Api<CursorPagination & {
3939
}>,
4040
users: User[],
4141
latestRepliers: LatestReplier[],
42-
queries: Record<PostType, { query: string, plan: ObjUnknown[] }>
42+
query: { query: string, plan: ObjUnknown[] }
4343
}, { query: JsonString }>;
4444
export type ApiForumThreadsID = Api<CursorPagination & {
4545
tid: Tid[]

fe/src/components/post/QueryPlanVisualizer.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<template>
2-
<div class="query-plan-visualizer">
2+
<div class="query-plan-visualizer d-flex flex-wrap">
33
<ClientOnly>
44
<div class="d-inline-flex justify-content-center w-100 border-bottom">
55
<span class="align-self-center">查询计划:</span>
6-
<AMenu v-model:selectedKeys="selectedPostTypes" mode="horizontal" class="justify-content-center w-25">
7-
<AMenuItem key="thread">主题帖</AMenuItem>
8-
<AMenuItem key="reply">回复帖</AMenuItem>
9-
<AMenuItem key="subReply">楼中楼</AMenuItem>
10-
</AMenu>
116
<select v-model="selectedPage" class="form-select">
127
<option
138
v-for="page in data.pages"
@@ -23,11 +18,10 @@
2318
:planSource="JSON.stringify(query.plan, null, 4)" class="pev2" />
2419
</DefinePlan>
2520
<ReusePlan
26-
:key="`${selectedPage}/${selectedPostType}`"
27-
v-if="!(selectedPostType === undefined || selectedPage === undefined)"
21+
:key="selectedPage" v-if="selectedPage !== undefined"
2822
:query="data.pages
2923
.find(page => page.pages.currentCursor === selectedPage)
30-
?.queries[selectedPostType]" />
24+
?.query" />
3125
</ClientOnly>
3226
</div>
3327
</template>
@@ -38,13 +32,8 @@ import { Plan } from 'pev2';
3832
import 'pev2/dist/pev2.css';
3933
4034
const { data } = defineProps<{ data: InfiniteData<ApiPosts['response']> }>();
41-
const selectedPostTypes = ref<[PostType]>();
42-
const selectedPostType = computed(() => selectedPostTypes.value?.[0]);
4335
const selectedPage = ref<Cursor>();
44-
const [DefinePlan, ReusePlan] = createReusableTemplate<{ query?: ApiPosts['response']['queries'][PostType] }>();
45-
46-
watchEffect(() => {
47-
selectedPage.value = data.pages.at(-1)?.pages.currentCursor;
36+
const [DefinePlan, ReusePlan] = createReusableTemplate<{ query?: ApiPosts['response']['query'] }>();
4837
});
4938
</script>
5039

@@ -58,7 +47,7 @@ select {
5847
}
5948
6049
.pev2 {
61-
height: 40vh;
50+
height: 53rem;
6251
resize: block;
6352
contain: content;
6453
}

0 commit comments

Comments
 (0)