mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2026-07-15 14:31:14 +08:00
Compare commits
2 Commits
1b0d3409bb
...
c0723990c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0723990c7 | ||
|
|
c7e7efaa31 |
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,3 +1,13 @@
|
||||
## [3.1.8](https://github.com/WeBankFinTech/fes.js/compare/v3.1.7...v3.1.8) (2024-5-6)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* login 兼容不同的 request 版本 ([#242](https://github.com/WeBankFinTech/fes.js/issues/242)) ([c7e7efa](https://github.com/WeBankFinTech/fes.js/commit/c7e7efaa316986bbd65d64fc9b6ce2102fa792ca))
|
||||
* **plugin-access:** 修复切换角色时,getAccess 不正确 ([#240](https://github.com/WeBankFinTech/fes.js/issues/240)) ([1b0d340](https://github.com/WeBankFinTech/fes.js/commit/1b0d3409bb9da3f9b4f91121fbc1035fc0b7df7b))
|
||||
|
||||
|
||||
|
||||
## [3.1.7](https://github.com/WeBankFinTech/fes.js/compare/v3.1.6...v3.1.7) (2024-3-28)
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "fes.js",
|
||||
"type": "module",
|
||||
"version": "3.1.7",
|
||||
"version": "3.1.8",
|
||||
"private": true,
|
||||
"description": "一个好用的前端管理台快速开发框架",
|
||||
"preferGlobal": true,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fesjs/plugin-access",
|
||||
"version": "3.1.4",
|
||||
"version": "3.1.5",
|
||||
"description": "@fesjs/plugin-access",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fesjs/plugin-layout",
|
||||
"version": "5.1.10",
|
||||
"version": "5.1.11",
|
||||
"description": "@fesjs/plugin-layout",
|
||||
"author": "harrywan",
|
||||
"license": "MIT",
|
||||
|
||||
@ -1,36 +1,36 @@
|
||||
{
|
||||
"name": "@fesjs/plugin-login",
|
||||
"version": "3.0.0",
|
||||
"description": "@fesjs/plugin-login",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
"lib",
|
||||
"types.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
|
||||
"directory": "packages/fes-plugin-login"
|
||||
},
|
||||
"keywords": [
|
||||
"fes"
|
||||
],
|
||||
"author": "qlin",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/WeBankFinTech/fes.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@fesjs/fes": "^3.0.0",
|
||||
"@fesjs/plugin-request": "^3.0.0",
|
||||
"vue": "^3.2.47"
|
||||
},
|
||||
"typings": "./types.d.ts"
|
||||
"name": "@fesjs/plugin-login",
|
||||
"version": "3.0.1",
|
||||
"description": "@fesjs/plugin-login",
|
||||
"main": "lib/index.js",
|
||||
"files": [
|
||||
"lib",
|
||||
"types.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
|
||||
"directory": "packages/fes-plugin-login"
|
||||
},
|
||||
"keywords": [
|
||||
"fes"
|
||||
],
|
||||
"author": "qlin",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/WeBankFinTech/fes.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@fesjs/fes": "^3.0.0",
|
||||
"@fesjs/plugin-request": "^4.0.0-rc.3",
|
||||
"vue": "^3.2.47"
|
||||
},
|
||||
"typings": "./types.d.ts"
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
import { request } from '@@/core/pluginExports';
|
||||
import { ApplyPluginsType, getRouter, plugin } from '@fesjs/fes';
|
||||
|
||||
let config;
|
||||
function getLoginConfig() {
|
||||
if (config) return config;
|
||||
if (config) {
|
||||
return config;
|
||||
}
|
||||
|
||||
config = plugin.applyPlugins({
|
||||
key: 'login',
|
||||
type: ApplyPluginsType.modify,
|
||||
@ -14,38 +18,63 @@ function getLoginConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
const defaultExport = {
|
||||
onRouterCreated({ router }) {
|
||||
const { hasLogin, loginPath } = getLoginConfig();
|
||||
if (hasLogin && loginPath) {
|
||||
let isAuthenticated;
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.path !== loginPath && !isAuthenticated) {
|
||||
isAuthenticated = await hasLogin();
|
||||
if (!isAuthenticated) {
|
||||
return next({ path: loginPath });
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// ACCESS
|
||||
|
||||
export function request(memo) {
|
||||
if (!memo.responseInterceptors) {
|
||||
memo.responseInterceptors = [];
|
||||
}
|
||||
memo.responseInterceptors.push([
|
||||
(response) => response,
|
||||
(error) => {
|
||||
if (request.version) {
|
||||
defaultExport.request = (memo) => {
|
||||
const config = getRunTimeConfig();
|
||||
if (config.ignore401Redirect) {
|
||||
return memo;
|
||||
}
|
||||
|
||||
const errorHandler = memo.errorHandler;
|
||||
memo.errorHandler = (error) => {
|
||||
if (error?.response?.status === 401) {
|
||||
const router = getRouter();
|
||||
const { loginPath } = getLoginConfig();
|
||||
router.push({ path: loginPath });
|
||||
}
|
||||
throw error;
|
||||
},
|
||||
]);
|
||||
return memo;
|
||||
errorHandler && errorHandler(error);
|
||||
};
|
||||
return memo;
|
||||
};
|
||||
}
|
||||
else {
|
||||
defaultExport.request = (memo) => {
|
||||
if (!memo.responseInterceptors) {
|
||||
memo.responseInterceptors = [];
|
||||
}
|
||||
memo.responseInterceptors.push([
|
||||
response => response,
|
||||
(error) => {
|
||||
if (error?.response?.status === 401) {
|
||||
const router = getRouter();
|
||||
const { loginPath } = getLoginConfig();
|
||||
router.push({ path: loginPath });
|
||||
}
|
||||
throw error;
|
||||
},
|
||||
]);
|
||||
return memo;
|
||||
};
|
||||
}
|
||||
|
||||
export function onRouterCreated({ router }) {
|
||||
const { hasLogin, loginPath } = getLoginConfig();
|
||||
if (hasLogin && loginPath) {
|
||||
let isAuthenticated;
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.path !== loginPath && !isAuthenticated) {
|
||||
isAuthenticated = await hasLogin();
|
||||
if (!isAuthenticated) {
|
||||
return next({ path: loginPath });
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
}
|
||||
export default defaultExport;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fesjs/plugin-request",
|
||||
"version": "4.0.0-rc.2",
|
||||
"version": "4.0.0-rc.3",
|
||||
"description": "@fesjs/plugin-request",
|
||||
"author": "qlin",
|
||||
"license": "MIT",
|
||||
@ -33,7 +33,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@fesjs/utils": "^3.0.1",
|
||||
"@qlin/request": "^0.2.0"
|
||||
"@qlin/request": "^0.2.3"
|
||||
},
|
||||
"typings": "./types.d.ts"
|
||||
}
|
||||
|
||||
66
pnpm-lock.yaml
generated
66
pnpm-lock.yaml
generated
@ -475,8 +475,8 @@ importers:
|
||||
specifier: ^3.0.0
|
||||
version: link:../fes
|
||||
'@fesjs/plugin-request':
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0(@fesjs/fes@packages+fes)(vue@3.3.4)
|
||||
specifier: ^4.0.0-rc.3
|
||||
version: link:../fes-plugin-request
|
||||
vue:
|
||||
specifier: ^3.2.47
|
||||
version: 3.3.4
|
||||
@ -650,8 +650,8 @@ importers:
|
||||
specifier: ^3.0.1
|
||||
version: link:../fes-utils
|
||||
'@qlin/request':
|
||||
specifier: ^0.2.0
|
||||
version: 0.2.0
|
||||
specifier: ^0.2.3
|
||||
version: 0.2.3
|
||||
vue:
|
||||
specifier: ^3.2.37
|
||||
version: 3.3.4
|
||||
@ -3479,21 +3479,6 @@ packages:
|
||||
- '@vue/composition-api'
|
||||
dev: false
|
||||
|
||||
/@fesjs/plugin-request@3.0.0(@fesjs/fes@packages+fes)(vue@3.3.4):
|
||||
resolution: {integrity: sha512-xlTAaGW6xsaZ3NFdvmUm3a8X3nxwpbtFUm85D2IrKJT8Ie/reGpC2CIQ808hODVdyVJxbSounu5sRx5KZELKNQ==}
|
||||
peerDependencies:
|
||||
'@fesjs/fes': ^3.0.0
|
||||
vue: ^3.2.47
|
||||
dependencies:
|
||||
'@fesjs/fes': link:packages/fes
|
||||
'@fesjs/utils': 3.0.1
|
||||
axios: 1.6.5
|
||||
vue: 3.3.4
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@fesjs/utils@3.0.1:
|
||||
resolution: {integrity: sha512-L8Ygr1/coKCoRRsxZdkV2b0R3xgup127uXZ2mbzEihGzMzUJgN9jlfarHfsAaBbxvOcswEbLqMrTQWg6CNqFdg==}
|
||||
dependencies:
|
||||
@ -3921,8 +3906,8 @@ packages:
|
||||
resolution: {integrity: sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==}
|
||||
dev: false
|
||||
|
||||
/@qlin/request@0.2.0:
|
||||
resolution: {integrity: sha512-zbCIHy7wBYy4pz/GarBeDTGmtkT2QfsCqudKQMs6wkhZ/ZMMQzAhO7d+REH89d3cdUPvw7qMnpYXYpHEg2eCeg==}
|
||||
/@qlin/request@0.2.3:
|
||||
resolution: {integrity: sha512-haKCRgZZWF9cZF7btRNfZQlDtJQ0uVqjwp51mqT+073V7JbL2DpUmVsRODtb3nnw9uVAHOqS9rmq+ZigwftgGg==}
|
||||
dependencies:
|
||||
'@types/lodash-es': 4.17.12
|
||||
lodash-es: 4.17.21
|
||||
@ -5552,10 +5537,6 @@ packages:
|
||||
resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==}
|
||||
dev: false
|
||||
|
||||
/asynckit@0.4.0:
|
||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||
dev: false
|
||||
|
||||
/at-least-node@1.0.0:
|
||||
resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==}
|
||||
engines: {node: '>= 4.0.0'}
|
||||
@ -5598,16 +5579,6 @@ packages:
|
||||
engines: {node: '>= 0.4'}
|
||||
dev: true
|
||||
|
||||
/axios@1.6.5:
|
||||
resolution: {integrity: sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==}
|
||||
dependencies:
|
||||
follow-redirects: 1.15.5
|
||||
form-data: 4.0.0
|
||||
proxy-from-env: 1.1.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
dev: false
|
||||
|
||||
/babel-jest@29.0.0(@babel/core@7.23.3):
|
||||
resolution: {integrity: sha512-EJM2dqxz9+uWJLLucZLPYAmRsHHt1IMkitAHGqjDlIP2IQXzkIMO3ATbBWk0lU6VwX4rNeVN04t/DDB8U5C2rg==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
@ -6178,13 +6149,6 @@ packages:
|
||||
resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==}
|
||||
dev: true
|
||||
|
||||
/combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
dev: false
|
||||
|
||||
/commander@11.1.0:
|
||||
resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==}
|
||||
engines: {node: '>=16'}
|
||||
@ -6923,11 +6887,6 @@ packages:
|
||||
object-keys: 1.1.1
|
||||
dev: true
|
||||
|
||||
/delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
dev: false
|
||||
|
||||
/depd@1.1.2:
|
||||
resolution: {integrity: sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@ -8069,15 +8028,6 @@ packages:
|
||||
is-callable: 1.2.7
|
||||
dev: true
|
||||
|
||||
/form-data@4.0.0:
|
||||
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
|
||||
engines: {node: '>= 6'}
|
||||
dependencies:
|
||||
asynckit: 0.4.0
|
||||
combined-stream: 1.0.8
|
||||
mime-types: 2.1.35
|
||||
dev: false
|
||||
|
||||
/forwarded@0.2.0:
|
||||
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@ -11295,10 +11245,6 @@ packages:
|
||||
ipaddr.js: 1.9.1
|
||||
dev: false
|
||||
|
||||
/proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
dev: false
|
||||
|
||||
/prr@1.0.1:
|
||||
resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==}
|
||||
requiresBuild: true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user