diff --git a/src/components/ContextMenu/index.ts b/src/components/ContextMenu/index.ts index 31e385ac2c54322f111ea178a43a3ec4c48263bd..ed294d7bb20ed8dd148adf856fda84e07deb05f2 100644 --- a/src/components/ContextMenu/index.ts +++ b/src/components/ContextMenu/index.ts @@ -1,3 +1,3 @@ export { createContextMenu, destroyContextMenu } from './src/createContextMenu'; -export * from './src/types'; +export * from './src/typing'; diff --git a/src/components/ContextMenu/src/ContextMenu.tsx b/src/components/ContextMenu/src/ContextMenu.tsx deleted file mode 100644 index 3fb2d9642c69baae14670a1d87ebc4fc08e1514e..0000000000000000000000000000000000000000 --- a/src/components/ContextMenu/src/ContextMenu.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import './index.less'; - -import type { ContextMenuItem, ItemContentProps } from './types'; -import type { FunctionalComponent, CSSProperties } from 'vue'; - -import { defineComponent, nextTick, onMounted, computed, ref, unref, onUnmounted } from 'vue'; - -import Icon from '/@/components/Icon'; -import { Menu, Divider } from 'ant-design-vue'; - -import { contextMenuProps } from './props'; - -const prefixCls = 'context-menu'; - -const ItemContent: FunctionalComponent = (props) => { - const { item } = props; - return ( - - {props.showIcon && item.icon && } - {item.label} - - ); -}; - -export default defineComponent({ - name: 'ContextMenu', - props: contextMenuProps, - setup(props) { - const wrapRef = ref(null); - const showRef = ref(false); - - const getStyle = computed((): CSSProperties => { - const { axis, items, styles, width } = props; - const { x, y } = axis || { x: 0, y: 0 }; - const menuHeight = (items || []).length * 40; - const menuWidth = width; - const body = document.body; - - const left = body.clientWidth < x + menuWidth ? x - menuWidth : x; - const top = body.clientHeight < y + menuHeight ? y - menuHeight : y; - return { - ...styles, - width: `${width}px`, - left: `${left + 1}px`, - top: `${top + 1}px`, - }; - }); - - onMounted(() => { - nextTick(() => (showRef.value = true)); - }); - - onUnmounted(() => { - const el = unref(wrapRef); - el && document.body.removeChild(el); - }); - - function handleAction(item: ContextMenuItem, e: MouseEvent) { - const { handler, disabled } = item; - if (disabled) return; - showRef.value = false; - - e?.stopPropagation(); - e?.preventDefault(); - handler?.(); - } - - function renderMenuItem(items: ContextMenuItem[]) { - return items.map((item) => { - const { disabled, label, children, divider = false } = item; - - const DividerComp = divider ? : null; - if (!children || children.length === 0) { - return ( - <> - - - - {DividerComp} - - ); - } - if (!unref(showRef)) return null; - - return ( - - {{ - title: () => ( - - ), - default: () => renderMenuItem(children), - }} - - ); - }); - } - return () => { - const { items } = props; - if (!unref(showRef)) return null; - return ( - - {renderMenuItem(items)} - - ); - }; - }, -}); diff --git a/src/components/ContextMenu/src/ContextMenu.vue b/src/components/ContextMenu/src/ContextMenu.vue new file mode 100644 index 0000000000000000000000000000000000000000..da8ee55445c7b3e1cbf19227f2b45a194ee155c7 --- /dev/null +++ b/src/components/ContextMenu/src/ContextMenu.vue @@ -0,0 +1,204 @@ + + diff --git a/src/components/ContextMenu/src/createContextMenu.ts b/src/components/ContextMenu/src/createContextMenu.ts index 5fc3ed456a3c183e6468c0d15c32124d80b6efce..8f7a1c82bb3955f738297b42a41150ecb4134518 100644 --- a/src/components/ContextMenu/src/createContextMenu.ts +++ b/src/components/ContextMenu/src/createContextMenu.ts @@ -1,6 +1,6 @@ -import contextMenuVue from './ContextMenu'; +import contextMenuVue from './ContextMenu.vue'; import { isClient } from '/@/utils/is'; -import { CreateContextOptions, ContextMenuProps } from './types'; +import { CreateContextOptions, ContextMenuProps } from './typing'; import { createVNode, render } from 'vue'; const menuManager: { @@ -16,7 +16,9 @@ export const createContextMenu = function (options: CreateContextOptions) { event && event?.preventDefault(); - if (!isClient) return; + if (!isClient) { + return; + } return new Promise((resolve) => { const body = document.body; @@ -54,9 +56,9 @@ export const createContextMenu = function (options: CreateContextOptions) { body.removeEventListener('scroll', handleClick); }; - menuManager.resolve = function (...arg: any) { + menuManager.resolve = function (arg) { remove(); - resolve(arg[0]); + resolve(arg); }; remove(); body.appendChild(container); diff --git a/src/components/ContextMenu/src/index.less b/src/components/ContextMenu/src/index.less deleted file mode 100644 index 3d8dec03e352c281be1dd20ebae66813b43473d9..0000000000000000000000000000000000000000 --- a/src/components/ContextMenu/src/index.less +++ /dev/null @@ -1,65 +0,0 @@ -@default-height: 42px !important; - -@small-height: 36px !important; - -@large-height: 36px !important; - -.item-style() { - li { - display: inline-block; - width: 100%; - height: @default-height; - margin: 0 !important; - line-height: @default-height; - - span { - line-height: @default-height; - } - - > div { - margin: 0 !important; - } - - &:not(.ant-menu-item-disabled):hover { - color: @text-color-base; - background-color: @item-hover-bg; - } - } -} - -.context-menu { - position: fixed; - top: 0; - left: 0; - z-index: 200; - display: block; - width: 156px; - margin: 0; - list-style: none; - background-color: @component-background; - border: 1px solid rgba(0, 0, 0, 0.08); - border-radius: 0.25rem; - box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.1), - 0 1px 5px 0 rgba(0, 0, 0, 0.06); - background-clip: padding-box; - user-select: none; - - .item-style(); - - .ant-divider { - margin: 0 0; - } - - &__popup { - .ant-divider { - margin: 0 0; - } - - .item-style(); - } - - .ant-menu-submenu-title, - .ant-menu-item { - padding: 0 !important; - } -} diff --git a/src/components/ContextMenu/src/props.ts b/src/components/ContextMenu/src/props.ts deleted file mode 100644 index 509b424f6dda41e9b78b9e6d3d71a23bbb50ad71..0000000000000000000000000000000000000000 --- a/src/components/ContextMenu/src/props.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { PropType } from 'vue'; -import type { Axis, ContextMenuItem } from './types'; -import { propTypes } from '/@/utils/propTypes'; -export const contextMenuProps = { - width: propTypes.number.def(156), - customEvent: { - type: Object as PropType, - default: null, - }, - styles: propTypes.style, - showIcon: propTypes.bool.def(true), - axis: { - // The position of the right mouse button click - type: Object as PropType, - default() { - return { x: 0, y: 0 }; - }, - }, - items: { - // The most important list, if not, will not be displayed - type: Array as PropType, - default() { - return []; - }, - }, -}; diff --git a/src/components/ContextMenu/src/types.ts b/src/components/ContextMenu/src/typing.ts similarity index 100% rename from src/components/ContextMenu/src/types.ts rename to src/components/ContextMenu/src/typing.ts diff --git a/src/components/Drawer/src/BasicDrawer.vue b/src/components/Drawer/src/BasicDrawer.vue index 6e451bf1fd864c13e40fb187751593ec0080146c..b88c2ddc438a4abce469ee8309a8540c523cdca0 100644 --- a/src/components/Drawer/src/BasicDrawer.vue +++ b/src/components/Drawer/src/BasicDrawer.vue @@ -81,46 +81,40 @@ instance && emit('register', drawerInstance, instance.uid); - const getMergeProps = computed( - (): DrawerProps => { - return deepMerge(toRaw(props), unref(propsRef)); - } - ); + const getMergeProps = computed((): DrawerProps => { + return deepMerge(toRaw(props), unref(propsRef)); + }); - const getProps = computed( - (): DrawerProps => { - const opt = { - placement: 'right', - ...unref(attrs), - ...unref(getMergeProps), - visible: unref(visibleRef), - }; - opt.title = undefined; - const { isDetail, width, wrapClassName, getContainer } = opt; - if (isDetail) { - if (!width) { - opt.width = '100%'; - } - const detailCls = `${prefixCls}__detail`; - opt.wrapClassName = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls; - - if (!getContainer) { - // TODO type error? - opt.getContainer = `.${prefixVar}-layout-content` as any; - } + const getProps = computed((): DrawerProps => { + const opt = { + placement: 'right', + ...unref(attrs), + ...unref(getMergeProps), + visible: unref(visibleRef), + }; + opt.title = undefined; + const { isDetail, width, wrapClassName, getContainer } = opt; + if (isDetail) { + if (!width) { + opt.width = '100%'; } - return opt as DrawerProps; - } - ); + const detailCls = `${prefixCls}__detail`; + opt.wrapClassName = wrapClassName ? `${wrapClassName} ${detailCls}` : detailCls; - const getBindValues = computed( - (): DrawerProps => { - return { - ...attrs, - ...unref(getProps), - }; + if (!getContainer) { + // TODO type error? + opt.getContainer = `.${prefixVar}-layout-content` as any; + } } - ); + return opt as DrawerProps; + }); + + const getBindValues = computed((): DrawerProps => { + return { + ...attrs, + ...unref(getProps), + }; + }); // Custom implementation of the bottom button, const getFooterHeight = computed(() => { @@ -133,15 +127,13 @@ return `0px`; }); - const getScrollContentStyle = computed( - (): CSSProperties => { - const footerHeight = unref(getFooterHeight); - return { - position: 'relative', - height: `calc(100% - ${footerHeight})`, - }; - } - ); + const getScrollContentStyle = computed((): CSSProperties => { + const footerHeight = unref(getFooterHeight); + return { + position: 'relative', + height: `calc(100% - ${footerHeight})`, + }; + }); const getLoading = computed(() => { return !!unref(getProps)?.loading; diff --git a/src/components/Drawer/src/components/DrawerFooter.vue b/src/components/Drawer/src/components/DrawerFooter.vue index 8688ce9668e4bb1d90ed795f03ae5b7b55e849d1..903aa832160d0aa0966b9584b08424165a5f6d9e 100644 --- a/src/components/Drawer/src/components/DrawerFooter.vue +++ b/src/components/Drawer/src/components/DrawerFooter.vue @@ -43,15 +43,13 @@ setup(props, { emit }) { const { prefixCls } = useDesign('basic-drawer-footer'); - const getStyle = computed( - (): CSSProperties => { - const heightStr = `${props.height}`; - return { - height: heightStr, - lineHeight: heightStr, - }; - } - ); + const getStyle = computed((): CSSProperties => { + const heightStr = `${props.height}`; + return { + height: heightStr, + lineHeight: heightStr, + }; + }); function handleOk() { emit('ok'); diff --git a/src/components/Form/src/components/FormItem.vue b/src/components/Form/src/components/FormItem.vue index b9701e0bd31a7cd30a4b5ed4f2d901c4cc53f209..724cfd0985c8f554f8dd5d7b9060c55f7c94b531 100644 --- a/src/components/Form/src/components/FormItem.vue +++ b/src/components/Form/src/components/FormItem.vue @@ -174,9 +174,7 @@ return Promise.resolve(); } - const getRequired = isFunction(required) - ? required(unref(getValues)) - : required; + const getRequired = isFunction(required) ? required(unref(getValues)) : required; if ((!rules || rules.length === 0) && getRequired) { rules = [{ required: getRequired, validator }]; diff --git a/src/components/Icon/src/SvgIcon.vue b/src/components/Icon/src/SvgIcon.vue index cb5331d0a621eb8b9e564788df17019852abebe1..2afa4de16ca9b198d2fc5ede6aca51d314fe85a3 100644 --- a/src/components/Icon/src/SvgIcon.vue +++ b/src/components/Icon/src/SvgIcon.vue @@ -36,17 +36,15 @@ const { prefixCls } = useDesign('svg-icon'); const symbolId = computed(() => `#${props.prefix}-${props.name}`); - const getStyle = computed( - (): CSSProperties => { - const { size } = props; - let s = `${size}`; - s = `${s.replace('px', '')}px`; - return { - width: s, - height: s, - }; - } - ); + const getStyle = computed((): CSSProperties => { + const { size } = props; + let s = `${size}`; + s = `${s.replace('px', '')}px`; + return { + width: s, + height: s, + }; + }); return { symbolId, prefixCls, getStyle }; }, }); diff --git a/src/components/Modal/src/BasicModal.vue b/src/components/Modal/src/BasicModal.vue index de2152c823a81a38bde3711aea5d0410f0c9f039..ab14fde8f7a4f033f29e2080dcde38818a99c2ea 100644 --- a/src/components/Modal/src/BasicModal.vue +++ b/src/components/Modal/src/BasicModal.vue @@ -107,14 +107,12 @@ } // Custom title component: get title - const getMergeProps = computed( - (): ModalProps => { - return { - ...props, - ...(unref(propsRef) as any), - }; - } - ); + const getMergeProps = computed((): ModalProps => { + return { + ...props, + ...(unref(propsRef) as any), + }; + }); const { handleFullScreen, getWrapClassName, fullScreenRef } = useFullScreen({ modalWrapperRef, @@ -123,31 +121,27 @@ }); // modal component does not need title and origin buttons - const getProps = computed( - (): ModalProps => { - const opt = { - ...unref(getMergeProps), - visible: unref(visibleRef), - okButtonProps: undefined, - cancelButtonProps: undefined, - title: undefined, - }; - return { - ...opt, - wrapClassName: unref(getWrapClassName), - }; - } - ); + const getProps = computed((): ModalProps => { + const opt = { + ...unref(getMergeProps), + visible: unref(visibleRef), + okButtonProps: undefined, + cancelButtonProps: undefined, + title: undefined, + }; + return { + ...opt, + wrapClassName: unref(getWrapClassName), + }; + }); - const getBindValue = computed( - (): Recordable => { - const attr = { ...attrs, ...unref(getProps) }; - if (unref(fullScreenRef)) { - return omit(attr, 'height'); - } - return attr; + const getBindValue = computed((): Recordable => { + const attr = { ...attrs, ...unref(getProps) }; + if (unref(fullScreenRef)) { + return omit(attr, 'height'); } - ); + return attr; + }); const getWrapperHeight = computed(() => { if (unref(fullScreenRef)) return undefined; diff --git a/src/components/SimpleMenu/src/components/MenuItem.vue b/src/components/SimpleMenu/src/components/MenuItem.vue index 15d5534e31b90b0fbbeb6d91e4a4284b9c034f58..222c7b622869584d71e19ab143f22256d6c06138 100644 --- a/src/components/SimpleMenu/src/components/MenuItem.vue +++ b/src/components/SimpleMenu/src/components/MenuItem.vue @@ -39,9 +39,8 @@ const active = ref(false); - const { getItemStyle, getParentList, getParentMenu, getParentRootMenu } = useMenuItem( - instance - ); + const { getItemStyle, getParentList, getParentMenu, getParentRootMenu } = + useMenuItem(instance); const { prefixCls } = useDesign('menu'); diff --git a/src/components/SimpleMenu/src/components/SubMenuItem.vue b/src/components/SimpleMenu/src/components/SubMenuItem.vue index 0d24cbd7f07f1ce7dd3039357d18a8255adc98a2..0c5dd9a15fa4435d6e43931c25a8579db7dba8ad 100644 --- a/src/components/SimpleMenu/src/components/SubMenuItem.vue +++ b/src/components/SimpleMenu/src/components/SubMenuItem.vue @@ -109,9 +109,8 @@ isChild: false, }); - const { getParentSubMenu, getItemStyle, getParentMenu, getParentList } = useMenuItem( - instance - ); + const { getParentSubMenu, getItemStyle, getParentMenu, getParentList } = + useMenuItem(instance); const { prefixCls } = useDesign('menu'); @@ -148,13 +147,11 @@ const getCollapse = computed(() => rootProps.collapse); const getTheme = computed(() => rootProps.theme); - const getOverlayStyle = computed( - (): CSSProperties => { - return { - minWidth: '200px', - }; - } - ); + const getOverlayStyle = computed((): CSSProperties => { + return { + minWidth: '200px', + }; + }); const getIsOpend = computed(() => { const name = props.name; diff --git a/src/components/SimpleMenu/src/components/useMenu.ts b/src/components/SimpleMenu/src/components/useMenu.ts index beb4c840a76137086389949e89e2d889a1442199..8830559d32589c061cbbbcb7a7a0eb6307969777 100644 --- a/src/components/SimpleMenu/src/components/useMenu.ts +++ b/src/components/SimpleMenu/src/components/useMenu.ts @@ -14,26 +14,24 @@ export function useMenuItem(instance: ComponentInternalInstance | null) { return findParentMenu(['SubMenu']); }); - const getItemStyle = computed( - (): CSSProperties => { - let parent = instance?.parent; - if (!parent) return {}; - const indentSize = (unref(getParentRootMenu)?.props.indentSize as number) ?? 20; - let padding = indentSize; + const getItemStyle = computed((): CSSProperties => { + let parent = instance?.parent; + if (!parent) return {}; + const indentSize = (unref(getParentRootMenu)?.props.indentSize as number) ?? 20; + let padding = indentSize; - if (unref(getParentRootMenu)?.props.collapse) { - padding = indentSize; - } else { - while (parent && parent.type.name !== 'Menu') { - if (parent.type.name === 'SubMenu') { - padding += indentSize; - } - parent = parent.parent; + if (unref(getParentRootMenu)?.props.collapse) { + padding = indentSize; + } else { + while (parent && parent.type.name !== 'Menu') { + if (parent.type.name === 'SubMenu') { + padding += indentSize; } + parent = parent.parent; } - return { paddingLeft: padding + 'px' }; } - ); + return { paddingLeft: padding + 'px' }; + }); function findParentMenu(name: string[]) { let parent = instance?.parent; diff --git a/src/directives/clickOutside.ts b/src/directives/clickOutside.ts index 8c1b2dc49435535d238ae491b35f3f1902b74971..f6f3051a3d98290c40debb9889448d317047896f 100644 --- a/src/directives/clickOutside.ts +++ b/src/directives/clickOutside.ts @@ -31,12 +31,14 @@ function createDocumentHandler(el: HTMLElement, binding: DirectiveBinding): Docu excludes = binding.arg; } else { // due to current implementation on binding type is wrong the type casting is necessary here - excludes.push((binding.arg as unknown) as HTMLElement); + excludes.push(binding.arg as unknown as HTMLElement); } return function (mouseup, mousedown) { - const popperRef = (binding.instance as ComponentPublicInstance<{ - popperRef: Nullable; - }>).popperRef; + const popperRef = ( + binding.instance as ComponentPublicInstance<{ + popperRef: Nullable; + }> + ).popperRef; const mouseUpTarget = mouseup.target as Node; const mouseDownTarget = mousedown.target as Node; const isBound = !binding || !binding.instance; diff --git a/src/hooks/web/useI18n.ts b/src/hooks/web/useI18n.ts index 40e11920099601e9ec3af4641ca42162aa4c6bfc..2a777b7815f22a3bb6cf3c4545929ea86d7fa05a 100644 --- a/src/hooks/web/useI18n.ts +++ b/src/hooks/web/useI18n.ts @@ -21,9 +21,7 @@ function getKey(namespace: string | undefined, key: string) { return `${namespace}.${key}`; } -export function useI18n( - namespace?: string -): { +export function useI18n(namespace?: string): { t: I18nGlobalTranslation; } { const normalFn = { diff --git a/src/hooks/web/useMessage.tsx b/src/hooks/web/useMessage.tsx index 56074e0e600810671edcdd347680b1868e41320b..ecb8fbbdd2cf436c862d0cb3656ba72aae95f35c 100644 --- a/src/hooks/web/useMessage.tsx +++ b/src/hooks/web/useMessage.tsx @@ -60,7 +60,7 @@ function createConfirm(options: ModalOptionsEx): ConfirmOptions { icon: getIcon(iconType), ...options, }; - return (Modal.confirm(opt) as unknown) as ConfirmOptions; + return Modal.confirm(opt) as unknown as ConfirmOptions; } const getBaseOptions = () => { diff --git a/src/layouts/default/header/components/Breadcrumb.vue b/src/layouts/default/header/components/Breadcrumb.vue index c135340a066dc6d670421b0634fa02fbb07e07fc..6d5d2255b0cbd0eec8aad2b1ea33d810ada93104 100644 --- a/src/layouts/default/header/components/Breadcrumb.vue +++ b/src/layouts/default/header/components/Breadcrumb.vue @@ -71,10 +71,10 @@ const breadcrumbList = filterItem(matched); if (currentRoute.value.meta?.currentActiveMenu) { - breadcrumbList.push(({ + breadcrumbList.push({ ...currentRoute.value, name: currentRoute.value.meta?.title || currentRoute.value.name, - } as unknown) as RouteLocationMatched); + } as unknown as RouteLocationMatched); } routes.value = breadcrumbList; }); diff --git a/src/layouts/default/menu/index.vue b/src/layouts/default/menu/index.vue index 9e3409060452991484ec0c8ad457985453e92aff..9dcb2d519dabc1e21993bf1549a688223421272c 100644 --- a/src/layouts/default/menu/index.vue +++ b/src/layouts/default/menu/index.vue @@ -76,13 +76,11 @@ ); }); - const getWrapperStyle = computed( - (): CSSProperties => { - return { - height: `calc(100% - ${unref(getIsShowLogo) ? '48px' : '0px'})`, - }; - } - ); + const getWrapperStyle = computed((): CSSProperties => { + return { + height: `calc(100% - ${unref(getIsShowLogo) ? '48px' : '0px'})`, + }; + }); const getLogoClass = computed(() => { return [ diff --git a/src/layouts/default/setting/SettingDrawer.tsx b/src/layouts/default/setting/SettingDrawer.tsx index beba91c92d8e30fd89ef97e13c88241a31886524..c98288683db6c690c60a72878b5ab45dd8356572 100644 --- a/src/layouts/default/setting/SettingDrawer.tsx +++ b/src/layouts/default/setting/SettingDrawer.tsx @@ -58,12 +58,8 @@ export default defineComponent({ getThemeColor, } = useRootSetting(); - const { - getOpenPageLoading, - getBasicTransition, - getEnableTransition, - getOpenNProgress, - } = useTransitionSetting(); + const { getOpenPageLoading, getBasicTransition, getEnableTransition, getOpenNProgress } = + useTransitionSetting(); const { getIsHorizontal, diff --git a/src/layouts/default/sider/LayoutSider.vue b/src/layouts/default/sider/LayoutSider.vue index 1106062d383a566ff19aafb50e7ad86e18dee904..cfe46ba04f7bd199f64e947bc3d05f105ddad55c 100644 --- a/src/layouts/default/sider/LayoutSider.vue +++ b/src/layouts/default/sider/LayoutSider.vue @@ -89,19 +89,17 @@ ]; }); - const getHiddenDomStyle = computed( - (): CSSProperties => { - const width = `${unref(getRealWidth)}px`; - return { - width: width, - overflow: 'hidden', - flex: `0 0 ${width}`, - maxWidth: width, - minWidth: width, - transition: 'all 0.2s', - }; - } - ); + const getHiddenDomStyle = computed((): CSSProperties => { + const width = `${unref(getRealWidth)}px`; + return { + width: width, + overflow: 'hidden', + flex: `0 0 ${width}`, + maxWidth: width, + minWidth: width, + transition: 'all 0.2s', + }; + }); return { prefixCls, diff --git a/src/layouts/default/sider/MixSider.vue b/src/layouts/default/sider/MixSider.vue index dea9bb798a42e4eb9ad9760245d2fbecc6ce5e04..46f0b62dc1f74ba9326c8dc4a786562e0c46a14d 100644 --- a/src/layouts/default/sider/MixSider.vue +++ b/src/layouts/default/sider/MixSider.vue @@ -147,14 +147,12 @@ useDragLine(sideRef, dragBarRef, true); - const getMenuStyle = computed( - (): CSSProperties => { - return { - width: unref(openMenu) ? `${unref(getMenuWidth)}px` : 0, - left: `${unref(getMixSideWidth)}px`, - }; - } - ); + const getMenuStyle = computed((): CSSProperties => { + return { + width: unref(openMenu) ? `${unref(getMenuWidth)}px` : 0, + left: `${unref(getMixSideWidth)}px`, + }; + }); const getIsFixed = computed(() => { /* eslint-disable-next-line */ @@ -171,20 +169,16 @@ return unref(getCollapsed) ? SIDE_BAR_MINI_WIDTH : SIDE_BAR_SHOW_TIT_MINI_WIDTH; }); - const getDomStyle = computed( - (): CSSProperties => { - const fixedWidth = unref(getIsFixed) ? unref(getRealWidth) : 0; - const width = `${unref(getMixSideWidth) + fixedWidth}px`; - return getWrapCommonStyle(width); - } - ); + const getDomStyle = computed((): CSSProperties => { + const fixedWidth = unref(getIsFixed) ? unref(getRealWidth) : 0; + const width = `${unref(getMixSideWidth) + fixedWidth}px`; + return getWrapCommonStyle(width); + }); - const getWrapStyle = computed( - (): CSSProperties => { - const width = `${unref(getMixSideWidth)}px`; - return getWrapCommonStyle(width); - } - ); + const getWrapStyle = computed((): CSSProperties => { + const width = `${unref(getMixSideWidth)}px`; + return getWrapCommonStyle(width); + }); const getMenuEvents = computed(() => { return !unref(getMixSideFixed) diff --git a/src/layouts/default/tabs/index.vue b/src/layouts/default/tabs/index.vue index ad3028811e92fd2700adfdefc59547d821691220..fd7a4eba58a1559698ca8f5105e9efc4ca2b843d 100644 --- a/src/layouts/default/tabs/index.vue +++ b/src/layouts/default/tabs/index.vue @@ -106,8 +106,7 @@ .getRoutes() .find((item) => item.path === currentActiveMenu); - findParentRoute && - tabStore.addTab((findParentRoute as unknown) as RouteLocationNormalized); + findParentRoute && tabStore.addTab(findParentRoute as unknown as RouteLocationNormalized); } else { tabStore.addTab(unref(route)); } diff --git a/src/layouts/default/tabs/useMultipleTabs.ts b/src/layouts/default/tabs/useMultipleTabs.ts index 60b01a3602f3398281ea967b69680be504605033..35b553b3d4a1b5f7ea9c43d046a22b21c0b93ce9 100644 --- a/src/layouts/default/tabs/useMultipleTabs.ts +++ b/src/layouts/default/tabs/useMultipleTabs.ts @@ -30,14 +30,14 @@ export function initAffixTabs(): string[] { * @description: Set fixed tabs */ function addAffixTabs(): void { - const affixTabs = filterAffixTabs((router.getRoutes() as unknown) as RouteLocationNormalized[]); + const affixTabs = filterAffixTabs(router.getRoutes() as unknown as RouteLocationNormalized[]); affixList.value = affixTabs; for (const tab of affixTabs) { - tabStore.addTab(({ + tabStore.addTab({ meta: tab.meta, name: tab.name, path: tab.path, - } as unknown) as RouteLocationNormalized); + } as unknown as RouteLocationNormalized); } } diff --git a/src/layouts/default/tabs/useTabDropdown.ts b/src/layouts/default/tabs/useTabDropdown.ts index d1e9f78f1e0a6e434b9f4d28db0398c342684c7b..54b0bbba1924b2df7e1be9a4a5c0725340cb8799 100644 --- a/src/layouts/default/tabs/useTabDropdown.ts +++ b/src/layouts/default/tabs/useTabDropdown.ts @@ -20,11 +20,9 @@ export function useTabDropdown(tabContentProps: TabContentProps, getIsTabs: Comp const { currentRoute } = useRouter(); const { refreshPage, closeAll, close, closeLeft, closeOther, closeRight } = useTabs(); - const getTargetTab = computed( - (): RouteLocationNormalized => { - return unref(getIsTabs) ? tabContentProps.tabItem : unref(currentRoute); - } - ); + const getTargetTab = computed((): RouteLocationNormalized => { + return unref(getIsTabs) ? tabContentProps.tabItem : unref(currentRoute); + }); /** * @description: drop-down list diff --git a/src/layouts/iframe/useFrameKeepAlive.ts b/src/layouts/iframe/useFrameKeepAlive.ts index 64b089ce7d4b82238c2a01c1c6a0f0c1a9858acf..e84c49fe969c97b360ea7107295d15a04253edfa 100644 --- a/src/layouts/iframe/useFrameKeepAlive.ts +++ b/src/layouts/iframe/useFrameKeepAlive.ts @@ -16,8 +16,7 @@ export function useFrameKeepAlive() { const { getShowMultipleTab } = useMultipleTabSetting(); const tabStore = useMultipleTabStore(); const getFramePages = computed(() => { - const ret = - getAllFramePages((toRaw(router.getRoutes()) as unknown) as AppRouteRecordRaw[]) || []; + const ret = getAllFramePages(toRaw(router.getRoutes()) as unknown as AppRouteRecordRaw[]) || []; return ret; }); diff --git a/src/router/guard/permissionGuard.ts b/src/router/guard/permissionGuard.ts index a4fd199495b2dc0a905fdb03b8419376353623f2..e955126402b6e02474a17590cfda9673891f1a92 100644 --- a/src/router/guard/permissionGuard.ts +++ b/src/router/guard/permissionGuard.ts @@ -60,7 +60,7 @@ export function createPermissionGuard(router: Router) { const routes = await permissionStore.buildRoutesAction(); routes.forEach((route) => { - router.addRoute((route as unknown) as RouteRecordRaw); + router.addRoute(route as unknown as RouteRecordRaw); }); const redirectPath = (from.query.redirect || to.path) as string; diff --git a/src/utils/cache/memory.ts b/src/utils/cache/memory.ts index b0a89f9c57f77111cd33a09d8ce06d3d1a440444..7e9607278e7c7fe47352d4d524607e054775abaf 100644 --- a/src/utils/cache/memory.ts +++ b/src/utils/cache/memory.ts @@ -80,7 +80,7 @@ export class Memory { resetCache(cache: { [K in keyof T]: Cache }) { Object.keys(cache).forEach((key) => { - const k = (key as any) as keyof T; + const k = key as any as keyof T; const item = cache[k]; if (item && item.time) { const now = new Date().getTime(); diff --git a/src/utils/env.ts b/src/utils/env.ts index 67f71ebff450f1cccabeb27d2d7f184741b1f1fd..7dfa40c099833140f6d65020334adec86e3173ac 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -17,10 +17,10 @@ export function getStorageShortName() { export function getAppEnvConfig() { const ENV_NAME = getConfigFileName(import.meta.env); - const ENV = ((import.meta.env.DEV + const ENV = (import.meta.env.DEV ? // Get the global configuration (the configuration will be extracted independently when packaging) - ((import.meta.env as unknown) as GlobEnvConfig) - : window[ENV_NAME as any]) as unknown) as GlobEnvConfig; + (import.meta.env as unknown as GlobEnvConfig) + : window[ENV_NAME as any]) as unknown as GlobEnvConfig; const { VITE_GLOB_APP_TITLE, diff --git a/src/utils/is.ts b/src/utils/is.ts index d6202e034b9f9d3e8a7809fd2b9e5d3a6880e0ed..eeff9270f380a3a3d39c4253ff079bab93b0c966 100644 --- a/src/utils/is.ts +++ b/src/utils/is.ts @@ -89,6 +89,7 @@ export const isServer = typeof window === 'undefined'; export const isClient = !isServer; export function isUrl(path: string): boolean { - const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; + const reg = + /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; return reg.test(path); } diff --git a/src/views/demo/form/DynamicForm.vue b/src/views/demo/form/DynamicForm.vue index c4f0c0e556c050d0ee4be96ee8cafa4185eb6637..cb7b43529a97be0897784d846da89f766991bfc7 100644 --- a/src/views/demo/form/DynamicForm.vue +++ b/src/views/demo/form/DynamicForm.vue @@ -181,16 +181,14 @@ export default defineComponent({ components: { BasicForm, CollapseContainer, PageWrapper }, setup() { - const [ - register, - { setProps, updateSchema, appendSchemaByField, removeSchemaByFiled }, - ] = useForm({ - labelWidth: 120, - schemas, - actionColOptions: { - span: 24, - }, - }); + const [register, { setProps, updateSchema, appendSchemaByField, removeSchemaByFiled }] = + useForm({ + labelWidth: 120, + schemas, + actionColOptions: { + span: 24, + }, + }); const [register1] = useForm({ labelWidth: 120, schemas: schemas1, diff --git a/src/views/demo/system/account/DeptTree.vue b/src/views/demo/system/account/DeptTree.vue index d9b7154768627c9ee9b441ab12861284f5cd51a0..a449862de8a01ce891530a3cfaf0e8a0cb2b5ef3 100644 --- a/src/views/demo/system/account/DeptTree.vue +++ b/src/views/demo/system/account/DeptTree.vue @@ -26,7 +26,7 @@ const treeData = ref([]); async function fetch() { - treeData.value = ((await getDeptList()) as unknown) as TreeItem[]; + treeData.value = (await getDeptList()) as unknown as TreeItem[]; } function handleSelect(keys: string, e) { diff --git a/src/views/demo/system/role/RoleDrawer.vue b/src/views/demo/system/role/RoleDrawer.vue index 7754f2e8cdabc2410cd503cd79932b0c5c6e43fd..b41019d0db26e8a660f0b60fb8aef21b23172181 100644 --- a/src/views/demo/system/role/RoleDrawer.vue +++ b/src/views/demo/system/role/RoleDrawer.vue @@ -54,7 +54,7 @@ ...data.record, }); } - treeData.value = ((await getMenuList()) as any) as TreeItem[]; + treeData.value = (await getMenuList()) as any as TreeItem[]; }); const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色')); diff --git a/src/views/sys/exception/Exception.vue b/src/views/sys/exception/Exception.vue index b5bac267898c42b8ddff536f08bc2524c84cba8d..dab9c576e84001e2c4a6b76fd042d85bf237066f 100644 --- a/src/views/sys/exception/Exception.vue +++ b/src/views/sys/exception/Exception.vue @@ -64,11 +64,9 @@ return Number(routeStatus) || status; }); - const getMapValue = computed( - (): MapValue => { - return unref(statusMapRef).get(unref(getStatus)) as MapValue; - } - ); + const getMapValue = computed((): MapValue => { + return unref(statusMapRef).get(unref(getStatus)) as MapValue; + }); const backLoginI18n = t('sys.exception.backLogin'); const backHomeI18n = t('sys.exception.backHome'); diff --git a/src/views/sys/iframe/index.vue b/src/views/sys/iframe/index.vue index 564491ad0a5788e898ef80de9c2e0a45b783f492..6c1b15c16a4f951c0d7f2337b4af9e9f9fae0bdf 100644 --- a/src/views/sys/iframe/index.vue +++ b/src/views/sys/iframe/index.vue @@ -32,13 +32,11 @@ const { prefixCls } = useDesign('iframe-page'); useWindowSizeFn(calcHeight, 150, { immediate: true }); - const getWrapStyle = computed( - (): CSSProperties => { - return { - height: `${unref(heightRef)}px`, - }; - } - ); + const getWrapStyle = computed((): CSSProperties => { + return { + height: `${unref(heightRef)}px`, + }; + }); function calcHeight() { const iframe = unref(frameRef); diff --git a/stylelint.config.js b/stylelint.config.js index 0e63041c167f7a56ebe1f41bef41d54c669f9f99..cfa743d7936e1d78ca16d7c29efb7799276007e7 100644 --- a/stylelint.config.js +++ b/stylelint.config.js @@ -28,7 +28,7 @@ module.exports = { 'font-family-no-missing-generic-family-keyword': null, 'declaration-colon-space-after': 'always-single-line', 'declaration-colon-space-before': 'never', - 'declaration-block-trailing-semicolon': 'always', + // 'declaration-block-trailing-semicolon': 'always', 'rule-empty-line-before': [ 'always', {