fix: fix hot update error #1071 (#1072)

This commit is contained in:
conghuhu 2022-08-29 13:45:31 +08:00 committed by GitHub
parent 11b8b65ca0
commit 674d1619dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3574 additions and 5476 deletions

View File

@ -4,12 +4,18 @@
"es6": true, "es6": true,
"node": true "node": true
}, },
"parser": "babel-eslint", "parser": "@babel/eslint-parser",
"parserOptions": { "parserOptions": {
"ecmaVersion": 12, "ecmaVersion": 12,
"sourceType": "module", "sourceType": "module",
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true "jsx": true
},
"requireConfigFile": false,
"babelOptions": {
"babelrc": false,
"configFile": false,
"presets": ["@babel/preset-react"]
} }
}, },
"settings": { "settings": {

17
web/babel.config.json Normal file
View File

@ -0,0 +1,17 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"edge": "17",
"firefox": "60",
"chrome": "67",
"safari": "11.1"
},
"useBuiltIns": "usage",
"corejs": "3.6.5"
}
]
]
}

View File

@ -4,8 +4,8 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.7.0", "@ant-design/icons": "^4.7.0",
"@craco/craco": "^6.1.1", "@craco/craco": "^6.4.5",
"@crowdin/cli": "^3.6.4", "@crowdin/cli": "^3.7.10",
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2", "@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2", "@testing-library/user-event": "^7.1.2",
@ -13,7 +13,7 @@
"codemirror": "^5.61.1", "codemirror": "^5.61.1",
"copy-to-clipboard": "^3.3.1", "copy-to-clipboard": "^3.3.1",
"core-js": "^3.25.0", "core-js": "^3.25.0",
"craco-less": "^1.17.1", "craco-less": "^2.0.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-unused-imports": "^2.0.0",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"i18n-iso-countries": "^7.0.0", "i18n-iso-countries": "^7.0.0",
@ -31,7 +31,7 @@
"react-highlight-words": "^0.18.0", "react-highlight-words": "^0.18.0",
"react-i18next": "^11.8.7", "react-i18next": "^11.8.7",
"react-router-dom": "^5.3.3", "react-router-dom": "^5.3.3",
"react-scripts": "4.0.3", "react-scripts": "5.0.1",
"react-social-login-buttons": "^3.4.0" "react-social-login-buttons": "^3.4.0"
}, },
"scripts": { "scripts": {
@ -61,9 +61,12 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.18.13",
"@babel/eslint-parser": "^7.18.9",
"@babel/preset-react": "^7.18.6",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^7.11.0", "eslint": "^8.23.0",
"eslint-plugin-react": "^7.30.1", "eslint-plugin-react": "^7.31.1",
"husky": "^4.3.8", "husky": "^4.3.8",
"lint-staged": "^13.0.3" "lint-staged": "^13.0.3"
}, },

View File

@ -39,101 +39,102 @@ class BaseListPage extends React.Component {
this.fetch({pagination}); this.fetch({pagination});
} }
getColumnSearchProps = dataIndex => ({ getColumnSearchProps = dataIndex => ({
filterDropdown: ({setSelectedKeys, selectedKeys, confirm, clearFilters}) => ( filterDropdown: ({setSelectedKeys, selectedKeys, confirm, clearFilters}) => (
<div style={{padding: 8}}> <div style={{padding: 8}}>
<Input <Input
ref={node => { ref={node => {
this.searchInput = node; this.searchInput = node;
}} }}
placeholder={`Search ${dataIndex}`} placeholder={`Search ${dataIndex}`}
value={selectedKeys[0]} value={selectedKeys[0]}
onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])} onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
onPressEnter={() => this.handleSearch(selectedKeys, confirm, dataIndex)} onPressEnter={() => this.handleSearch(selectedKeys, confirm, dataIndex)}
style={{marginBottom: 8, display: "block"}} style={{marginBottom: 8, display: "block"}}
/> />
<Space>
<Button <Space>
type="primary" <Button
onClick={() => this.handleSearch(selectedKeys, confirm, dataIndex)} type="primary"
icon={<SearchOutlined />} onClick={() => this.handleSearch(selectedKeys, confirm, dataIndex)}
size="small" icon={<SearchOutlined />}
style={{width: 90}} size="small"
> style={{width: 90}}
>
Search Search
</Button> </Button>
<Button onClick={() => this.handleReset(clearFilters)} size="small" style={{width: 90}}> <Button onClick={() => this.handleReset(clearFilters)} size="small" style={{width: 90}}>
Reset Reset
</Button> </Button>
<Button <Button
type="link" type="link"
size="small" size="small"
onClick={() => { onClick={() => {
confirm({closeDropdown: false}); confirm({closeDropdown: false});
this.setState({ this.setState({
searchText: selectedKeys[0], searchText: selectedKeys[0],
searchedColumn: dataIndex, searchedColumn: dataIndex,
}); });
}} }}
> >
Filter Filter
</Button> </Button>
</Space> </Space>
</div> </div>
),
filterIcon: filtered => <SearchOutlined style={{color: filtered ? "#1890ff" : undefined}} />,
onFilter: (value, record) =>
record[dataIndex]
? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase())
: "",
onFilterDropdownVisibleChange: visible => {
if (visible) {
setTimeout(() => this.searchInput.select(), 100);
}
},
render: text =>
this.state.searchedColumn === dataIndex ? (
<Highlighter
highlightStyle={{backgroundColor: "#ffc069", padding: 0}}
searchWords={[this.state.searchText]}
autoEscape
textToHighlight={text ? text.toString() : ""}
/>
) : (
text
), ),
filterIcon: filtered => <SearchOutlined style={{color: filtered ? "#1890ff" : undefined}} />, });
onFilter: (value, record) =>
record[dataIndex] handleSearch = (selectedKeys, confirm, dataIndex) => {
? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) this.fetch({searchText: selectedKeys[0], searchedColumn: dataIndex, pagination: this.state.pagination});
: "", };
onFilterDropdownVisibleChange: visible => {
if (visible) { handleReset = clearFilters => {
setTimeout(() => this.searchInput.select(), 100); clearFilters();
} const {pagination} = this.state;
}, this.fetch({pagination});
render: text => };
this.state.searchedColumn === dataIndex ? (
<Highlighter handleTableChange = (pagination, filters, sorter) => {
highlightStyle={{backgroundColor: "#ffc069", padding: 0}} this.fetch({
searchWords={[this.state.searchText]} sortField: sorter.field,
autoEscape sortOrder: sorter.order,
textToHighlight={text ? text.toString() : ""} pagination,
/> ...filters,
) : ( searchText: this.state.searchText,
text searchedColumn: this.state.searchedColumn,
),
}); });
};
handleSearch = (selectedKeys, confirm, dataIndex) => { render() {
this.fetch({searchText: selectedKeys[0], searchedColumn: dataIndex, pagination: this.state.pagination}); return (
}; <div>
{
handleReset = clearFilters => { this.renderTable(this.state.data)
clearFilters(); }
const {pagination} = this.state; </div>
this.fetch({pagination}); );
}; }
handleTableChange = (pagination, filters, sorter) => {
this.fetch({
sortField: sorter.field,
sortOrder: sorter.order,
pagination,
...filters,
searchText: this.state.searchText,
searchedColumn: this.state.searchedColumn,
});
};
render() {
return (
<div>
{
this.renderTable(this.state.data)
}
</div>
);
}
} }
export default BaseListPage; export default BaseListPage;

File diff suppressed because it is too large Load Diff