Merge pull request #293 from netcookies/fix/madao-country-iso-dev

fix(madao): 适配国家中文标签和线路归一化
This commit is contained in:
QLHazyCoder
2026-05-30 04:09:50 +08:00
committed by GitHub
17 changed files with 4738 additions and 3597 deletions
+22 -3
View File
@@ -199,6 +199,23 @@
return String(visibleSpan?.textContent || '').trim();
}
function phoneNumberMatchesDialCode(phoneNumber = '', dialCode = '') {
const digits = normalizePhoneDigits(phoneNumber);
const normalizedDialCode = normalizePhoneDigits(dialCode);
if (!digits || !normalizedDialCode) {
return false;
}
return digits.startsWith(normalizedDialCode) && digits.length > normalizedDialCode.length;
}
function selectedCountryMatchesPhoneNumber(phoneNumber = '') {
const digits = normalizePhoneDigits(phoneNumber);
if (!digits) {
return true;
}
return phoneNumberMatchesDialCode(phoneNumber, getDisplayedDialCode());
}
function toNationalPhoneNumber(value, dialCode) {
const digits = normalizePhoneDigits(value);
const normalizedDialCode = normalizePhoneDigits(dialCode);
@@ -364,15 +381,17 @@
const byLabel = findCountryOptionByLabel(countryLabel);
if (await trySelectCountryOption(select, byLabel)) {
return true;
if (selectedCountryMatchesPhoneNumber(phoneNumber)) {
return true;
}
}
const byPhoneNumber = findCountryOptionByPhoneNumber(phoneNumber);
if (await trySelectCountryOption(select, byPhoneNumber)) {
return true;
return selectedCountryMatchesPhoneNumber(phoneNumber);
}
return Boolean(getSelectedCountryOption());
return selectedCountryMatchesPhoneNumber(phoneNumber);
}
function getAddPhoneSubmitButton() {