4 Commits
v1.1.0 ... main

Author SHA1 Message Date
agoodday
50737455ac Add files via upload 2026-03-14 19:24:00 +08:00
agoodday
723a4380fb Add files via upload 2026-03-11 01:15:49 +08:00
agoodday
57ac14a553 Add files via upload 2026-03-09 21:09:01 +08:00
agoodday
2dfbf4b3cf Add files via upload 2026-03-09 21:08:25 +08:00
3 changed files with 49 additions and 24 deletions

View File

@@ -236,7 +236,7 @@ export async function generateUSAddress(selectedState = 'RANDOM') {
stateCode,
zip,
fullAddress,
country: '美国'
country: 'US'
};
} catch (error) {
console.error('Error generating US address:', error);
@@ -391,7 +391,7 @@ export async function generateHKAddress(selectedRegion = 'RANDOM', isEnglish = f
area: city, // 保留原字段以兼容
fullAddress,
zip,
country: isEnglish ? '香港 Hong Kong' : '香港'
country: 'HK'
};
} catch (error) {
console.error('Error generating HK address:', error);
@@ -500,7 +500,7 @@ export async function generateUKAddress(selectedRegion = 'RANDOM') {
postcode,
region: regionNameEn, // 显示英文地区名
fullAddress,
country: '英国'
country: 'UK'
};
} catch (error) {
console.error('Error generating UK address:', error);
@@ -610,7 +610,7 @@ export async function generateCAAddress(selectedProvince = 'RANDOM') {
postcode,
province: provinceNameEn, // 显示英文省份名
fullAddress,
country: '加拿大'
country: 'CA'
};
} catch (error) {
console.error('Error generating CA address:', error);
@@ -778,7 +778,7 @@ export async function generateJPAddress(selectedPrefecture = 'RANDOM') {
prefecture: prefectureName,
postcode,
fullAddress,
country: '日本'
country: 'JP'
};
} catch (error) {
console.error('Error generating JP address:', error);
@@ -897,7 +897,7 @@ export async function generateINAddress(selectedState = 'RANDOM') {
state: stateNameEn, // 显示英文邦名
pin,
fullAddress,
country: '印度'
country: 'IN'
};
} catch (error) {
console.error('Error generating IN address:', error);
@@ -1022,7 +1022,7 @@ export async function generateTWAddress(selectedCounty = 'RANDOM') {
district,
postcode,
fullAddress,
country: '台灣'
country: 'TW'
};
} catch (error) {
console.error('Error generating TW address:', error);
@@ -1051,12 +1051,13 @@ export async function generateIdentityInfo(address) {
}
// Use the same name group as the address based on country
const c = address.country || '';
let nameGroup;
if (address.country === '香港' || address.country === '台灣') {
if (c === '香港' || c === '台灣' || c === 'HK' || c === 'TW') {
nameGroup = namesData.nameGroups.chinese;
} else if (address.country === '印度') {
} else if (c === '印度' || c === 'IN') {
nameGroup = namesData.nameGroups.indian;
} else if (address.country === '日本') {
} else if (c === '日本' || c === 'JP') {
nameGroup = namesData.nameGroups.asian || namesData.nameGroups.western;
} else {
// Default to western names for US, UK, Canada, etc.
@@ -1125,14 +1126,14 @@ export async function generateIdentityInfo(address) {
let ssn;
const country = address.country || '';
if (country.includes('德国') || country.includes('Germany')) {
if (country.includes('德国') || country.includes('Germany') || country === 'DE') {
// Generate German Steuer-ID (Tax ID): 11 digits, format: XX XXX XXX XXX
const part1 = randomInt(10, 99);
const part2 = randomInt(100, 999);
const part3 = randomInt(100, 999);
const part4 = randomInt(100, 999);
ssn = `${part1} ${part2} ${part3} ${part4}`;
} else if (country.includes('英国') || country.includes('UK') || country.includes('United Kingdom')) {
} else if (country.includes('英国') || country.includes('UK') || country.includes('United Kingdom') || country === 'UK') {
// Generate UK NINO: Format: AA 12 34 56 A
const letters1 = 'ABCDEFGHJKLMNOPRSTUVWXYZ';
const letters2 = 'ABCDEFGHJKLMNOPRSTUVWXYZ';
@@ -1141,25 +1142,25 @@ export async function generateIdentityInfo(address) {
const digits = randomInt(100000, 999999);
const letter3 = randomElement(letters2.split(''));
ssn = `${letter1}${letter2} ${digits.toString().slice(0, 2)} ${digits.toString().slice(2, 4)} ${digits.toString().slice(4, 6)} ${letter3}`;
} else if (country.includes('加拿大') || country.includes('Canada')) {
} else if (country.includes('加拿大') || country.includes('Canada') || country === 'CA') {
// Generate Canadian SIN: Format: XXX XXX XXX
const sin1 = randomInt(100, 999);
const sin2 = randomInt(100, 999);
const sin3 = randomInt(100, 999);
ssn = `${sin1} ${sin2} ${sin3}`;
} else if (country.includes('日本') || country.includes('Japan')) {
} else if (country.includes('日本') || country.includes('Japan') || country === 'JP') {
// Generate Japanese My Number: Format: XXXX-XXXX-XXXX
const myNum1 = randomInt(1000, 9999);
const myNum2 = randomInt(1000, 9999);
const myNum3 = randomInt(1000, 9999);
ssn = `${myNum1}-${myNum2}-${myNum3}`;
} else if (country.includes('印度') || country.includes('India')) {
} else if (country.includes('印度') || country.includes('India') || country === 'IN') {
// Generate Indian Aadhaar: Format: XXXX XXXX XXXX
const aadhaar1 = randomInt(1000, 9999);
const aadhaar2 = randomInt(1000, 9999);
const aadhaar3 = randomInt(1000, 9999);
ssn = `${aadhaar1} ${aadhaar2} ${aadhaar3}`;
} else if (country.includes('香港') || country.includes('Hong Kong')) {
} else if (country.includes('香港') || country.includes('Hong Kong') || country === 'HK') {
// Generate Hong Kong ID Card: Format: A123456(7) or AB123456(7)
// 70%概率单字母30%概率双字母
const letters = 'ABCDEFGHJKLMNPQRSTUVWXYZ';
@@ -1175,7 +1176,7 @@ export async function generateIdentityInfo(address) {
const digits = randomInt(100000, 999999).toString();
const checkDigit = randomInt(0, 9);
ssn = `${prefix}${digits}(${checkDigit})`;
} else if (country.includes('台灣') || country.includes('台湾') || country.includes('Taiwan')) {
} else if (country.includes('台灣') || country.includes('台湾') || country.includes('Taiwan') || country === 'TW') {
// Generate Taiwan ID Card: Format: A123456789
// 1st: letter (birthplace), 2nd: gender (1=Male, 2=Female), 3rd-9th: sequence
const letters = 'ABCDEFGHJKLMNPQRSTUVXY';
@@ -1183,7 +1184,7 @@ export async function generateIdentityInfo(address) {
const genderDigit = isMaleForIdentity ? '1' : '2'; // 1=男, 2=女
const sequenceDigits = randomInt(10000000, 99999999).toString();
ssn = `${firstLetter}${genderDigit}${sequenceDigits}`;
} else if (country.includes('新加坡') || country.includes('Singapore')) {
} else if (country.includes('新加坡') || country.includes('Singapore') || country === 'SG') {
// Generate Singapore NRIC: Format: S1234567D (prefix + 7 digits + check letter)
// S=citizen pre-2000, T=citizen 2000+, G/F=PR. Prefix should match birth year
let prefix;
@@ -1204,7 +1205,7 @@ export async function generateIdentityInfo(address) {
// Default: US SSN format (XXX-XX-XXXX)
// SSN Area Number (first 3 digits) should match the state if available
let ssnAreaNumber;
if (address.stateCode && address.country === '美国') {
if (address.stateCode && (address.country === '美国' || address.country === 'US')) {
try {
const usData = await loadData('data/usData.json');
const state = usData.states[address.stateCode];
@@ -1418,7 +1419,7 @@ export async function generateSGAddress(selectedState = 'RANDOM') {
state: stateNameEn,
stateCode: stateKey,
fullAddress,
country: '新加坡'
country: 'SG'
};
} catch (error) {
console.error('Error generating SG address:', error);
@@ -1530,7 +1531,7 @@ export async function generateDEAddress(selectedState = 'RANDOM') {
state: stateNameEn,
stateCode: stateKey,
fullAddress,
country: '德国'
country: 'DE'
};
} catch (error) {
console.error('Error generating DE address:', error);

View File

@@ -197,6 +197,13 @@ export function initLanguageSwitcher() {
// 获取当前语言
const currentLang = getCurrentLanguage();
const currentLangData = languages[currentLang];
const isMobileViewport = () => window.matchMedia && window.matchMedia('(max-width: 768px)').matches;
const formatCurrentLangLabel = () => {
// 模板工程:保持与正式站一致的移动端缩写策略
if (currentLang === 'zh' && isMobileViewport()) return 'CN';
if (currentLang === 'pt' && isMobileViewport()) return 'PT';
return `${currentLangData.flag} ${currentLangData.nativeName}`;
};
// 添加全局点击事件监听器(只添加一次)
if (!globalClickHandlerAdded) {
@@ -239,7 +246,7 @@ export function initLanguageSwitcher() {
// 更新按钮显示
if (langButtonText) {
langButtonText.textContent = `${currentLangData.flag} ${currentLangData.nativeName}`;
langButtonText.textContent = formatCurrentLangLabel();
}
// 生成语言选项(不使用 inline onclick避免被其他脚本/策略影响)
@@ -296,6 +303,23 @@ export function initLanguageSwitcher() {
}
});
});
// 处理横竖屏/窗口尺寸变化:与正式站保持一致
if (!window.__langBtnResizeBound) {
window.__langBtnResizeBound = true;
const onResize = () => {
document.querySelectorAll('.language-switcher').forEach((wrapper) => {
const langButtonText =
wrapper.querySelector('#language-switcher-text') ||
wrapper.querySelector('.language-switcher-text');
if (langButtonText) {
langButtonText.textContent = formatCurrentLangLabel();
}
});
};
window.addEventListener('resize', onResize, { passive: true });
window.addEventListener('orientationchange', onResize, { passive: true });
}
}
// 自动初始化 - 只在 DOM 加载完成后执行

View File

@@ -114,7 +114,7 @@ export function exportToCSV() {
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `地址列表_${new Date().toISOString().split('T')[0]}.csv`;
link.download = `CSV-${new Date().toISOString().split('T')[0]}.csv`;
link.click();
URL.revokeObjectURL(url);
@@ -139,7 +139,7 @@ export function exportToJSON() {
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `地址列表_${new Date().toISOString().split('T')[0]}.json`;
link.download = `JSON-${new Date().toISOString().split('T')[0]}.json`;
link.click();
URL.revokeObjectURL(url);