11
Some checks failed
Node CI / build (14.x, macOS-latest) (push) Has been cancelled
Node CI / build (14.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (14.x, windows-latest) (push) Has been cancelled
Node CI / build (16.x, macOS-latest) (push) Has been cancelled
Node CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node CI / build (16.x, windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
coverage CI / build (push) Has been cancelled
Node pnpm CI / build (16.x, macOS-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, ubuntu-latest) (push) Has been cancelled
Node pnpm CI / build (16.x, windows-latest) (push) Has been cancelled

This commit is contained in:
francis-fh
2026-06-04 16:25:38 +08:00
parent 3815dd63da
commit 03f26885c5
32 changed files with 2642 additions and 3062 deletions

View File

@@ -0,0 +1,38 @@
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;
};

View File

@@ -0,0 +1,64 @@
import type { DictValueEnumObj } from '@/components/DictTag';
/** 字典值转展示文案 */
export function getDictLabel(
enums: DictValueEnumObj | Record<string, any>,
value?: string | number | null,
): string {
if (value === null || value === undefined || value === '') {
return '';
}
const strVal = String(value);
if (!enums || !Object.keys(enums).length) {
return strVal;
}
const direct = enums[strVal] ?? enums[Number(value)];
if (direct) {
return direct.label || direct.text || strVal;
}
const matched = Object.values(enums).find((item: any) => {
return (
String(item.value) === strVal ||
String(item.key) === strVal ||
String(item.id) === strVal
);
});
if (matched) {
return (matched as any).label || (matched as any).text || strVal;
}
return strVal;
}
/** 树形数据 id 转 label岗位分类 / 行业等) */
export function findTreeLabelById(
nodes: any[] | undefined,
id?: string | number | null,
): string {
if (id === null || id === undefined || id === '') {
return '';
}
const idStr = String(id);
if (!nodes?.length) {
return '';
}
for (const node of nodes) {
const nodeId = String(node.id ?? node.value ?? '');
if (nodeId === idStr) {
return node.label ?? node.title ?? '';
}
if (node.children?.length) {
const childLabel = findTreeLabelById(node.children, id);
if (childLabel) {
return childLabel;
}
}
}
return '';
}
/** @deprecated 使用 findTreeLabelById */
export const findIndustryLabelInTree = findTreeLabelById;