完成token自动刷新

main
wuyize 2022-12-27 21:33:49 +08:00
parent 0b96a9cf34
commit 2ecacddd27
8 changed files with 236 additions and 429 deletions

332
package-lock.json generated
View File

@ -8,7 +8,6 @@
"name": "financial-reimbursement",
"version": "0.1.0",
"dependencies": {
"@ant-design/compatible": "^5.1.1",
"@reduxjs/toolkit": "^1.9.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
@ -19,6 +18,7 @@
"@types/react-dom": "^18.0.9",
"antd": "^5.1.0",
"axios": "^1.2.1",
"history": "^5.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
@ -54,30 +54,6 @@
"@ctrl/tinycolor": "^3.4.0"
}
},
"node_modules/@ant-design/compatible": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@ant-design/compatible/-/compatible-5.1.1.tgz",
"integrity": "sha512-frGsAfzW49y5dq5U9jFDnIsYsEO84IYWF0mNKHCEYE+vyAPbZ+Kzlpv9CBqHtRy4cc0yVE5LHAuNqavKY/cigw==",
"dependencies": {
"classnames": "^2.2.6",
"dayjs": "^1.11.4",
"lodash.camelcase": "^4.3.0",
"lodash.upperfirst": "^4.3.1",
"rc-animate": "^3.1.1",
"rc-form": "^2.4.12",
"rc-util": "^5.24.5"
},
"peerDependencies": {
"antd": "^5.0.1",
"react": ">=16.0.0",
"react-dom": ">=16.0.0"
}
},
"node_modules/@ant-design/css-animation": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/@ant-design/css-animation/-/css-animation-1.7.3.tgz",
"integrity": "sha512-LrX0OGZtW+W6iLnTAqnTaoIsRelYeuLZWsrmBJFUXDALQphPsN8cE5DCsmoSlL0QYb94BQxINiuS70Ar/8BNgA=="
},
"node_modules/@ant-design/cssinjs": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/@ant-design/cssinjs/-/cssinjs-1.2.0.tgz",
@ -4397,14 +4373,6 @@
"node": ">=0.4.0"
}
},
"node_modules/add-dom-event-listener": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/add-dom-event-listener/-/add-dom-event-listener-1.1.0.tgz",
"integrity": "sha512-WCxx1ixHT0GQU9hb0KI/mhgRQhnU+U3GvwY6ZvVjYq8rsihIGoaIOUbY0yMPBxLH5MDtr0kz3fisWGNcbWW7Jw==",
"dependencies": {
"object-assign": "4.x"
}
},
"node_modules/address": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/address/-/address-1.2.2.tgz",
@ -5080,27 +5048,6 @@
"babel-plugin-transform-react-remove-prop-types": "^0.4.24"
}
},
"node_modules/babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==",
"dependencies": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
}
},
"node_modules/babel-runtime/node_modules/core-js": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
"integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==",
"deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.",
"hasInstallScript": true
},
"node_modules/babel-runtime/node_modules/regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
@ -5707,15 +5654,6 @@
"node": ">=10"
}
},
"node_modules/create-react-class": {
"version": "15.7.0",
"resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.7.0.tgz",
"integrity": "sha512-QZv4sFWG9S5RUvkTYWbflxeZX+JG7Cz0Tn33rQBJ+WFQTqTfUTjMjiv9tnfXazjsO5r0KhPs+AqCjyrQX6h2ng==",
"dependencies": {
"loose-envify": "^1.3.1",
"object-assign": "^4.1.1"
}
},
"node_modules/cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -6378,11 +6316,6 @@
"utila": "~0.4"
}
},
"node_modules/dom-scroll-into-view": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/dom-scroll-into-view/-/dom-scroll-into-view-1.2.1.tgz",
"integrity": "sha512-LwNVg3GJOprWDO+QhLL1Z9MMgWe/KAFLxVWKzjRTxNSPn8/LLDIfmuG71YHznXCqaqTjvHJDYO1MEAgX6XCNbQ=="
},
"node_modules/dom-serializer": {
"version": "1.4.1",
"resolved": "https://registry.npmmirror.com/dom-serializer/-/dom-serializer-1.4.1.tgz",
@ -8213,6 +8146,14 @@
"he": "bin/he"
}
},
"node_modules/history": {
"version": "5.3.0",
"resolved": "https://registry.npmmirror.com/history/-/history-5.3.0.tgz",
"integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==",
"dependencies": {
"@babel/runtime": "^7.7.6"
}
},
"node_modules/hoist-non-react-statics": {
"version": "3.3.2",
"resolved": "https://registry.npmmirror.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
@ -11085,11 +11026,6 @@
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
},
"node_modules/lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmmirror.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
@ -11115,11 +11051,6 @@
"resolved": "https://registry.npmmirror.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
"integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ=="
},
"node_modules/lodash.upperfirst": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz",
"integrity": "sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg=="
},
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/loose-envify/-/loose-envify-1.4.0.tgz",
@ -13296,34 +13227,6 @@
"react-dom": ">=16.9.0"
}
},
"node_modules/rc-animate": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/rc-animate/-/rc-animate-3.1.1.tgz",
"integrity": "sha512-8wg2Zg3EETy0k/9kYuis30NJNQg1D6/WSQwnCiz6SvyxQXNet/rVraRz3bPngwY6rcU2nlRvoShiYOorXyF7Sg==",
"dependencies": {
"@ant-design/css-animation": "^1.7.2",
"classnames": "^2.2.6",
"raf": "^3.4.0",
"rc-util": "^4.15.3"
}
},
"node_modules/rc-animate/node_modules/rc-util": {
"version": "4.21.1",
"resolved": "https://registry.npmjs.org/rc-util/-/rc-util-4.21.1.tgz",
"integrity": "sha512-Z+vlkSQVc1l8O2UjR3WQ+XdWlhj5q9BMQNLk2iOBch75CqPfrJyGtcWMcnhRlNuDu0Ndtt4kLVO8JI8BrABobg==",
"dependencies": {
"add-dom-event-listener": "^1.1.0",
"prop-types": "^15.5.10",
"react-is": "^16.12.0",
"react-lifecycles-compat": "^3.0.4",
"shallowequal": "^1.1.0"
}
},
"node_modules/rc-animate/node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"node_modules/rc-cascader": {
"version": "3.8.0",
"resolved": "https://registry.npmmirror.com/rc-cascader/-/rc-cascader-3.8.0.tgz",
@ -13434,47 +13337,6 @@
"react-dom": ">=16.9.0"
}
},
"node_modules/rc-form": {
"version": "2.4.12",
"resolved": "https://registry.npmjs.org/rc-form/-/rc-form-2.4.12.tgz",
"integrity": "sha512-sHfyWRrnjCHkeCYfYAGop2GQBUC6CKMPcJF9h/gL/vTmZB/RN6fNOGKjXrXjFbwFwKXUWBoPtIDDDmXQW9xNdw==",
"dependencies": {
"async-validator": "~1.11.3",
"babel-runtime": "6.x",
"create-react-class": "^15.5.3",
"dom-scroll-into-view": "1.x",
"hoist-non-react-statics": "^3.3.0",
"lodash": "^4.17.4",
"rc-util": "^4.15.3",
"react-is": "^16.13.1",
"warning": "^4.0.3"
},
"peerDependencies": {
"prop-types": "^15.0"
}
},
"node_modules/rc-form/node_modules/async-validator": {
"version": "1.11.5",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-1.11.5.tgz",
"integrity": "sha512-XNtCsMAeAH1pdLMEg1z8/Bb3a8cdCbui9QbJATRFHHHW5kT6+NPI3zSVQUXgikTFITzsg+kYY5NTWhM2Orwt9w=="
},
"node_modules/rc-form/node_modules/rc-util": {
"version": "4.21.1",
"resolved": "https://registry.npmjs.org/rc-util/-/rc-util-4.21.1.tgz",
"integrity": "sha512-Z+vlkSQVc1l8O2UjR3WQ+XdWlhj5q9BMQNLk2iOBch75CqPfrJyGtcWMcnhRlNuDu0Ndtt4kLVO8JI8BrABobg==",
"dependencies": {
"add-dom-event-listener": "^1.1.0",
"prop-types": "^15.5.10",
"react-is": "^16.12.0",
"react-lifecycles-compat": "^3.0.4",
"shallowequal": "^1.1.0"
}
},
"node_modules/rc-form/node_modules/react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
},
"node_modules/rc-image": {
"version": "5.12.1",
"resolved": "https://registry.npmmirror.com/rc-image/-/rc-image-5.12.1.tgz",
@ -14110,11 +13972,6 @@
"resolved": "https://registry.npmmirror.com/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
"node_modules/react-lifecycles-compat": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"node_modules/react-redux": {
"version": "8.0.5",
"resolved": "https://registry.npmmirror.com/react-redux/-/react-redux-8.0.5.tgz",
@ -16076,14 +15933,6 @@
"makeerror": "1.0.12"
}
},
"node_modules/warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"dependencies": {
"loose-envify": "^1.0.0"
}
},
"node_modules/watchpack": {
"version": "2.4.0",
"resolved": "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.0.tgz",
@ -16983,25 +16832,6 @@
"@ctrl/tinycolor": "^3.4.0"
}
},
"@ant-design/compatible": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@ant-design/compatible/-/compatible-5.1.1.tgz",
"integrity": "sha512-frGsAfzW49y5dq5U9jFDnIsYsEO84IYWF0mNKHCEYE+vyAPbZ+Kzlpv9CBqHtRy4cc0yVE5LHAuNqavKY/cigw==",
"requires": {
"classnames": "^2.2.6",
"dayjs": "^1.11.4",
"lodash.camelcase": "^4.3.0",
"lodash.upperfirst": "^4.3.1",
"rc-animate": "^3.1.1",
"rc-form": "^2.4.12",
"rc-util": "^5.24.5"
}
},
"@ant-design/css-animation": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/@ant-design/css-animation/-/css-animation-1.7.3.tgz",
"integrity": "sha512-LrX0OGZtW+W6iLnTAqnTaoIsRelYeuLZWsrmBJFUXDALQphPsN8cE5DCsmoSlL0QYb94BQxINiuS70Ar/8BNgA=="
},
"@ant-design/cssinjs": {
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/@ant-design/cssinjs/-/cssinjs-1.2.0.tgz",
@ -20159,14 +19989,6 @@
"resolved": "https://registry.npmmirror.com/acorn-walk/-/acorn-walk-7.2.0.tgz",
"integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA=="
},
"add-dom-event-listener": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/add-dom-event-listener/-/add-dom-event-listener-1.1.0.tgz",
"integrity": "sha512-WCxx1ixHT0GQU9hb0KI/mhgRQhnU+U3GvwY6ZvVjYq8rsihIGoaIOUbY0yMPBxLH5MDtr0kz3fisWGNcbWW7Jw==",
"requires": {
"object-assign": "4.x"
}
},
"address": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/address/-/address-1.2.2.tgz",
@ -20708,27 +20530,6 @@
"babel-plugin-transform-react-remove-prop-types": "^0.4.24"
}
},
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g==",
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
},
"dependencies": {
"core-js": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
"integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ=="
},
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg=="
}
}
},
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz",
@ -21232,15 +21033,6 @@
"yaml": "^1.10.0"
}
},
"create-react-class": {
"version": "15.7.0",
"resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.7.0.tgz",
"integrity": "sha512-QZv4sFWG9S5RUvkTYWbflxeZX+JG7Cz0Tn33rQBJ+WFQTqTfUTjMjiv9tnfXazjsO5r0KhPs+AqCjyrQX6h2ng==",
"requires": {
"loose-envify": "^1.3.1",
"object-assign": "^4.1.1"
}
},
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -21738,11 +21530,6 @@
"utila": "~0.4"
}
},
"dom-scroll-into-view": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/dom-scroll-into-view/-/dom-scroll-into-view-1.2.1.tgz",
"integrity": "sha512-LwNVg3GJOprWDO+QhLL1Z9MMgWe/KAFLxVWKzjRTxNSPn8/LLDIfmuG71YHznXCqaqTjvHJDYO1MEAgX6XCNbQ=="
},
"dom-serializer": {
"version": "1.4.1",
"resolved": "https://registry.npmmirror.com/dom-serializer/-/dom-serializer-1.4.1.tgz",
@ -23178,6 +22965,14 @@
"resolved": "https://registry.npmmirror.com/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
},
"history": {
"version": "5.3.0",
"resolved": "https://registry.npmmirror.com/history/-/history-5.3.0.tgz",
"integrity": "sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==",
"requires": {
"@babel/runtime": "^7.7.6"
}
},
"hoist-non-react-statics": {
"version": "3.3.2",
"resolved": "https://registry.npmmirror.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
@ -25409,11 +25204,6 @@
"resolved": "https://registry.npmmirror.com/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"lodash.camelcase": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
},
"lodash.debounce": {
"version": "4.0.8",
"resolved": "https://registry.npmmirror.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
@ -25439,11 +25229,6 @@
"resolved": "https://registry.npmmirror.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz",
"integrity": "sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ=="
},
"lodash.upperfirst": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz",
"integrity": "sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg=="
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/loose-envify/-/loose-envify-1.4.0.tgz",
@ -26972,36 +26757,6 @@
"resize-observer-polyfill": "^1.5.1"
}
},
"rc-animate": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/rc-animate/-/rc-animate-3.1.1.tgz",
"integrity": "sha512-8wg2Zg3EETy0k/9kYuis30NJNQg1D6/WSQwnCiz6SvyxQXNet/rVraRz3bPngwY6rcU2nlRvoShiYOorXyF7Sg==",
"requires": {
"@ant-design/css-animation": "^1.7.2",
"classnames": "^2.2.6",
"raf": "^3.4.0",
"rc-util": "^4.15.3"
},
"dependencies": {
"rc-util": {
"version": "4.21.1",
"resolved": "https://registry.npmjs.org/rc-util/-/rc-util-4.21.1.tgz",
"integrity": "sha512-Z+vlkSQVc1l8O2UjR3WQ+XdWlhj5q9BMQNLk2iOBch75CqPfrJyGtcWMcnhRlNuDu0Ndtt4kLVO8JI8BrABobg==",
"requires": {
"add-dom-event-listener": "^1.1.0",
"prop-types": "^15.5.10",
"react-is": "^16.12.0",
"react-lifecycles-compat": "^3.0.4",
"shallowequal": "^1.1.0"
}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
}
}
},
"rc-cascader": {
"version": "3.8.0",
"resolved": "https://registry.npmmirror.com/rc-cascader/-/rc-cascader-3.8.0.tgz",
@ -27081,46 +26836,6 @@
"rc-util": "^5.8.0"
}
},
"rc-form": {
"version": "2.4.12",
"resolved": "https://registry.npmjs.org/rc-form/-/rc-form-2.4.12.tgz",
"integrity": "sha512-sHfyWRrnjCHkeCYfYAGop2GQBUC6CKMPcJF9h/gL/vTmZB/RN6fNOGKjXrXjFbwFwKXUWBoPtIDDDmXQW9xNdw==",
"requires": {
"async-validator": "~1.11.3",
"babel-runtime": "6.x",
"create-react-class": "^15.5.3",
"dom-scroll-into-view": "1.x",
"hoist-non-react-statics": "^3.3.0",
"lodash": "^4.17.4",
"rc-util": "^4.15.3",
"react-is": "^16.13.1",
"warning": "^4.0.3"
},
"dependencies": {
"async-validator": {
"version": "1.11.5",
"resolved": "https://registry.npmjs.org/async-validator/-/async-validator-1.11.5.tgz",
"integrity": "sha512-XNtCsMAeAH1pdLMEg1z8/Bb3a8cdCbui9QbJATRFHHHW5kT6+NPI3zSVQUXgikTFITzsg+kYY5NTWhM2Orwt9w=="
},
"rc-util": {
"version": "4.21.1",
"resolved": "https://registry.npmjs.org/rc-util/-/rc-util-4.21.1.tgz",
"integrity": "sha512-Z+vlkSQVc1l8O2UjR3WQ+XdWlhj5q9BMQNLk2iOBch75CqPfrJyGtcWMcnhRlNuDu0Ndtt4kLVO8JI8BrABobg==",
"requires": {
"add-dom-event-listener": "^1.1.0",
"prop-types": "^15.5.10",
"react-is": "^16.12.0",
"react-lifecycles-compat": "^3.0.4",
"shallowequal": "^1.1.0"
}
},
"react-is": {
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
}
}
},
"rc-image": {
"version": "5.12.1",
"resolved": "https://registry.npmmirror.com/rc-image/-/rc-image-5.12.1.tgz",
@ -27568,11 +27283,6 @@
"resolved": "https://registry.npmmirror.com/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
"react-lifecycles-compat": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz",
"integrity": "sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA=="
},
"react-redux": {
"version": "8.0.5",
"resolved": "https://registry.npmmirror.com/react-redux/-/react-redux-8.0.5.tgz",
@ -29099,14 +28809,6 @@
"makeerror": "1.0.12"
}
},
"warning": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/warning/-/warning-4.0.3.tgz",
"integrity": "sha512-rpJyN222KWIvHJ/F53XSZv0Zl/accqHR8et1kpaMTD/fLCRxtV8iX8czMzY7sVZupTI3zcUTg8eycS2kNF9l6w==",
"requires": {
"loose-envify": "^1.0.0"
}
},
"watchpack": {
"version": "2.4.0",
"resolved": "https://registry.npmmirror.com/watchpack/-/watchpack-2.4.0.tgz",

View File

@ -13,6 +13,7 @@
"@types/react-dom": "^18.0.9",
"antd": "^5.1.0",
"axios": "^1.2.1",
"history": "^5.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",

View File

@ -6,7 +6,7 @@ import reportWebVitals from './reportWebVitals';
import {Provider} from 'react-redux';
import {store, persistor} from './models/store';
import {RouterProvider} from "react-router-dom";
import router from "./router/router";
import CustomRouter from "./router/router";
import {PersistGate} from 'redux-persist/integration/react'
import {ConfigProvider} from "antd";
@ -26,7 +26,7 @@ root.render(
wireframe: false
}
}}>
<RouterProvider router={router}/>
<CustomRouter />
</ConfigProvider>
</PersistGate>
</Provider>

