mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
fix(modules/web): 重构阅读API;封面图片优先使用源站资源
- 添加图片代理接口API;API地址测试(3s超时)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user