qa-prevention-xgf-app/api/refreshToken.js

15 lines
421 B
JavaScript

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();
}
}
}