dlt-for-react 2.0.11 → 2.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/lib/index.js +12 -0
- package/lib/layouts/Login/login.js +26 -18
- package/lib/routes/AuthorizedRoute.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ npm publish
|
|
|
8
8
|
|
|
9
9
|
## 前端 dlt-for-react 依赖包版本更新记录
|
|
10
10
|
|
|
11
|
-
##### 当前最新版本:2.0.
|
|
11
|
+
##### 当前最新版本:2.0.12
|
|
12
12
|
|
|
13
13
|
##### 安装依赖
|
|
14
14
|
|
|
@@ -16,6 +16,10 @@ npm publish
|
|
|
16
16
|
|
|
17
17
|
##### 版本修改记录
|
|
18
18
|
|
|
19
|
+
#### V2.0.12—2024 年 4 月 22 日
|
|
20
|
+
|
|
21
|
+
1. 新增 getRedirect、setRedirect 添加|获取重定向地址
|
|
22
|
+
|
|
19
23
|
#### V2.0.11—2024 年 4 月 15 日
|
|
20
24
|
|
|
21
25
|
1. 新增 store 缓存方式
|
package/lib/index.js
CHANGED
|
@@ -1011,6 +1011,18 @@ Object.defineProperty(exports, "getExpiresIn", {
|
|
|
1011
1011
|
return _login.getExpiresIn;
|
|
1012
1012
|
}
|
|
1013
1013
|
});
|
|
1014
|
+
Object.defineProperty(exports, "getRedirect", {
|
|
1015
|
+
enumerable: true,
|
|
1016
|
+
get: function get() {
|
|
1017
|
+
return _login.getRedirect;
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
Object.defineProperty(exports, "setRedirect", {
|
|
1021
|
+
enumerable: true,
|
|
1022
|
+
get: function get() {
|
|
1023
|
+
return _login.setRedirect;
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1014
1026
|
|
|
1015
1027
|
var _store = require("./utils/store.js");
|
|
1016
1028
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getRedirect = exports.setRedirect = exports.tryAllConfigInfo = exports.tryLoginUserInfo = exports.getExpiresIn = exports.getDifferDate = exports.refreshToken = exports.userLogout = exports.userLogin = undefined;
|
|
7
7
|
|
|
8
8
|
var _typeof2 = require("babel-runtime/helpers/typeof");
|
|
9
9
|
|
|
@@ -116,7 +116,7 @@ var userLogin = exports.userLogin = function userLogin(allMenu, params, func) {
|
|
|
116
116
|
} else if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
|
|
117
117
|
nextUrl = res.data.menus[0].children[0].children[0].url;
|
|
118
118
|
}
|
|
119
|
-
var routerAfterLogin =
|
|
119
|
+
var routerAfterLogin = getRedirect();
|
|
120
120
|
if (routerAfterLogin) {
|
|
121
121
|
//如果系统设置了登录后的首页 跳转到该路由
|
|
122
122
|
nextUrl = routerAfterLogin;
|
|
@@ -142,7 +142,7 @@ var userLogin = exports.userLogin = function userLogin(allMenu, params, func) {
|
|
|
142
142
|
} else if (res.data.menus[0].children && res.data.menus[0].children.length > 0 && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
|
|
143
143
|
nextUrl = res.data.menus[0].children[0].children[0].url;
|
|
144
144
|
}
|
|
145
|
-
var routerAfterLogin =
|
|
145
|
+
var routerAfterLogin = getRedirect();
|
|
146
146
|
if (routerAfterLogin) {
|
|
147
147
|
//如果系统设置了登录后的首页 跳转到该路由
|
|
148
148
|
nextUrl = routerAfterLogin;
|
|
@@ -189,7 +189,7 @@ var userLogin = exports.userLogin = function userLogin(allMenu, params, func) {
|
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
var userLogout = exports.userLogout = function userLogout() {
|
|
192
|
-
|
|
192
|
+
setRedirect("add");
|
|
193
193
|
fetch("logout", {
|
|
194
194
|
method: "GET",
|
|
195
195
|
credentials: "include",
|
|
@@ -546,7 +546,7 @@ var sso = function sso(func, allMenu, notConf) {
|
|
|
546
546
|
} else if (res.data.menus[0].children && res.data.menus[0].children[0].children && res.data.menus[0].children[0].children.length > 0) {
|
|
547
547
|
nextUrl = res.data.menus[0].children[0].children[0].url;
|
|
548
548
|
}
|
|
549
|
-
var routerAfterLogin =
|
|
549
|
+
var routerAfterLogin = getRedirect();
|
|
550
550
|
if (routerAfterLogin) {
|
|
551
551
|
//如果系统设置了登录后的首页 跳转到该路由
|
|
552
552
|
nextUrl = routerAfterLogin;
|
|
@@ -632,30 +632,38 @@ var filterAuthMenus = function filterAuthMenus(menus, auths) {
|
|
|
632
632
|
return fitlerMenus;
|
|
633
633
|
};
|
|
634
634
|
|
|
635
|
-
|
|
636
|
-
|
|
635
|
+
/*******
|
|
636
|
+
* @description: 缓存重定向地址:userid+页面地址,未登录前只取页面地址
|
|
637
|
+
* @author: 琴时
|
|
638
|
+
* @param {*} action add:添加、remove:移除
|
|
639
|
+
* @param {*} value
|
|
640
|
+
* @return {*}
|
|
641
|
+
*/
|
|
642
|
+
var setRedirect = exports.setRedirect = function setRedirect() {
|
|
643
|
+
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "add";
|
|
644
|
+
var value = arguments[1];
|
|
645
|
+
|
|
637
646
|
var userId = (0, _index.getLoginUser)().userId;
|
|
638
647
|
var projectName = window.location.host + window.location.pathname; // 区分同源项目
|
|
639
|
-
projectName = userId ?
|
|
640
|
-
var oldData =
|
|
648
|
+
projectName = userId ? encodeURIComponent(userId + "-" + projectName) : encodeURIComponent(projectName); // 区分同项目不同用户
|
|
649
|
+
var oldData = session.get("routerAfterLogin", {});
|
|
641
650
|
var currentUrl = value || location.hash.split("#")[1];
|
|
642
651
|
var routerAfterLogin = (0, _extends4.default)({}, oldData);
|
|
643
652
|
if (action === "add") {
|
|
644
|
-
routerAfterLogin = (0, _extends4.default)({}, routerAfterLogin, (0, _defineProperty3.default)({}, projectName,
|
|
653
|
+
routerAfterLogin = (0, _extends4.default)({}, routerAfterLogin, (0, _defineProperty3.default)({}, projectName, encodeURIComponent(currentUrl)));
|
|
645
654
|
} else if (action === "remove") {
|
|
646
655
|
delete routerAfterLogin[projectName];
|
|
647
656
|
}
|
|
648
|
-
|
|
657
|
+
session.set("routerAfterLogin", routerAfterLogin);
|
|
649
658
|
};
|
|
650
|
-
//
|
|
651
|
-
var
|
|
659
|
+
// 获取重定向缓存地址
|
|
660
|
+
var getRedirect = exports.getRedirect = function getRedirect(key) {
|
|
652
661
|
var userId = (0, _index.getLoginUser)().userId;
|
|
653
662
|
var projectName = window.location.host + window.location.pathname;
|
|
654
|
-
var name = userId ?
|
|
655
|
-
var routerAfterLogin =
|
|
656
|
-
var url =
|
|
657
|
-
|
|
658
|
-
return url;
|
|
663
|
+
var name = userId ? encodeURIComponent(userId + "-" + projectName) : encodeURIComponent(projectName);
|
|
664
|
+
var routerAfterLogin = session.get("routerAfterLogin", {});
|
|
665
|
+
var url = key ? routerAfterLogin[key] : routerAfterLogin[name] || routerAfterLogin[encodeURIComponent(projectName)];
|
|
666
|
+
return url ? decodeURIComponent(url) : url;
|
|
659
667
|
};
|
|
660
668
|
|
|
661
669
|
var deepCopy = function deepCopy(obj) {
|
|
@@ -201,7 +201,7 @@ var AuthorizedRoute = function (_React$Component) {
|
|
|
201
201
|
} else if (menus[0].children && menus[0].children.length > 0 && menu[0] && menus[0].children[0].children && menus[0].children[0].children.length > 0) {
|
|
202
202
|
nextUrl = menus[0].children[0].children[0].url;
|
|
203
203
|
}
|
|
204
|
-
var routerAfterLogin = (0, _login.
|
|
204
|
+
var routerAfterLogin = (0, _login.getRedirect)();
|
|
205
205
|
if (routerAfterLogin) {
|
|
206
206
|
//如果系统设置了登录后的首页 跳转到该路由
|
|
207
207
|
nextUrl = routerAfterLogin;
|