@litianxiang/portal-core 0.2.2 → 0.2.4

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/dist/index.d.ts CHANGED
@@ -326,8 +326,10 @@ declare function createTabStoreOptions(homePath?: string): {
326
326
  };
327
327
 
328
328
  interface BaseUserStoreLike {
329
- userno: string;
330
- username: string;
329
+ user_no: string;
330
+ user_name: string;
331
+ dept_id: string;
332
+ dept_name: string;
331
333
  access_token: string;
332
334
  refresh_token: string;
333
335
  lastActiveTime: number | null;
@@ -342,6 +344,10 @@ declare function createBaseUserState(): BaseUserStoreLike;
342
344
  */
343
345
  declare function createBaseUserGetters(): {
344
346
  getUserInfo: (state: any) => {
347
+ user_no: any;
348
+ user_name: any;
349
+ dept_id: any;
350
+ dept_name: any;
345
351
  userno: any;
346
352
  username: any;
347
353
  access_token: any;
@@ -350,6 +356,8 @@ declare function createBaseUserGetters(): {
350
356
  };
351
357
  getUserNo: (state: any) => any;
352
358
  getUserName: (state: any) => any;
359
+ getDeptId: (state: any) => any;
360
+ getDeptName: (state: any) => any;
353
361
  getUserAccessToken: (state: any) => any;
354
362
  getUserRefreshToken: (state: any) => any;
355
363
  getUserLastActiveTime: (state: any) => any;
@@ -390,6 +398,8 @@ declare function createMenuUserGetters<TUserInfo = any>(): {
390
398
  getUserInfo: (state: any) => TUserInfo;
391
399
  getUserNo: (state: any) => any;
392
400
  getUserName: (state: any) => any;
401
+ getDeptId: (state: any) => any;
402
+ getDeptName: (state: any) => any;
393
403
  getUserAccessToken: (state: any) => any;
394
404
  getUserRefreshToken: (state: any) => any;
395
405
  getUserLastActiveTime: (state: any) => any;
package/dist/index.js CHANGED
@@ -44,12 +44,13 @@ function _findParentMenuIds(menuList, targetPath, parentIds = []) {
44
44
  if (!target || !Array.isArray(menuList)) return [];
45
45
  for (const menu of menuList) {
46
46
  const current = normalizePath(menu?.path);
47
+ if (current === target) {
48
+ return parentIds;
49
+ }
47
50
  if (menu?.children && menu.children.length > 0) {
48
51
  const currentIds = [...parentIds, menu.id];
49
52
  const result = _findParentMenuIds(menu.children, targetPath, currentIds);
50
53
  if (result.length > 0) return result;
51
- } else if (current === target) {
52
- return parentIds;
53
54
  }
54
55
  }
55
56
  return [];
@@ -472,7 +473,7 @@ function createAuthHttpClient(options) {
472
473
  getLoadingStore,
473
474
  authLoginUrl,
474
475
  ssoStorageKey = AUTH_CONFIG.ssoStorageKey,
475
- refreshUrl = "/proxy/auth/api/token/refresh",
476
+ refreshUrl = "/proxy/sys/auth/api/token/refresh",
476
477
  inactiveExpireMs,
477
478
  inactiveBufferMs,
478
479
  onShowError
@@ -874,8 +875,10 @@ function createTabStoreOptions(homePath = DEFAULT_HOME_PATH) {
874
875
  // src/user/user.ts
875
876
  function createBaseUserState() {
876
877
  return {
877
- userno: "",
878
- username: "",
878
+ user_no: "",
879
+ user_name: "",
880
+ dept_id: "",
881
+ dept_name: "",
879
882
  access_token: "",
880
883
  refresh_token: "",
881
884
  lastActiveTime: null
@@ -885,16 +888,24 @@ function createBaseUserGetters() {
885
888
  return {
886
889
  // 获取完整用户信息
887
890
  getUserInfo: (state) => ({
888
- userno: state.userno,
889
- username: state.username,
891
+ user_no: state.user_no ?? state.userno ?? "",
892
+ user_name: state.user_name ?? state.username ?? "",
893
+ dept_id: state.dept_id ?? "",
894
+ dept_name: state.dept_name ?? "",
895
+ userno: state.user_no ?? state.userno ?? "",
896
+ username: state.user_name ?? state.username ?? "",
890
897
  access_token: state.access_token,
891
898
  refresh_token: state.refresh_token,
892
899
  lastActiveTime: state.lastActiveTime
893
900
  }),
894
901
  // 获取用户工号
895
- getUserNo: (state) => state.userno,
902
+ getUserNo: (state) => state.user_no ?? state.userno,
896
903
  // 获取用户姓名
897
- getUserName: (state) => state.username,
904
+ getUserName: (state) => state.user_name ?? state.username,
905
+ // 获取用户部门ID
906
+ getDeptId: (state) => state.dept_id,
907
+ // 获取用户部门名称
908
+ getDeptName: (state) => state.dept_name,
898
909
  // 获取用户access_token
899
910
  getUserAccessToken: (state) => state.access_token,
900
911
  // 获取用户refresh_token
@@ -908,8 +919,10 @@ function createBaseUserActions(options) {
908
919
  return {
909
920
  // 设置用户信息
910
921
  setUserInfo(userInfo) {
911
- this.userno = userInfo.userno;
912
- this.username = userInfo.username;
922
+ this.user_no = userInfo.user_no ?? userInfo.userno ?? "";
923
+ this.user_name = userInfo.user_name ?? userInfo.username ?? "";
924
+ this.dept_id = userInfo.dept_id ?? "";
925
+ this.dept_name = userInfo.dept_name ?? "";
913
926
  this.access_token = userInfo.access_token;
914
927
  this.refresh_token = userInfo.refresh_token;
915
928
  this.lastActiveTime = userInfo.lastActiveTime;
@@ -932,8 +945,10 @@ function createBaseUserActions(options) {
932
945
  },
933
946
  // 清除用户信息
934
947
  clearUserInfo() {
935
- this.userno = "";
936
- this.username = "";
948
+ this.user_no = "";
949
+ this.user_name = "";
950
+ this.dept_id = "";
951
+ this.dept_name = "";
937
952
  this.access_token = "";
938
953
  this.refresh_token = "";
939
954
  this.lastActiveTime = null;
@@ -942,8 +957,10 @@ function createBaseUserActions(options) {
942
957
  }
943
958
  function createMenuUserState() {
944
959
  return {
945
- userno: "",
946
- username: "",
960
+ user_no: "",
961
+ user_name: "",
962
+ dept_id: "",
963
+ dept_name: "",
947
964
  access_token: "",
948
965
  refresh_token: "",
949
966
  lastActiveTime: null,
@@ -956,17 +973,25 @@ function createMenuUserGetters() {
956
973
  return {
957
974
  // 获取完整用户信息
958
975
  getUserInfo: (state) => ({
959
- userno: state.userno,
960
- username: state.username,
976
+ user_no: state.user_no ?? state.userno ?? "",
977
+ user_name: state.user_name ?? state.username ?? "",
978
+ dept_id: state.dept_id ?? "",
979
+ dept_name: state.dept_name ?? "",
980
+ userno: state.user_no ?? state.userno ?? "",
981
+ username: state.user_name ?? state.username ?? "",
961
982
  access_token: state.access_token,
962
983
  refresh_token: state.refresh_token,
963
984
  lastActiveTime: state.lastActiveTime,
964
985
  all_menu: state.all_menu
965
986
  }),
966
987
  // 获取用户工号
967
- getUserNo: (state) => state.userno,
988
+ getUserNo: (state) => state.user_no ?? state.userno,
968
989
  // 获取用户姓名
969
- getUserName: (state) => state.username,
990
+ getUserName: (state) => state.user_name ?? state.username,
991
+ // 获取用户部门ID
992
+ getDeptId: (state) => state.dept_id,
993
+ // 获取用户部门名称
994
+ getDeptName: (state) => state.dept_name,
970
995
  // 获取用户access_token
971
996
  getUserAccessToken: (state) => state.access_token,
972
997
  // 获取用户refresh_token
@@ -1002,13 +1027,19 @@ function syncFromAuthStoreToStore(store, options) {
1002
1027
  const accessToken = window.localStorage.getItem(fallbackAccessTokenKey);
1003
1028
  if (!accessToken) return false;
1004
1029
  store.access_token = accessToken;
1030
+ store.user_no = "";
1031
+ store.user_name = "";
1032
+ store.dept_id = "";
1033
+ store.dept_name = "";
1005
1034
  store.lastActiveTime = Date.now();
1006
1035
  return true;
1007
1036
  }
1008
1037
  const data = JSON.parse(raw);
1009
1038
  if (!data || !data.access_token) return false;
1010
- store.userno = data.userno || "";
1011
- store.username = data.username || "";
1039
+ store.user_no = data.user_no ?? data.userno ?? "";
1040
+ store.user_name = data.user_name ?? data.username ?? "";
1041
+ store.dept_id = data.dept_id ?? "";
1042
+ store.dept_name = data.dept_name ?? "";
1012
1043
  store.access_token = data.access_token || "";
1013
1044
  store.refresh_token = data.refresh_token || "";
1014
1045
  store.lastActiveTime = data.lastActiveTime ?? null;
@@ -1030,8 +1061,10 @@ function createMenuUserActions(options) {
1030
1061
  return {
1031
1062
  // 设置用户信息
1032
1063
  setUserInfo(userInfo) {
1033
- this.userno = userInfo.userno;
1034
- this.username = userInfo.username;
1064
+ this.user_no = userInfo.user_no ?? userInfo.userno ?? "";
1065
+ this.user_name = userInfo.user_name ?? userInfo.username ?? "";
1066
+ this.dept_id = userInfo.dept_id ?? "";
1067
+ this.dept_name = userInfo.dept_name ?? "";
1035
1068
  this.access_token = userInfo.access_token;
1036
1069
  this.refresh_token = userInfo.refresh_token;
1037
1070
  this.lastActiveTime = userInfo.lastActiveTime;
@@ -1074,8 +1107,10 @@ function createMenuUserActions(options) {
1074
1107
  },
1075
1108
  // 清除用户信息
1076
1109
  clearUserInfo() {
1077
- this.userno = "";
1078
- this.username = "";
1110
+ this.user_no = "";
1111
+ this.user_name = "";
1112
+ this.dept_id = "";
1113
+ this.dept_name = "";
1079
1114
  this.access_token = "";
1080
1115
  this.refresh_token = "";
1081
1116
  this.lastActiveTime = null;
@@ -1089,7 +1124,7 @@ async function fetchUserMenuForStore(store, options) {
1089
1124
  const { http, site, transformMenuData, getALLMenu, filterOptions } = options;
1090
1125
  if (!store.access_token) return false;
1091
1126
  try {
1092
- const response = await http.post("/proxy/auth/api/user_menu_all", { site });
1127
+ const response = await http.post("/proxy/sys/auth/api/user_menu_all", { site });
1093
1128
  if (response.code === 200) {
1094
1129
  const menuTree = transformMenuData(response.data);
1095
1130
  const allMenu = getALLMenu(menuTree);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litianxiang/portal-core",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/index.js",