xieb
2023-09-18 2900f50c28b5e2a1cb0f72e4556fb761f61c408e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const layerTreeTypes = ['layer', 'resource'] as const
type LayerTreeType = (typeof layerTreeTypes)[number]
const Spliter = '__'
 
export function getLayerTreeKey (type: LayerTreeType, id: number | string) {
  return `${type}${Spliter}${id}`
}
 
export function isLayerTreeKey (key: string, type?: LayerTreeType) {
  if (type) {
    return key.startsWith(`${type}${Spliter}`)
  } else {
    return layerTreeTypes.some(t => key.startsWith(`${t}${Spliter}`))
  }
}
 
export function getIdFromLayerTreeKey (key: string) {
  return key.split(Spliter)[1]
}