fix(modules/web): 重构阅读API;封面图片优先使用源站资源

- 添加图片代理接口API;API地址测试(3s超时)
This commit is contained in:
Xwite
2024-09-29 18:05:04 +08:00
parent ed5d13f455
commit bf91a6f206
12 changed files with 222 additions and 176 deletions

View File

@@ -1,25 +1,10 @@
import axios from "axios";
const SECOND = 1000;
const remoteIp = ref(localStorage.getItem("remoteIp"));
const ajax = axios.create({
// baseURL: import.meta.env.VITE_API || location.origin,
baseURL: import.meta.env.VITE_API || localStorage.getItem("remoteIp") || location.origin,
timeout: 120 * SECOND,
});
ajax.interceptors.request.use((config) => {
config.baseURL = baseUrl();
return config;
});
export default ajax;
export const setRemoteIp = (ip) => {
remoteIp.value = ip;
localStorage.setItem("remoteIp", ip);
};
export const baseUrl = () => {
return remoteIp.value || location.origin;
};