valaxy 0.25.10 → 0.26.0

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.
@@ -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 { useFrontmatter, useValaxyHead, useValaxyI18n } from '../../composables'
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
  }
@@ -15,7 +15,7 @@ export function getKeyMaterial(password: string) {
15
15
  )
16
16
  }
17
17
 
18
- export function getKey(keyMaterial: CryptoKey, salt: Uint8Array) {
18
+ export function getKey(keyMaterial: CryptoKey, salt: BufferSource) {
19
19
  return window.crypto.subtle.deriveKey(
20
20
  {
21
21
  name: 'PBKDF2',
@@ -35,7 +35,7 @@ export function useCollapseCode() {
35
35
 
36
36
  useEventListener('click', (e) => {
37
37
  const el = e.target as HTMLElement
38
- if (el.matches('[class*="language-"] > button.collapse')) {
38
+ if (el.matches('[class*="language-"] > button.code-block-unfold-btn')) {
39
39
  const parent = el.parentElement
40
40
  parent?.classList.remove('folded')
41
41
  const codeHeightLimitClass = `max-h-${codeHeightLimit}px`
@@ -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
- const toggleLocales = () => {
21
- // change to some real logic
22
- const locales = availableLocales
23
-
24
- locale.value = locales[(locales.indexOf(locale.value) + 1) % locales.length]
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 = locale.value
27
-
27
+ lang.value = newLocale
28
28
  // set date locale
29
29
  // setDefaultOptions({ locale: locale.value === 'zh-CN' ? zhCN : enUS })
30
- dayjs.locale(locale.value === 'zh-CN' ? 'zh-cn' : 'en')
31
-
30
+ dayjs.locale(newLocale === 'zh-CN' ? 'zh-cn' : 'en')
32
31
  if (isClient)
33
- document.documentElement.setAttribute('lang', locale.value)
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
  }
@@ -227,7 +227,7 @@ html:not(.dark) .vp-code-dark {
227
227
  }
228
228
 
229
229
  // collapse
230
- [class*='language-']>button.collapse {
230
+ [class*='language-']>button.code-block-unfold-btn {
231
231
  display: none;
232
232
  position: absolute;
233
233
  z-index: 10;
@@ -251,7 +251,7 @@ html:not(.dark) .vp-code-dark {
251
251
  }
252
252
  }
253
253
 
254
- [class*='language-'].folded>button.collapse {
254
+ [class*='language-'].folded>button.code-block-unfold-btn {
255
255
  display: block;
256
256
  }
257
257
  }