MCPcopy Create free account
hub / github.com/027xiguapi/code-box / filterHistory

Function filterHistory

tabs/history.tsx:69–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67 }
68
69 function filterHistory() {
70 const _filterVal = String(filterVal).trim().toLowerCase()
71 let _list = []
72 if (filterVal) {
73 const searchProps = ["value", "createdAt", "link", "remark"]
74 const filterRE = new RegExp(filterVal, "gi")
75 const rest = data.filter((item: any) =>
76 searchProps.some((key) => {
77 if (key == "createdAt") {
78 return (
79 dayjs(item[key])
80 .format("YYYY-MM-DD HH:mm:ss")
81 .indexOf(_filterVal) > -1
82 )
83 } else {
84 return String(item[key]).toLowerCase().indexOf(_filterVal) > -1
85 }
86 })
87 )
88 _list = rest.map((row) => {
89 const item = Object.assign({}, row)
90 searchProps.forEach((key) => {
91 item[key] = String(item[key]).replace(
92 filterRE,
93 // (match) => `<span class="keyword-lighten">${match}</span>`
94 () => ``
95 )
96 })
97 return item
98 })
99 } else {
100 _list = [...data]
101 }
102
103 setList(_list)
104 window.dispatchEvent(new Event("resize"))
105 }
106
107 function onLoadMore() {
108 setLoading(true)

Callers 1

HistoryPageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected