1
1
<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"
12
11
13
- const t = useTheme <HTheme >();
12
+ const t = useTheme <HTheme >()
14
13
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
+ }>()
20
20
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 )
26
26
27
27
const data = computed (() => {
28
28
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
+ }[] = []
38
38
function go(c : TreeNode <Category , " children" >, i = 0 ) {
39
39
res .push ({
40
40
text: c .name ,
@@ -44,12 +44,12 @@ const data = computed(() => {
44
44
sub: c .posts .length ,
45
45
key: c .slug ,
46
46
slug: c .slug ,
47
- });
48
- c .children ?.forEach ((child ) => go (child , i + 1 ));
47
+ })
48
+ c .children ?.forEach ((child ) => go (child , i + 1 ))
49
49
}
50
- categories .value .forEach ((c ) => go (c ));
51
- return res ;
52
- });
50
+ categories .value .forEach ((c ) => go (c ))
51
+ return res
52
+ })
53
53
const colors = computed (() => ({
54
54
deploy: t ?.value .color .primary .n ,
55
55
generate: t ?.value .color .primary .n ,
@@ -60,12 +60,10 @@ const colors = computed(() => ({
60
60
post: t ?.value .color .post ,
61
61
page: t ?.value .color .page ,
62
62
draft: t ?.value .color .draft ,
63
- }));
63
+ }))
64
64
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
+ }
69
67
</script >
70
68
<template >
71
69
<div class =" py-0 pl-4 pr-2" >
0 commit comments