wujingjing
2025-01-09 3be90604de82ef494e16bea7abda936013a7852a
pingLogin
已修改1个文件
已添加1个文件
36 ■■■■■ 文件已修改
src/api/system/index.ts 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/index.vue 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/system/index.ts
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
import type { ExtraConfig } from '/@/utils/request';
import request from '/@/utils/request';
/**
 * ç»´æŒç™»å½•状态,延长登录时间
 * @param req
 * @returns
 */
export const PingLogin = ( extraData: ExtraConfig = {}) => {
    return request({
        url: '/system/ping',
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
        },
        ...extraData,
    });
};
src/layout/index.vue
@@ -8,6 +8,7 @@
import { useThemeConfig } from '/@/stores/themeConfig';
import { Local } from '/@/utils/storage';
import mittBus from '/@/utils/mitt';
import { PingLogin } from '/@/api/system';
// å¼•入组件
const layouts: any = {
@@ -38,10 +39,27 @@
        });
    }
};
const pingLogin = async () => {
    // 5分钟
    const interval = 1000 * 60 * 5;
    // const interval = 1000 *2;
    const timer = setInterval(async () => {
        const res = await PingLogin({
            loading: false,
        });
        if (!res?.is_login) {
            clearInterval(timer);
        }
    }, interval);
    return timer;
};
// é¡µé¢åŠ è½½å‰
onBeforeMount(() => {
    onLayoutResize();
    window.addEventListener('resize', onLayoutResize);
    pingLogin();
});
// é¡µé¢å¸è½½æ—¶
onUnmounted(() => {