Merge branch 'main' of github.com:DesignHhuang/vue-vben-admin
| | |
| | | { |
| | | "name": "vben-admin", |
| | | "version": "2.10.0", |
| | | "version": "2.10.1", |
| | | "homepage": "https://github.com/vbenjs/vue-vben-admin", |
| | | "bugs": { |
| | | "url": "https://github.com/vbenjs/vue-vben-admin/issues" |
| | |
| | | import type { Ref } from 'vue'; |
| | | import type { ComponentPublicInstance, Ref } from 'vue'; |
| | | import { onBeforeUpdate, shallowRef } from 'vue'; |
| | | |
| | | function useRefs<T = HTMLElement>(): { |
| | | refs: Ref<T[]>; |
| | | setRefs: (index: number) => (el: T) => void; |
| | | setRefs: (index: number) => (el: Element | ComponentPublicInstance | null) => void; |
| | | } { |
| | | const refs = shallowRef([]) as Ref<T[]>; |
| | | |
| | |
| | | refs.value = []; |
| | | }); |
| | | |
| | | const setRefs = (index: number) => (el: T) => { |
| | | refs.value[index] = el; |
| | | const setRefs = (index: number) => (el: Element | ComponentPublicInstance | null) => { |
| | | refs.value[index] = el as T; |
| | | }; |
| | | |
| | | return { |
| | |
| | | const left = body.clientWidth < x + menuWidth ? x - menuWidth : x; |
| | | const top = body.clientHeight < y + menuHeight ? y - menuHeight : y; |
| | | return { |
| | | ...styles, |
| | | position: 'absolute', |
| | | width: `${width}px`, |
| | | left: `${left + 1}px`, |
| | | top: `${top + 1}px`, |
| | | zIndex: 9999, |
| | | ...styles, // Not the first, fix options.styles.width not working |
| | | }; |
| | | }); |
| | | |
| | |
| | | } |
| | | const { items } = props; |
| | | return ( |
| | | <div class={prefixCls}> |
| | | <Menu inlineIndent={12} mode="vertical" ref={wrapRef} style={unref(getStyle)}> |
| | | {renderMenuItem(items)} |
| | | </Menu> |
| | | </div> |
| | | <Menu |
| | | inlineIndent={12} |
| | | mode="vertical" |
| | | class={prefixCls} |
| | | ref={wrapRef} |
| | | style={unref(getStyle)} |
| | | > |
| | | {renderMenuItem(items)} |
| | | </Menu> |
| | | ); |
| | | }; |
| | | }, |
| | |
| | | .item-style() { |
| | | li { |
| | | display: inline-block; |
| | | width: 100%; |
| | | width: 100% !important; |
| | | height: @default-height; |
| | | margin: 0 !important; |
| | | line-height: @default-height; |
| | |
| | | } |
| | | |
| | | > div { |
| | | width: 100% !important; |
| | | height: 100% !important; |
| | | margin: 0 !important; |
| | | } |
| | | |
| | |
| | | width: 156px; |
| | | margin: 0; |
| | | border: 1px solid rgb(0 0 0 / 8%); |
| | | border-radius: 0.25rem; |
| | | border-radius: 8px; |
| | | background-clip: padding-box; |
| | | background-color: @component-background; |
| | | box-shadow: 0 2px 2px 0 rgb(0 0 0 / 14%), 0 3px 1px -2px rgb(0 0 0 / 10%), |
| | | box-shadow: |
| | | 0 2px 2px 0 rgb(0 0 0 / 14%), |
| | | 0 3px 1px -2px rgb(0 0 0 / 10%), |
| | | 0 1px 5px 0 rgb(0 0 0 / 6%); |
| | | list-style: none; |
| | | user-select: none; |
| | |
| | | <template> |
| | | <Drawer :rootClassName="prefixCls" @close="onClose" v-bind="getBindValues"> |
| | | <Drawer @close="onClose" v-bind="getBindValues"> |
| | | <template #title v-if="!$slots.title"> |
| | | <DrawerHeader |
| | | :title="getMergeProps.title" |
| | |
| | | import type { ScrollContainerOptions } from '/@/components/Container/index'; |
| | | |
| | | export interface DrawerInstance { |
| | | setDrawerProps: (props: Partial<DrawerProps> | boolean) => void; |
| | | setDrawerProps: (props: Partial<DrawerProps>) => void; |
| | | emitOpen?: (open: boolean, uid: number) => void; |
| | | } |
| | | |
| | |
| | | getOpen?: ComputedRef<boolean>; |
| | | } |
| | | |
| | | export type RegisterFn = (drawerInstance: DrawerInstance, uuid?: string) => void; |
| | | export type RegisterFn = (drawerInstance: DrawerInstance, uuid: number) => void; |
| | | |
| | | export interface ReturnInnerMethods extends DrawerInstance { |
| | | closeDrawer: () => void; |
| | |
| | | * @default 'body' |
| | | * @type any ( HTMLElement| () => HTMLElement | string) |
| | | */ |
| | | getContainer?: () => HTMLElement | string; |
| | | getContainer?: string | false | HTMLElement | (() => HTMLElement); |
| | | |
| | | /** |
| | | * Whether to show mask or not. |
| | |
| | | } |
| | | const drawer = ref<DrawerInstance | null>(null); |
| | | const loaded = ref<Nullable<boolean>>(false); |
| | | const uid = ref<string>(''); |
| | | const uid = ref<number>(0); |
| | | |
| | | function register(drawerInstance: DrawerInstance, uuid: string) { |
| | | function register(drawerInstance: DrawerInstance, uuid: number) { |
| | | isProdMode() && |
| | | tryOnUnmounted(() => { |
| | | drawer.value = null; |
| | |
| | | export const useDrawerInner = (callbackFn?: Fn): UseDrawerInnerReturnType => { |
| | | const drawerInstanceRef = ref<Nullable<DrawerInstance>>(null); |
| | | const currentInstance = getCurrentInstance(); |
| | | const uidRef = ref<string>(''); |
| | | const uidRef = ref<number>(0); |
| | | |
| | | if (!getCurrentInstance()) { |
| | | throw new Error('useDrawerInner() can only be used inside setup() or functional components!'); |
| | |
| | | return instance; |
| | | }; |
| | | |
| | | const register = (modalInstance: DrawerInstance, uuid: string) => { |
| | | const register = (modalInstance: DrawerInstance, uuid: number) => { |
| | | isProdMode() && |
| | | tryOnUnmounted(() => { |
| | | drawerInstanceRef.value = null; |
| | |
| | | getInstance()?.setDrawerProps({ open: false }); |
| | | }, |
| | | |
| | | setDrawerProps: (props: Partial<DrawerProps> | boolean) => { |
| | | setDrawerProps: (props: Partial<DrawerProps>) => { |
| | | getInstance()?.setDrawerProps(props); |
| | | }, |
| | | }, |
| | |
| | | } |
| | | |
| | | function handleChange(_, ...args) { |
| | | emit('change', args[0] ? args[0].value : undefined); |
| | | emitData.value = args; |
| | | } |
| | | |
| | |
| | | <template #[item]="data" v-for="item in Object.keys($slots)"> |
| | | <slot :name="item" v-bind="data || {}"></slot> |
| | | </template> |
| | | <template #suffixIcon v-if="loading"> |
| | | <LoadingOutlined spin /> |
| | | </template> |
| | | </a-tree> |
| | | </template> |
| | | |
| | |
| | | import { isArray, isFunction } from '/@/utils/is'; |
| | | import { get } from 'lodash-es'; |
| | | import { propTypes } from '/@/utils/propTypes'; |
| | | import { LoadingOutlined } from '@ant-design/icons-vue'; |
| | | import { DataNode } from 'ant-design-vue/es/tree'; |
| | | |
| | | export default defineComponent({ |
| | | name: 'ApiTree', |
| | | components: { ATree: Tree, LoadingOutlined }, |
| | | components: { ATree: Tree }, |
| | | props: { |
| | | api: { type: Function as PropType<(arg?: Recordable<any>) => Promise<Recordable<any>>> }, |
| | | params: { type: Object }, |
| | |
| | | }, |
| | | emits: ['options-change', 'change'], |
| | | setup(props, { attrs, emit }) { |
| | | const treeData = ref<Recordable<any>[]>([]); |
| | | const treeData = ref<DataNode[]>([]); |
| | | const isFirstLoaded = ref<Boolean>(false); |
| | | const loading = ref(false); |
| | | const getAttrs = computed(() => { |
| | |
| | | |
| | | <script lang="ts"> |
| | | import { type Recordable } from '@vben/types'; |
| | | import { |
| | | type PropType, |
| | | computed, |
| | | defineComponent, |
| | | watchEffect, |
| | | watch, |
| | | ref, |
| | | onMounted, |
| | | unref, |
| | | } from 'vue'; |
| | | import { type PropType, computed, defineComponent, watch, ref, onMounted, unref } from 'vue'; |
| | | import { TreeSelect } from 'ant-design-vue'; |
| | | import { isArray, isFunction } from '/@/utils/is'; |
| | | import { get } from 'lodash-es'; |
| | |
| | | 'Upload', |
| | | 'ApiTransfer', |
| | | 'ApiTree', |
| | | 'ApiSelect', |
| | | 'ApiTreeSelect', |
| | | 'ApiRadioGroup', |
| | | 'ApiCascader', |
| | |
| | | |
| | | let stopElResizeFn: AnyFunction = () => {}; |
| | | |
| | | useWindowSizeFn(setModalHeight.bind(null, false)); |
| | | useWindowSizeFn(setModalHeight.bind(null)); |
| | | |
| | | useMutationObserver( |
| | | spinRef, |
| | |
| | | export function useModal(): UseModalReturnType { |
| | | const modal = ref<Nullable<ModalMethods>>(null); |
| | | const loaded = ref<Nullable<boolean>>(false); |
| | | const uid = ref<string>(''); |
| | | const uid = ref<number>(0); |
| | | |
| | | function register(modalMethod: ModalMethods, uuid: string) { |
| | | function register(modalMethod: ModalMethods, uuid: number) { |
| | | if (!getCurrentInstance()) { |
| | | throw new Error('useModal() can only be used inside setup() or functional components!'); |
| | | } |
| | |
| | | onUnmounted(() => { |
| | | modal.value = null; |
| | | loaded.value = false; |
| | | dataTransfer[unref(uid)] = null; |
| | | dataTransfer[String(unref(uid))] = null; |
| | | }); |
| | | if (unref(loaded) && isProdMode() && modalMethod === unref(modal)) return; |
| | | |
| | |
| | | export const useModalInner = (callbackFn?: Fn): UseModalInnerReturnType => { |
| | | const modalInstanceRef = ref<Nullable<ModalMethods>>(null); |
| | | const currentInstance = getCurrentInstance(); |
| | | const uidRef = ref<string>(''); |
| | | const uidRef = ref<number>(0); |
| | | |
| | | const getInstance = () => { |
| | | const instance = unref(modalInstanceRef); |
| | |
| | | return instance; |
| | | }; |
| | | |
| | | const register = (modalInstance: ModalMethods, uuid: string) => { |
| | | const register = (modalInstance: ModalMethods, uuid: number) => { |
| | | isProdMode() && |
| | | tryOnUnmounted(() => { |
| | | modalInstanceRef.value = null; |
| | |
| | | height: 100%; |
| | | } |
| | | } |
| | | |
| | | .ant-modal-footer { |
| | | margin-top: 0; |
| | | } |
| | | } |
| | | |
| | | .vben-basic-modal-wrap .ant-modal { |
| | |
| | | redoModalHeight?: () => void; |
| | | } |
| | | |
| | | export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void; |
| | | export type RegisterFn = (modalMethods: ModalMethods, uuid: number) => void; |
| | | |
| | | export interface ReturnMethods extends ModalMethods { |
| | | openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void; |
| | |
| | | :rowClassName="getRowClassName" |
| | | v-show="getEmptyDataIsShowTable" |
| | | @change="handleTableChange" |
| | | @resizeColumn="setColumnWidth" |
| | | > |
| | | <template #[item]="data" v-for="item in Object.keys($slots)" :key="item"> |
| | | <slot :name="item" v-bind="data || {}"></slot> |
| | |
| | | getColumns, |
| | | setCacheColumnsByField, |
| | | setCacheColumns, |
| | | setColumnWidth, |
| | | setColumns, |
| | | getColumnsRef, |
| | | getCacheColumns, |
| | |
| | | handleSearchInfoChange, |
| | | getEmptyDataIsShowTable, |
| | | handleTableChange, |
| | | setColumnWidth, |
| | | getRowClassName, |
| | | wrapRef, |
| | | tableAction, |
| | |
| | | if (!isArray(columns)) return; |
| | | cacheColumns = columns.filter((item) => !item.flag); |
| | | } |
| | | /** |
| | | * 拖拽列宽修改列的宽度 |
| | | */ |
| | | function setColumnWidth(w: number, col: BasicColumn) { |
| | | col.width = w; |
| | | } |
| | | |
| | | return { |
| | | getColumnsRef, |
| | | getCacheColumns, |
| | | getColumns, |
| | | setColumns, |
| | | setColumnWidth, |
| | | getViewColumns, |
| | | setCacheColumnsByField, |
| | | setCacheColumns, |