Skip to content

Commit bf2f63c

Browse files
committed
feat(new tool): My IP Address
Fix CorentinTh#1435
1 parent fcee9d8 commit bf2f63c

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { tool as angleConverter } from './angle-converter';
2525
import { tool as floatingPointNumberConverter } from './floating-point-number-converter';
2626
import { tool as snowflakeIdExtractor } from './snowflake-id-extractor';
2727
import { tool as emailNormalizer } from './email-normalizer';
28+
import { tool as myIp } from './my-ip';
2829
import { tool as geoDistanceCalculator } from './geo-distance-calculator';
2930
import { tool as xVrSpamcauseDecoder } from './x-vr-spamcause-decoder';
3031
import { tool as bounceParser } from './bounce-parser';
@@ -491,6 +492,7 @@ export const toolsByCategory: ToolCategory[] = [
491492
raidCalculator,
492493
sipAuth,
493494
xVrSpamcauseDecoder,
495+
myIp,
494496
],
495497
},
496498
{

src/tools/my-ip/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { World } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'My IP Address',
6+
path: '/my-ip',
7+
description: 'Get your client IP Address (IPv4/6) using https://getjsonip.com/',
8+
keywords: ['my', 'client', 'ip'],
9+
component: () => import('./my-ip.vue'),
10+
icon: World,
11+
createdAt: new Date('2025-01-01'),
12+
});

src/tools/my-ip/my-ip.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<script setup lang="ts">
2+
import { computedRefreshableAsync } from '@/composable/computedRefreshable';
3+
import { useCopy } from '@/composable/copy';
4+
5+
const [clientIP, refreshClientIP] = computedRefreshableAsync(async () => {
6+
try {
7+
return (await (await fetch('https://jsonip.com', { mode: 'cors' })).json()).ip?.toString();
8+
}
9+
catch (e: any) {
10+
return e.toString();
11+
}
12+
});
13+
14+
const { copy } = useCopy({ source: clientIP, text: 'Client IP copied to the clipboard' });
15+
</script>
16+
17+
<template>
18+
<c-card title="Your IPv4/6 address">
19+
<div class="ip">
20+
{{ clientIP }}
21+
</div>
22+
<div flex justify-center gap-3>
23+
<c-button @click="copy()">
24+
Copy
25+
</c-button>
26+
<c-button @click="refreshClientIP">
27+
Refresh
28+
</c-button>
29+
</div>
30+
</c-card>
31+
</template>
32+
33+
<style lang="less" scoped>
34+
.ip {
35+
text-align: center;
36+
font-size: 26px;
37+
font-weight: 400;
38+
margin: 10px 0 25px;
39+
}
40+
</style>

0 commit comments

Comments
 (0)