diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 8774bcc..b2d0697 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -16,8 +16,9 @@ - + {{ t('common.login.actions.sendCode') }} @@ -58,8 +59,7 @@ - + @@ -128,9 +128,22 @@ const filteredCountries = computed(() => { if (!q) { return COUNTRY_CALLING_CODES; } + + const dialQuery = q.startsWith("+") ? q.slice(1) : q; + const isDialQuery = /^\d+$/.test(dialQuery); + return COUNTRY_CALLING_CODES.filter((item) => { - const haystack = `${item.name} ${item.iso2} ${item.dialCode}`.toLowerCase(); - return haystack.includes(q); + if (isDialQuery) { + const dialCode = item.dialCode.replace("+", ""); + return dialCode.startsWith(dialQuery); + } + + const nameTokens = item.name + .toLowerCase() + .replace(/[^a-z\s]/g, " ") + .split(/\s+/) + .filter(Boolean); + return nameTokens.some((token) => token.startsWith(q)); }); }); @@ -323,11 +336,38 @@ onMounted(() => {