Skip to content

Commit fc59eae

Browse files
committed
show api switch on first visit
1 parent ecac34b commit fc59eae

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/.vitepress/theme/components/PreferenceSwitch.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
1212
const route = useRoute()
1313
const show = computed(() => /^\/(guide|tutorial|examples)\//.test(route.path))
14-
const isOpen = ref(false)
14+
const isOpen = ref(
15+
typeof localStorage !== 'undefined' &&
16+
!localStorage.getItem(preferCompositionKey)
17+
)
1518
1619
const toggleOpen = () => (isOpen.value = !isOpen.value)
1720
const toggleCompositionAPI = useToggleFn(
@@ -218,7 +221,8 @@ function useToggleFn(
218221
transform: translateX(18px);
219222
}
220223
221-
.tip .options-api, .tip .composition-api {
224+
.tip .options-api,
225+
.tip .composition-api {
222226
color: var(--vt-c-text-code);
223227
transition: color 0.5s;
224228
font-weight: 600;

0 commit comments

Comments
 (0)