This commit is contained in:
dap
2024-09-12 07:47:12 +08:00
22 changed files with 697 additions and 244 deletions

View File

@@ -32,9 +32,13 @@
body,
html {
@apply size-full overscroll-none;
/* scrollbar-gutter: stable; */
}
body {
@apply !pointer-events-auto;
min-height: 100vh;
/* overflow: overlay; */
@@ -90,6 +94,7 @@
}
/* 只有非mac下才进行调整mac下使用默认滚动条 */
html:not([data-platform='macOs']) {
::-webkit-scrollbar {
@apply h-[10px] w-[10px];

View File

@@ -71,6 +71,7 @@
"dependencies": {
"@ctrl/tinycolor": "^4.1.0",
"@tanstack/vue-store": "^0.5.5",
"@vue/reactivity": "^3.5.4",
"@vue/shared": "^3.5.4",
"clsx": "^2.1.1",
"defu": "^6.1.4",

View File

@@ -5,6 +5,7 @@ export * from './inference';
export * from './letter';
export * from './merge';
export * from './nprogress';
export * from './reactivity';
export * from './state-handler';
export * from './to';
export * from './tree';

View File

@@ -0,0 +1,26 @@
import { isProxy, isReactive, isRef, toRaw } from '@vue/reactivity';
function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {
const objectIterator = (input: any): any => {
if (Array.isArray(input)) {
return input.map((item) => objectIterator(item));
}
if (isRef(input) || isReactive(input) || isProxy(input)) {
return objectIterator(toRaw(input));
}
if (input && typeof input === 'object') {
const result = {} as T;
for (const key in input) {
if (Object.prototype.hasOwnProperty.call(input, key)) {
result[key as keyof T] = objectIterator(input[key]);
}
}
return result;
}
return input;
};
return objectIterator(sourceObj);
}
export { deepToRaw };

View File

@@ -41,6 +41,7 @@ export class ModalApi {
isOpen: false,
loading: false,
modal: true,
openAutoFocus: false,
showCancelButton: true,
showConfirmButton: true,
title: '',

View File

@@ -75,6 +75,10 @@ export interface ModalProps {
* @default true
*/
modal?: boolean;
/**
* 是否自动聚焦
*/
openAutoFocus?: boolean;
/**
* 是否显示取消按钮
* @default true

View File

@@ -68,6 +68,7 @@ const {
header,
loading: showLoading,
modal,
openAutoFocus,
showCancelButton,
showConfirmButton,
title,
@@ -133,6 +134,13 @@ function escapeKeyDown(e: KeyboardEvent) {
e.preventDefault();
}
}
function handerOpenAutoFocus(e: Event) {
if (!openAutoFocus.value) {
e?.preventDefault();
}
}
// pointer-down-outside
function pointerDownOutside(e: Event) {
const target = e.target as HTMLElement;
@@ -166,6 +174,7 @@ function pointerDownOutside(e: Event) {
close-class="top-3"
@escape-key-down="escapeKeyDown"
@interact-outside="interactOutside"
@open-auto-focus="handerOpenAutoFocus"
@pointer-down-outside="pointerDownOutside"
>
<DialogHeader

View File

@@ -40,6 +40,7 @@
"@vben-core/composables": "workspace:*",
"@vben-core/icons": "workspace:*",
"@vben-core/shadcn-ui": "workspace:*",
"@vben-core/shared": "workspace:*",
"@vben-core/typings": "workspace:*",
"@vueuse/core": "^11.0.3",
"vue": "^3.5.4"

View File

@@ -7,6 +7,7 @@ import { computed, ref } from 'vue';
import { Pin, X } from '@vben-core/icons';
import { VbenContextMenu, VbenIcon } from '@vben-core/shadcn-ui';
import { deepToRaw } from '@vben-core/shared/utils';
interface Props extends TabsProps {}
@@ -40,7 +41,8 @@ const style = computed(() => {
});
const tabsView = computed((): TabConfig[] => {
return props.tabs.map((tab) => {
return props.tabs.map((_tab) => {
const tab = deepToRaw(_tab);
return {
...tab,
affixTab: !!tab.meta?.affixTab,

View File

@@ -7,6 +7,7 @@ import { computed } from 'vue';
import { Pin, X } from '@vben-core/icons';
import { VbenContextMenu, VbenIcon } from '@vben-core/shadcn-ui';
import { deepToRaw } from '@vben-core/shared/utils';
interface Props extends TabsProps {}
@@ -46,7 +47,8 @@ const typeWithClass = computed(() => {
});
const tabsView = computed((): TabConfig[] => {
return props.tabs.map((tab) => {
return props.tabs.map((_tab) => {
const tab = deepToRaw(_tab);
return {
...tab,
affixTab: !!tab.meta?.affixTab,