/** * cmdType 与前端路由映射(设备推送页面跳转) */ export const TSB_CMD_ROUTE_MAP = { 'common:tax': '/app-common/tax' } /** 设备工作区固定路由(切换设备不改地址) */ export const TSB_WORKSPACE_ROUTE = '/tsb/workspace' /** * 根据 cmdType 获取路由路径 * @param {string} cmdType * @param {number|string} [deviceSn] 有设备上下文时进入工作区 */ export function getRouteByCmdType(cmdType, deviceSn) { const base = TSB_CMD_ROUTE_MAP[cmdType] if (!base) { return null } if (deviceSn == null || deviceSn === '') { return base } if (cmdType === 'common:tax') { return TSB_WORKSPACE_ROUTE } return base } /** * 是否处于某 cmdType 对应页面 * @param {string} path 当前路由 * @param {string} cmdType * @param {number|string} [deviceSn] * @param {string} [currentPanel] 工作区子页面 */ export function isOnCmdRoute(path, cmdType, deviceSn, currentPanel) { const legacy = TSB_CMD_ROUTE_MAP[cmdType] if (path === legacy) { return true } if (cmdType === 'common:tax' && path === TSB_WORKSPACE_ROUTE) { return currentPanel === 'tax' } return false }