import dayjs from "dayjs";
import store from "../store";
import {setRefreshToken} from "./api";

export default async function () {
    const userStore = store.state.userInfo;
    if (userStore.getTokenTime) {
        if (dayjs().diff(dayjs(userStore.getTokenTime), "minute") >= 5) {
            await userStore.setTokenTime(dayjs().format("YYYY-MM-DD HH:mm:ss"));
            await setRefreshToken();
        }
    }

}
