tsbCmdRoute.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * cmdType 与前端路由映射(设备推送页面跳转)
  3. */
  4. export const TSB_CMD_ROUTE_MAP = {
  5. 'common:tax': '/app-common/tax'
  6. }
  7. /** 设备工作区固定路由(切换设备不改地址) */
  8. export const TSB_WORKSPACE_ROUTE = '/tsb/workspace'
  9. /**
  10. * 根据 cmdType 获取路由路径
  11. * @param {string} cmdType
  12. * @param {number|string} [deviceSn] 有设备上下文时进入工作区
  13. */
  14. export function getRouteByCmdType(cmdType, deviceSn) {
  15. const base = TSB_CMD_ROUTE_MAP[cmdType]
  16. if (!base) {
  17. return null
  18. }
  19. if (deviceSn == null || deviceSn === '') {
  20. return base
  21. }
  22. if (cmdType === 'common:tax') {
  23. return TSB_WORKSPACE_ROUTE
  24. }
  25. return base
  26. }
  27. /**
  28. * 是否处于某 cmdType 对应页面
  29. * @param {string} path 当前路由
  30. * @param {string} cmdType
  31. * @param {number|string} [deviceSn]
  32. * @param {string} [currentPanel] 工作区子页面
  33. */
  34. export function isOnCmdRoute(path, cmdType, deviceSn, currentPanel) {
  35. const legacy = TSB_CMD_ROUTE_MAP[cmdType]
  36. if (path === legacy) {
  37. return true
  38. }
  39. if (cmdType === 'common:tax' && path === TSB_WORKSPACE_ROUTE) {
  40. return currentPanel === 'tax'
  41. }
  42. return false
  43. }