IT-TOOLS-PRO v1 - 定制版开发者工具站

12个原创工具(批量条码/二维码识别/在线翻译/OCR/面单设计/AI修图/网站收藏/PDF工具/图片工具/文档转换等)
+ 卡密授权系统(CardAuth对接,30分钟试用,换卡/撤销)
+ 体验优化(中文默认/收藏/最近使用/菜单展开/宽屏/品牌页脚)
This commit is contained in:
personal82555 committed 2026-10-11 23:58:39 +08:00
commit 01ff133ac9
528 files changed
+50026

No files matched your search

@@ -0,0 +1,25 @@
import { Phone } from '@vicons/tabler';
import { defineTool } from '../tool';
import { translate } from '@/plugins/i18n.plugin';
export const tool = defineTool({
name: translate('tools.phone-parser-and-formatter.title'),
path: '/phone-parser-and-formatter',
description: translate('tools.phone-parser-and-formatter.description'),
keywords: [
'phone',
'parser',
'formatter',
'validate',
'format',
'number',
'telephone',
'mobile',
'cell',
'international',
'national',
],
component: () => import('./phone-parser-and-formatter.vue'),
icon: Phone,
createdAt: new Date('2023-05-01'),
});
@@ -0,0 +1,11 @@
import { expect, test } from '@playwright/test';
test.describe('Tool - Phone parser and formatter', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/phone-parser-and-formatter');
});
test('Has correct title', async ({ page }) => {
await expect(page).toHaveTitle('Phone parser and formatter - IT Tools');
});
});
@@ -0,0 +1,47 @@
import type { CountryCode, NumberType } from 'libphonenumber-js/types';
import lookup from 'country-code-lookup';
export { formatTypeToHumanReadable, getFullCountryName, getDefaultCountryCode };
const typeToLabel: Record<NonNullable<NumberType>, string> = {
MOBILE: 'Mobile',
FIXED_LINE: 'Fixed line',
FIXED_LINE_OR_MOBILE: 'Fixed line or mobile',
PERSONAL_NUMBER: 'Personal number',
PREMIUM_RATE: 'Premium rate',
SHARED_COST: 'Shared cost',
TOLL_FREE: 'Toll free',
UAN: 'Universal access number',
VOICEMAIL: 'Voicemail',
VOIP: 'VoIP',
PAGER: 'Pager',
};
function formatTypeToHumanReadable(type: NumberType): string | undefined {
if (!type) {
return undefined;
}
return typeToLabel[type];
}
function getFullCountryName(countryCode: string | undefined) {
if (!countryCode) {
return undefined;
}
return lookup.byIso(countryCode)?.country;
}
function getDefaultCountryCode({
locale = window.navigator.language,
defaultCode = 'FR',
}: { locale?: string; defaultCode?: CountryCode } = {}): CountryCode {
const countryCode = locale.split('-')[1]?.toUpperCase();
if (!countryCode) {
return defaultCode;
}
return (lookup.byIso(countryCode)?.iso2 ?? defaultCode) as CountryCode;
}
@@ -0,0 +1,114 @@
<script setup lang="ts">
import { getCountries, getCountryCallingCode, parsePhoneNumber } from 'libphonenumber-js/max';
import lookup from 'country-code-lookup';
import {
formatTypeToHumanReadable,
getDefaultCountryCode,
getFullCountryName,
} from './phone-parser-and-formatter.models';
import { withDefaultOnError } from '@/utils/defaults';
import { booleanToHumanReadable } from '@/utils/boolean';
import { useValidation } from '@/composable/validation';
const rawPhone = ref('');
const defaultCountryCode = ref(getDefaultCountryCode());
const validation = useValidation({
source: rawPhone,
rules: [
{
validator: value => value === '' || /^[0-9 +\-()]+$/.test(value),
message: 'Invalid phone number',
},
],
});
const parsedDetails = computed(() => {
if (!validation.isValid) {
return undefined;
}
const parsed = withDefaultOnError(() => parsePhoneNumber(rawPhone.value, defaultCountryCode.value), undefined);
if (!parsed) {
return undefined;
}
return [
{
label: 'Country',
value: parsed.country,
},
{
label: 'Country',
value: getFullCountryName(parsed.country),
},
{
label: 'Country calling code',
value: parsed.countryCallingCode,
},
{
label: 'Is valid?',
value: booleanToHumanReadable(parsed.isValid()),
},
{
label: 'Is possible?',
value: booleanToHumanReadable(parsed.isPossible()),
},
{
label: 'Type',
value: formatTypeToHumanReadable(parsed.getType()),
},
{
label: 'International format',
value: parsed.formatInternational(),
},
{
label: 'National format',
value: parsed.formatNational(),
},
{
label: 'E.164 format',
value: parsed.format('E.164'),
},
{
label: 'RFC3966 format',
value: parsed.format('RFC3966'),
},
];
});
const countriesOptions = getCountries().map(code => ({
label: `${lookup.byIso(code)?.country || code} (+${getCountryCallingCode(code)})`,
value: code,
}));
</script>
<template>
<div>
<c-select v-model:value="defaultCountryCode" label="Default country code:" :options="countriesOptions" searchable mb-5 />
<c-input-text
v-model:value="rawPhone"
placeholder="Enter a phone number"
label="Phone number:"
:validation="validation"
mb-5
/>
<n-table v-if="parsedDetails">
<tbody>
<tr v-for="{ label, value } in parsedDetails" :key="label">
<td font-bold>
{{ label }}
</td>
<td>
<span-copyable v-if="value" :value="value" />
<span v-else op-70>
Unknown
</span>
</td>
</tr>
</tbody>
</n-table>
</div>
</template>