gant-core 0.1.25 → 0.1.27

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/lib/index.d.ts CHANGED
@@ -2040,7 +2040,7 @@ interface GetValidateCodeParams {
2040
2040
  imageWidth?: number;
2041
2041
  }
2042
2042
 
2043
- type LoginErrorType = 'passwordError' | 'validateError' | 'passwordExpiration' | 'SLIDER_VERIFICATION_LOGIN';
2043
+ type LoginErrorType = "passwordError" | "validateError" | "passwordExpiration" | "SLIDER_VERIFICATION_LOGIN";
2044
2044
  declare class BaseLogin {
2045
2045
  loginPathname?: string;
2046
2046
  BASE: string;
@@ -2106,7 +2106,7 @@ declare class UserStore {
2106
2106
  getUserSetting: (dataType: string) => Promise<any>;
2107
2107
  updateUserSetting: (dataType: string, data: any) => Promise<any>;
2108
2108
  removeUserSetting: (dataType: string) => Promise<void>;
2109
- getUserInfo: (userId: string) => Promise<any>;
2109
+ getUserInfo: (userId: string, userLoginName?: boolean) => Promise<any>;
2110
2110
  }
2111
2111
 
2112
2112
  interface ParameterItem {
package/lib/index.js CHANGED
@@ -616,30 +616,37 @@ const storage = createStorage();
616
616
 
617
617
  //公司定制化数据接口
618
618
  async function setUserDataApi(params, options) {
619
- return request('/accountUserSelf/setUserData', {
619
+ return request("/accountUserSelf/setUserData", {
620
620
  data: params,
621
- serviceId: 'fwSecurity',
621
+ serviceId: "fwSecurity",
622
622
  }, options);
623
623
  }
624
624
  //获取公司定制化信息
625
625
  async function getUserDataApi(params) {
626
- return request('/accountUserSelf/getUserData', {
626
+ return request("/accountUserSelf/getUserData", {
627
627
  data: params,
628
- serviceId: 'fwSecurity',
628
+ serviceId: "fwSecurity",
629
629
  });
630
630
  }
631
631
  //删除公司定制化信息
632
632
  async function delUserDataApi(params, options) {
633
- return request('/accountUserSelf/delUserData', {
633
+ return request("/accountUserSelf/delUserData", {
634
634
  data: params,
635
- serviceId: 'fwSecurity',
635
+ serviceId: "fwSecurity",
636
636
  }, options);
637
637
  }
638
638
  async function getUserByIdApi(userId) {
639
- return request('/security/getUserById', {
640
- method: 'POST',
639
+ return request("/security/getUserById", {
640
+ method: "POST",
641
641
  data: { id: userId },
642
- serviceId: 'fwSecurity',
642
+ serviceId: "fwSecurity",
643
+ });
644
+ }
645
+ async function getUserByUserLoginNameApi(userLoginName) {
646
+ return request("/security/getUserByUserLoginName", {
647
+ method: "POST",
648
+ data: { userLoginName: userLoginName },
649
+ serviceId: "fwSecurity",
643
650
  });
644
651
  }
645
652
 
@@ -654,7 +661,7 @@ class UserStore {
654
661
  getUserIdentity() {
655
662
  if (!isEmpty(this.userIdentity))
656
663
  return this.userIdentity;
657
- const localUserIdentity = storage?.get('userIdentity');
664
+ const localUserIdentity = storage?.get("userIdentity");
658
665
  return localUserIdentity ? localUserIdentity : {};
659
666
  }
660
667
  setUserIdentity(identity) {
@@ -662,11 +669,11 @@ class UserStore {
662
669
  ...this.userIdentity,
663
670
  ...identity,
664
671
  };
665
- storage.set('userIdentity', this.userIdentity);
672
+ storage.set("userIdentity", this.userIdentity);
666
673
  return this.userIdentity;
667
674
  }
668
675
  clearUserIdentity() {
669
- storage.remove('userIdentity');
676
+ storage.remove("userIdentity");
670
677
  this.userIdentity = {};
671
678
  }
672
679
  setUserAggregateInfo = ({ delegations, roles, functions, isSuperAdmin, currentUser, }) => {
@@ -708,7 +715,9 @@ class UserStore {
708
715
  await delUserDataApi({ dataType, dataId: userId });
709
716
  delete this.userSetting[key];
710
717
  };
711
- getUserInfo = async (userId) => {
718
+ getUserInfo = async (userId, userLoginName) => {
719
+ if (userLoginName)
720
+ return getUserByUserLoginNameApi(userId);
712
721
  return await getUserByIdApi(userId);
713
722
  };
714
723
  }
@@ -929,17 +938,17 @@ function checkCaptchaApi(payload) {
929
938
 
930
939
  class BaseLogin {
931
940
  loginPathname;
932
- BASE = '/';
941
+ BASE = "/";
933
942
  get baseLoginPathname() {
934
- return `${this.BASE}${this.loginPathname?.replace('/', '')}`;
943
+ return `${this.BASE}${this.loginPathname?.replace("/", "")}`;
935
944
  }
936
- tokenValue = '';
945
+ tokenValue = "";
937
946
  get isLoginPathname() {
938
947
  const pathname = window.location.pathname;
939
948
  return this.baseLoginPathname == pathname;
940
949
  }
941
950
  getRealPath = (pathname) => {
942
- return `${this.BASE}${pathname.replace('/', '')}`;
951
+ return `${this.BASE}${pathname.replace("/", "")}`;
943
952
  };
944
953
  chekToken = async () => {
945
954
  const res = await checkTokenApi();
@@ -956,15 +965,15 @@ class BaseLogin {
956
965
  if (this.isLoginPathname)
957
966
  return true;
958
967
  const urlParams = new URLSearchParams();
959
- if (pathname !== this.BASE)
960
- urlParams.append('redirectUrl', url);
968
+ if (pathname !== this.BASE && pathname !== "/")
969
+ urlParams.append("redirectUrl", url);
961
970
  const searchString = decodeURIComponent(urlParams.toString());
962
- window.location.replace(`${this.baseLoginPathname}${!!searchString ? '?' + decodeURIComponent(urlParams.toString()) : ''}`);
971
+ window.location.replace(`${this.baseLoginPathname}${!!searchString ? "?" + decodeURIComponent(urlParams.toString()) : ""}`);
963
972
  return false;
964
973
  };
965
974
  checkPassword = async () => {
966
975
  const res = await checkPasswordApi();
967
- if (res === 'noPass') {
976
+ if (res === "noPass") {
968
977
  // 临时清除token,待修改完密码后恢复
969
978
  this.tokenValue = await extractTokenApi();
970
979
  return false;
@@ -993,26 +1002,26 @@ class BaseLogin {
993
1002
  result.data = res;
994
1003
  const checked = await this.checkPassword();
995
1004
  if (!checked)
996
- result.error = 'passwordExpiration';
1005
+ result.error = "passwordExpiration";
997
1006
  return result;
998
1007
  }
999
1008
  //traceId 需要第三方验证 //验证码之后的由业务自行判断
1000
1009
  if (traceId) {
1001
1010
  result.data = res;
1002
- result.error = 'SLIDER_VERIFICATION_LOGIN';
1011
+ result.error = "SLIDER_VERIFICATION_LOGIN";
1003
1012
  return result;
1004
1013
  }
1005
- result.error = 'passwordError';
1014
+ result.error = "passwordError";
1006
1015
  return result;
1007
1016
  }
1008
1017
  catch (err) {
1009
- result.error = 'validateError';
1018
+ result.error = "validateError";
1010
1019
  return result;
1011
1020
  }
1012
1021
  };
1013
1022
  loginSuccess = () => {
1014
1023
  const params = new URLSearchParams(window.location.search);
1015
- let url = params.get('redirectUrl');
1024
+ let url = params.get("redirectUrl");
1016
1025
  if (url)
1017
1026
  window.location.href = url;
1018
1027
  else
@@ -1022,7 +1031,7 @@ class BaseLogin {
1022
1031
  const params = new URLSearchParams();
1023
1032
  const url = window.location.href;
1024
1033
  if (window.location.pathname !== this.BASE)
1025
- params.append('redirectUrl', url);
1034
+ params.append("redirectUrl", url);
1026
1035
  await accountLogoutApi();
1027
1036
  window.location.replace(`${this.baseLoginPathname}?${params.toString()}`);
1028
1037
  };