@@ -3,11 +3,14 @@ import { rpc } from '../logic/rpc'
3
3
import type { DocumentInfo } from ' ../../types'
4
4
import { data } from ' ../logic/documentations'
5
5
6
+ const rawItems = data
6
7
const items = ref (data )
7
8
const iframeViewUrl = ref (' ' )
9
+ let packagesName
10
+
8
11
rpc .getPackages ().then ((res ) => {
9
- const packagesName = Object .keys (res .packages )
10
- items .value = items . value .filter (item => packagesName .includes (item .id ))
12
+ packagesName = Object .keys (res .packages )
13
+ items .value = rawItems .filter (item => packagesName .includes (item .id ))
11
14
})
12
15
13
16
function navigate(data : DocumentInfo ) {
@@ -17,24 +20,35 @@ function navigate(data: DocumentInfo) {
17
20
iframeViewUrl .value = data .website
18
21
}
19
22
23
+ const keywords = ref (' ' )
24
+
25
+ watch (keywords , () => {
26
+ items .value = rawItems .filter (item => packagesName .includes (item .id ) && (item .id .includes (keywords .value ) || keywords .value .length === 0 ))
27
+ })
28
+
20
29
function back() {
21
30
iframeViewUrl .value = ' '
22
31
}
23
32
</script >
24
33
25
34
<template >
26
- <div v-if =" iframeViewUrl" relative h-screen >
27
- <IframeView :src =" iframeViewUrl" />
28
- <teleport to =" body" >
29
- <span
30
- fixed left-2 top-2 z-1000 h-8 w-8 flex cursor-pointer select-none items-center justify-center rounded-5
31
- bg-base hover =" text-primary" @click.prevent.stop =" back"
32
- >
33
- <i tabler:arrow-back-up />
34
- </span >
35
- </teleport >
36
- </div >
37
- <div v-else grid grid-cols-minmax-400px h-screen select-none gap3 overflow-scroll p4 class =" no-scrollbar" >
38
- <DocDetails v-for =" (item, index) in items" :key =" index" :data =" item" @navigate =" navigate" />
35
+ <div class =" overflow-y-scroll" >
36
+ <div border =" b base" flex =" ~ col gap1" px4 py3 navbar-glass >
37
+ <VTextInput v-model =" keywords" font-mono icon =" carbon:search" placeholder =" Filter Documentations" op50 />
38
+ </div >
39
+ <div v-if =" iframeViewUrl" >
40
+ <IframeView :src =" iframeViewUrl" />
41
+ <teleport to =" body" >
42
+ <span
43
+ fixed left-2 top-2 z-1000 h-8 w-8 flex cursor-pointer select-none items-center justify-center rounded-5
44
+ bg-base hover =" text-primary" @click.prevent.stop =" back"
45
+ >
46
+ <i tabler:arrow-back-up />
47
+ </span >
48
+ </teleport >
49
+ </div >
50
+ <div v-else grid grid-cols-minmax-400px h-screen select-none gap3 overflow-scroll p4 class =" no-scrollbar" >
51
+ <DocDetails v-for =" (item, index) in items" :key =" index" :data =" item" @navigate =" navigate" />
52
+ </div >
39
53
</div >
40
54
</template >
0 commit comments