valaxy 0.25.9 → 0.25.11
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.
- package/client/composables/app/useValaxyApp.ts +9 -2
- package/client/composables/locale.ts +18 -10
- package/dist/{chunk-MSK4KQXZ.js → chunk-YYHL7OM3.js} +239 -259
- package/dist/{config-CSOxBD5d.d.ts → config-bf4WqwPK.d.ts} +8 -0
- package/dist/node/cli/index.js +1 -1
- package/dist/node/index.d.ts +2 -6
- package/dist/node/index.js +1 -3
- package/dist/types/index.d.ts +2 -2
- package/package.json +9 -8
- package/shared/utils/i18n.ts +1 -1
- package/types/config.ts +8 -0
|
@@ -5,8 +5,9 @@ import { useSeoMeta } from '@unhead/vue'
|
|
|
5
5
|
import { computed } from 'vue'
|
|
6
6
|
import { useI18n } from 'vue-i18n'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useRoute } from 'vue-router'
|
|
9
9
|
|
|
10
|
+
import { useFrontmatter, useLocale, useValaxyHead, useValaxyI18n } from '../../composables'
|
|
10
11
|
import { useTimezone } from '../../composables/global'
|
|
11
12
|
// https://github.com/vueuse/head
|
|
12
13
|
// you can use this to manipulate the document head in any components,
|
|
@@ -23,6 +24,13 @@ export function useValaxyApp() {
|
|
|
23
24
|
|
|
24
25
|
const title = computed(() => $tO(fm.value.title))
|
|
25
26
|
|
|
27
|
+
const route = useRoute()
|
|
28
|
+
const { toggleLocale } = useLocale()
|
|
29
|
+
// if lang exist, toggle the locale
|
|
30
|
+
if (route.query.lang) {
|
|
31
|
+
toggleLocale(route.query.lang as string)
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
// seo
|
|
27
35
|
// todo: get first image url from markdown
|
|
28
36
|
const siteUrl = computed(() => fm.value.url || siteConfig.value.url)
|
|
@@ -59,6 +67,5 @@ export function useValaxyApp() {
|
|
|
59
67
|
])
|
|
60
68
|
|
|
61
69
|
useTimezone()
|
|
62
|
-
|
|
63
70
|
useValaxyHead()
|
|
64
71
|
}
|
|
@@ -17,24 +17,32 @@ export function useLocale() {
|
|
|
17
17
|
// setDefaultOptions({ locale: locale.value === 'zh-CN' ? zhCN : enUS })
|
|
18
18
|
dayjs.locale(locale.value === 'zh-CN' ? 'zh-cn' : 'en')
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
/**
|
|
21
|
+
* toggle to new locale
|
|
22
|
+
* @param newLocale
|
|
23
|
+
*/
|
|
24
|
+
function toggleLocale(newLocale: string) {
|
|
25
|
+
locale.value = newLocale
|
|
25
26
|
// for localStorage
|
|
26
|
-
lang.value =
|
|
27
|
-
|
|
27
|
+
lang.value = newLocale
|
|
28
28
|
// set date locale
|
|
29
29
|
// setDefaultOptions({ locale: locale.value === 'zh-CN' ? zhCN : enUS })
|
|
30
|
-
dayjs.locale(
|
|
31
|
-
|
|
30
|
+
dayjs.locale(newLocale === 'zh-CN' ? 'zh-cn' : 'en')
|
|
32
31
|
if (isClient)
|
|
33
|
-
document.documentElement.setAttribute('lang',
|
|
32
|
+
document.documentElement.setAttribute('lang', newLocale)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const toggleLocales = () => {
|
|
36
|
+
// change to some real logic
|
|
37
|
+
const locales = availableLocales
|
|
38
|
+
locale.value = locales[(locales.indexOf(locale.value) + 1) % locales.length]
|
|
39
|
+
const newLocale = locale.value
|
|
40
|
+
toggleLocale(newLocale)
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
return {
|
|
37
44
|
lang,
|
|
45
|
+
toggleLocale,
|
|
38
46
|
toggleLocales,
|
|
39
47
|
}
|
|
40
48
|
}
|