@oeos-components/utils 0.0.23 → 0.0.25
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/base.cjs +43 -7
- package/dist/base.d.cts +5 -1
- package/dist/base.d.mts +5 -1
- package/dist/base.d.ts +5 -1
- package/dist/base.mjs +43 -7
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
|
@@ -624,28 +624,64 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
624
624
|
};
|
|
625
625
|
return _debounce;
|
|
626
626
|
}
|
|
627
|
-
function confirm(message, options) {
|
|
627
|
+
function confirm(message, options = {}, appContext = null) {
|
|
628
628
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
629
|
-
const
|
|
629
|
+
const resolvedAppendTo = _resolveAppendTarget(options?.appendTo);
|
|
630
|
+
const resolvedAppContext = _resolveAppContext(options?.appContext || appContext);
|
|
630
631
|
const mergeOptions = {
|
|
631
632
|
title: "\u63D0\u793A",
|
|
632
633
|
draggable: true,
|
|
633
634
|
showCancelButton: false,
|
|
634
635
|
confirmButtonText: "\u786E\u5B9A",
|
|
635
636
|
dangerouslyUseHTMLString: true,
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
...options
|
|
637
|
+
...options,
|
|
638
|
+
appendTo: resolvedAppendTo,
|
|
639
|
+
appContext: resolvedAppContext
|
|
640
640
|
};
|
|
641
641
|
return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
642
642
|
}
|
|
643
|
+
function _resolveAppendTarget(appendTo) {
|
|
644
|
+
if (typeof document === "undefined") {
|
|
645
|
+
return appendTo;
|
|
646
|
+
}
|
|
647
|
+
if (appendTo instanceof HTMLElement) {
|
|
648
|
+
return appendTo;
|
|
649
|
+
}
|
|
650
|
+
if (typeof appendTo === "string" && appendTo.trim()) {
|
|
651
|
+
const rawSelector = appendTo.trim();
|
|
652
|
+
try {
|
|
653
|
+
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
654
|
+
return document.querySelector(selector) || appendTo;
|
|
655
|
+
} catch (error) {
|
|
656
|
+
return appendTo;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const overlayList = Array.from(document.querySelectorAll(".el-overlay"));
|
|
660
|
+
const dialogOverlay = overlayList.filter((item) => {
|
|
661
|
+
if (!item.isConnected || item.style.display === "none") {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
const containsDialog = item.querySelector(".el-dialog, .el-drawer");
|
|
665
|
+
const containsMessageBox = item.querySelector(".el-message-box");
|
|
666
|
+
return !!containsDialog && !containsMessageBox;
|
|
667
|
+
}).at(-1);
|
|
668
|
+
return dialogOverlay || appendTo;
|
|
669
|
+
}
|
|
670
|
+
function _resolveAppContext(appContext) {
|
|
671
|
+
if (appContext) {
|
|
672
|
+
return appContext;
|
|
673
|
+
}
|
|
674
|
+
if (typeof document === "undefined") {
|
|
675
|
+
return elementPlus.ElMessageBox.install?.context || elementPlus.ElMessageBox._context;
|
|
676
|
+
}
|
|
677
|
+
return elementPlus.ElMessageBox.install?.context || elementPlus.ElMessageBox._context || document.querySelector("#app")?._vue_app?._context;
|
|
678
|
+
}
|
|
643
679
|
function getVariable(propertyName) {
|
|
644
680
|
let res = getComputedStyle(document.documentElement).getPropertyValue(propertyName).trim();
|
|
645
681
|
return res;
|
|
646
682
|
}
|
|
647
683
|
function test() {
|
|
648
|
-
return
|
|
684
|
+
return `build time: ${"2026-04-04 18:19:03"}`;
|
|
649
685
|
}
|
|
650
686
|
|
|
651
687
|
exports.$toast = $toast;
|
package/dist/base.d.cts
CHANGED
|
@@ -326,9 +326,13 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
326
326
|
};
|
|
327
327
|
/**
|
|
328
328
|
* proxy.confirm('确定删除吗?')
|
|
329
|
+
*
|
|
329
330
|
* proxy.confirm('哈哈', { icon: 'el-icon-plus' })
|
|
331
|
+
*
|
|
330
332
|
* close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
|
|
333
|
+
*
|
|
331
334
|
* lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
|
|
335
|
+
*
|
|
332
336
|
* 设置宽度, 内容使用组件
|
|
333
337
|
import GWarning from '@/autoComponents/gWarning.vue'
|
|
334
338
|
await proxy.confirm('', {
|
|
@@ -346,7 +350,7 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
346
350
|
})
|
|
347
351
|
* 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
|
|
348
352
|
*/
|
|
349
|
-
declare function confirm(message: any, options
|
|
353
|
+
declare function confirm(message: any, options?: {}, appContext?: null): Promise<element_plus.MessageBoxData>;
|
|
350
354
|
/** Function to get a CSS custom property value
|
|
351
355
|
*
|
|
352
356
|
* getVariable('--blue');
|
package/dist/base.d.mts
CHANGED
|
@@ -326,9 +326,13 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
326
326
|
};
|
|
327
327
|
/**
|
|
328
328
|
* proxy.confirm('确定删除吗?')
|
|
329
|
+
*
|
|
329
330
|
* proxy.confirm('哈哈', { icon: 'el-icon-plus' })
|
|
331
|
+
*
|
|
330
332
|
* close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
|
|
333
|
+
*
|
|
331
334
|
* lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
|
|
335
|
+
*
|
|
332
336
|
* 设置宽度, 内容使用组件
|
|
333
337
|
import GWarning from '@/autoComponents/gWarning.vue'
|
|
334
338
|
await proxy.confirm('', {
|
|
@@ -346,7 +350,7 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
346
350
|
})
|
|
347
351
|
* 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
|
|
348
352
|
*/
|
|
349
|
-
declare function confirm(message: any, options
|
|
353
|
+
declare function confirm(message: any, options?: {}, appContext?: null): Promise<element_plus.MessageBoxData>;
|
|
350
354
|
/** Function to get a CSS custom property value
|
|
351
355
|
*
|
|
352
356
|
* getVariable('--blue');
|
package/dist/base.d.ts
CHANGED
|
@@ -326,9 +326,13 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
326
326
|
};
|
|
327
327
|
/**
|
|
328
328
|
* proxy.confirm('确定删除吗?')
|
|
329
|
+
*
|
|
329
330
|
* proxy.confirm('哈哈', { icon: 'el-icon-plus' })
|
|
331
|
+
*
|
|
330
332
|
* close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
|
|
333
|
+
*
|
|
331
334
|
* lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
|
|
335
|
+
*
|
|
332
336
|
* 设置宽度, 内容使用组件
|
|
333
337
|
import GWarning from '@/autoComponents/gWarning.vue'
|
|
334
338
|
await proxy.confirm('', {
|
|
@@ -346,7 +350,7 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
346
350
|
})
|
|
347
351
|
* 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
|
|
348
352
|
*/
|
|
349
|
-
declare function confirm(message: any, options
|
|
353
|
+
declare function confirm(message: any, options?: {}, appContext?: null): Promise<element_plus.MessageBoxData>;
|
|
350
354
|
/** Function to get a CSS custom property value
|
|
351
355
|
*
|
|
352
356
|
* getVariable('--blue');
|
package/dist/base.mjs
CHANGED
|
@@ -622,28 +622,64 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
622
622
|
};
|
|
623
623
|
return _debounce;
|
|
624
624
|
}
|
|
625
|
-
function confirm(message, options) {
|
|
625
|
+
function confirm(message, options = {}, appContext = null) {
|
|
626
626
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
627
|
-
const
|
|
627
|
+
const resolvedAppendTo = _resolveAppendTarget(options?.appendTo);
|
|
628
|
+
const resolvedAppContext = _resolveAppContext(options?.appContext || appContext);
|
|
628
629
|
const mergeOptions = {
|
|
629
630
|
title: "\u63D0\u793A",
|
|
630
631
|
draggable: true,
|
|
631
632
|
showCancelButton: false,
|
|
632
633
|
confirmButtonText: "\u786E\u5B9A",
|
|
633
634
|
dangerouslyUseHTMLString: true,
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
...options
|
|
635
|
+
...options,
|
|
636
|
+
appendTo: resolvedAppendTo,
|
|
637
|
+
appContext: resolvedAppContext
|
|
638
638
|
};
|
|
639
639
|
return ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
640
640
|
}
|
|
641
|
+
function _resolveAppendTarget(appendTo) {
|
|
642
|
+
if (typeof document === "undefined") {
|
|
643
|
+
return appendTo;
|
|
644
|
+
}
|
|
645
|
+
if (appendTo instanceof HTMLElement) {
|
|
646
|
+
return appendTo;
|
|
647
|
+
}
|
|
648
|
+
if (typeof appendTo === "string" && appendTo.trim()) {
|
|
649
|
+
const rawSelector = appendTo.trim();
|
|
650
|
+
try {
|
|
651
|
+
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
652
|
+
return document.querySelector(selector) || appendTo;
|
|
653
|
+
} catch (error) {
|
|
654
|
+
return appendTo;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const overlayList = Array.from(document.querySelectorAll(".el-overlay"));
|
|
658
|
+
const dialogOverlay = overlayList.filter((item) => {
|
|
659
|
+
if (!item.isConnected || item.style.display === "none") {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
const containsDialog = item.querySelector(".el-dialog, .el-drawer");
|
|
663
|
+
const containsMessageBox = item.querySelector(".el-message-box");
|
|
664
|
+
return !!containsDialog && !containsMessageBox;
|
|
665
|
+
}).at(-1);
|
|
666
|
+
return dialogOverlay || appendTo;
|
|
667
|
+
}
|
|
668
|
+
function _resolveAppContext(appContext) {
|
|
669
|
+
if (appContext) {
|
|
670
|
+
return appContext;
|
|
671
|
+
}
|
|
672
|
+
if (typeof document === "undefined") {
|
|
673
|
+
return ElMessageBox.install?.context || ElMessageBox._context;
|
|
674
|
+
}
|
|
675
|
+
return ElMessageBox.install?.context || ElMessageBox._context || document.querySelector("#app")?._vue_app?._context;
|
|
676
|
+
}
|
|
641
677
|
function getVariable(propertyName) {
|
|
642
678
|
let res = getComputedStyle(document.documentElement).getPropertyValue(propertyName).trim();
|
|
643
679
|
return res;
|
|
644
680
|
}
|
|
645
681
|
function test() {
|
|
646
|
-
return
|
|
682
|
+
return `build time: ${"2026-04-04 18:19:03"}`;
|
|
647
683
|
}
|
|
648
684
|
|
|
649
685
|
export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getVariable, isEmpty, log, merge, notEmpty, processWidth, random, setStorage, sleep, test, throttle, toLine, tryCatch, uuid, validForm, validate, validateTrigger };
|