Skip to content

Commit 9e71621

Browse files
committed
fix: h-nav-list
1 parent 5cfbe80 commit 9e71621

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

packages/hexon-web/src/components/HNavList.vue

+38-40
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
<script setup lang="ts">
2-
import { toRefs, computed } from "vue";
3-
import { useTheme } from "@winwin/vue-global-theming";
4-
import { HTheme } from "~/themes";
5-
import { TreeNode } from "~/lib/list2tree";
6-
import { Category } from "~/types";
7-
import HNavTitle from "./HNavTitle.vue";
8-
import HNavItem from "./HNavItem.vue";
9-
import { HIconName } from "./HIconName";
10-
import { HNavListActionPayload } from "./types";
11-
import { useArticleListStore } from "~/store/articleList";
2+
import { toRefs, computed } from "vue"
3+
import { useTheme } from "@winwin/vue-global-theming"
4+
import { HTheme } from "~/themes"
5+
import { TreeNode } from "~/lib/list2tree"
6+
import { Category } from "~/types"
7+
import HNavTitle from "./HNavTitle.vue"
8+
import HNavItem from "./HNavItem.vue"
9+
import { HIconName } from "./HIconName"
10+
import { HNavListActionPayload } from "./types"
1211
13-
const t = useTheme<HTheme>();
12+
const t = useTheme<HTheme>()
1413
const props = defineProps<{
15-
categories: TreeNode<Category, "children">[];
16-
post: number;
17-
page: number;
18-
draft: number;
19-
}>();
14+
categories: TreeNode<Category, "children">[]
15+
post: number
16+
page: number
17+
draft: number
18+
type: "all" | "post" | "page" | "draft" | "category" | "tag"
19+
}>()
2020
const emits = defineEmits<{
21-
(e: "on-action", payload: HNavListActionPayload): void;
22-
(e: "on-click", key: string): void;
23-
}>();
24-
const { categories, post, page, draft } = toRefs(props);
25-
const all = computed(() => post.value + page.value + draft.value);
21+
(e: "on-action", payload: HNavListActionPayload): void
22+
(e: "on-click", key: string): void
23+
}>()
24+
const { categories, post, page, draft, type } = toRefs(props)
25+
const all = computed(() => post.value + page.value + draft.value)
2626
2727
const data = computed(() => {
2828
const res: {
29-
icon: HIconName;
30-
text: string;
31-
indent?: number;
32-
selected?: boolean;
33-
color?: string;
34-
sub?: string | number;
35-
key: string;
36-
slug: string;
37-
}[] = [];
29+
icon: HIconName
30+
text: string
31+
indent?: number
32+
selected?: boolean
33+
color?: string
34+
sub?: string | number
35+
key: string
36+
slug: string
37+
}[] = []
3838
function go(c: TreeNode<Category, "children">, i = 0) {
3939
res.push({
4040
text: c.name,
@@ -44,12 +44,12 @@ const data = computed(() => {
4444
sub: c.posts.length,
4545
key: c.slug,
4646
slug: c.slug,
47-
});
48-
c.children?.forEach((child) => go(child, i + 1));
47+
})
48+
c.children?.forEach((child) => go(child, i + 1))
4949
}
50-
categories.value.forEach((c) => go(c));
51-
return res;
52-
});
50+
categories.value.forEach((c) => go(c))
51+
return res
52+
})
5353
const colors = computed(() => ({
5454
deploy: t?.value.color.primary.n,
5555
generate: t?.value.color.primary.n,
@@ -60,12 +60,10 @@ const colors = computed(() => ({
6060
post: t?.value.color.post,
6161
page: t?.value.color.page,
6262
draft: t?.value.color.draft,
63-
}));
63+
}))
6464
const onAction = (payload: HNavListActionPayload) => {
65-
emits("on-action", payload);
66-
};
67-
const articleList = useArticleListStore();
68-
const type = computed(() => articleList.filter.type);
65+
emits("on-action", payload)
66+
}
6967
</script>
7068
<template>
7169
<div class="py-0 pl-4 pr-2">

packages/hexon-web/src/pages/HomePage.vue

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ const onArticleClick = ({
116116
params: { source, type },
117117
})
118118
}
119+
const articleList = useArticleListStore()
120+
const type = computed(() => articleList.filter.type)
119121
</script>
120122
<template>
121123
<SplitView
@@ -138,6 +140,7 @@ const onArticleClick = ({
138140
:page="pagesCount"
139141
:post="postsCount"
140142
:draft="draftsCount"
143+
:type="type"
141144
@on-action="onNavListAction"
142145
/>
143146
</div>

0 commit comments

Comments
 (0)