inl-ui 0.1.170 → 0.1.172

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.
@@ -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({
@@ -7337,7 +7378,8 @@ const PageContent = vue.defineComponent({
7337
7378
  "onFullscreen": handleFullscreen,
7338
7379
  "onRefreshIframe": handleRefreshIframe,
7339
7380
  "onRefreshExtraPage": handleRefreshExtraPage,
7340
- "onMouseLeave": () => isTabsShow.value = false
7381
+ "onMouseLeave": () => isTabsShow.value = false,
7382
+ "beforeTabClose": props.beforeTabClose
7341
7383
  }, null), [[vue.vShow, !isFullscreen.value || isTabsShow.value]]);
7342
7384
  const containerCns = {
7343
7385
  padding: isPadding.value,
@@ -7498,6 +7540,9 @@ const Props = {
7498
7540
  showNotice: {
7499
7541
  type: Boolean,
7500
7542
  default: true
7543
+ },
7544
+ beforeTabClose: {
7545
+ type: Function
7501
7546
  }
7502
7547
  };
7503
7548
  const Layout = vue.defineComponent({
@@ -7550,13 +7595,22 @@ const Layout = vue.defineComponent({
7550
7595
  currMenu.value = menu;
7551
7596
  vue.nextTick(() => currMenu.value = void 0);
7552
7597
  };
7598
+ vue.watch(() => props.beforeTabClose, beforeTabClose => {
7599
+ qiankunState.value = {
7600
+ ...(qiankunState.value ?? {}),
7601
+ beforeTabClose
7602
+ };
7603
+ }, {
7604
+ immediate: true
7605
+ });
7553
7606
  vue.onBeforeUnmount(() => {
7554
7607
  qiankunState.value = {
7555
7608
  ...qiankunState.value,
7556
7609
  extraTabs: [],
7557
7610
  removeMenuTabs: [],
7558
7611
  activeTabKey: "",
7559
- refreshTabKey: ""
7612
+ refreshTabKey: "",
7613
+ beforeTabClose: void 0
7560
7614
  };
7561
7615
  });
7562
7616
  const pageContainerRef = vue.ref();
@@ -7613,7 +7667,8 @@ const Layout = vue.defineComponent({
7613
7667
  "menu": props.userMenu,
7614
7668
  "extraPages": props.extraPages,
7615
7669
  "appList": props.appList,
7616
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
7670
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
7671
+ "beforeTabClose": props.beforeTabClose
7617
7672
  }, null);
7618
7673
  return vue.createVNode("div", {
7619
7674
  "class": `${config.prefix}-layout`
@@ -8776,6 +8831,9 @@ const getDetailContainer = () => vue.defineComponent({
8776
8831
  const detailList = vue.ref([]);
8777
8832
  const extraPages = vue.computed(() => qiankunState.value.extraTabs);
8778
8833
  const handleClose = async tab => {
8834
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
8835
+ return;
8836
+ }
8779
8837
  const copyPages = [...extraPages.value];
8780
8838
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
8781
8839
  if (idx !== -1) {
@@ -8808,6 +8866,7 @@ const getDetailContainer = () => vue.defineComponent({
8808
8866
  uniqueKey: dataId.value,
8809
8867
  icon: props.icon,
8810
8868
  isExtraTab: true,
8869
+ type: "extraTab",
8811
8870
  params: ___default["default"].omit(route.query, "name")
8812
8871
  };
8813
8872
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
@@ -9028,6 +9087,7 @@ const VideoPlayerV2 = vue.defineComponent({
9028
9087
  if ("stopPlay" in play) {
9029
9088
  play.stopPlay(`videoPlayer_${uuid}`);
9030
9089
  }
9090
+ release();
9031
9091
  };
9032
9092
  const init = () => {
9033
9093
  let camera = videoInfo2.value;
@@ -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;
@@ -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({
@@ -7308,7 +7349,8 @@ const PageContent = defineComponent({
7308
7349
  "onFullscreen": handleFullscreen,
7309
7350
  "onRefreshIframe": handleRefreshIframe,
7310
7351
  "onRefreshExtraPage": handleRefreshExtraPage,
7311
- "onMouseLeave": () => isTabsShow.value = false
7352
+ "onMouseLeave": () => isTabsShow.value = false,
7353
+ "beforeTabClose": props.beforeTabClose
7312
7354
  }, null), [[vShow, !isFullscreen.value || isTabsShow.value]]);
7313
7355
  const containerCns = {
7314
7356
  padding: isPadding.value,
@@ -7469,6 +7511,9 @@ const Props = {
7469
7511
  showNotice: {
7470
7512
  type: Boolean,
7471
7513
  default: true
7514
+ },
7515
+ beforeTabClose: {
7516
+ type: Function
7472
7517
  }
7473
7518
  };
7474
7519
  const Layout = defineComponent({
@@ -7521,13 +7566,22 @@ const Layout = defineComponent({
7521
7566
  currMenu.value = menu;
7522
7567
  nextTick(() => currMenu.value = void 0);
7523
7568
  };
7569
+ watch(() => props.beforeTabClose, beforeTabClose => {
7570
+ qiankunState.value = {
7571
+ ...(qiankunState.value ?? {}),
7572
+ beforeTabClose
7573
+ };
7574
+ }, {
7575
+ immediate: true
7576
+ });
7524
7577
  onBeforeUnmount(() => {
7525
7578
  qiankunState.value = {
7526
7579
  ...qiankunState.value,
7527
7580
  extraTabs: [],
7528
7581
  removeMenuTabs: [],
7529
7582
  activeTabKey: "",
7530
- refreshTabKey: ""
7583
+ refreshTabKey: "",
7584
+ beforeTabClose: void 0
7531
7585
  };
7532
7586
  });
7533
7587
  const pageContainerRef = ref();
@@ -7584,7 +7638,8 @@ const Layout = defineComponent({
7584
7638
  "menu": props.userMenu,
7585
7639
  "extraPages": props.extraPages,
7586
7640
  "appList": props.appList,
7587
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
7641
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
7642
+ "beforeTabClose": props.beforeTabClose
7588
7643
  }, null);
7589
7644
  return createVNode("div", {
7590
7645
  "class": `${config.prefix}-layout`
@@ -8747,6 +8802,9 @@ const getDetailContainer = () => defineComponent({
8747
8802
  const detailList = ref([]);
8748
8803
  const extraPages = computed(() => qiankunState.value.extraTabs);
8749
8804
  const handleClose = async tab => {
8805
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
8806
+ return;
8807
+ }
8750
8808
  const copyPages = [...extraPages.value];
8751
8809
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
8752
8810
  if (idx !== -1) {
@@ -8779,6 +8837,7 @@ const getDetailContainer = () => defineComponent({
8779
8837
  uniqueKey: dataId.value,
8780
8838
  icon: props.icon,
8781
8839
  isExtraTab: true,
8840
+ type: "extraTab",
8782
8841
  params: _.omit(route.query, "name")
8783
8842
  };
8784
8843
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
@@ -8999,6 +9058,7 @@ const VideoPlayerV2 = defineComponent({
8999
9058
  if ("stopPlay" in play) {
9000
9059
  play.stopPlay(`videoPlayer_${uuid}`);
9001
9060
  }
9061
+ release();
9002
9062
  };
9003
9063
  const init = () => {
9004
9064
  let camera = videoInfo2.value;
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.170";
49
49
 
50
50
  const setTheme = theme => {
51
51
  if (theme === "dark") {
@@ -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({
@@ -8484,7 +8525,8 @@ const PageContent = vue.defineComponent({
8484
8525
  "onFullscreen": handleFullscreen,
8485
8526
  "onRefreshIframe": handleRefreshIframe,
8486
8527
  "onRefreshExtraPage": handleRefreshExtraPage,
8487
- "onMouseLeave": () => isTabsShow.value = false
8528
+ "onMouseLeave": () => isTabsShow.value = false,
8529
+ "beforeTabClose": props.beforeTabClose
8488
8530
  }, null), [[vue.vShow, !isFullscreen.value || isTabsShow.value]]);
8489
8531
  const containerCns = {
8490
8532
  padding: isPadding.value,
@@ -8645,6 +8687,9 @@ const Props = {
8645
8687
  showNotice: {
8646
8688
  type: Boolean,
8647
8689
  default: true
8690
+ },
8691
+ beforeTabClose: {
8692
+ type: Function
8648
8693
  }
8649
8694
  };
8650
8695
  const Layout = vue.defineComponent({
@@ -8697,13 +8742,22 @@ const Layout = vue.defineComponent({
8697
8742
  currMenu.value = menu;
8698
8743
  vue.nextTick(() => currMenu.value = void 0);
8699
8744
  };
8745
+ vue.watch(() => props.beforeTabClose, beforeTabClose => {
8746
+ qiankunState.value = {
8747
+ ...(qiankunState.value ?? {}),
8748
+ beforeTabClose
8749
+ };
8750
+ }, {
8751
+ immediate: true
8752
+ });
8700
8753
  vue.onBeforeUnmount(() => {
8701
8754
  qiankunState.value = {
8702
8755
  ...qiankunState.value,
8703
8756
  extraTabs: [],
8704
8757
  removeMenuTabs: [],
8705
8758
  activeTabKey: "",
8706
- refreshTabKey: ""
8759
+ refreshTabKey: "",
8760
+ beforeTabClose: void 0
8707
8761
  };
8708
8762
  });
8709
8763
  const pageContainerRef = vue.ref();
@@ -8760,7 +8814,8 @@ const Layout = vue.defineComponent({
8760
8814
  "menu": props.userMenu,
8761
8815
  "extraPages": props.extraPages,
8762
8816
  "appList": props.appList,
8763
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
8817
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
8818
+ "beforeTabClose": props.beforeTabClose
8764
8819
  }, null);
8765
8820
  return vue.createVNode("div", {
8766
8821
  "class": `${config.prefix}-layout`
@@ -9762,6 +9817,9 @@ const getDetailContainer = () => vue.defineComponent({
9762
9817
  const detailList = vue.ref([]);
9763
9818
  const extraPages = vue.computed(() => qiankunState.value.extraTabs);
9764
9819
  const handleClose = async tab => {
9820
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
9821
+ return;
9822
+ }
9765
9823
  const copyPages = [...extraPages.value];
9766
9824
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
9767
9825
  if (idx !== -1) {
@@ -9794,6 +9852,7 @@ const getDetailContainer = () => vue.defineComponent({
9794
9852
  uniqueKey: dataId.value,
9795
9853
  icon: props.icon,
9796
9854
  isExtraTab: true,
9855
+ type: "extraTab",
9797
9856
  params: ___default["default"].omit(route.query, "name")
9798
9857
  };
9799
9858
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
@@ -10014,6 +10073,7 @@ const VideoPlayerV2 = vue.defineComponent({
10014
10073
  if ("stopPlay" in play) {
10015
10074
  play.stopPlay(`videoPlayer_${uuid}`);
10016
10075
  }
10076
+ release();
10017
10077
  };
10018
10078
  const init = () => {
10019
10079
  let camera = videoInfo2.value;
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.170";
15
15
 
16
16
  declare const _default$p: {
17
17
  set(theme: string): void;
@@ -782,6 +782,9 @@ declare const _default$l: vue.DefineComponent<{
782
782
 
783
783
  declare const _default$k: vue.FunctionalComponent<_ant_design_icons_vue_lib_components_IconFont.IconFontProps, {}, any>;
784
784
 
785
+ type BeforeTabCloseResult = boolean | void;
786
+ type BeforeTabClose<T = any> = (tab: T) => BeforeTabCloseResult | Promise<BeforeTabCloseResult>;
787
+
785
788
  interface IMenuItem {
786
789
  id: string;
787
790
  code: string;
@@ -836,6 +839,9 @@ declare const _default$j: vue.DefineComponent<{
836
839
  type: BooleanConstructor;
837
840
  default: boolean;
838
841
  };
842
+ beforeTabClose: {
843
+ type: PropType<BeforeTabClose>;
844
+ };
839
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<{
840
846
  userMenu: {
841
847
  type: PropType<MenuList>;
@@ -878,6 +884,9 @@ declare const _default$j: vue.DefineComponent<{
878
884
  type: BooleanConstructor;
879
885
  default: boolean;
880
886
  };
887
+ beforeTabClose: {
888
+ type: PropType<BeforeTabClose>;
889
+ };
881
890
  }>> & {
882
891
  onGlobalSearch?: ((...args: any[]) => any) | undefined;
883
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.170";
18
18
 
19
19
  const setTheme = theme => {
20
20
  if (theme === "dark") {
@@ -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({
@@ -8453,7 +8494,8 @@ const PageContent = defineComponent({
8453
8494
  "onFullscreen": handleFullscreen,
8454
8495
  "onRefreshIframe": handleRefreshIframe,
8455
8496
  "onRefreshExtraPage": handleRefreshExtraPage,
8456
- "onMouseLeave": () => isTabsShow.value = false
8497
+ "onMouseLeave": () => isTabsShow.value = false,
8498
+ "beforeTabClose": props.beforeTabClose
8457
8499
  }, null), [[vShow, !isFullscreen.value || isTabsShow.value]]);
8458
8500
  const containerCns = {
8459
8501
  padding: isPadding.value,
@@ -8614,6 +8656,9 @@ const Props = {
8614
8656
  showNotice: {
8615
8657
  type: Boolean,
8616
8658
  default: true
8659
+ },
8660
+ beforeTabClose: {
8661
+ type: Function
8617
8662
  }
8618
8663
  };
8619
8664
  const Layout = defineComponent({
@@ -8666,13 +8711,22 @@ const Layout = defineComponent({
8666
8711
  currMenu.value = menu;
8667
8712
  nextTick(() => currMenu.value = void 0);
8668
8713
  };
8714
+ watch(() => props.beforeTabClose, beforeTabClose => {
8715
+ qiankunState.value = {
8716
+ ...(qiankunState.value ?? {}),
8717
+ beforeTabClose
8718
+ };
8719
+ }, {
8720
+ immediate: true
8721
+ });
8669
8722
  onBeforeUnmount(() => {
8670
8723
  qiankunState.value = {
8671
8724
  ...qiankunState.value,
8672
8725
  extraTabs: [],
8673
8726
  removeMenuTabs: [],
8674
8727
  activeTabKey: "",
8675
- refreshTabKey: ""
8728
+ refreshTabKey: "",
8729
+ beforeTabClose: void 0
8676
8730
  };
8677
8731
  });
8678
8732
  const pageContainerRef = ref();
@@ -8729,7 +8783,8 @@ const Layout = defineComponent({
8729
8783
  "menu": props.userMenu,
8730
8784
  "extraPages": props.extraPages,
8731
8785
  "appList": props.appList,
8732
- "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage
8786
+ "showTabList": (props.withMenu || showSideMenu.value) && !isOnlyPage,
8787
+ "beforeTabClose": props.beforeTabClose
8733
8788
  }, null);
8734
8789
  return createVNode("div", {
8735
8790
  "class": `${config.prefix}-layout`
@@ -9731,6 +9786,9 @@ const getDetailContainer = () => defineComponent({
9731
9786
  const detailList = ref([]);
9732
9787
  const extraPages = computed(() => qiankunState.value.extraTabs);
9733
9788
  const handleClose = async tab => {
9789
+ if (!(await canCloseTab(tab, qiankunState.value?.beforeTabClose))) {
9790
+ return;
9791
+ }
9734
9792
  const copyPages = [...extraPages.value];
9735
9793
  const idx = copyPages.findIndex(item => item.name === tab.name && tab.uniqueKey === item.uniqueKey);
9736
9794
  if (idx !== -1) {
@@ -9763,6 +9821,7 @@ const getDetailContainer = () => defineComponent({
9763
9821
  uniqueKey: dataId.value,
9764
9822
  icon: props.icon,
9765
9823
  isExtraTab: true,
9824
+ type: "extraTab",
9766
9825
  params: _.omit(route.query, "name")
9767
9826
  };
9768
9827
  const detail = detailList.value.find(item => item.key + item.uniqueKey === tab.key + tab.uniqueKey);
@@ -9983,6 +10042,7 @@ const VideoPlayerV2 = defineComponent({
9983
10042
  if ("stopPlay" in play) {
9984
10043
  play.stopPlay(`videoPlayer_${uuid}`);
9985
10044
  }
10045
+ release();
9986
10046
  };
9987
10047
  const init = () => {
9988
10048
  let camera = videoInfo2.value;
@@ -5982,6 +5982,7 @@ const VideoPlayerV2 = vue.defineComponent({
5982
5982
  if ("stopPlay" in play) {
5983
5983
  play.stopPlay(`videoPlayer_${uuid}`);
5984
5984
  }
5985
+ release();
5985
5986
  };
5986
5987
  const init = () => {
5987
5988
  let camera = videoInfo2.value;
@@ -5954,6 +5954,7 @@ const VideoPlayerV2 = defineComponent({
5954
5954
  if ("stopPlay" in play) {
5955
5955
  play.stopPlay(`videoPlayer_${uuid}`);
5956
5956
  }
5957
+ release();
5957
5958
  };
5958
5959
  const init = () => {
5959
5960
  let camera = videoInfo2.value;
@@ -5957,6 +5957,7 @@ const VideoPlayerV2 = vue.defineComponent({
5957
5957
  if ("stopPlay" in play) {
5958
5958
  play.stopPlay(`videoPlayer_${uuid}`);
5959
5959
  }
5960
+ release();
5960
5961
  };
5961
5962
  const init = () => {
5962
5963
  let camera = videoInfo2.value;
@@ -5949,6 +5949,7 @@ const VideoPlayerV2 = defineComponent({
5949
5949
  if ("stopPlay" in play) {
5950
5950
  play.stopPlay(`videoPlayer_${uuid}`);
5951
5951
  }
5952
+ release();
5952
5953
  };
5953
5954
  const init = () => {
5954
5955
  let camera = videoInfo2.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inl-ui",
3
- "version": "0.1.170",
3
+ "version": "0.1.172",
4
4
  "description": "工业 pc ui库",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",