更新记录
1.0.0(2025-09-01)
下载此版本
Changelog
1.0.0
- Initial release: fetch public IP via ip138 jsonp API with ipify fallback.
平台兼容性
uni-app(4.76)
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(4.76)
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
- |
- |
- |
- |
ip138-public-ip
Get current public IP using ip138 (JSON) with ipify fallback.
Install
Place this folder under uni_modules/ip138-public-ip
.
Usage
import { getPublicIp } from 'uni_modules/ip138-public-ip/utssdk/index.uts'
// Pass ip138 token if available; otherwise it will fallback to ipify
const result = await getPublicIp('<your-ip138-token>')
console.log(result.ip, result.source)
- When
token
is provided, it calls https://api.ip138.com/ip/?datatype=json&token=...
and parses JSON.
- When
token
is omitted or ip138 fails, it falls back to https://api.ipify.org?format=json
.