valaxy-theme-yun 0.13.3 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
|
|
1
|
+
<script lang="ts" setup>
|
2
|
+
import { watch } from 'vue'
|
3
|
+
|
4
|
+
const props = defineProps<{
|
5
|
+
open: boolean
|
6
|
+
}>()
|
7
|
+
|
8
|
+
const { useAddonAlgolia } = await import('valaxy-addon-algolia')
|
9
|
+
|
10
|
+
const { loaded, load, dispatchEvent } = useAddonAlgolia()
|
11
|
+
|
12
|
+
watch(() => props.open, () => {
|
13
|
+
if (props.open)
|
14
|
+
load()
|
15
|
+
|
16
|
+
if (loaded)
|
17
|
+
dispatchEvent()
|
18
|
+
})
|
19
|
+
</script>
|
20
|
+
|
21
|
+
<template>
|
22
|
+
<AlgoliaSearchBox v-if="loaded" class="hidden" />
|
23
|
+
</template>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<script lang="ts" setup>
|
2
|
+
import { useI18n } from 'vue-i18n'
|
3
|
+
|
4
|
+
withDefaults(defineProps<{
|
5
|
+
open?: boolean
|
6
|
+
}>(), {
|
7
|
+
open: false,
|
8
|
+
})
|
9
|
+
|
10
|
+
const { t } = useI18n()
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<template>
|
14
|
+
<button class="search-btn popup-trigger yun-icon-btn" :title="t('menu.search')">
|
15
|
+
<div v-if="!open" i-ri-search-line />
|
16
|
+
<div v-else text="!2xl" i-ri-close-line />
|
17
|
+
</button>
|
18
|
+
</template>
|
@@ -1,24 +1,12 @@
|
|
1
1
|
<script lang="ts" setup>
|
2
|
-
import { computed } from '@vue/reactivity'
|
3
2
|
import { useSiteConfig } from 'valaxy'
|
4
|
-
import { ref, watch } from 'vue'
|
5
|
-
import { useI18n } from 'vue-i18n'
|
3
|
+
import { computed, defineAsyncComponent, ref, watch } from 'vue'
|
6
4
|
import { useMagicKeys } from '@vueuse/core'
|
7
5
|
|
8
6
|
const siteConfig = useSiteConfig()
|
9
|
-
const { t } = useI18n()
|
10
|
-
|
11
|
-
// to avoid loading the docsearch js upfront (which is more than 1/3 of the
|
12
|
-
// payload), we delay initializing it until the user has actually clicked or
|
13
|
-
// hit the hotkey to invoke it.
|
14
|
-
const loaded = ref(false)
|
15
|
-
|
16
|
-
function load() {
|
17
|
-
if (!loaded.value)
|
18
|
-
loaded.value = true
|
19
|
-
}
|
20
7
|
|
21
8
|
const isAlgolia = computed(() => siteConfig.value.search.type === 'algolia')
|
9
|
+
const isFuse = computed(() => siteConfig.value.search.type === 'fuse')
|
22
10
|
|
23
11
|
const open = ref(false)
|
24
12
|
|
@@ -29,21 +17,20 @@ const togglePopup = () => {
|
|
29
17
|
const { Meta_K } = useMagicKeys()
|
30
18
|
|
31
19
|
watch(Meta_K, (val) => {
|
32
|
-
if (val)
|
20
|
+
if (val)
|
33
21
|
togglePopup()
|
34
|
-
load()
|
35
|
-
}
|
36
22
|
})
|
23
|
+
|
24
|
+
const YunAlgoliaSearch = isAlgolia.value
|
25
|
+
? defineAsyncComponent(() => import('./YunAlgoliaSearch.vue'))
|
26
|
+
: () => null
|
37
27
|
</script>
|
38
28
|
|
39
29
|
<template>
|
40
|
-
<
|
41
|
-
<div v-if="!open" i-ri-search-line />
|
42
|
-
<div v-else text="!2xl" i-ri-close-line />
|
43
|
-
</button>
|
30
|
+
<YunSearchBtn :open="open && !isAlgolia" @click="togglePopup" />
|
44
31
|
|
45
|
-
<
|
46
|
-
<YunFuseSearch v-else-if="
|
32
|
+
<YunAlgoliaSearch v-if="isAlgolia" :open="open" @close="open = false" />
|
33
|
+
<YunFuseSearch v-else-if="isFuse" :open="open" @close="open = false" />
|
47
34
|
</template>
|
48
35
|
|
49
36
|
<style lang="scss">
|
package/composables/helper.ts
CHANGED
@@ -15,7 +15,7 @@ export function useRandomData<T>(source: string | T[], random = false) {
|
|
15
15
|
if (typeof source === 'string') {
|
16
16
|
if (!isClient)
|
17
17
|
return
|
18
|
-
rawData = await fetch(source).then(res => res.json()) as T[]
|
18
|
+
rawData = (await fetch(source).then(res => res.json()) as T[]) || []
|
19
19
|
}
|
20
20
|
else { rawData = source }
|
21
21
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "valaxy-theme-yun",
|
3
|
-
"version": "0.13.
|
3
|
+
"version": "0.13.5",
|
4
4
|
"author": {
|
5
5
|
"email": "me@yunyoujun.cn",
|
6
6
|
"name": "YunYouJun",
|
@@ -22,6 +22,6 @@
|
|
22
22
|
"valaxy-addon-waline": "0.0.9"
|
23
23
|
},
|
24
24
|
"devDependencies": {
|
25
|
-
"valaxy": "0.13.
|
25
|
+
"valaxy": "0.13.5"
|
26
26
|
}
|
27
27
|
}
|
package/valaxy.config.ts
CHANGED
@@ -34,7 +34,11 @@ export default defineValaxyTheme<ThemeConfig>((options) => {
|
|
34
34
|
build: {
|
35
35
|
rollupOptions: {
|
36
36
|
// add on demand external
|
37
|
-
external: [
|
37
|
+
external: [
|
38
|
+
// 'valaxy-addon-algolia',
|
39
|
+
'valaxy-addon-twikoo',
|
40
|
+
'valaxy-addon-waline',
|
41
|
+
],
|
38
42
|
},
|
39
43
|
},
|
40
44
|
plugins: [ThemeVitePlugin(options)],
|