mirror of
https://github.com/gedoor/legado.git
synced 2024-06-30 23:06:46 +08:00
resolve refresh
This commit is contained in:
parent
96a3b6b802
commit
94aaee8d9b
|
@ -1,14 +1,25 @@
|
|||
import axios from "axios";
|
||||
|
||||
const SECOND = 1000;
|
||||
|
||||
export const baseUrl = () => {
|
||||
return localStorage.getItem("remoteIp");
|
||||
};
|
||||
const remoteIp = ref(localStorage.getItem("remoteIp"));
|
||||
|
||||
const ajax = axios.create({
|
||||
// baseURL: import.meta.env.VITE_API || location.origin,
|
||||
timeout: 120 * SECOND,
|
||||
});
|
||||
|
||||
ajax.interceptors.request.use((config) => {
|
||||
config.baseURL = remoteIp.value;
|
||||
return config;
|
||||
});
|
||||
|
||||
export default ajax;
|
||||
|
||||
export const setRemoteIp = (ip) => {
|
||||
remoteIp.value = ip;
|
||||
localStorage.setItem("remoteIp", ip);
|
||||
};
|
||||
|
||||
export const baseUrl = () => {
|
||||
return remoteIp.value;
|
||||
};
|
||||
|
|
|
@ -91,7 +91,7 @@ import githubUrl from "@/assets/imgs/github.png";
|
|||
import { useLoading } from "@/hooks/loading";
|
||||
import { Search } from "@element-plus/icons-vue";
|
||||
import API from "@api";
|
||||
import ajax from "@/api/axios.js";
|
||||
import { baseUrl, setRemoteIp } from "@/api/axios.js";
|
||||
|
||||
const store = useBookStore();
|
||||
const { connectStatus, connectType, newConnect, shelf } = storeToRefs(store);
|
||||
|
@ -164,15 +164,15 @@ const searchBook = () => {
|
|||
};
|
||||
|
||||
const ipInput = reactive({
|
||||
ip: "",
|
||||
ip: baseUrl(),
|
||||
disable: true,
|
||||
});
|
||||
const toggleIpConfig = () => {
|
||||
ipInput.ip = localStorage.getItem("remoteIp");
|
||||
ipInput.ip = baseUrl();
|
||||
ipInput.disable = !ipInput.disable;
|
||||
};
|
||||
const setIP = () => {
|
||||
localStorage.setItem("remoteIp", ipInput.ip);
|
||||
setRemoteIp(ipInput.ip);
|
||||
ipInput.disable = true;
|
||||
loadShelf();
|
||||
};
|
||||
|
@ -212,11 +212,6 @@ const toDetail = (bookUrl, bookName, bookAuthor, chapterIndex, chapterPos) => {
|
|||
onMounted(() => {
|
||||
//获取最近阅读书籍
|
||||
let readingRecentStr = localStorage.getItem("readingRecent");
|
||||
ipInput.ip = localStorage.getItem("remoteIp");
|
||||
ajax.interceptors.request.use((config) => {
|
||||
config.baseURL = ipInput.ip;
|
||||
return config;
|
||||
});
|
||||
if (readingRecentStr != null) {
|
||||
readingRecent.value = JSON.parse(readingRecentStr);
|
||||
if (typeof readingRecent.value.chapterIndex == "undefined") {
|
||||
|
|
Loading…
Reference in New Issue
Block a user