View File

@ -16,9 +16,12 @@ const tokenSlice = createSlice({
state.refreshToken = action.payload.refreshToken
state.clientSecret = action.payload.clientSecret
},
setAccessToken: (state, action: PayloadAction<string>) => {
state.accessToken = action.payload
},
},
});
export const {setToken} = tokenSlice.actions;
export const {setToken, setAccessToken} = tokenSlice.actions;
export const getToken = (state: RootState) => state.token;
const persistConfig = {

View File

@ -19,6 +19,7 @@ function HeaderBar(props: any) {
token: {colorBgContainer, colorPrimary},
} = theme.useToken();
const token = useAppSelector(getToken);
const dispatch = useAppDispatch()
const navigate = useNavigate()
@ -33,7 +34,21 @@ function HeaderBar(props: any) {
refreshToken: '',
clientSecret: ''
}))
navigate("/login")
axiosInstance({
url: 'logout',
method: 'post',
data: {
refreshToken: token.refreshToken
}
}).then(response => {
console.log(response.data)
navigate("/login")
}).catch(function (error) {
console.log(error)
})
break
}
};
@ -89,29 +104,40 @@ function HeaderBar(props: any) {
)
}
function MyMenu(props: any) {
return (
<Menu
mode="inline"
defaultSelectedKeys={['0']}
items={props.items}
/>
)
}
function HomeView() {
const token = useAppSelector(getToken);
const navigate = useNavigate();
console.log(store.getState())
let items = [{
key: "/invoice/mine",
key: "0",
//icon: React.createElement(UserOutlined),
label: <Link to="/invoice/mine"></Link>
}, {
key: "/reimbursement/mine",
key: "1",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/invoice/management",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/reimbursement/management",
key: "2",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/stat",
key: "3",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "4",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}]
@ -122,25 +148,12 @@ function HomeView() {
const [staff, setStaff] = useState({
staffName: "王司徒",
managingDepartment: {
departmentId: 3,
departmentName: "投影立体角部"
},
staffName: "",
managingDepartment: null,
staffDepartments: []
})
const [menuItems, setMenuItems] = useState(
[{
key: "/invoice/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/invoice/mine"></Link>
}, {
key: "/reimbursement/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}]
)
const [menuItems, setMenuItems] = useState(items.slice(0,2))
const getStaffInfo = () => {
axiosInstance({
@ -148,7 +161,25 @@ function HomeView() {
method: 'get'
}).then(response => {
console.log(response.data)
const staff = response.data
setStaff( response.data)
navigate('/invoice/mine')
if(staff.managingDepartment)
{
// @ts-ignore
if(staff.managingDepartment.departmentName==='财务部')
{
setMenuItems(items)
}
else{
console.log('aaaaaaaaaaa')
setMenuItems(items.slice(0,3))
}
}
else {
setMenuItems(items.slice(0,2))
}
}).catch(function (error) {
console.log(error)
})
@ -159,59 +190,7 @@ function HomeView() {
navigate("/login")
}
getStaffInfo()
if(staff.managingDepartment)
{
if(staff.managingDepartment.departmentName==='财务部')
{
setMenuItems([{
key: "/invoice/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/invoice/mine"></Link>
}, {
key: "/reimbursement/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/invoice/management",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/reimbursement/management",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/stat",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}])
}
else{
setMenuItems([{
key: "/invoice/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/invoice/mine"></Link>
}, {
key: "/reimbursement/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}, {
key: "/reimbursement/management",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}])
}
}
else {
setMenuItems([{
key: "/invoice/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/invoice/mine"></Link>
}, {
key: "/reimbursement/mine",
//icon: React.createElement(UserOutlined),
label: <Link to="/reimbursement/mine"></Link>,
}])
}
}, []);
return (
<Layout style={{height: '100%'}}>
@ -242,15 +221,11 @@ function HomeView() {
marginLeft: '4px'
}}></span>
</div>
<Menu
mode="inline"
defaultSelectedKeys={['/invoice/mine']}
items={menuItems}
/>
<MyMenu items={menuItems}/>
</Sider>
<Layout>
<HeaderBar staff={staff}/>
<Content style={{margin: '24px 16px 0'}}>
<Content style={{margin: '0'}}>
<Outlet/>
</Content>
<Footer style={{textAlign: 'center'}}></Footer>

View File

@ -0,0 +1,83 @@
import React, {
useRef,
createContext,
useState,
useLayoutEffect,
type MutableRefObject,
} from 'react'
import { Router, type BrowserRouterProps } from 'react-router-dom'
import {
createBrowserHistory,
type BrowserHistory,
type History as RemixHistory,
} from '@remix-run/router'
import { type History as LegacyHistory } from 'history'
type BrowserRouterListener = Parameters<RemixHistory['listen']>[0]
/**
* browser router state
* @example history.listen((state: BrowserRouterHistoryState) => {})
*/
export type BrowserRouterHistoryState = Parameters<BrowserRouterListener>[0]
export const SubscriptionContext = createContext<{
ref: MutableRefObject<Set<BrowserRouterListener>>
} | null>(null)
interface IBrowserRouterProps extends BrowserRouterProps {
history?: BrowserHistory | LegacyHistory
}
export function BrowserRouter({
basename,
children,
window,
history: specifiedHistory,
}: IBrowserRouterProps) {
// if `v5Compat: true`, cannot add more listeners
// so we manage the subscriptions manually
const subscriptionRef = useRef<Set<BrowserRouterListener>>(new Set())
let historyRef = useRef<BrowserHistory>()
if (!historyRef.current) {
// @ts-ignore
historyRef.current =
specifiedHistory || createBrowserHistory({ window, v5Compat: true })
}
let history = historyRef.current
let [state, setState] = useState({
// @ts-ignore
action: history.action,
// @ts-ignore
location: history.location,
})
// @ts-ignore
useLayoutEffect(
() =>
// @ts-ignore
history.listen((state) => {
subscriptionRef.current.forEach((listener) => listener(state))
setState(state)
}),
[history]
)
return (
<SubscriptionContext.Provider
value={{
ref: subscriptionRef,
}}
>
<Router
basename={basename}
children={children}
location={state.location}
navigationType={state.action}
// @ts-ignore
navigator={history}
/>
</SubscriptionContext.Provider>
)
}

View File

@ -1,28 +1,25 @@
import {createBrowserRouter, redirect} from "react-router-dom";
import {Routes, Route} from "react-router-dom";
import {createBrowserHistory} from "history";
import LoginView from "../pages/login/LoginView";
import HomeView from "../pages/HomeView";
import InvoiceListView from "../pages/Invoice/mine/InvoiceListView";
import MyReimbursement from "../pages/reimbursement/mine/MyReimbursement";
import {BrowserRouter} from "./BrowserRouter"
const router = createBrowserRouter([
{
path: "/login",
element: <LoginView/>,
},
{
path: "/",
element: <HomeView/>,
children: [
{
path: "invoice/mine",
element: <InvoiceListView />,
},
{
path: "reimbursement/mine",
element: <MyReimbursement />,
},
],
},
]);
export const history = createBrowserHistory()
export default router
function CustomRouter() {
return (
<BrowserRouter history={history}>
<Routes>
<Route path="/" element={<HomeView/>}>
<Route path="invoice/mine" element={<InvoiceListView/>}></Route>
<Route path="reimbursement/mine" element={<MyReimbursement/>}></Route>
</Route>
<Route path="/login" element={<LoginView/>}></Route>
</Routes>
</BrowserRouter>
)
}
export default CustomRouter

View File

@ -1,5 +1,7 @@
import axios, {AxiosRequestConfig, AxiosResponse} from "axios";
import {store} from "../models/store";
import {persistor, setAccessToken, setToken, store} from "../models/store";
import {history} from "../router/router";
export const baseUrl = "http://101.34.228.45:8080/"
//export const baseUrl = "https://mock.apifox.cn/m1/2116708-0-default/"
@ -12,7 +14,7 @@ const axiosInstance = axios.create({
axiosInstance.interceptors.request.use(
function (config: AxiosRequestConfig) {
// @ts-ignore
config.headers.Authorization = "Bearer "+store.getState().token.accessToken
config.headers.Authorization = "Bearer " + store.getState().token.accessToken
console.log(config)
return config
},
@ -27,10 +29,54 @@ axiosInstance.interceptors.response.use(
return response
},
function (error) {
console.log(error.response)
console.log(error)
if (error.response.status === 401) {
}
return Promise.reject(error)
if (error.config.isRetry) {
console.log('isRetry')
store.dispatch(setToken({
accessToken: '',
refreshToken: '',
clientSecret: ''
}))
history.push('/login')
} else {
let config = error.config
let result: any
console.log(store.getState())
const response = axios.get(baseUrl + 'refresh', {
params: {
refreshToken: store.getState().token.refreshToken,
clientSecret: store.getState().token.clientSecret
}
})
.then(function (response) {
console.log(response);
store.dispatch(setAccessToken(response.data.accessToken))
config.isRetry = true
result = axiosInstance(config)
})
.catch(function (error) {
console.log('refresh error')
console.log(error);
store.dispatch(setToken({
accessToken: '',
refreshToken: '',
clientSecret: ''
}))
history.push('/login')
result = Promise.reject(error)
});
return response.then(function () {
console.log('retried')
return result
});
}
} else
return Promise.reject(error)
});
export default axiosInstance