Skip to content

使用https://github.com/ljxi/GeoCN项目自建api替换原有api需要注意的一些事项 #24

Description

@Mtoly

如果需要使用https://github.com/ljxi/GeoCN 项目自建api,替换原有http://app.netart.cn/network-panel/ip.ajax 接口
需要修改.env文件中

VITE_API_URL =

以及src\components目录下IPinfo.vue 121行 和162行

async function queryIp(ip: string) {
    const rsp = await fetch(import.meta.env.VITE_API_URL + "?ip=" + ip, {
        method: "GET",
        mode: "cors",
        redirect: "follow",
        referrerPolicy: "no-referrer"
    });
    let resp = await rsp.json();
    return resp; // 原代码为 return resp['data']
}
(async function watchLocalIp() {
    if (props.isVisible) {
        try {
            const response = await fetch(import.meta.env.VITE_API_URL, { referrerPolicy: 'no-referrer' });
            let resp = await response.json();
            ipInfo.local = await handleIP(resp["ip"]); // 原代码为 resp["data"]["ip"]
        } catch (error) {
            console.log(error)
        }
    }
    setTimeout(watchLocalIp, 60000)
})();

新API的ip在顶层,不需要通过data获取

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions