From 00fca0fe6c912141ba8b06576b6c53c5b4c3cd9e Mon Sep 17 00:00:00 2001 From: Vben Date: Wed, 9 Jun 2021 22:36:30 +0800 Subject: [PATCH] chore: prettier code --- src/components/ContextMenu/index.ts | 2 +- .../ContextMenu/src/ContextMenu.tsx | 117 ---------- .../ContextMenu/src/ContextMenu.vue | 204 ++++++++++++++++++ .../ContextMenu/src/createContextMenu.ts | 12 +- src/components/ContextMenu/src/index.less | 65 ------ src/components/ContextMenu/src/props.ts | 26 --- .../ContextMenu/src/{types.ts => typing.ts} | 0 src/components/Drawer/src/BasicDrawer.vue | 82 ++++--- .../Drawer/src/components/DrawerFooter.vue | 16 +- .../Form/src/components/FormItem.vue | 4 +- src/components/Icon/src/SvgIcon.vue | 20 +- src/components/Modal/src/BasicModal.vue | 56 +++-- .../SimpleMenu/src/components/MenuItem.vue | 5 +- .../SimpleMenu/src/components/SubMenuItem.vue | 17 +- .../SimpleMenu/src/components/useMenu.ts | 30 ++- src/directives/clickOutside.ts | 10 +- src/hooks/web/useI18n.ts | 4 +- src/hooks/web/useMessage.tsx | 2 +- .../default/header/components/Breadcrumb.vue | 4 +- src/layouts/default/menu/index.vue | 12 +- src/layouts/default/setting/SettingDrawer.tsx | 8 +- src/layouts/default/sider/LayoutSider.vue | 24 +-- src/layouts/default/sider/MixSider.vue | 36 ++-- src/layouts/default/tabs/index.vue | 3 +- src/layouts/default/tabs/useMultipleTabs.ts | 6 +- src/layouts/default/tabs/useTabDropdown.ts | 8 +- src/layouts/iframe/useFrameKeepAlive.ts | 3 +- src/router/guard/permissionGuard.ts | 2 +- src/utils/cache/memory.ts | 2 +- src/utils/env.ts | 6 +- src/utils/is.ts | 3 +- src/views/demo/form/DynamicForm.vue | 18 +- src/views/demo/system/account/DeptTree.vue | 2 +- src/views/demo/system/role/RoleDrawer.vue | 2 +- src/views/sys/exception/Exception.vue | 8 +- src/views/sys/iframe/index.vue | 12 +- stylelint.config.js | 2 +- 37 files changed, 391 insertions(+), 442 deletions(-) delete mode 100644 src/components/ContextMenu/src/ContextMenu.tsx create mode 100644 src/components/ContextMenu/src/ContextMenu.vue delete mode 100644 src/components/ContextMenu/src/index.less delete mode 100644 src/components/ContextMenu/src/props.ts rename src/components/ContextMenu/src/{types.ts => typing.ts} (100%) diff --git a/src/components/ContextMenu/index.ts b/src/components/ContextMenu/index.ts index 31e385ac..ed294d7b 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 3fb2d964..00000000 --- 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 00000000..da8ee554 --- /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 5fc3ed45..8f7a1c82 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 3d8dec03..00000000 --- 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 509b424f..00000000 --- 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 6e451bf1..b88c2ddc 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 8688ce96..903aa832 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 b9701e0b..724cfd09 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 cb5331d0..2afa4de1 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 de2152c8..ab14fde8 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 15d5534e..222c7b62 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 0d24cbd7..0c5dd9a1 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 beb4c840..8830559d 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 8c1b2dc4..f6f3051a 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 40e11920..2a777b78 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 56074e0e..ecb8fbbd 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 c135340a..6d5d2255 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 9e340906..9dcb2d51 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 beba91c9..c9828868 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 1106062d..cfe46ba0 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 dea9bb79..46f0b62d 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 ad302881..fd7a4eba 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 60b01a36..35b553b3 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 d1e9f78f..54b0bbba 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 64b089ce..e84c49fe 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 a4fd1994..e9551264 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 b0a89f9c..7e960727 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 67f71ebf..7dfa40c0 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 d6202e03..eeff9270 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 c4f0c0e5..cb7b4352 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 d9b71547..a449862d 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 7754f2e8..b41019d0 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 b5bac267..dab9c576 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 564491ad..6c1b15c1 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 0e63041c..cfa743d7 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', { -- GitLab