From 614b590d25b18b4046b0a887f468e8c6c1e7a6fe Mon Sep 17 00:00:00 2001 From: IlyaL Date: Tue, 19 Aug 2025 00:21:20 +0800 Subject: [PATCH] perf(usePreferredLanguages): use shallowRef for better performance --- packages/core/usePreferredLanguages/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/core/usePreferredLanguages/index.ts b/packages/core/usePreferredLanguages/index.ts index 3d94e4bb4d3..8d01ddfa20e 100644 --- a/packages/core/usePreferredLanguages/index.ts +++ b/packages/core/usePreferredLanguages/index.ts @@ -1,6 +1,6 @@ -import type { Ref } from 'vue' +import type { ShallowRef } from 'vue' import type { ConfigurableWindow } from '../_configurable' -import { ref as deepRef } from 'vue' +import { shallowRef } from 'vue' import { defaultWindow } from '../_configurable' import { useEventListener } from '../useEventListener' @@ -12,13 +12,13 @@ import { useEventListener } from '../useEventListener' * * @__NO_SIDE_EFFECTS__ */ -export function usePreferredLanguages(options: ConfigurableWindow = {}): Ref { +export function usePreferredLanguages(options: ConfigurableWindow = {}): ShallowRef { const { window = defaultWindow } = options if (!window) - return deepRef(['en']) + return shallowRef(['en']) const navigator = window.navigator - const value = deepRef(navigator.languages) + const value = shallowRef(navigator.languages) useEventListener(window, 'languagechange', () => { value.value = navigator.languages