inl-ui 0.1.171 → 0.1.173

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.
@@ -88,20 +88,20 @@ const getUserinfo = () => {
88
88
  }
89
89
  };
90
90
  const getCommonHeaders = () => {
91
- const userInfo = getUserinfo();
92
- const userId = getUserId();
91
+ getUserinfo();
92
+ getUserId();
93
93
  const token = getToken();
94
94
  const appId = getAppId();
95
- const corpId = getCorpId();
95
+ getCorpId();
96
96
  const Authorization = `Bearer ${token}`;
97
97
  return {
98
- userName: userInfo?.userName,
99
- userId: userInfo?.userId || userId,
100
- employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
101
- employeeId: userInfo?.employeeId,
98
+ // userName: userInfo?.userName,
99
+ // userId: userInfo?.userId || userId,
100
+ // employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
101
+ // employeeId: userInfo?.employeeId,
102
102
  token,
103
103
  appId,
104
- corpId,
104
+ // corpId,
105
105
  Authorization,
106
106
  "Content-Type": "application/json;charset=utf-8"
107
107
  };
@@ -6661,6 +6661,24 @@ function getOpenUrl(url) {
6661
6661
  return res;
6662
6662
  }
6663
6663
 
6664
+ async function canCloseTab(tab, beforeTabClose) {
6665
+ if (typeof beforeTabClose !== "function") return true;
6666
+ try {
6667
+ const result = await beforeTabClose(tab);
6668
+ return result !== false;
6669
+ } catch {
6670
+ return false;
6671
+ }
6672
+ }
6673
+ async function canCloseTabs(tabs, beforeTabClose) {
6674
+ for (const tab of tabs) {
6675
+ if (!(await canCloseTab(tab, beforeTabClose))) {
6676
+ return false;
6677
+ }
6678
+ }
6679
+ return true;
6680
+ }
6681
+
6664
6682
  const closeTabMagicKey = "control_shift_q";
6665
6683
  const TabList = vue.defineComponent({
6666
6684
  emits: ["update:activeKey", "update:list", "tabSelect", "closeExtraPage", "closeIframePage", "fullscreen", "refreshIframe", "refreshExtraPage", "mouseLeave"],
@@ -6672,7 +6690,10 @@ const TabList = vue.defineComponent({
6672
6690
  activeKey: {
6673
6691
  type: String
6674
6692
  },
6675
- containerRef: Object
6693
+ containerRef: Object,
6694
+ beforeTabClose: {
6695
+ type: Function
6696
+ }
6676
6697
  },
6677
6698
  setup(props, {
6678
6699
  emit,
@@ -6704,37 +6725,54 @@ const TabList = vue.defineComponent({
6704
6725
  scrollLeft(e.deltaY < 0 ? -300 : 300);
6705
6726
  }
6706
6727
  };
6707
- const handleRemove = async (tab, index) => {
6708
- if (getTabUniqueKey(tab) === activeTabKey.value) {
6709
- const next = tabList.value[index + 1];
6710
- const prev = tabList.value[index - 1];
6711
- if (next) {
6712
- activeTabKey.value = getTabUniqueKey(next);
6713
- emit("tabSelect", next);
6714
- } else if (prev) {
6715
- activeTabKey.value = getTabUniqueKey(prev);
6716
- emit("tabSelect", prev);
6717
- } else {
6718
- return;
6728
+ const getBeforeTabClose = () => props.beforeTabClose ?? qiankunState.value?.beforeTabClose;
6729
+ const selectTab = tab => {
6730
+ activeTabKey.value = getTabUniqueKey(tab);
6731
+ emit("tabSelect", tab);
6732
+ };
6733
+ const removeTabs = async (tabs, fallbackTab) => {
6734
+ const closeKeys = new Set(tabs.map(item => getTabUniqueKey(item)));
6735
+ const currentTabs = tabList.value.filter(item => closeKeys.has(getTabUniqueKey(item)));
6736
+ if (!currentTabs.length || currentTabs.length >= tabList.value.length) {
6737
+ return false;
6738
+ }
6739
+ if (!(await canCloseTabs(currentTabs, getBeforeTabClose()))) {
6740
+ return false;
6741
+ }
6742
+ const remainingTabs = tabList.value.filter(item => !closeKeys.has(getTabUniqueKey(item)));
6743
+ if (!remainingTabs.length) {
6744
+ return false;
6745
+ }
6746
+ if (activeTabKey.value && closeKeys.has(activeTabKey.value)) {
6747
+ const nextActiveTab = fallbackTab && remainingTabs.some(item => getTabUniqueKey(item) === getTabUniqueKey(fallbackTab)) ? fallbackTab : remainingTabs[0];
6748
+ if (nextActiveTab) {
6749
+ selectTab(nextActiveTab);
6719
6750
  }
6720
6751
  }
6721
- tabList.value.splice(index, 1);
6752
+ tabList.value = remainingTabs;
6753
+ return true;
6722
6754
  };
6723
- const closeToRight = index => tabList.value = tabList.value.filter((_2, i) => i <= index);
6724
- const closeToLeft = index => tabList.value = tabList.value.filter((_2, i) => i >= index);
6725
- const closeOther = index => {
6726
- activeTabKey.value = tabList.value[index].key;
6727
- tabList.value = tabList.value.filter((_2, i) => i === index);
6755
+ const handleRemove = async (tab, index) => {
6756
+ const target = tabList.value[index];
6757
+ if (!target || getTabUniqueKey(target) !== getTabUniqueKey(tab)) {
6758
+ return closeTab(tab);
6759
+ }
6760
+ const fallbackTab = tabList.value[index + 1] ?? tabList.value[index - 1];
6761
+ return removeTabs([target], fallbackTab);
6728
6762
  };
6729
- const closeTab = tab => {
6763
+ const closeToRight = index => removeTabs(tabList.value.filter((_2, i) => i > index), tabList.value[index]);
6764
+ const closeToLeft = index => removeTabs(tabList.value.filter((_2, i) => i < index), tabList.value[index]);
6765
+ const closeOther = index => removeTabs(tabList.value.filter((_2, i) => i !== index), tabList.value[index]);
6766
+ const closeTab = async tab => {
6730
6767
  const idx = tabList.value.findIndex(item => getTabUniqueKey(item) === getTabUniqueKey(tab));
6731
6768
  if (idx !== -1) {
6732
- handleRemove(tab, idx);
6769
+ return handleRemove(tabList.value[idx], idx);
6733
6770
  }
6771
+ return false;
6734
6772
  };
6735
6773
  const magicKeys = core.useMagicKeys();
6736
6774
  core.whenever(magicKeys[closeTabMagicKey], () => {
6737
- if (tabList.value.length > 1) {
6775
+ if (tabList.value.length > 1 && activeTabIndex.value !== -1) {
6738
6776
  handleRemove(tabList.value[activeTabIndex.value], activeTabIndex.value);
6739
6777
  }
6740
6778
  });
@@ -7020,6 +7058,9 @@ const Props$1 = {
7020
7058
  pageContainerRef: {
7021
7059
  type: Object,
7022
7060
  required: true
7061
+ },
7062
+ beforeTabClose: {
7063
+ type: Function
7023
7064
  }
7024
7065
  };
7025
7066
  const PageContent = vue.defineComponent({
@@ -7256,6 +7297,35 @@ const PageContent = vue.defineComponent({
7256
7297
  data
7257
7298
  } = event;
7258
7299
  if (type === "addTab") {
7300
+ if (data.mode === "microApp") {
7301
+ const uniqueKey = data.uniqueKey || data.key;
7302
+ const tab = {
7303
+ ...data,
7304
+ uniqueKey,
7305
+ isExtraTab: true,
7306
+ params: data.params ?? {}
7307
+ };
7308
+ const extraTabs = Array.isArray(qiankunState.value.extraTabs) ? [...qiankunState.value.extraTabs] : [];
7309
+ const tabIndex = extraTabs.findIndex(item => item.key === tab.key && item.uniqueKey === tab.uniqueKey);
7310
+ if (tabIndex === -1) {
7311
+ extraTabs.push(tab);
7312
+ } else {
7313
+ extraTabs[tabIndex] = {
7314
+ ...extraTabs[tabIndex],
7315
+ ...tab
7316
+ };
7317
+ }
7318
+ qiankunState.value = {
7319
+ ...qiankunState.value,
7320
+ extraTabs,
7321
+ activeTabKey: `${tab.key}${tab.uniqueKey}`
7322
+ };
7323
+ router.push({
7324
+ path: tab.url,
7325
+ query: tab.params
7326
+ });
7327
+ return;
7328
+ }
7259
7329
  handleMenuChange({
7260
7330
  ...data,
7261
7331
  mode: 2,
@@ -7337,7 +7407,8 @@ const PageContent = vue.defineComponent({
7337
7407
  "onFullscreen": handleFullscreen,
7338
7408
  "onRefreshIframe": handleRefreshIframe,
7339
7409
  "onRefreshExtraPage": handleRefreshExtraPage,
7340
- "onMouseLeave": () => isTabsShow.value = false
7410
+ "onMouseLeave": () => isTabsShow.value = false,
7411
+ "beforeTabClose": props.beforeTabClose
7341
7412
  }, null), [[vue.vShow, !isFullscreen.value || isTabsShow.value]]);
7342
7413
  const containerCns = {
7343
7414
  padding: isPadding.value,
@@ -7498,6 +7569,9 @@ const Props = {
7498
7569
  showNotice: {
7499
7570
  type: Boolean,
7500
7571
  default: true
7572
+ },
7573
+ beforeTabClose: {
7574
+ type: Function
7501
7575
  }
7502
7576
  };
7503
7577
  const Layout = vue.defineComponent({
@@ -7550,13 +7624,22 @@ const Layout = vue.defineComponent({
7550
7624
  currMenu.value = menu;
7551
7625
  vue.nextTick(() => currMenu.value = void 0);
7552
7626
  };
7627
+ vue.watch(() => props.beforeTabClose, beforeTabClose => {
7628
+ qiankunState.value = {
7629
+ ...(qiankunState.value ?? {}),
7630
+ beforeTabClose
7631
+ };
7632
+ }, {
7633
+ immediate: true
7634
+ });
7553
7635
  vue.onBeforeUnmount(() => {
7554
7636
  qiankunState.value = {
7555
7637
  ...qiankunState.value,
7556
7638
  extraTabs: [],
7557
7639
  removeMenuTabs: [],
7558
7640
  activeTabKey: "",
7559
- refreshTabKey: ""
7641
+ refreshTabKey: "",
7642
+ beforeTabClose: void 0
7560
7643
  };
7561
7644
  });
7562
7645
  const pageContainerRef = vue.ref();
@@ -7613,7 +7696,8 @@ const Layout = vue.defineComponent({
7613
7696
  "menu": props.userMenu,
7614
7697
  "extraPages": props.extraPages,
7615
7698
  "appList": props.appList,
7616
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
7699
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
7700
+ "beforeTabClose": props.beforeTabClose
7617
7701
  }, null);
7618
7702
  return vue.createVNode("div", {
7619
7703
  "class": `${config.prefix}-layout`
@@ -8776,6 +8860,9 @@ const getDetailContainer = () => vue.defineComponent({
8776
8860
  const detailList = vue.ref([]);
8777
8861
  const extraPages = vue.computed(() => qiankunState.value.extraTabs);
8778
8862
  const handleClose = async tab => {
8863
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
8864
+ return;
8865
+ }
8779
8866
  const copyPages = [...extraPages.value];
8780
8867
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
8781
8868
  if (idx !== -1) {
@@ -8808,6 +8895,7 @@ const getDetailContainer = () => vue.defineComponent({
8808
8895
  uniqueKey: dataId.value,
8809
8896
  icon: props.icon,
8810
8897
  isExtraTab: true,
8898
+ type: "extraTab",
8811
8899
  params: ___default["default"].omit(route.query, "name")
8812
8900
  };
8813
8901
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
@@ -19,6 +19,9 @@ declare const _default$k: vue.DefineComponent<{
19
19
 
20
20
  declare const _default$j: vue.FunctionalComponent<_ant_design_icons_vue_lib_components_IconFont.IconFontProps, {}, any>;
21
21
 
22
+ type BeforeTabCloseResult = boolean | void;
23
+ type BeforeTabClose<T = any> = (tab: T) => BeforeTabCloseResult | Promise<BeforeTabCloseResult>;
24
+
22
25
  interface IMenuItem {
23
26
  id: string;
24
27
  code: string;
@@ -73,6 +76,9 @@ declare const _default$i: vue.DefineComponent<{
73
76
  type: BooleanConstructor;
74
77
  default: boolean;
75
78
  };
79
+ beforeTabClose: {
80
+ type: PropType<BeforeTabClose>;
81
+ };
76
82
  }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("globalSearch" | "personalCenter" | "logout" | "extraPage")[], "globalSearch" | "personalCenter" | "logout" | "extraPage", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
77
83
  userMenu: {
78
84
  type: PropType<MenuList>;
@@ -115,6 +121,9 @@ declare const _default$i: vue.DefineComponent<{
115
121
  type: BooleanConstructor;
116
122
  default: boolean;
117
123
  };
124
+ beforeTabClose: {
125
+ type: PropType<BeforeTabClose>;
126
+ };
118
127
  }>> & {
119
128
  onGlobalSearch?: ((...args: any[]) => any) | undefined;
120
129
  onPersonalCenter?: ((...args: any[]) => any) | undefined;
@@ -59,20 +59,20 @@ const getUserinfo = () => {
59
59
  }
60
60
  };
61
61
  const getCommonHeaders = () => {
62
- const userInfo = getUserinfo();
63
- const userId = getUserId();
62
+ getUserinfo();
63
+ getUserId();
64
64
  const token = getToken();
65
65
  const appId = getAppId();
66
- const corpId = getCorpId();
66
+ getCorpId();
67
67
  const Authorization = `Bearer ${token}`;
68
68
  return {
69
- userName: userInfo?.userName,
70
- userId: userInfo?.userId || userId,
71
- employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
72
- employeeId: userInfo?.employeeId,
69
+ // userName: userInfo?.userName,
70
+ // userId: userInfo?.userId || userId,
71
+ // employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
72
+ // employeeId: userInfo?.employeeId,
73
73
  token,
74
74
  appId,
75
- corpId,
75
+ // corpId,
76
76
  Authorization,
77
77
  "Content-Type": "application/json;charset=utf-8"
78
78
  };
@@ -6632,6 +6632,24 @@ function getOpenUrl(url) {
6632
6632
  return res;
6633
6633
  }
6634
6634
 
6635
+ async function canCloseTab(tab, beforeTabClose) {
6636
+ if (typeof beforeTabClose !== "function") return true;
6637
+ try {
6638
+ const result = await beforeTabClose(tab);
6639
+ return result !== false;
6640
+ } catch {
6641
+ return false;
6642
+ }
6643
+ }
6644
+ async function canCloseTabs(tabs, beforeTabClose) {
6645
+ for (const tab of tabs) {
6646
+ if (!(await canCloseTab(tab, beforeTabClose))) {
6647
+ return false;
6648
+ }
6649
+ }
6650
+ return true;
6651
+ }
6652
+
6635
6653
  const closeTabMagicKey = "control_shift_q";
6636
6654
  const TabList = defineComponent({
6637
6655
  emits: ["update:activeKey", "update:list", "tabSelect", "closeExtraPage", "closeIframePage", "fullscreen", "refreshIframe", "refreshExtraPage", "mouseLeave"],
@@ -6643,7 +6661,10 @@ const TabList = defineComponent({
6643
6661
  activeKey: {
6644
6662
  type: String
6645
6663
  },
6646
- containerRef: Object
6664
+ containerRef: Object,
6665
+ beforeTabClose: {
6666
+ type: Function
6667
+ }
6647
6668
  },
6648
6669
  setup(props, {
6649
6670
  emit,
@@ -6675,37 +6696,54 @@ const TabList = defineComponent({
6675
6696
  scrollLeft(e.deltaY < 0 ? -300 : 300);
6676
6697
  }
6677
6698
  };
6678
- const handleRemove = async (tab, index) => {
6679
- if (getTabUniqueKey(tab) === activeTabKey.value) {
6680
- const next = tabList.value[index + 1];
6681
- const prev = tabList.value[index - 1];
6682
- if (next) {
6683
- activeTabKey.value = getTabUniqueKey(next);
6684
- emit("tabSelect", next);
6685
- } else if (prev) {
6686
- activeTabKey.value = getTabUniqueKey(prev);
6687
- emit("tabSelect", prev);
6688
- } else {
6689
- return;
6699
+ const getBeforeTabClose = () => props.beforeTabClose ?? qiankunState.value?.beforeTabClose;
6700
+ const selectTab = tab => {
6701
+ activeTabKey.value = getTabUniqueKey(tab);
6702
+ emit("tabSelect", tab);
6703
+ };
6704
+ const removeTabs = async (tabs, fallbackTab) => {
6705
+ const closeKeys = new Set(tabs.map(item => getTabUniqueKey(item)));
6706
+ const currentTabs = tabList.value.filter(item => closeKeys.has(getTabUniqueKey(item)));
6707
+ if (!currentTabs.length || currentTabs.length >= tabList.value.length) {
6708
+ return false;
6709
+ }
6710
+ if (!(await canCloseTabs(currentTabs, getBeforeTabClose()))) {
6711
+ return false;
6712
+ }
6713
+ const remainingTabs = tabList.value.filter(item => !closeKeys.has(getTabUniqueKey(item)));
6714
+ if (!remainingTabs.length) {
6715
+ return false;
6716
+ }
6717
+ if (activeTabKey.value && closeKeys.has(activeTabKey.value)) {
6718
+ const nextActiveTab = fallbackTab && remainingTabs.some(item => getTabUniqueKey(item) === getTabUniqueKey(fallbackTab)) ? fallbackTab : remainingTabs[0];
6719
+ if (nextActiveTab) {
6720
+ selectTab(nextActiveTab);
6690
6721
  }
6691
6722
  }
6692
- tabList.value.splice(index, 1);
6723
+ tabList.value = remainingTabs;
6724
+ return true;
6693
6725
  };
6694
- const closeToRight = index => tabList.value = tabList.value.filter((_2, i) => i <= index);
6695
- const closeToLeft = index => tabList.value = tabList.value.filter((_2, i) => i >= index);
6696
- const closeOther = index => {
6697
- activeTabKey.value = tabList.value[index].key;
6698
- tabList.value = tabList.value.filter((_2, i) => i === index);
6726
+ const handleRemove = async (tab, index) => {
6727
+ const target = tabList.value[index];
6728
+ if (!target || getTabUniqueKey(target) !== getTabUniqueKey(tab)) {
6729
+ return closeTab(tab);
6730
+ }
6731
+ const fallbackTab = tabList.value[index + 1] ?? tabList.value[index - 1];
6732
+ return removeTabs([target], fallbackTab);
6699
6733
  };
6700
- const closeTab = tab => {
6734
+ const closeToRight = index => removeTabs(tabList.value.filter((_2, i) => i > index), tabList.value[index]);
6735
+ const closeToLeft = index => removeTabs(tabList.value.filter((_2, i) => i < index), tabList.value[index]);
6736
+ const closeOther = index => removeTabs(tabList.value.filter((_2, i) => i !== index), tabList.value[index]);
6737
+ const closeTab = async tab => {
6701
6738
  const idx = tabList.value.findIndex(item => getTabUniqueKey(item) === getTabUniqueKey(tab));
6702
6739
  if (idx !== -1) {
6703
- handleRemove(tab, idx);
6740
+ return handleRemove(tabList.value[idx], idx);
6704
6741
  }
6742
+ return false;
6705
6743
  };
6706
6744
  const magicKeys = useMagicKeys();
6707
6745
  whenever(magicKeys[closeTabMagicKey], () => {
6708
- if (tabList.value.length > 1) {
6746
+ if (tabList.value.length > 1 && activeTabIndex.value !== -1) {
6709
6747
  handleRemove(tabList.value[activeTabIndex.value], activeTabIndex.value);
6710
6748
  }
6711
6749
  });
@@ -6991,6 +7029,9 @@ const Props$1 = {
6991
7029
  pageContainerRef: {
6992
7030
  type: Object,
6993
7031
  required: true
7032
+ },
7033
+ beforeTabClose: {
7034
+ type: Function
6994
7035
  }
6995
7036
  };
6996
7037
  const PageContent = defineComponent({
@@ -7227,6 +7268,35 @@ const PageContent = defineComponent({
7227
7268
  data
7228
7269
  } = event;
7229
7270
  if (type === "addTab") {
7271
+ if (data.mode === "microApp") {
7272
+ const uniqueKey = data.uniqueKey || data.key;
7273
+ const tab = {
7274
+ ...data,
7275
+ uniqueKey,
7276
+ isExtraTab: true,
7277
+ params: data.params ?? {}
7278
+ };
7279
+ const extraTabs = Array.isArray(qiankunState.value.extraTabs) ? [...qiankunState.value.extraTabs] : [];
7280
+ const tabIndex = extraTabs.findIndex(item => item.key === tab.key && item.uniqueKey === tab.uniqueKey);
7281
+ if (tabIndex === -1) {
7282
+ extraTabs.push(tab);
7283
+ } else {
7284
+ extraTabs[tabIndex] = {
7285
+ ...extraTabs[tabIndex],
7286
+ ...tab
7287
+ };
7288
+ }
7289
+ qiankunState.value = {
7290
+ ...qiankunState.value,
7291
+ extraTabs,
7292
+ activeTabKey: `${tab.key}${tab.uniqueKey}`
7293
+ };
7294
+ router.push({
7295
+ path: tab.url,
7296
+ query: tab.params
7297
+ });
7298
+ return;
7299
+ }
7230
7300
  handleMenuChange({
7231
7301
  ...data,
7232
7302
  mode: 2,
@@ -7308,7 +7378,8 @@ const PageContent = defineComponent({
7308
7378
  "onFullscreen": handleFullscreen,
7309
7379
  "onRefreshIframe": handleRefreshIframe,
7310
7380
  "onRefreshExtraPage": handleRefreshExtraPage,
7311
- "onMouseLeave": () => isTabsShow.value = false
7381
+ "onMouseLeave": () => isTabsShow.value = false,
7382
+ "beforeTabClose": props.beforeTabClose
7312
7383
  }, null), [[vShow, !isFullscreen.value || isTabsShow.value]]);
7313
7384
  const containerCns = {
7314
7385
  padding: isPadding.value,
@@ -7469,6 +7540,9 @@ const Props = {
7469
7540
  showNotice: {
7470
7541
  type: Boolean,
7471
7542
  default: true
7543
+ },
7544
+ beforeTabClose: {
7545
+ type: Function
7472
7546
  }
7473
7547
  };
7474
7548
  const Layout = defineComponent({
@@ -7521,13 +7595,22 @@ const Layout = defineComponent({
7521
7595
  currMenu.value = menu;
7522
7596
  nextTick(() => currMenu.value = void 0);
7523
7597
  };
7598
+ watch(() => props.beforeTabClose, beforeTabClose => {
7599
+ qiankunState.value = {
7600
+ ...(qiankunState.value ?? {}),
7601
+ beforeTabClose
7602
+ };
7603
+ }, {
7604
+ immediate: true
7605
+ });
7524
7606
  onBeforeUnmount(() => {
7525
7607
  qiankunState.value = {
7526
7608
  ...qiankunState.value,
7527
7609
  extraTabs: [],
7528
7610
  removeMenuTabs: [],
7529
7611
  activeTabKey: "",
7530
- refreshTabKey: ""
7612
+ refreshTabKey: "",
7613
+ beforeTabClose: void 0
7531
7614
  };
7532
7615
  });
7533
7616
  const pageContainerRef = ref();
@@ -7584,7 +7667,8 @@ const Layout = defineComponent({
7584
7667
  "menu": props.userMenu,
7585
7668
  "extraPages": props.extraPages,
7586
7669
  "appList": props.appList,
7587
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
7670
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
7671
+ "beforeTabClose": props.beforeTabClose
7588
7672
  }, null);
7589
7673
  return createVNode("div", {
7590
7674
  "class": `${config.prefix}-layout`
@@ -8747,6 +8831,9 @@ const getDetailContainer = () => defineComponent({
8747
8831
  const detailList = ref([]);
8748
8832
  const extraPages = computed(() => qiankunState.value.extraTabs);
8749
8833
  const handleClose = async tab => {
8834
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
8835
+ return;
8836
+ }
8750
8837
  const copyPages = [...extraPages.value];
8751
8838
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
8752
8839
  if (idx !== -1) {
@@ -8779,6 +8866,7 @@ const getDetailContainer = () => defineComponent({
8779
8866
  uniqueKey: dataId.value,
8780
8867
  icon: props.icon,
8781
8868
  isExtraTab: true,
8869
+ type: "extraTab",
8782
8870
  params: _.omit(route.query, "name")
8783
8871
  };
8784
8872
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
package/dist/index.cjs CHANGED
@@ -45,7 +45,7 @@ var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
45
45
  var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
46
46
  var mqtt__default = /*#__PURE__*/_interopDefaultLegacy(mqtt);
47
47
 
48
- var version = "0.1.164";
48
+ var version = "0.1.172";
49
49
 
50
50
  const setTheme = theme => {
51
51
  if (theme === "dark") {
@@ -227,20 +227,20 @@ const getUserinfo = () => {
227
227
  }
228
228
  };
229
229
  const getCommonHeaders = () => {
230
- const userInfo = getUserinfo();
231
- const userId = getUserId();
230
+ getUserinfo();
231
+ getUserId();
232
232
  const token = getToken();
233
233
  const appId = getAppId();
234
- const corpId = getCorpId();
234
+ getCorpId();
235
235
  const Authorization = `Bearer ${token}`;
236
236
  return {
237
- userName: userInfo?.userName,
238
- userId: userInfo?.userId || userId,
239
- employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
240
- employeeId: userInfo?.employeeId,
237
+ // userName: userInfo?.userName,
238
+ // userId: userInfo?.userId || userId,
239
+ // employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
240
+ // employeeId: userInfo?.employeeId,
241
241
  token,
242
242
  appId,
243
- corpId,
243
+ // corpId,
244
244
  Authorization,
245
245
  "Content-Type": "application/json;charset=utf-8"
246
246
  };
@@ -7816,6 +7816,24 @@ function getOpenUrl(url) {
7816
7816
  return res;
7817
7817
  }
7818
7818
 
7819
+ async function canCloseTab(tab, beforeTabClose) {
7820
+ if (typeof beforeTabClose !== "function") return true;
7821
+ try {
7822
+ const result = await beforeTabClose(tab);
7823
+ return result !== false;
7824
+ } catch {
7825
+ return false;
7826
+ }
7827
+ }
7828
+ async function canCloseTabs(tabs, beforeTabClose) {
7829
+ for (const tab of tabs) {
7830
+ if (!(await canCloseTab(tab, beforeTabClose))) {
7831
+ return false;
7832
+ }
7833
+ }
7834
+ return true;
7835
+ }
7836
+
7819
7837
  const closeTabMagicKey = "control_shift_q";
7820
7838
  const TabList = vue.defineComponent({
7821
7839
  emits: ["update:activeKey", "update:list", "tabSelect", "closeExtraPage", "closeIframePage", "fullscreen", "refreshIframe", "refreshExtraPage", "mouseLeave"],
@@ -7827,7 +7845,10 @@ const TabList = vue.defineComponent({
7827
7845
  activeKey: {
7828
7846
  type: String
7829
7847
  },
7830
- containerRef: Object
7848
+ containerRef: Object,
7849
+ beforeTabClose: {
7850
+ type: Function
7851
+ }
7831
7852
  },
7832
7853
  setup(props, {
7833
7854
  emit,
@@ -7859,37 +7880,54 @@ const TabList = vue.defineComponent({
7859
7880
  scrollLeft(e.deltaY < 0 ? -300 : 300);
7860
7881
  }
7861
7882
  };
7862
- const handleRemove = async (tab, index) => {
7863
- if (getTabUniqueKey(tab) === activeTabKey.value) {
7864
- const next = tabList.value[index + 1];
7865
- const prev = tabList.value[index - 1];
7866
- if (next) {
7867
- activeTabKey.value = getTabUniqueKey(next);
7868
- emit("tabSelect", next);
7869
- } else if (prev) {
7870
- activeTabKey.value = getTabUniqueKey(prev);
7871
- emit("tabSelect", prev);
7872
- } else {
7873
- return;
7883
+ const getBeforeTabClose = () => props.beforeTabClose ?? qiankunState.value?.beforeTabClose;
7884
+ const selectTab = tab => {
7885
+ activeTabKey.value = getTabUniqueKey(tab);
7886
+ emit("tabSelect", tab);
7887
+ };
7888
+ const removeTabs = async (tabs, fallbackTab) => {
7889
+ const closeKeys = new Set(tabs.map(item => getTabUniqueKey(item)));
7890
+ const currentTabs = tabList.value.filter(item => closeKeys.has(getTabUniqueKey(item)));
7891
+ if (!currentTabs.length || currentTabs.length >= tabList.value.length) {
7892
+ return false;
7893
+ }
7894
+ if (!(await canCloseTabs(currentTabs, getBeforeTabClose()))) {
7895
+ return false;
7896
+ }
7897
+ const remainingTabs = tabList.value.filter(item => !closeKeys.has(getTabUniqueKey(item)));
7898
+ if (!remainingTabs.length) {
7899
+ return false;
7900
+ }
7901
+ if (activeTabKey.value && closeKeys.has(activeTabKey.value)) {
7902
+ const nextActiveTab = fallbackTab && remainingTabs.some(item => getTabUniqueKey(item) === getTabUniqueKey(fallbackTab)) ? fallbackTab : remainingTabs[0];
7903
+ if (nextActiveTab) {
7904
+ selectTab(nextActiveTab);
7874
7905
  }
7875
7906
  }
7876
- tabList.value.splice(index, 1);
7907
+ tabList.value = remainingTabs;
7908
+ return true;
7877
7909
  };
7878
- const closeToRight = index => tabList.value = tabList.value.filter((_2, i) => i <= index);
7879
- const closeToLeft = index => tabList.value = tabList.value.filter((_2, i) => i >= index);
7880
- const closeOther = index => {
7881
- activeTabKey.value = tabList.value[index].key;
7882
- tabList.value = tabList.value.filter((_2, i) => i === index);
7910
+ const handleRemove = async (tab, index) => {
7911
+ const target = tabList.value[index];
7912
+ if (!target || getTabUniqueKey(target) !== getTabUniqueKey(tab)) {
7913
+ return closeTab(tab);
7914
+ }
7915
+ const fallbackTab = tabList.value[index + 1] ?? tabList.value[index - 1];
7916
+ return removeTabs([target], fallbackTab);
7883
7917
  };
7884
- const closeTab = tab => {
7918
+ const closeToRight = index => removeTabs(tabList.value.filter((_2, i) => i > index), tabList.value[index]);
7919
+ const closeToLeft = index => removeTabs(tabList.value.filter((_2, i) => i < index), tabList.value[index]);
7920
+ const closeOther = index => removeTabs(tabList.value.filter((_2, i) => i !== index), tabList.value[index]);
7921
+ const closeTab = async tab => {
7885
7922
  const idx = tabList.value.findIndex(item => getTabUniqueKey(item) === getTabUniqueKey(tab));
7886
7923
  if (idx !== -1) {
7887
- handleRemove(tab, idx);
7924
+ return handleRemove(tabList.value[idx], idx);
7888
7925
  }
7926
+ return false;
7889
7927
  };
7890
7928
  const magicKeys = core.useMagicKeys();
7891
7929
  core.whenever(magicKeys[closeTabMagicKey], () => {
7892
- if (tabList.value.length > 1) {
7930
+ if (tabList.value.length > 1 && activeTabIndex.value !== -1) {
7893
7931
  handleRemove(tabList.value[activeTabIndex.value], activeTabIndex.value);
7894
7932
  }
7895
7933
  });
@@ -8167,6 +8205,9 @@ const Props$1 = {
8167
8205
  pageContainerRef: {
8168
8206
  type: Object,
8169
8207
  required: true
8208
+ },
8209
+ beforeTabClose: {
8210
+ type: Function
8170
8211
  }
8171
8212
  };
8172
8213
  const PageContent = vue.defineComponent({
@@ -8403,6 +8444,35 @@ const PageContent = vue.defineComponent({
8403
8444
  data
8404
8445
  } = event;
8405
8446
  if (type === "addTab") {
8447
+ if (data.mode === "microApp") {
8448
+ const uniqueKey = data.uniqueKey || data.key;
8449
+ const tab = {
8450
+ ...data,
8451
+ uniqueKey,
8452
+ isExtraTab: true,
8453
+ params: data.params ?? {}
8454
+ };
8455
+ const extraTabs = Array.isArray(qiankunState.value.extraTabs) ? [...qiankunState.value.extraTabs] : [];
8456
+ const tabIndex = extraTabs.findIndex(item => item.key === tab.key && item.uniqueKey === tab.uniqueKey);
8457
+ if (tabIndex === -1) {
8458
+ extraTabs.push(tab);
8459
+ } else {
8460
+ extraTabs[tabIndex] = {
8461
+ ...extraTabs[tabIndex],
8462
+ ...tab
8463
+ };
8464
+ }
8465
+ qiankunState.value = {
8466
+ ...qiankunState.value,
8467
+ extraTabs,
8468
+ activeTabKey: `${tab.key}${tab.uniqueKey}`
8469
+ };
8470
+ router.push({
8471
+ path: tab.url,
8472
+ query: tab.params
8473
+ });
8474
+ return;
8475
+ }
8406
8476
  handleMenuChange({
8407
8477
  ...data,
8408
8478
  mode: 2,
@@ -8484,7 +8554,8 @@ const PageContent = vue.defineComponent({
8484
8554
  "onFullscreen": handleFullscreen,
8485
8555
  "onRefreshIframe": handleRefreshIframe,
8486
8556
  "onRefreshExtraPage": handleRefreshExtraPage,
8487
- "onMouseLeave": () => isTabsShow.value = false
8557
+ "onMouseLeave": () => isTabsShow.value = false,
8558
+ "beforeTabClose": props.beforeTabClose
8488
8559
  }, null), [[vue.vShow, !isFullscreen.value || isTabsShow.value]]);
8489
8560
  const containerCns = {
8490
8561
  padding: isPadding.value,
@@ -8645,6 +8716,9 @@ const Props = {
8645
8716
  showNotice: {
8646
8717
  type: Boolean,
8647
8718
  default: true
8719
+ },
8720
+ beforeTabClose: {
8721
+ type: Function
8648
8722
  }
8649
8723
  };
8650
8724
  const Layout = vue.defineComponent({
@@ -8697,13 +8771,22 @@ const Layout = vue.defineComponent({
8697
8771
  currMenu.value = menu;
8698
8772
  vue.nextTick(() => currMenu.value = void 0);
8699
8773
  };
8774
+ vue.watch(() => props.beforeTabClose, beforeTabClose => {
8775
+ qiankunState.value = {
8776
+ ...(qiankunState.value ?? {}),
8777
+ beforeTabClose
8778
+ };
8779
+ }, {
8780
+ immediate: true
8781
+ });
8700
8782
  vue.onBeforeUnmount(() => {
8701
8783
  qiankunState.value = {
8702
8784
  ...qiankunState.value,
8703
8785
  extraTabs: [],
8704
8786
  removeMenuTabs: [],
8705
8787
  activeTabKey: "",
8706
- refreshTabKey: ""
8788
+ refreshTabKey: "",
8789
+ beforeTabClose: void 0
8707
8790
  };
8708
8791
  });
8709
8792
  const pageContainerRef = vue.ref();
@@ -8760,7 +8843,8 @@ const Layout = vue.defineComponent({
8760
8843
  "menu": props.userMenu,
8761
8844
  "extraPages": props.extraPages,
8762
8845
  "appList": props.appList,
8763
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
8846
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
8847
+ "beforeTabClose": props.beforeTabClose
8764
8848
  }, null);
8765
8849
  return vue.createVNode("div", {
8766
8850
  "class": `${config.prefix}-layout`
@@ -9762,6 +9846,9 @@ const getDetailContainer = () => vue.defineComponent({
9762
9846
  const detailList = vue.ref([]);
9763
9847
  const extraPages = vue.computed(() => qiankunState.value.extraTabs);
9764
9848
  const handleClose = async tab => {
9849
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
9850
+ return;
9851
+ }
9765
9852
  const copyPages = [...extraPages.value];
9766
9853
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
9767
9854
  if (idx !== -1) {
@@ -9794,6 +9881,7 @@ const getDetailContainer = () => vue.defineComponent({
9794
9881
  uniqueKey: dataId.value,
9795
9882
  icon: props.icon,
9796
9883
  isExtraTab: true,
9884
+ type: "extraTab",
9797
9885
  params: ___default["default"].omit(route.query, "name")
9798
9886
  };
9799
9887
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import { Key } from 'ant-design-vue/lib/table/interface';
11
11
  import * as vue_jsx_runtime from 'vue/jsx-runtime';
12
12
  import * as _ant_design_icons_vue_lib_components_IconFont from '@ant-design/icons-vue/lib/components/IconFont';
13
13
 
14
- var version = "0.1.164";
14
+ var version = "0.1.172";
15
15
 
16
16
  declare const _default$p: {
17
17
  set(theme: string): void;
@@ -78,13 +78,8 @@ interface IApiInstanceConfig extends AxiosRequestConfig {
78
78
  * keepProperty: boolean; 保留多余的属性,如createUser
79
79
  */
80
80
  declare const getCommonHeaders: () => {
81
- userName: any;
82
- userId: any;
83
- employeeName: string;
84
- employeeId: any;
85
81
  token: string;
86
82
  appId: any;
87
- corpId: any;
88
83
  Authorization: string;
89
84
  "Content-Type": string;
90
85
  };
@@ -787,6 +782,9 @@ declare const _default$l: vue.DefineComponent<{
787
782
 
788
783
  declare const _default$k: vue.FunctionalComponent<_ant_design_icons_vue_lib_components_IconFont.IconFontProps, {}, any>;
789
784
 
785
+ type BeforeTabCloseResult = boolean | void;
786
+ type BeforeTabClose<T = any> = (tab: T) => BeforeTabCloseResult | Promise<BeforeTabCloseResult>;
787
+
790
788
  interface IMenuItem {
791
789
  id: string;
792
790
  code: string;
@@ -841,6 +839,9 @@ declare const _default$j: vue.DefineComponent<{
841
839
  type: BooleanConstructor;
842
840
  default: boolean;
843
841
  };
842
+ beforeTabClose: {
843
+ type: PropType<BeforeTabClose>;
844
+ };
844
845
  }, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("globalSearch" | "personalCenter" | "logout" | "extraPage")[], "globalSearch" | "personalCenter" | "logout" | "extraPage", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
845
846
  userMenu: {
846
847
  type: PropType<MenuList>;
@@ -883,6 +884,9 @@ declare const _default$j: vue.DefineComponent<{
883
884
  type: BooleanConstructor;
884
885
  default: boolean;
885
886
  };
887
+ beforeTabClose: {
888
+ type: PropType<BeforeTabClose>;
889
+ };
886
890
  }>> & {
887
891
  onGlobalSearch?: ((...args: any[]) => any) | undefined;
888
892
  onPersonalCenter?: ((...args: any[]) => any) | undefined;
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ import { XPopup, CommentBlock, setAxiosOption } from '@sszj-temp/mobile';
14
14
  import { marked } from 'marked';
15
15
  import '@sszj-temp/mobile/style.css';
16
16
 
17
- var version = "0.1.164";
17
+ var version = "0.1.172";
18
18
 
19
19
  const setTheme = theme => {
20
20
  if (theme === "dark") {
@@ -196,20 +196,20 @@ const getUserinfo = () => {
196
196
  }
197
197
  };
198
198
  const getCommonHeaders = () => {
199
- const userInfo = getUserinfo();
200
- const userId = getUserId();
199
+ getUserinfo();
200
+ getUserId();
201
201
  const token = getToken();
202
202
  const appId = getAppId();
203
- const corpId = getCorpId();
203
+ getCorpId();
204
204
  const Authorization = `Bearer ${token}`;
205
205
  return {
206
- userName: userInfo?.userName,
207
- userId: userInfo?.userId || userId,
208
- employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
209
- employeeId: userInfo?.employeeId,
206
+ // userName: userInfo?.userName,
207
+ // userId: userInfo?.userId || userId,
208
+ // employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
209
+ // employeeId: userInfo?.employeeId,
210
210
  token,
211
211
  appId,
212
- corpId,
212
+ // corpId,
213
213
  Authorization,
214
214
  "Content-Type": "application/json;charset=utf-8"
215
215
  };
@@ -7785,6 +7785,24 @@ function getOpenUrl(url) {
7785
7785
  return res;
7786
7786
  }
7787
7787
 
7788
+ async function canCloseTab(tab, beforeTabClose) {
7789
+ if (typeof beforeTabClose !== "function") return true;
7790
+ try {
7791
+ const result = await beforeTabClose(tab);
7792
+ return result !== false;
7793
+ } catch {
7794
+ return false;
7795
+ }
7796
+ }
7797
+ async function canCloseTabs(tabs, beforeTabClose) {
7798
+ for (const tab of tabs) {
7799
+ if (!(await canCloseTab(tab, beforeTabClose))) {
7800
+ return false;
7801
+ }
7802
+ }
7803
+ return true;
7804
+ }
7805
+
7788
7806
  const closeTabMagicKey = "control_shift_q";
7789
7807
  const TabList = defineComponent({
7790
7808
  emits: ["update:activeKey", "update:list", "tabSelect", "closeExtraPage", "closeIframePage", "fullscreen", "refreshIframe", "refreshExtraPage", "mouseLeave"],
@@ -7796,7 +7814,10 @@ const TabList = defineComponent({
7796
7814
  activeKey: {
7797
7815
  type: String
7798
7816
  },
7799
- containerRef: Object
7817
+ containerRef: Object,
7818
+ beforeTabClose: {
7819
+ type: Function
7820
+ }
7800
7821
  },
7801
7822
  setup(props, {
7802
7823
  emit,
@@ -7828,37 +7849,54 @@ const TabList = defineComponent({
7828
7849
  scrollLeft(e.deltaY < 0 ? -300 : 300);
7829
7850
  }
7830
7851
  };
7831
- const handleRemove = async (tab, index) => {
7832
- if (getTabUniqueKey(tab) === activeTabKey.value) {
7833
- const next = tabList.value[index + 1];
7834
- const prev = tabList.value[index - 1];
7835
- if (next) {
7836
- activeTabKey.value = getTabUniqueKey(next);
7837
- emit("tabSelect", next);
7838
- } else if (prev) {
7839
- activeTabKey.value = getTabUniqueKey(prev);
7840
- emit("tabSelect", prev);
7841
- } else {
7842
- return;
7852
+ const getBeforeTabClose = () => props.beforeTabClose ?? qiankunState.value?.beforeTabClose;
7853
+ const selectTab = tab => {
7854
+ activeTabKey.value = getTabUniqueKey(tab);
7855
+ emit("tabSelect", tab);
7856
+ };
7857
+ const removeTabs = async (tabs, fallbackTab) => {
7858
+ const closeKeys = new Set(tabs.map(item => getTabUniqueKey(item)));
7859
+ const currentTabs = tabList.value.filter(item => closeKeys.has(getTabUniqueKey(item)));
7860
+ if (!currentTabs.length || currentTabs.length >= tabList.value.length) {
7861
+ return false;
7862
+ }
7863
+ if (!(await canCloseTabs(currentTabs, getBeforeTabClose()))) {
7864
+ return false;
7865
+ }
7866
+ const remainingTabs = tabList.value.filter(item => !closeKeys.has(getTabUniqueKey(item)));
7867
+ if (!remainingTabs.length) {
7868
+ return false;
7869
+ }
7870
+ if (activeTabKey.value && closeKeys.has(activeTabKey.value)) {
7871
+ const nextActiveTab = fallbackTab && remainingTabs.some(item => getTabUniqueKey(item) === getTabUniqueKey(fallbackTab)) ? fallbackTab : remainingTabs[0];
7872
+ if (nextActiveTab) {
7873
+ selectTab(nextActiveTab);
7843
7874
  }
7844
7875
  }
7845
- tabList.value.splice(index, 1);
7876
+ tabList.value = remainingTabs;
7877
+ return true;
7846
7878
  };
7847
- const closeToRight = index => tabList.value = tabList.value.filter((_2, i) => i <= index);
7848
- const closeToLeft = index => tabList.value = tabList.value.filter((_2, i) => i >= index);
7849
- const closeOther = index => {
7850
- activeTabKey.value = tabList.value[index].key;
7851
- tabList.value = tabList.value.filter((_2, i) => i === index);
7879
+ const handleRemove = async (tab, index) => {
7880
+ const target = tabList.value[index];
7881
+ if (!target || getTabUniqueKey(target) !== getTabUniqueKey(tab)) {
7882
+ return closeTab(tab);
7883
+ }
7884
+ const fallbackTab = tabList.value[index + 1] ?? tabList.value[index - 1];
7885
+ return removeTabs([target], fallbackTab);
7852
7886
  };
7853
- const closeTab = tab => {
7887
+ const closeToRight = index => removeTabs(tabList.value.filter((_2, i) => i > index), tabList.value[index]);
7888
+ const closeToLeft = index => removeTabs(tabList.value.filter((_2, i) => i < index), tabList.value[index]);
7889
+ const closeOther = index => removeTabs(tabList.value.filter((_2, i) => i !== index), tabList.value[index]);
7890
+ const closeTab = async tab => {
7854
7891
  const idx = tabList.value.findIndex(item => getTabUniqueKey(item) === getTabUniqueKey(tab));
7855
7892
  if (idx !== -1) {
7856
- handleRemove(tab, idx);
7893
+ return handleRemove(tabList.value[idx], idx);
7857
7894
  }
7895
+ return false;
7858
7896
  };
7859
7897
  const magicKeys = useMagicKeys();
7860
7898
  whenever(magicKeys[closeTabMagicKey], () => {
7861
- if (tabList.value.length > 1) {
7899
+ if (tabList.value.length > 1 && activeTabIndex.value !== -1) {
7862
7900
  handleRemove(tabList.value[activeTabIndex.value], activeTabIndex.value);
7863
7901
  }
7864
7902
  });
@@ -8136,6 +8174,9 @@ const Props$1 = {
8136
8174
  pageContainerRef: {
8137
8175
  type: Object,
8138
8176
  required: true
8177
+ },
8178
+ beforeTabClose: {
8179
+ type: Function
8139
8180
  }
8140
8181
  };
8141
8182
  const PageContent = defineComponent({
@@ -8372,6 +8413,35 @@ const PageContent = defineComponent({
8372
8413
  data
8373
8414
  } = event;
8374
8415
  if (type === "addTab") {
8416
+ if (data.mode === "microApp") {
8417
+ const uniqueKey = data.uniqueKey || data.key;
8418
+ const tab = {
8419
+ ...data,
8420
+ uniqueKey,
8421
+ isExtraTab: true,
8422
+ params: data.params ?? {}
8423
+ };
8424
+ const extraTabs = Array.isArray(qiankunState.value.extraTabs) ? [...qiankunState.value.extraTabs] : [];
8425
+ const tabIndex = extraTabs.findIndex(item => item.key === tab.key && item.uniqueKey === tab.uniqueKey);
8426
+ if (tabIndex === -1) {
8427
+ extraTabs.push(tab);
8428
+ } else {
8429
+ extraTabs[tabIndex] = {
8430
+ ...extraTabs[tabIndex],
8431
+ ...tab
8432
+ };
8433
+ }
8434
+ qiankunState.value = {
8435
+ ...qiankunState.value,
8436
+ extraTabs,
8437
+ activeTabKey: `${tab.key}${tab.uniqueKey}`
8438
+ };
8439
+ router.push({
8440
+ path: tab.url,
8441
+ query: tab.params
8442
+ });
8443
+ return;
8444
+ }
8375
8445
  handleMenuChange({
8376
8446
  ...data,
8377
8447
  mode: 2,
@@ -8453,7 +8523,8 @@ const PageContent = defineComponent({
8453
8523
  "onFullscreen": handleFullscreen,
8454
8524
  "onRefreshIframe": handleRefreshIframe,
8455
8525
  "onRefreshExtraPage": handleRefreshExtraPage,
8456
- "onMouseLeave": () => isTabsShow.value = false
8526
+ "onMouseLeave": () => isTabsShow.value = false,
8527
+ "beforeTabClose": props.beforeTabClose
8457
8528
  }, null), [[vShow, !isFullscreen.value || isTabsShow.value]]);
8458
8529
  const containerCns = {
8459
8530
  padding: isPadding.value,
@@ -8614,6 +8685,9 @@ const Props = {
8614
8685
  showNotice: {
8615
8686
  type: Boolean,
8616
8687
  default: true
8688
+ },
8689
+ beforeTabClose: {
8690
+ type: Function
8617
8691
  }
8618
8692
  };
8619
8693
  const Layout = defineComponent({
@@ -8666,13 +8740,22 @@ const Layout = defineComponent({
8666
8740
  currMenu.value = menu;
8667
8741
  nextTick(() => currMenu.value = void 0);
8668
8742
  };
8743
+ watch(() => props.beforeTabClose, beforeTabClose => {
8744
+ qiankunState.value = {
8745
+ ...(qiankunState.value ?? {}),
8746
+ beforeTabClose
8747
+ };
8748
+ }, {
8749
+ immediate: true
8750
+ });
8669
8751
  onBeforeUnmount(() => {
8670
8752
  qiankunState.value = {
8671
8753
  ...qiankunState.value,
8672
8754
  extraTabs: [],
8673
8755
  removeMenuTabs: [],
8674
8756
  activeTabKey: "",
8675
- refreshTabKey: ""
8757
+ refreshTabKey: "",
8758
+ beforeTabClose: void 0
8676
8759
  };
8677
8760
  });
8678
8761
  const pageContainerRef = ref();
@@ -8729,7 +8812,8 @@ const Layout = defineComponent({
8729
8812
  "menu": props.userMenu,
8730
8813
  "extraPages": props.extraPages,
8731
8814
  "appList": props.appList,
8732
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
8815
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
8816
+ "beforeTabClose": props.beforeTabClose
8733
8817
  }, null);
8734
8818
  return createVNode("div", {
8735
8819
  "class": `${config.prefix}-layout`
@@ -9731,6 +9815,9 @@ const getDetailContainer = () => defineComponent({
9731
9815
  const detailList = ref([]);
9732
9816
  const extraPages = computed(() => qiankunState.value.extraTabs);
9733
9817
  const handleClose = async tab => {
9818
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
9819
+ return;
9820
+ }
9734
9821
  const copyPages = [...extraPages.value];
9735
9822
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
9736
9823
  if (idx !== -1) {
@@ -9763,6 +9850,7 @@ const getDetailContainer = () => defineComponent({
9763
9850
  uniqueKey: dataId.value,
9764
9851
  icon: props.icon,
9765
9852
  isExtraTab: true,
9853
+ type: "extraTab",
9766
9854
  params: _.omit(route.query, "name")
9767
9855
  };
9768
9856
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
@@ -213,20 +213,20 @@ const getUserinfo = () => {
213
213
  }
214
214
  };
215
215
  const getCommonHeaders = () => {
216
- const userInfo = getUserinfo();
217
- const userId = getUserId();
216
+ getUserinfo();
217
+ getUserId();
218
218
  const token = getToken();
219
219
  const appId = getAppId();
220
- const corpId = getCorpId();
220
+ getCorpId();
221
221
  const Authorization = `Bearer ${token}`;
222
222
  return {
223
- userName: userInfo?.userName,
224
- userId: userInfo?.userId || userId,
225
- employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
226
- employeeId: userInfo?.employeeId,
223
+ // userName: userInfo?.userName,
224
+ // userId: userInfo?.userId || userId,
225
+ // employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
226
+ // employeeId: userInfo?.employeeId,
227
227
  token,
228
228
  appId,
229
- corpId,
229
+ // corpId,
230
230
  Authorization,
231
231
  "Content-Type": "application/json;charset=utf-8"
232
232
  };
@@ -69,13 +69,8 @@ interface IApiInstanceConfig extends AxiosRequestConfig {
69
69
  * keepProperty: boolean; 保留多余的属性,如createUser
70
70
  */
71
71
  declare const getCommonHeaders: () => {
72
- userName: any;
73
- userId: any;
74
- employeeName: string;
75
- employeeId: any;
76
72
  token: string;
77
73
  appId: any;
78
- corpId: any;
79
74
  Authorization: string;
80
75
  "Content-Type": string;
81
76
  };
@@ -185,20 +185,20 @@ const getUserinfo = () => {
185
185
  }
186
186
  };
187
187
  const getCommonHeaders = () => {
188
- const userInfo = getUserinfo();
189
- const userId = getUserId();
188
+ getUserinfo();
189
+ getUserId();
190
190
  const token = getToken();
191
191
  const appId = getAppId();
192
- const corpId = getCorpId();
192
+ getCorpId();
193
193
  const Authorization = `Bearer ${token}`;
194
194
  return {
195
- userName: userInfo?.userName,
196
- userId: userInfo?.userId || userId,
197
- employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
198
- employeeId: userInfo?.employeeId,
195
+ // userName: userInfo?.userName,
196
+ // userId: userInfo?.userId || userId,
197
+ // employeeName: encodeURIComponent(userInfo?.employeeName ?? ""),
198
+ // employeeId: userInfo?.employeeId,
199
199
  token,
200
200
  appId,
201
- corpId,
201
+ // corpId,
202
202
  Authorization,
203
203
  "Content-Type": "application/json;charset=utf-8"
204
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inl-ui",
3
- "version": "0.1.171",
3
+ "version": "0.1.173",
4
4
  "description": "工业 pc ui库",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",