Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions babel.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const plugins = [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-transform-runtime'],
['@babel/plugin-transform-object-rest-spread'],
['babel-plugin-react-compiler'],
['babel-plugin-react-compiler']
]

module.exports = {
Expand All @@ -12,27 +12,30 @@ module.exports = {
'@babel/preset-env',
{
targets: {
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8'],
browsers: ['> 1%', 'last 2 versions', 'not ie <= 8']
},
modules: false,
useBuiltIns: 'entry',
corejs: 3,
},
corejs: 3
}
],
[
'@babel/preset-react',
{
runtime: 'automatic',
},
runtime: 'automatic'
}
],
'@babel/preset-typescript',
'@babel/preset-typescript'
],
compact: true,
comments: true,
plugins: process.env.NODE_ENV === 'production' ? [...plugins, 'transform-remove-console', 'transform-remove-debugger'] : plugins,
plugins:
process.env.NODE_ENV === 'production'
? [...plugins, 'transform-remove-console', 'transform-remove-debugger']
: plugins,
env: {
development: {
plugins: ['react-refresh/babel'],
},
},
plugins: ['react-refresh/babel']
}
}
}
6 changes: 3 additions & 3 deletions jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ module.exports = {
testEnvironment: 'jsdom',
collectCoverage: true,
transform: {
'^.+\\.(t|j)sx?$': 'esbuild-jest',
'^.+\\.(t|j)sx?$': 'esbuild-jest'
},
// When the package is ESM ("type": "module"), treat these extensions as ESM for Jest
extensionsToTreatAsEsm: ['.ts', '.tsx', '.jsx'],
// esbuild-jest does not need babel-jest globals
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
moduleNameMapper: {
'\\.(css|less|scss)$': '<rootDir>/jest/styleMock.js',
'^@\\/(.*)$': '<rootDir>/src/$1',
'^@\\/(.*)$': '<rootDir>/src/$1'
},
// Ignore built/distribution files to avoid haste name collisions
modulePathIgnorePatterns: ['<rootDir>/dist-lib/'],
testPathIgnorePatterns: ['/tests/e2e/'],
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js'],
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.js']
}
8 changes: 4 additions & 4 deletions src/app-hooks/proTabsContext/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const defaultValue = {
setActiveKey: () => {},
panes: [],
setPanes: () => {},
removeTab: () => {},
removeTab: () => {}
}

const initialPanes = [
Expand All @@ -18,8 +18,8 @@ const initialPanes = [
key: '/',
content: <Home />,
closable: false,
path: '/',
},
path: '/'
}
]

const ProTabContext = createContext(defaultValue)
Expand Down Expand Up @@ -62,7 +62,7 @@ const ProTabProvider = ({ children }) => {
setActiveKey,
panes,
setPanes,
removeTab,
removeTab
}),
[activeKey, setActiveKey, panes, setPanes, removeTab]
)
Expand Down
29 changes: 15 additions & 14 deletions src/components/KeepAlive/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ const createKeepAliveManager = () => {
// set global options: { deactivateDelay, keepInactiveCount, limit }
setOptions: (opts = {}) => {
if (typeof opts.deactivateDelay === 'number') deactivateDelay = opts.deactivateDelay
if (typeof opts.keepInactiveCount === 'number')
if (typeof opts.keepInactiveCount === 'number') {
keepInactiveCount = Math.max(0, Math.floor(opts.keepInactiveCount))
}
if (typeof opts.limit === 'number') limit = Math.max(0, Math.floor(opts.limit))
},
register: (id, opts) => {
// opts: { setShouldRender, persistOnUnmount }
instances.set(id, {
setShouldRender: opts.setShouldRender,
persistOnUnmount: !!opts.persistOnUnmount,
persistOnUnmount: !!opts.persistOnUnmount
})
},
unregister: (id) => {
Expand Down Expand Up @@ -193,7 +194,7 @@ const createKeepAliveManager = () => {
instances.delete(id)
activeMap.delete(id)
keys = keys.filter((k) => k !== id)
},
}
}
}

Expand Down Expand Up @@ -236,7 +237,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
const effectivePersist = ActivityComponent ? true : persistOnUnmount
keepAliveManager.register(id, {
setShouldRender,
persistOnUnmount: effectivePersist,
persistOnUnmount: effectivePersist
})
}
return () => {
Expand Down Expand Up @@ -329,14 +330,14 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
if (!active) return
scrollPos.current.set(e.target, {
left: e.target.scrollLeft,
top: e.target.scrollTop,
top: e.target.scrollTop
})
}

// Capture scroll events to record positions
target.addEventListener('scroll', onScroll, {
capture: true,
passive: true,
passive: true
})

