提交 352ee666 编写于 作者: B baiy 提交者: ninecents

替换ip查询接口

上级 bd0e31b3
{
"name": "c-tool",
"version": "1.7.6",
"version": "1.7.7",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -2150,11 +2150,6 @@
}
}
},
"axios-jsonp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/axios-jsonp/-/axios-jsonp-1.0.4.tgz",
"integrity": "sha512-KI5Fc4ery6DR+oneXG09hPZfGuNUW8Lblhe750h53Z0Eh5MRsrHn49YitDU4RsMk0HV+12zcvL2Q51QkOLGdIQ=="
},
"babel-code-frame": {
"version": "6.26.0",
"resolved": "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz",
......
{
"name": "c-tool",
"version": "1.7.7",
"version": "1.7.8",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
......@@ -9,7 +9,6 @@
},
"dependencies": {
"axios": "^0.21.4",
"axios-jsonp": "^1.0.4",
"babel-runtime": "^6.26.0",
"code-formatter": "0.0.1",
"cron-parser": "^2.16.3",
......
......@@ -24,7 +24,7 @@
"clipboardRead"
],
"host_permissions": [
"*://ifconfig.co/*",
"*://get.geojs.io/*",
"*://*.baiy.org/*"
],
"commands": {
......@@ -35,4 +35,4 @@
}
},
"update_url": "http://clients2.google.com/service/update2/crx"
}
\ No newline at end of file
}
......@@ -24,7 +24,7 @@
"clipboardRead"
],
"host_permissions": [
"*://ifconfig.co/*",
"*://get.geojs.io/*",
"*://*.baiy.org/*"
],
"commands": {
......@@ -34,4 +34,4 @@
"global": true
}
}
}
\ No newline at end of file
}
......@@ -11,8 +11,7 @@
</ButtonGroup>
</FormItem>
<FormItem>
<Alert v-if="!isWeb">ip信息来源 <a href="https://ifconfig.co/json" target="_blank">https://ifconfig.co/json</a></Alert>
<Alert v-else>ip信息来源 <a href="https://whois.pconline.com.cn/" target="_blank">https://whois.pconline.com.cn/</a></Alert>
<Alert>ip信息来源 <a href="https://get.geojs.io/" target="_blank">https://get.geojs.io/</a></Alert>
</FormItem>
</option-block>
<div style="border: 1px solid #dcdee2;border-radius: 4px;">
......@@ -22,7 +21,7 @@
</template>
<script>
import axios from "axios"
import axiosJsonp from 'axios-jsonp';
import _ from "lodash"
import {codemirror} from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'
import 'codemirror/mode/javascript/javascript.js'
......@@ -31,7 +30,6 @@ import 'codemirror/addon/fold/foldgutter.js'
import 'codemirror/addon/fold/brace-fold.js'
import 'codemirror/addon/fold/comment-fold.js'
import 'codemirror/addon/fold/foldgutter.css'
import {isWeb} from "../../helper"
export default {
components: {
......@@ -51,30 +49,15 @@ export default {
methods: {
handle() {
if (this.current.input) {
if (!this.isWeb){
axios({
url: 'https://ifconfig.co/json',
responseType: 'json',
params: this.current.input !== "localhost" ? {ip: this.current.input} : {}
}).then(({data}) => {
this.current.output = JSON.stringify(data, null, 4);
this.$saveToolData(this.current);
}).catch((error) => {
return this.$Message.error("ip地址信息查询错误:" + error);
});
}
else{
axios({
url: 'https://whois.pconline.com.cn/ipJson.jsp',
adapter: axiosJsonp,
params: this.current.input !== "localhost" ? {ip: this.current.input} : {},
}).then(({data}) => {
this.current.output = JSON.stringify(data, null, 4);
this.$saveToolData(this.current);
}).catch((error) => {
return this.$Message.error("ip地址信息查询错误:" + error);
});
}
axios({
url: 'https://get.geojs.io/v1/ip/geo.json',
params: this.current.input !== "localhost" ? {ip: this.current.input} : {}
}).then(({data}) => {
this.current.output = JSON.stringify(_.isArray(data) && data.length < 2 ? data[0] : data,null, 4);
this.$saveToolData(this.current);
}).catch((error) => {
return this.$Message.error("ip地址信息查询错误:" + error);
});
}
},
local() {
......@@ -95,8 +78,7 @@ export default {
foldGutter: true,
indentUnit: 4,
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],
},
isWeb: isWeb
}
}
},
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册