|
|
@ -262,10 +262,36 @@ export class Flow {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FlowFilter {
|
|
|
|
|
|
|
|
private keyword: string | RegExp | undefined
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(text: string) {
|
|
|
|
|
|
|
|
text = text.trim()
|
|
|
|
|
|
|
|
if (!text) return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// regexp
|
|
|
|
|
|
|
|
if (text.startsWith('/') && text.endsWith('/')) {
|
|
|
|
|
|
|
|
text = text.slice(1, text.length - 1).trim()
|
|
|
|
|
|
|
|
if (!text) return
|
|
|
|
|
|
|
|
this.keyword = new RegExp(text)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// string
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
this.keyword = text
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
match(flow: Flow): boolean {
|
|
|
|
|
|
|
|
if (!this.keyword) return true
|
|
|
|
|
|
|
|
if (this.keyword instanceof RegExp) return this.keyword.test(flow.request.url)
|
|
|
|
|
|
|
|
return flow.request.url.includes(this.keyword)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export class FlowManager {
|
|
|
|
export class FlowManager {
|
|
|
|
private items: Flow[]
|
|
|
|
private items: Flow[]
|
|
|
|
private _map: Map<string, Flow>
|
|
|
|
private _map: Map<string, Flow>
|
|
|
|
private filterText: string
|
|
|
|
private flowFilter: FlowFilter | undefined
|
|
|
|
private filterTimer: number | null
|
|
|
|
private filterTimer: number | null
|
|
|
|
private num: number
|
|
|
|
private num: number
|
|
|
|
private max: number
|
|
|
|
private max: number
|
|
|
@ -273,7 +299,6 @@ export class FlowManager {
|
|
|
|
constructor() {
|
|
|
|
constructor() {
|
|
|
|
this.items = []
|
|
|
|
this.items = []
|
|
|
|
this._map = new Map()
|
|
|
|
this._map = new Map()
|
|
|
|
this.filterText = ''
|
|
|
|
|
|
|
|
this.filterTimer = null
|
|
|
|
this.filterTimer = null
|
|
|
|
this.num = 0
|
|
|
|
this.num = 0
|
|
|
|
|
|
|
|
|
|
|
@ -281,27 +306,8 @@ export class FlowManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
showList() {
|
|
|
|
showList() {
|
|
|
|
let text = this.filterText
|
|
|
|
if (!this.flowFilter) return this.items
|
|
|
|
if (text) text = text.trim()
|
|
|
|
return this.items.filter(item => (this.flowFilter as FlowFilter).match(item))
|
|
|
|
if (!text) return this.items
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// regexp
|
|
|
|
|
|
|
|
if (text.startsWith('/') && text.endsWith('/')) {
|
|
|
|
|
|
|
|
text = text.slice(1, text.length - 1).trim()
|
|
|
|
|
|
|
|
if (!text) return this.items
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const reg = new RegExp(text)
|
|
|
|
|
|
|
|
return this.items.filter(item => {
|
|
|
|
|
|
|
|
return reg.test(item.request.url)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
return this.items
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.items.filter(item => {
|
|
|
|
|
|
|
|
return item.request.url.includes(text)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
add(item: Flow) {
|
|
|
|
add(item: Flow) {
|
|
|
@ -320,18 +326,23 @@ export class FlowManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
changeFilter(text: string) {
|
|
|
|
changeFilter(text: string) {
|
|
|
|
this.filterText = text
|
|
|
|
this.flowFilter = new FlowFilter(text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
changeFilterLazy(text: string, callback: () => void) {
|
|
|
|
changeFilterLazy(text: string, callback: (err: any) => void) {
|
|
|
|
if (this.filterTimer) {
|
|
|
|
if (this.filterTimer) {
|
|
|
|
clearTimeout(this.filterTimer)
|
|
|
|
clearTimeout(this.filterTimer)
|
|
|
|
this.filterTimer = null
|
|
|
|
this.filterTimer = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.filterTimer = setTimeout(() => {
|
|
|
|
this.filterTimer = setTimeout(() => {
|
|
|
|
this.filterText = text
|
|
|
|
try {
|
|
|
|
callback()
|
|
|
|
this.changeFilter(text)
|
|
|
|
|
|
|
|
callback(null)
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
this.changeFilter('')
|
|
|
|
|
|
|
|
callback(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}, 300) as any
|
|
|
|
}, 300) as any
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|