import { Modal } from 'antd'; import { getAccessToken } from '@/access'; /** 人社门户登录页 */ export const PORTAL_LOGIN_URL = 'http://218.31.252.15:9081/hrss-web-vue/login'; export const isJobPortalLoggedIn = (): boolean => { if (getAccessToken()) { return true; } try { const cached = localStorage.getItem('userInfo'); if (cached) { const userInfo = JSON.parse(cached); return !!userInfo?.userId; } } catch { // ignore } return false; }; /** 未登录时弹窗提示并跳转登录页,已登录返回 true */ export const ensureJobPortalLogin = (actionHint = '该操作'): boolean => { if (isJobPortalLoggedIn()) { return true; } Modal.confirm({ title: '请先登录', content: `登录后才可${actionHint},是否前往登录?`, okText: '去登录', cancelText: '取消', onOk: () => { window.location.href = PORTAL_LOGIN_URL; }, }); return false; };