return () => {
Expand Down Expand Up @@ -390,7 +391,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
// 在移动 DOM 之前,发送自定义事件通知子组件,然后同步移动到占位符下。
// 之前使用短延迟的异步移动会导致渲染滞后和大量定时器/帧回调,移到同步移动以提升响应性。
const event = new CustomEvent('keepalive-dom-move', {
detail: { from: container.parentNode, to: placeholder },
detail: { from: container.parentNode, to: placeholder }
})

let dispatchError = null
Expand All @@ -405,7 +406,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
console.debug('[KeepAlive] appending container to placeholder', id, {
from: container.parentNode,
to: placeholder,
dispatchError,
dispatchError
})
} catch (e) {}
}
Expand All @@ -428,7 +429,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
id,
note: 'no-children-after-append',
childElementCount: container.childElementCount,
time: Date.now(),
time: Date.now()
})
try {
document.body.dataset.keepaliveIssue = 'no-children'
Expand All @@ -454,7 +455,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
childElementCount: container.childElementCount,
appended,
dispatchError,
time: Date.now(),
time: Date.now()
})
}
} catch (e) {}
Expand Down Expand Up @@ -492,7 +493,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
note: 'cleared-inline-display-none',
clearedCount: cleared.length,
clearedTagsSample: cleared.slice(0, 5),
time: Date.now(),
time: Date.now()
})
}
} catch (e) {}
Expand Down Expand Up @@ -523,7 +524,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
window.__keepalive_debug_details.push({
id,
note: 'force-visible-root',
time: Date.now(),
time: Date.now()
})
}
}
Expand Down Expand Up @@ -555,7 +556,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
shouldRender,
containerNode: !!containerNode,
childrenType: typeof children,
time: Date.now(),
time: Date.now()
})
} catch (e) {}
}, [shouldRender, active, containerNode, id, children])
Expand Down Expand Up @@ -613,7 +614,7 @@ KeepAlive.propTypes = {
active: PropTypes.bool,
children: PropTypes.node,
persistOnUnmount: PropTypes.bool,
cacheLimit: PropTypes.number,
cacheLimit: PropTypes.number
}

export default KeepAlive
2 changes: 1 addition & 1 deletion src/components/hooks/useInViewport/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const useInViewport = (triggerOnce = false, threshold = 0, rootMargin = '0px') =

return {
inViewRef,
inViewport,
inViewport
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/hooks/useScrollIntoView/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const useScrollIntoView = ({ offset = 0 }) => {
if (shouldScrollY) {
window.scrollTo({
top: shouldScrollY ? adjustedTop : scrollTop,
behavior: 'smooth',
behavior: 'smooth'
})
}

if (shouldScrollX) {
window.scrollTo({
left: shouldScrollX ? adjustedLeft : scrollLeft,
behavior: 'smooth',
behavior: 'smooth'
})
}

Expand All @@ -50,7 +50,7 @@ const useScrollIntoView = ({ offset = 0 }) => {

return {
scrollIntoView,
targetRef,
targetRef
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/hooks/useTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const useTable = (props) => {
}
dataInterface({
...(isPagination ? { pageNum: page, pageSize } : {}),
...other,
...other
}).then((resp) => {
if (resp && resp.status === 1) {
setPage(page)
Expand Down Expand Up @@ -73,7 +73,7 @@ const useTable = (props) => {
setCachePayload({ ...safePayload })
getTableList(dataInterface || props.dataInterface, {
...cachePayload,
...safePayload,
...safePayload
})
}

Expand All @@ -99,16 +99,16 @@ const useTable = (props) => {
showQuickJumper: true,
showSizeChanger: true,
hideOnSinglePage: false,
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>,
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>
}
: false,
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false,
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false
},
page,
pageSize,
rawData,
updateTable,
resetTable,
resetTable
}
}
export default useTable
Expand Down
16 changes: 8 additions & 8 deletions src/components/stateful/TreeList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Index = forwardRef((props, ref) => {
selectedKeys, // 选中的节点
setSelectedKeys, // 选中外传函数
selectable = false, // 父级节点是否可以选中
params = {}, // 额外的参数
params = {} // 额外的参数
} = props
const [treeList, setTreeList] = useState([]) // 全量数据源列表
const [treeData, setTreeData] = useState([])
Expand Down Expand Up @@ -87,7 +87,7 @@ const Index = forwardRef((props, ref) => {
return {
...item,
key: itemPath,
...(item.children?.length ? { children: setPath(item.children, itemPath) } : {}),
...(item.children?.length ? { children: setPath(item.children, itemPath) } : {})
}
})
treeData = setPath(treeData)
Expand Down Expand Up @@ -123,7 +123,7 @@ const Index = forwardRef((props, ref) => {
const defaultKey = selectable
? {
selected: [treeData[0].key],
expanded: [treeData[0].key],
expanded: [treeData[0].key]
}
: getDefaultKey(treeData)
selected = defaultKey.selected
Expand All @@ -133,7 +133,7 @@ const Index = forwardRef((props, ref) => {
const defaultKey = selectable
? {
selected: [treeData[0].key],
expanded: [treeData[0].key],
expanded: [treeData[0].key]
}
: getDefaultKey(treeData)
selected = defaultKey.selected
Expand All @@ -159,7 +159,7 @@ const Index = forwardRef((props, ref) => {
})
selected = selectedKeys

function loop(params) {
function loop (params) {
return params.some((item) => {
if (item.realId === selectedKeys[0]) {
expanded = [item.key]
Expand All @@ -176,7 +176,7 @@ const Index = forwardRef((props, ref) => {
const defaultKey = selectable
? {
selected: [treeData[0].key],
expanded: [treeData[0].key],
expanded: [treeData[0].key]
}
: getDefaultKey(treeData)
selected = defaultKey.selected
Expand Down Expand Up @@ -216,14 +216,14 @@ const Index = forwardRef((props, ref) => {
expandedKeys,
setExpandedKeys,
setSelectedKeys: setFixSelectedKeys,
treeData,
treeData
}))

return (
<div className={`${styles.treeList} treeList`}>
<div>
{search && (
<Search placeholder="查询" onSearch={onSearch} style={{ marginBottom: 10, width: '100%' }} allowClear />
<Search placeholder='查询' onSearch={onSearch} style={{ marginBottom: 10, width: '100%' }} allowClear />
)}
<Tree
selectedKeys={!isEmpty(selectedKeys) ? selectedKeys : fixSelectedKeys}
Expand Down
Loading
Loading