From 4fb4cb9e82fed615a91658da52e9c9964fb71b0a Mon Sep 17 00:00:00 2001 From: xingyu Date: Sat, 29 Jul 2023 18:46:43 +0800 Subject: [PATCH] feat: antdv4.0 init --- .eslintrc.js | 81 +- .lintstagedrc.js | 8 - .vscode/settings.json | 64 +- build/config/themeConfig.ts | 12 +- build/generate/generateModifyVars.ts | 13 +- build/generate/icon/index.ts | 26 +- build/getConfigFileName.ts | 2 +- build/script/buildConf.ts | 11 +- build/script/postBuild.ts | 12 +- build/utils.ts | 17 +- build/vite/optimize.ts | 2 +- build/vite/plugin/compress.ts | 10 +- build/vite/plugin/html.ts | 12 +- build/vite/plugin/index.ts | 12 +- build/vite/plugin/pwa.ts | 10 +- build/vite/plugin/styleImport.ts | 20 +- build/vite/plugin/svgSprite.ts | 6 +- build/vite/plugin/theme.ts | 22 +- build/vite/plugin/visualizer.ts | 4 +- build/vite/proxy.ts | 6 +- commitlint.config.js | 30 +- index.html | 10 +- package.json | 68 +- pnpm-lock.yaml | 1398 +++++++++-------- prettier.config.js | 37 - src/App.vue | 17 +- src/api/base/login.ts | 26 +- src/api/base/model/loginModel.ts | 4 +- src/api/base/model/menuModel.ts | 1 + src/api/base/model/userModel.ts | 2 +- src/api/base/profile.ts | 24 +- src/api/base/upload.ts | 10 +- src/api/base/user.ts | 6 +- src/api/bpm/definition/index.ts | 2 +- src/api/bpm/form/index.ts | 6 +- src/api/bpm/leave/index.ts | 4 +- src/api/bpm/model/index.ts | 22 +- src/api/bpm/processInstance/index.ts | 10 +- src/api/bpm/task/index.ts | 2 +- src/api/bpm/task/types.ts | 8 +- src/api/bpm/taskAssignRule/index.ts | 2 +- src/api/bpm/userGroup/index.ts | 6 +- src/api/infra/apiErrorLog/index.ts | 6 +- src/api/infra/codegen/index.ts | 14 +- src/api/infra/codegen/types.ts | 14 +- src/api/infra/config/index.ts | 6 +- src/api/infra/dataSourceConfig/index.ts | 4 +- src/api/infra/file/index.ts | 2 +- src/api/infra/fileConfig/index.ts | 8 +- src/api/infra/job/index.ts | 10 +- src/api/infra/jobLog/index.ts | 2 +- src/api/infra/redis/index.ts | 12 +- src/api/mp/account/index.ts | 8 +- src/api/mp/autoReply/index.ts | 4 +- src/api/mp/draft/index.ts | 10 +- src/api/mp/freePublish/index.ts | 4 +- src/api/mp/material/index.ts | 2 +- src/api/mp/menu/index.ts | 8 +- src/api/mp/mpuser/index.ts | 4 +- src/api/mp/tag/index.ts | 6 +- src/api/pay/app/index.ts | 6 +- src/api/pay/channel/index.ts | 10 +- src/api/pay/demo/index.ts | 4 +- src/api/pay/merchant/index.ts | 10 +- src/api/pay/order/index.ts | 6 +- src/api/pay/refund/index.ts | 4 +- src/api/system/area/index.ts | 2 +- src/api/system/dept/index.ts | 4 +- src/api/system/dict/data.ts | 6 +- src/api/system/dict/type.ts | 6 +- src/api/system/dict/types.ts | 12 +- src/api/system/errorCode/index.ts | 4 +- src/api/system/mail/account.ts | 4 +- src/api/system/mail/log.ts | 2 +- src/api/system/mail/template.ts | 8 +- src/api/system/menu/index.ts | 4 +- src/api/system/notice/index.ts | 4 +- src/api/system/notify/message.ts | 4 +- src/api/system/notify/template.ts | 8 +- src/api/system/oauth2/client.ts | 4 +- src/api/system/oauth2/token.ts | 2 +- src/api/system/operatelog/index.ts | 2 +- src/api/system/permission/index.ts | 4 +- src/api/system/post/index.ts | 4 +- src/api/system/role/index.ts | 4 +- src/api/system/sensitiveWord/index.ts | 6 +- src/api/system/sms/smsChannel/index.ts | 4 +- src/api/system/sms/smsTemplate/index.ts | 6 +- src/api/system/tenant/index.ts | 4 +- src/api/system/tenantPackage/index.ts | 4 +- src/api/system/user/index.ts | 8 +- src/components/Application/index.ts | 3 +- .../Application/src/AppDarkModeToggle.vue | 24 +- .../Application/src/AppLocalePicker.vue | 45 +- src/components/Application/src/AppLogo.vue | 26 +- .../Application/src/AppProvider.vue | 23 +- .../Application/src/AppSizePicker.vue | 49 +- .../Application/src/search/AppSearch.vue | 4 +- .../src/search/AppSearchFooter.vue | 24 +- .../src/search/AppSearchKeyItem.vue | 14 +- .../Application/src/search/AppSearchModal.vue | 137 +- .../Application/src/search/useMenuSearch.ts | 51 +- .../Application/src/useAppContext.ts | 2 +- src/components/Authority/index.ts | 2 +- src/components/Authority/src/Authority.vue | 12 +- src/components/Basic/index.ts | 2 +- src/components/Basic/src/BasicArrow.vue | 20 +- src/components/Basic/src/BasicHelp.vue | 12 +- src/components/Basic/src/BasicTitle.vue | 24 +- src/components/Button/index.ts | 4 +- src/components/Button/src/BasicButton.vue | 25 +- .../Button/src/PopConfirmButton.vue | 21 +- src/components/Button/src/props.ts | 6 +- src/components/CardList/index.ts | 2 +- src/components/CardList/src/CardList.vue | 228 +-- src/components/CardList/src/data.ts | 9 +- src/components/CodeEditor/index.ts | 2 +- src/components/CodeEditor/src/CodeEditor.vue | 24 +- .../CodeEditor/src/codemirror/CodeMirror.vue | 35 +- .../CodeEditor/src/codemirror/codeMirror.ts | 2 + .../src/json-preview/JsonPreview.vue | 10 +- src/components/CodeEditor/src/typing.ts | 2 +- src/components/Container/index.ts | 2 +- .../Container/src/LazyContainer.vue | 64 +- .../Container/src/ScrollContainer.vue | 42 +- .../src/collapse/CollapseContainer.vue | 30 +- .../Container/src/collapse/CollapseHeader.vue | 8 +- .../ContextMenu/src/ContextMenu.vue | 40 +- .../ContextMenu/src/createContextMenu.ts | 21 +- src/components/CountDown/index.ts | 2 +- src/components/CountDown/src/CountButton.vue | 23 +- .../CountDown/src/CountdownInput.vue | 26 +- src/components/CountDown/src/useCountdown.ts | 7 +- src/components/CountTo/index.ts | 2 +- src/components/CountTo/src/CountTo.vue | 37 +- src/components/CronTab/src/CronTabInner.vue | 411 ++--- src/components/CronTab/src/CronTabInput.vue | 88 +- src/components/CronTab/src/CronTabModal.vue | 14 +- src/components/CronTab/src/cron.data.ts | 2 +- src/components/CronTab/src/tabs/DayUI.vue | 114 +- src/components/CronTab/src/tabs/HourUI.vue | 92 +- src/components/CronTab/src/tabs/MinuteUI.vue | 92 +- src/components/CronTab/src/tabs/MonthUI.vue | 92 +- src/components/CronTab/src/tabs/SecondUI.vue | 92 +- src/components/CronTab/src/tabs/WeekUI.vue | 140 +- src/components/CronTab/src/tabs/YearUI.vue | 66 +- .../CronTab/src/tabs/useTabMixin.ts | 73 +- src/components/CronTab/src/validator.ts | 32 +- src/components/Cropper/index.ts | 2 +- src/components/Cropper/src/CopperModal.vue | 225 +-- src/components/Cropper/src/Cropper.vue | 75 +- src/components/Cropper/src/CropperAvatar.vue | 54 +- src/components/Description/index.ts | 2 +- .../Description/src/Description.vue | 57 +- src/components/Description/src/typing.ts | 4 +- .../Description/src/useDescription.ts | 14 +- src/components/DictTag/index.ts | 2 +- src/components/DictTag/src/DictTag.vue | 42 +- src/components/Drawer/index.ts | 2 +- src/components/Drawer/src/BasicDrawer.vue | 92 +- .../Drawer/src/components/DrawerFooter.vue | 47 +- .../Drawer/src/components/DrawerHeader.vue | 45 +- src/components/Drawer/src/props.ts | 11 +- src/components/Drawer/src/typing.ts | 2 +- src/components/Drawer/src/useDrawer.ts | 53 +- src/components/Dropdown/index.ts | 2 +- src/components/Dropdown/src/Dropdown.vue | 92 +- src/components/Excel/index.ts | 2 +- src/components/Excel/src/Export2Excel.ts | 17 +- src/components/Excel/src/ExportExcelModal.vue | 36 +- src/components/Excel/src/ImportExcel.vue | 98 +- src/components/Excel/src/typing.ts | 2 +- src/components/Form/src/BasicForm.vue | 148 +- src/components/Form/src/componentMap.ts | 34 +- .../Form/src/components/ApiCascader.vue | 115 +- .../Form/src/components/ApiRadioGroup.vue | 65 +- .../Form/src/components/ApiSelect.vue | 76 +- .../Form/src/components/ApiTransfer.vue | 71 +- .../Form/src/components/ApiTree.vue | 58 +- .../Form/src/components/ApiTreeSelect.vue | 57 +- .../Form/src/components/FileUpload.vue | 185 +-- .../Form/src/components/FormAction.vue | 88 +- .../Form/src/components/FormItem.vue | 169 +- .../Form/src/components/RadioButtonGroup.vue | 50 +- .../Form/src/components/UploadItemActions.vue | 150 +- src/components/Form/src/helper.ts | 39 +- src/components/Form/src/hooks/useAdvanced.ts | 67 +- src/components/Form/src/hooks/useAutoFocus.ts | 18 +- .../Form/src/hooks/useComponentRegister.ts | 4 +- src/components/Form/src/hooks/useForm.ts | 21 +- .../Form/src/hooks/useFormEvents.ts | 137 +- .../Form/src/hooks/useFormValues.ts | 44 +- .../Form/src/hooks/useLabelWidth.ts | 9 +- src/components/Form/src/props.ts | 28 +- src/components/Form/src/types/form.ts | 11 +- .../VFormCreate/components/FormRender.vue | 82 +- .../src/components/VFormCreate/index.vue | 85 +- .../VFormDesign/components/CodeModal.vue | 34 +- .../VFormDesign/components/ComponentProps.vue | 197 +-- .../components/FormItemColumnProps.vue | 56 +- .../VFormDesign/components/FormItemProps.vue | 143 +- .../VFormDesign/components/FormNode.vue | 41 +- .../components/FormNodeOperate.vue | 40 +- .../VFormDesign/components/FormOptions.vue | 115 +- .../VFormDesign/components/FormProps.vue | 159 +- .../components/ImportJsonModal.vue | 86 +- .../VFormDesign/components/JsonModal.vue | 41 +- .../VFormDesign/components/LayoutItem.vue | 118 +- .../VFormDesign/components/PreviewCode.vue | 48 +- .../VFormDesign/components/RuleProps.vue | 149 +- .../config/componentPropsConfig.ts | 547 ++++--- .../VFormDesign/config/formItemPropsConfig.ts | 140 +- .../src/components/VFormDesign/index.vue | 216 +-- .../VFormDesign/modules/CollapseItem.vue | 84 +- .../modules/FormComponentPanel.vue | 79 +- .../VFormDesign/modules/PropsPanel.vue | 54 +- .../VFormDesign/modules/Toolbar.vue | 165 +- .../components/VFormDesign/styles/drag.less | 72 +- .../src/components/VFormItem/index.vue | 141 +- .../src/components/VFormItem/vFormItem.vue | 35 +- .../src/components/VFormPreview/index.vue | 60 +- .../src/components/VFormPreview/useForm.vue | 59 +- .../FormDesign/src/components/index.ts | 15 +- .../FormDesign/src/core/formItemConfig.ts | 167 +- .../FormDesign/src/core/iconConfig.ts | 8 +- .../src/hooks/useFormDesignState.ts | 9 +- .../src/hooks/useFormInstanceMethods.ts | 22 +- .../FormDesign/src/hooks/useVFormMethods.ts | 26 +- .../FormDesign/src/typings/form-type.ts | 6 +- .../src/typings/v-form-component.ts | 17 +- src/components/FormDesign/src/utils/index.ts | 85 +- .../FormDesign/src/utils/message.ts | 3 +- src/components/IFrame/index.ts | 3 +- src/components/IFrame/src/IFrame.vue | 19 +- src/components/Icon/data/icons.data.ts | 4 +- src/components/Icon/src/Icon.vue | 48 +- src/components/Icon/src/IconPicker.vue | 143 +- src/components/Icon/src/SvgIcon.vue | 24 +- src/components/Loading/src/Loading.vue | 30 +- src/components/Loading/src/createLoading.ts | 24 +- src/components/Loading/src/typing.ts | 2 +- src/components/Loading/src/useLoading.ts | 8 +- src/components/Markdown/index.ts | 2 +- src/components/Markdown/src/Markdown.vue | 54 +- .../Markdown/src/MarkdownViewer.vue | 32 +- src/components/Markdown/src/getTheme.ts | 2 +- src/components/Markdown/src/typing.ts | 3 +- src/components/Menu/src/BasicMenu.vue | 79 +- .../Menu/src/components/BasicMenuItem.vue | 11 +- .../Menu/src/components/BasicSubMenuItem.vue | 57 +- .../Menu/src/components/MenuItemContent.vue | 34 +- src/components/Menu/src/index.less | 2 +- src/components/Menu/src/props.ts | 25 +- src/components/Menu/src/useOpenKeys.ts | 41 +- src/components/Modal/src/BasicModal.vue | 146 +- src/components/Modal/src/components/Modal.tsx | 4 +- .../Modal/src/components/ModalClose.vue | 48 +- .../Modal/src/components/ModalFooter.vue | 27 +- .../Modal/src/components/ModalHeader.vue | 15 +- .../Modal/src/components/ModalWrapper.vue | 73 +- src/components/Modal/src/hooks/useModal.ts | 54 +- .../Modal/src/hooks/useModalContext.ts | 2 +- .../Modal/src/hooks/useModalDrag.ts | 35 +- .../Modal/src/hooks/useModalFullScreen.ts | 3 +- src/components/Modal/src/props.ts | 6 +- src/components/Modal/src/typing.ts | 3 +- src/components/Page/index.ts | 3 +- src/components/Page/src/PageFooter.vue | 27 +- src/components/Page/src/PageWrapper.vue | 91 +- src/components/Preview/src/Functional.vue | 139 +- src/components/Preview/src/Preview.vue | 56 +- src/components/Preview/src/functional.ts | 5 +- src/components/Preview/src/typing.ts | 12 +- src/components/Qrcode/index.ts | 2 +- src/components/Qrcode/src/Qrcode.vue | 57 +- src/components/Qrcode/src/drawCanvas.ts | 11 +- src/components/Qrcode/src/drawLogo.ts | 22 +- src/components/Qrcode/src/qrcodePlus.ts | 1 + src/components/Qrcode/src/toCanvas.ts | 5 +- src/components/Qrcode/src/typing.ts | 4 +- src/components/Scrollbar/src/Scrollbar.vue | 79 +- src/components/Scrollbar/src/bar.ts | 36 +- src/components/Scrollbar/src/util.ts | 10 +- src/components/SimpleMenu/src/SimpleMenu.vue | 69 +- .../SimpleMenu/src/SimpleMenuTag.vue | 29 +- .../SimpleMenu/src/SimpleSubMenu.vue | 99 +- .../SimpleMenu/src/components/Menu.vue | 51 +- .../src/components/MenuCollapseTransition.vue | 26 +- .../SimpleMenu/src/components/MenuItem.vue | 66 +- .../SimpleMenu/src/components/SubMenuItem.vue | 189 ++- .../SimpleMenu/src/components/menu.less | 12 +- .../SimpleMenu/src/components/types.ts | 2 +- .../SimpleMenu/src/components/useMenu.ts | 42 +- src/components/SimpleMenu/src/index.less | 4 +- src/components/SimpleMenu/src/useOpenKeys.ts | 26 +- src/components/StrengthMeter/index.ts | 2 +- .../StrengthMeter/src/StrengthMeter.vue | 37 +- src/components/Table/src/BasicTable.vue | 141 +- src/components/Table/src/componentMap.ts | 4 +- .../src/components/EditTableHeaderIcon.vue | 15 +- .../Table/src/components/HeaderCell.vue | 22 +- .../Table/src/components/TableAction.vue | 91 +- .../Table/src/components/TableFooter.vue | 64 +- .../Table/src/components/TableHeader.vue | 48 +- .../Table/src/components/TableImg.vue | 58 +- .../Table/src/components/TableTitle.vue | 24 +- .../src/components/editable/CellComponent.ts | 17 +- .../src/components/editable/EditableCell.vue | 131 +- .../Table/src/components/editable/helper.ts | 25 +- .../Table/src/components/editable/index.ts | 25 +- .../src/components/settings/ColumnSetting.vue | 276 ++-- .../src/components/settings/FormSetting.vue | 19 +- .../components/settings/FullScreenSetting.vue | 23 +- .../src/components/settings/RedoSetting.vue | 19 +- .../src/components/settings/SizeSetting.vue | 51 +- .../Table/src/components/settings/index.vue | 30 +- src/components/Table/src/hooks/useColumns.ts | 139 +- .../Table/src/hooks/useCustomRow.ts | 40 +- .../Table/src/hooks/useDataSource.ts | 123 +- src/components/Table/src/hooks/useLoading.ts | 5 +- .../Table/src/hooks/usePagination.tsx | 28 +- src/components/Table/src/hooks/useRender.ts | 67 +- .../Table/src/hooks/useRowSelection.ts | 38 +- src/components/Table/src/hooks/useScrollTo.ts | 29 +- src/components/Table/src/hooks/useTable.ts | 25 +- .../Table/src/hooks/useTableContext.ts | 4 +- .../Table/src/hooks/useTableExpand.ts | 13 +- .../Table/src/hooks/useTableFooter.ts | 15 +- .../Table/src/hooks/useTableForm.ts | 18 +- .../Table/src/hooks/useTableHeader.ts | 19 +- .../Table/src/hooks/useTableScroll.ts | 81 +- .../Table/src/hooks/useTableStyle.ts | 12 +- src/components/Table/src/props.ts | 56 +- src/components/Table/src/types/column.ts | 2 +- src/components/Table/src/types/pagination.ts | 2 +- src/components/Table/src/types/table.ts | 18 +- src/components/Table/src/types/tableAction.ts | 31 +- src/components/Tinymce/index.ts | 2 +- src/components/Tinymce/src/Editor.vue | 113 +- src/components/Tinymce/src/ImgUpload.vue | 34 +- src/components/Tinymce/src/helper.ts | 11 +- src/components/Tinymce/src/tinymce.ts | 4 +- src/components/Transition/index.ts | 2 +- .../Transition/src/CollapseTransition.vue | 26 +- .../Transition/src/CreateTransition.tsx | 18 +- .../Transition/src/ExpandTransition.ts | 18 +- src/components/Tree/src/BasicTree.vue | 157 +- src/components/Tree/src/TreeIcon.ts | 9 +- .../Tree/src/components/TreeHeader.vue | 119 +- src/components/Tree/src/hooks/useTree.ts | 86 +- src/components/Tree/src/types/tree.ts | 50 +- src/components/Tree/style/index.less | 2 +- src/components/Upload/index.ts | 2 +- src/components/Upload/src/BasicUpload.vue | 94 +- src/components/Upload/src/FileList.vue | 10 +- src/components/Upload/src/ThumbUrl.vue | 18 +- src/components/Upload/src/UploadModal.vue | 455 +++--- .../Upload/src/UploadPreviewModal.vue | 47 +- src/components/Upload/src/data.tsx | 58 +- src/components/Upload/src/helper.ts | 4 +- src/components/Upload/src/props.ts | 42 +- src/components/Upload/src/typing.ts | 4 +- src/components/Upload/src/useUpload.ts | 29 +- src/components/Verifition/index.ts | 2 +- src/components/Verifition/src/Verify.vue | 209 ++- .../Verifition/src/Verify/VerifyPoints.vue | 242 +-- .../Verifition/src/Verify/VerifySlide.vue | 279 ++-- src/components/Verifition/src/utils/ase.ts | 3 +- src/components/Verifition/src/utils/util.ts | 32 +- src/components/VirtualScroll/index.ts | 2 +- .../VirtualScroll/src/VirtualScroll.vue | 65 +- src/components/registerGlobComp.ts | 2 +- src/design/ant/btn.less | 14 +- src/design/ant/index.less | 6 +- src/design/ant/input.less | 4 +- src/design/ant/pagination.less | 2 +- src/design/ant/table.less | 2 +- src/design/config.less | 4 +- src/design/index.less | 18 +- src/design/theme.less | 4 +- src/design/transition/index.less | 12 +- src/design/var/index.less | 6 +- src/directives/clickOutside.ts | 24 +- src/directives/loading.ts | 14 +- src/directives/permission.ts | 10 +- src/directives/repeatClick.ts | 11 +- src/directives/ripple/index.ts | 41 +- src/enums/appEnum.ts | 14 +- src/enums/breakpointEnum.ts | 4 +- src/enums/cacheEnum.ts | 2 +- src/enums/exceptionEnum.ts | 4 +- src/enums/httpEnum.ts | 6 +- src/enums/menuEnum.ts | 12 +- src/enums/pageEnum.ts | 2 +- src/enums/roleEnum.ts | 2 +- src/enums/sizeEnum.ts | 4 +- src/enums/systemEnum.ts | 134 +- src/hooks/component/useFormItem.ts | 11 +- src/hooks/component/usePageContext.ts | 2 +- src/hooks/core/onMountedOrActivated.ts | 5 +- src/hooks/core/useAttrs.ts | 7 +- src/hooks/core/useContext.ts | 5 +- src/hooks/core/useLockFn.ts | 6 +- src/hooks/core/useRefs.ts | 2 +- src/hooks/event/useBreakpoint.ts | 27 +- src/hooks/event/useEventListener.ts | 11 +- src/hooks/event/useIntersectionObserver.ts | 7 +- src/hooks/event/useScroll.ts | 21 +- src/hooks/event/useScrollTo.ts | 22 +- src/hooks/event/useWindowSizeFn.ts | 4 +- src/hooks/setting/index.ts | 10 +- src/hooks/setting/useHeaderSetting.ts | 5 +- src/hooks/setting/useMenuSetting.ts | 24 +- src/hooks/setting/useMultipleTabSetting.ts | 5 +- src/hooks/setting/useRootSetting.ts | 10 +- src/hooks/setting/useTransitionSetting.ts | 5 +- src/hooks/web/useAppInject.ts | 4 +- src/hooks/web/useContentHeight.ts | 53 +- src/hooks/web/useContextMenu.ts | 3 +- src/hooks/web/useCopyToClipboard.ts | 9 +- src/hooks/web/useDesign.ts | 3 +- src/hooks/web/useECharts.ts | 36 +- src/hooks/web/useFullContent.ts | 9 +- src/hooks/web/useI18n.ts | 23 +- src/hooks/web/useLockPage.ts | 15 +- src/hooks/web/useMessage.tsx | 38 +- src/hooks/web/usePage.ts | 21 +- src/hooks/web/usePagination.ts | 2 +- src/hooks/web/usePermission.ts | 33 +- src/hooks/web/useScript.ts | 2 +- src/hooks/web/useSortable.ts | 5 +- src/hooks/web/useTabs.ts | 22 +- src/hooks/web/useTitle.ts | 13 +- src/hooks/web/useWatermark.ts | 36 +- src/layouts/default/content/index.vue | 14 +- .../default/content/useContentContext.ts | 2 +- .../default/content/useContentViewHeight.ts | 6 +- src/layouts/default/feature/index.vue | 30 +- src/layouts/default/footer/index.vue | 40 +- src/layouts/default/header/MultipleHeader.vue | 43 +- .../default/header/components/Breadcrumb.vue | 75 +- .../default/header/components/ErrorAction.vue | 20 +- .../default/header/components/FullScreen.vue | 19 +- .../default/header/components/index.ts | 4 +- .../header/components/lock/LockModal.vue | 52 +- .../header/components/notify/NoticeList.vue | 154 +- .../default/header/components/notify/data.ts | 48 +- .../header/components/notify/index.vue | 50 +- .../components/user-dropdown/DropMenuItem.vue | 19 +- .../header/components/user-dropdown/index.vue | 59 +- src/layouts/default/header/index.less | 30 +- src/layouts/default/header/index.vue | 179 ++- src/layouts/default/index.vue | 80 +- src/layouts/default/menu/index.vue | 45 +- src/layouts/default/menu/useLayoutMenu.ts | 30 +- src/layouts/default/setting/SettingDrawer.tsx | 47 +- .../setting/components/InputNumberItem.vue | 24 +- .../default/setting/components/SelectItem.vue | 32 +- .../setting/components/SettingFooter.vue | 47 +- .../default/setting/components/SwitchItem.vue | 40 +- .../setting/components/ThemeColorPicker.vue | 53 +- .../default/setting/components/TypePicker.vue | 52 +- src/layouts/default/setting/enum.ts | 50 +- src/layouts/default/setting/handler.ts | 16 +- src/layouts/default/setting/index.vue | 13 +- src/layouts/default/sider/DragBar.vue | 18 +- src/layouts/default/sider/LayoutSider.vue | 67 +- src/layouts/default/sider/MixSider.vue | 214 +-- src/layouts/default/sider/index.vue | 36 +- src/layouts/default/sider/useLayoutSider.ts | 39 +- .../default/tabs/components/FoldButton.vue | 15 +- .../default/tabs/components/TabContent.vue | 55 +- .../default/tabs/components/TabRedo.vue | 11 +- src/layouts/default/tabs/index.less | 38 +- src/layouts/default/tabs/index.vue | 86 +- src/layouts/default/tabs/types.ts | 6 +- src/layouts/default/tabs/useMultipleTabs.ts | 26 +- src/layouts/default/tabs/useTabDropdown.ts | 37 +- src/layouts/default/trigger/HeaderTrigger.vue | 11 +- src/layouts/default/trigger/SiderTrigger.vue | 15 +- src/layouts/default/trigger/index.vue | 17 +- src/layouts/iframe/index.vue | 20 +- src/layouts/iframe/useFrameKeepAlive.ts | 24 +- src/layouts/page/index.vue | 58 +- src/layouts/page/transition.ts | 9 +- src/locales/helper.ts | 6 +- src/locales/lang/en.ts | 6 +- src/locales/lang/en/action.ts | 2 +- src/locales/lang/en/common.ts | 2 +- src/locales/lang/en/component.ts | 30 +- src/locales/lang/en/layout.ts | 8 +- src/locales/lang/en/profile.ts | 10 +- src/locales/lang/en/routes/basic.ts | 2 +- src/locales/lang/en/routes/dashboard.ts | 2 +- src/locales/lang/en/sys.ts | 18 +- src/locales/lang/zh-CN/action.ts | 2 +- .../lang/zh-CN/antdLocale/DatePicker.ts | 4 +- src/locales/lang/zh-CN/common.ts | 2 +- src/locales/lang/zh-CN/component.ts | 30 +- src/locales/lang/zh-CN/layout.ts | 8 +- src/locales/lang/zh-CN/profile.ts | 10 +- src/locales/lang/zh-CN/routes/basic.ts | 2 +- src/locales/lang/zh-CN/routes/dashboard.ts | 2 +- src/locales/lang/zh-CN/sys.ts | 14 +- src/locales/lang/zh_CN.ts | 6 +- src/locales/setupI18n.ts | 12 +- src/locales/useLocale.ts | 19 +- src/logics/error-handle/index.ts | 60 +- src/logics/initAppConfig.ts | 16 +- src/logics/mitt/routeChange.ts | 2 +- src/logics/theme/dark.ts | 17 +- src/logics/theme/index.ts | 9 +- src/logics/theme/updateBackground.ts | 32 +- src/main.ts | 12 +- src/router/constant.ts | 4 +- src/router/guard/index.ts | 36 +- src/router/guard/paramMenuGuard.ts | 16 +- src/router/guard/permissionGuard.ts | 22 +- src/router/helper/menuHelper.ts | 37 +- src/router/helper/routeHelper.ts | 78 +- src/router/index.ts | 10 +- src/router/menus/index.ts | 59 +- src/router/routes/basic.ts | 22 +- src/router/routes/index.ts | 98 +- src/router/routes/modules/about.ts | 10 +- src/router/routes/modules/dashboard.ts | 14 +- src/router/types.ts | 8 +- src/settings/componentSetting.ts | 13 +- src/settings/designSetting.ts | 6 +- src/settings/encryptionSetting.ts | 2 +- src/settings/localeSetting.ts | 10 +- src/settings/projectSetting.ts | 22 +- src/settings/sizeSetting.ts | 15 +- src/store/modules/app.ts | 17 +- src/store/modules/dict.ts | 25 +- src/store/modules/errorLog.ts | 18 +- src/store/modules/locale.ts | 12 +- src/store/modules/lock.ts | 22 +- src/store/modules/multipleTab.ts | 100 +- src/store/modules/permission.ts | 48 +- src/store/modules/user.ts | 56 +- src/store/modules/userMessage.ts | 10 +- src/utils/auth/index.ts | 6 +- src/utils/bem.ts | 9 +- src/utils/cache/index.ts | 16 +- src/utils/cache/memory.ts | 18 +- src/utils/cache/persistent.ts | 38 +- src/utils/cache/storageCache.ts | 21 +- src/utils/cipher.ts | 14 +- src/utils/color.ts | 31 +- src/utils/dateUtil.ts | 61 +- src/utils/dict.ts | 20 +- src/utils/domUtils.ts | 76 +- src/utils/env.ts | 10 +- src/utils/event/index.ts | 9 +- src/utils/factory/createAsyncComponent.tsx | 7 +- src/utils/file/base64Conver.ts | 8 +- src/utils/file/download.ts | 14 +- src/utils/helper/treeHelper.ts | 45 +- src/utils/helper/tsxHelper.tsx | 13 +- src/utils/http/axios/Axios.ts | 114 +- src/utils/http/axios/axiosCancel.ts | 9 +- src/utils/http/axios/axiosRetry.ts | 13 +- src/utils/http/axios/checkStatus.ts | 14 +- src/utils/http/axios/helper.ts | 21 +- src/utils/http/axios/index.ts | 127 +- src/utils/index.ts | 53 +- src/utils/is.ts | 9 +- src/utils/lib/echarts.ts | 28 +- src/utils/mitt.ts | 10 +- src/utils/propTypes.ts | 7 +- src/utils/props.ts | 63 +- src/utils/tongji.ts | 12 +- src/utils/tree.ts | 82 +- src/utils/types.ts | 2 +- src/utils/uuid.ts | 14 +- src/views/base/about/index.vue | 68 +- src/views/base/exception/Exception.vue | 33 +- src/views/base/iframe/FrameBlank.vue | 7 +- src/views/base/iframe/index.vue | 28 +- src/views/base/lock/LockPage.vue | 147 +- src/views/base/lock/index.vue | 11 +- src/views/base/lock/useNow.ts | 8 +- src/views/base/login/ForgetPasswordForm.vue | 64 +- src/views/base/login/Login.vue | 69 +- src/views/base/login/LoginForm.vue | 227 +-- src/views/base/login/LoginFormTitle.vue | 15 +- src/views/base/login/MobileForm.vue | 115 +- src/views/base/login/QrCodeForm.vue | 31 +- src/views/base/login/RegisterForm.vue | 94 +- src/views/base/login/SSOForm.vue | 115 +- src/views/base/login/SessionTimeoutLogin.vue | 21 +- src/views/base/login/sso.vue | 61 +- src/views/base/login/useLogin.ts | 32 +- src/views/base/profile/AccountBind.vue | 54 +- src/views/base/profile/BaseSetting.vue | 58 +- src/views/base/profile/MsgNotify.vue | 18 +- src/views/base/profile/PasswordModal.vue | 21 +- src/views/base/profile/SecureSetting.vue | 53 +- src/views/base/profile/data.ts | 78 +- src/views/base/profile/index.vue | 25 +- src/views/base/redirect/index.vue | 16 +- src/views/bpm/form/FormModal.vue | 18 +- src/views/bpm/form/editor/index.vue | 7 +- src/views/bpm/form/form.data.ts | 23 +- src/views/bpm/form/index.vue | 80 +- src/views/bpm/group/GroupModal.vue | 26 +- src/views/bpm/group/group.data.ts | 48 +- src/views/bpm/group/index.vue | 75 +- src/views/bpm/model/ModelModal.vue | 26 +- src/views/bpm/model/editor/index.vue | 4 +- src/views/bpm/model/index.vue | 135 +- src/views/bpm/model/model.data.ts | 95 +- src/views/bpm/oa/leave/create.vue | 4 +- src/views/bpm/oa/leave/detail.vue | 4 +- src/views/bpm/oa/leave/index.vue | 17 +- src/views/bpm/oa/leave/leave.data.ts | 33 +- .../bpm/processInstance/create/index.vue | 4 +- .../bpm/processInstance/detail/index.vue | 4 +- src/views/bpm/processInstance/index.vue | 81 +- .../processInstance/processInstance.data.ts | 39 +- src/views/bpm/task/done/done.data.ts | 29 +- src/views/bpm/task/done/index.vue | 41 +- src/views/bpm/task/todo/index.vue | 31 +- src/views/bpm/task/todo/todo.data.ts | 28 +- .../analysis/components/GrowCard.vue | 33 +- .../analysis/components/SalesProductPie.vue | 36 +- .../analysis/components/SiteAnalysis.vue | 27 +- .../analysis/components/VisitAnalysis.vue | 50 +- .../analysis/components/VisitAnalysisBar.vue | 28 +- .../analysis/components/VisitRadar.vue | 58 +- .../analysis/components/VisitSource.vue | 47 +- .../dashboard/analysis/components/props.ts | 8 +- src/views/dashboard/analysis/data.ts | 10 +- src/views/dashboard/analysis/index.vue | 23 +- .../workbench/components/DynamicInfo.vue | 21 +- .../workbench/components/ProjectCard.vue | 19 +- .../workbench/components/QuickNav.vue | 11 +- .../workbench/components/SaleRadar.vue | 58 +- .../workbench/components/WorkbenchHeader.vue | 23 +- .../dashboard/workbench/components/data.ts | 46 +- src/views/dashboard/workbench/index.vue | 39 +- .../infra/apiAccessLog/AccessLogModal.vue | 18 +- .../infra/apiAccessLog/apiAccessLog.data.ts | 85 +- src/views/infra/apiAccessLog/index.vue | 66 +- src/views/infra/apiErrorLog/ErrorLogModal.vue | 18 +- .../infra/apiErrorLog/apiErrorLog.data.ts | 105 +- src/views/infra/apiErrorLog/index.vue | 98 +- src/views/infra/build/index.vue | 12 +- src/views/infra/codegen/EditTable.vue | 58 +- src/views/infra/codegen/codegen.data.ts | 64 +- .../codegen/components/BasicInfoForm.vue | 100 +- .../codegen/components/CloumInfoForm.vue | 53 +- .../infra/codegen/components/FinishForm.vue | 34 +- .../codegen/components/ImportTableModal.vue | 17 +- .../infra/codegen/components/PreviewModal.vue | 114 +- src/views/infra/codegen/components/data.ts | 116 +- src/views/infra/codegen/index.vue | 107 +- src/views/infra/config/ConfigModal.vue | 26 +- src/views/infra/config/config.data.ts | 55 +- src/views/infra/config/index.vue | 86 +- .../DataSourceConfigModal.vue | 26 +- .../dataSourceConfig/dataSourceConfig.data.ts | 27 +- src/views/infra/dataSourceConfig/index.vue | 89 +- src/views/infra/dbDoc/index.vue | 37 +- src/views/infra/druid/index.vue | 13 +- src/views/infra/file/file.data.ts | 33 +- src/views/infra/file/index.vue | 130 +- .../infra/fileConfig/FileConfigModal.vue | 35 +- .../infra/fileConfig/ficleConfig.data.ts | 65 +- src/views/infra/fileConfig/index.vue | 99 +- src/views/infra/job/JobModal.vue | 60 +- src/views/infra/job/index.vue | 115 +- src/views/infra/job/job.data.ts | 69 +- src/views/infra/job/logger/JobLogModal.vue | 17 +- src/views/infra/job/logger/index.vue | 50 +- src/views/infra/job/logger/jobLog.data.ts | 63 +- .../infra/redis/components/CommandStats.vue | 30 +- src/views/infra/redis/components/Memory.vue | 38 +- .../infra/redis/components/RedisModal.vue | 46 +- src/views/infra/redis/index.vue | 50 +- src/views/infra/redis/redis.data.ts | 53 +- src/views/infra/server/index.vue | 13 +- src/views/infra/skywalking/index.vue | 11 +- src/views/infra/swagger/index.vue | 16 +- src/views/infra/webSocket/index.vue | 129 +- src/views/mp/account/AccountModal.vue | 26 +- src/views/mp/account/account.data.ts | 43 +- src/views/mp/account/index.vue | 107 +- .../mp/components/WxAccountSelect/index.vue | 30 +- src/views/mp/components/WxLocation/index.vue | 75 +- .../mp/components/WxMaterialSelect/index.vue | 4 +- .../mp/components/WxMaterialSelect/type.ts | 4 +- src/views/mp/components/WxMsg/index.vue | 4 +- src/views/mp/components/WxMusic/index.vue | 4 +- src/views/mp/components/WxNews/index.vue | 155 +- src/views/mp/components/WxReply/index.vue | 4 +- src/views/mp/components/WxVideoPlay/index.vue | 4 +- src/views/mp/components/WxVoicePlay/index.vue | 4 +- src/views/mp/freePublish/index.vue | 25 +- src/views/mp/message/MessageModal.vue | 21 +- src/views/mp/message/index.vue | 39 +- src/views/mp/message/message.data.ts | 103 +- .../components/InterfaceSummaryChart.vue | 4 +- .../components/UpstreamMessageChart.vue | 4 +- .../components/UserCumulateChart.vue | 4 +- .../components/UserSummaryChart.vue | 4 +- src/views/mp/statistics/index.vue | 5 +- src/views/mp/tag/TagModal.vue | 28 +- src/views/mp/tag/index.vue | 83 +- src/views/mp/tag/tag.data.ts | 29 +- src/views/mp/user/MpUserModal.vue | 21 +- src/views/mp/user/index.vue | 51 +- src/views/mp/user/mpuser.data.ts | 43 +- src/views/pay/app/AppModal.vue | 28 +- src/views/pay/app/ChannelModal.vue | 35 +- src/views/pay/app/app.data.ts | 149 +- src/views/pay/app/index.vue | 158 +- src/views/pay/demo/DemoModal.vue | 21 +- src/views/pay/demo/demo.data.ts | 45 +- src/views/pay/demo/index.vue | 89 +- src/views/pay/merchant/MerchantModal.vue | 28 +- src/views/pay/merchant/index.vue | 86 +- src/views/pay/merchant/merchant.data.ts | 63 +- src/views/pay/order/OrderModal.vue | 13 +- src/views/pay/order/index.vue | 58 +- src/views/pay/order/order.data.ts | 135 +- src/views/pay/refund/RefundModal.vue | 13 +- src/views/pay/refund/index.vue | 58 +- src/views/pay/refund/refund.data.ts | 139 +- src/views/pay/submit/index.vue | 137 +- src/views/pay/submit/submit.data.ts | 18 +- src/views/report/goview/index.vue | 11 +- src/views/report/jmreport/index.vue | 13 +- src/views/system/area/AreaModal.vue | 18 +- src/views/system/area/area.data.ts | 14 +- src/views/system/area/index.vue | 37 +- src/views/system/dept/DeptModal.vue | 26 +- src/views/system/dept/dept.data.ts | 62 +- src/views/system/dept/index.vue | 100 +- src/views/system/dict/DictData.vue | 85 +- src/views/system/dict/DictDataModal.vue | 31 +- src/views/system/dict/DictTypeModal.vue | 26 +- src/views/system/dict/dict.data.ts | 89 +- src/views/system/dict/dict.type.ts | 37 +- src/views/system/dict/index.vue | 81 +- src/views/system/errorCode/ErrorCodeModal.vue | 26 +- src/views/system/errorCode/errorCode.data.ts | 45 +- src/views/system/errorCode/index.vue | 86 +- src/views/system/loginlog/index.vue | 30 +- src/views/system/loginlog/loginLog.data.ts | 33 +- .../system/mail/account/AccountModal.vue | 26 +- src/views/system/mail/account/account.data.ts | 47 +- src/views/system/mail/account/index.vue | 75 +- src/views/system/mail/log/MailLogModal.vue | 20 +- src/views/system/mail/log/index.vue | 51 +- src/views/system/mail/log/mailLog.data.ts | 79 +- .../system/mail/template/SendMailModal.vue | 49 +- .../system/mail/template/TemplateModal.vue | 26 +- src/views/system/mail/template/index.vue | 101 +- .../system/mail/template/template.data.ts | 87 +- src/views/system/menu/MenuModal.vue | 26 +- src/views/system/menu/index.vue | 83 +- src/views/system/menu/menu.data.ts | 71 +- src/views/system/notice/NoticeModal.vue | 26 +- src/views/system/notice/index.vue | 75 +- src/views/system/notice/notice.data.ts | 39 +- .../notify/components/MessageInfoModal.vue | 17 +- .../system/notify/components/message.data.ts | 34 +- src/views/system/notify/message/index.vue | 51 +- .../system/notify/message/message.data.ts | 77 +- src/views/system/notify/my/index.vue | 93 +- src/views/system/notify/my/my.data.ts | 45 +- .../notify/template/SendNotifyModal.vue | 47 +- .../system/notify/template/TemplateModal.vue | 26 +- src/views/system/notify/template/index.vue | 101 +- .../system/notify/template/template.data.ts | 65 +- .../system/oauth2/client/ClientModal.vue | 26 +- src/views/system/oauth2/client/client.data.ts | 81 +- src/views/system/oauth2/client/index.vue | 75 +- src/views/system/oauth2/token/index.vue | 59 +- src/views/system/oauth2/token/token.data.ts | 27 +- src/views/system/operatelog/LogInfoModal.vue | 14 +- src/views/system/operatelog/index.vue | 64 +- .../system/operatelog/operateLog.data.ts | 81 +- src/views/system/post/PostModal.vue | 26 +- src/views/system/post/index.vue | 86 +- src/views/system/post/post.data.ts | 45 +- src/views/system/role/RoleMenuModal.vue | 68 +- src/views/system/role/RoleModal.vue | 26 +- src/views/system/role/RoleScopeModal.vue | 47 +- src/views/system/role/index.vue | 122 +- src/views/system/role/role.data.ts | 71 +- .../sensitiveWord/SensitiveWordModal.vue | 26 +- src/views/system/sensitiveWord/index.vue | 96 +- .../sensitiveWord/sensitiveWord.data.ts | 45 +- .../system/sms/channel/SmsChannelModal.vue | 26 +- src/views/system/sms/channel/index.vue | 75 +- .../system/sms/channel/smsChannel.data.ts | 55 +- src/views/system/sms/log/index.vue | 32 +- src/views/system/sms/log/smsLog.data.ts | 56 +- .../system/sms/template/SendSmsModal.vue | 45 +- .../system/sms/template/SmsTemplateModal.vue | 26 +- src/views/system/sms/template/index.vue | 100 +- .../system/sms/template/smsTemplate.data.ts | 79 +- src/views/system/tenant/TenantModal.vue | 26 +- src/views/system/tenant/index.vue | 86 +- src/views/system/tenant/tenant.data.ts | 71 +- .../tenantPackage/TenantPackageModal.vue | 72 +- src/views/system/tenantPackage/index.vue | 85 +- .../tenantPackage/tenantPackage.data.ts | 37 +- src/views/system/user/DeptTree.vue | 32 +- src/views/system/user/ResetPwdModal.vue | 21 +- src/views/system/user/UserModal.vue | 26 +- src/views/system/user/UserRoleModal.vue | 21 +- src/views/system/user/index.vue | 126 +- src/views/system/user/user.data.ts | 115 +- stylelint.config.js | 85 +- vite.config.ts | 34 +- 819 files changed, 17792 insertions(+), 16878 deletions(-) delete mode 100644 .lintstagedrc.js delete mode 100644 prettier.config.js diff --git a/.eslintrc.js b/.eslintrc.js index af4a0fdc..04949ce7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,74 +1,15 @@ +const process = require('node:process') + +process.env.ESLINT_TSCONFIG = 'tsconfig.json' + module.exports = { - root: true, - env: { - browser: true, - node: true, - es6: true - }, - parser: 'vue-eslint-parser', - plugins: ['vue'], - parserOptions: { - parser: '@typescript-eslint/parser', - ecmaVersion: 2020, - sourceType: 'module', - jsxPragma: 'React', - ecmaFeatures: { - jsx: true - } - }, - extends: ['plugin:vue/vue3-recommended', 'prettier', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'], + extends: '@antfu', rules: { 'max-len': ['error', { code: 140, tabWidth: 2, ignoreComments: true }], - 'vue/script-setup-uses-vars': 'error', - '@typescript-eslint/ban-ts-ignore': 'off', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/no-var-requires': 'off', - '@typescript-eslint/no-empty-function': 'off', - 'vue/custom-event-name-casing': 'off', - 'no-use-before-define': 'off', - '@typescript-eslint/no-use-before-define': 'off', - '@typescript-eslint/ban-ts-comment': 'off', - '@typescript-eslint/ban-types': 'off', - '@typescript-eslint/no-non-null-assertion': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^_' - } - ], - 'no-unused-vars': [ - 'error', - { - argsIgnorePattern: '^_', - varsIgnorePattern: '^_' - } - ], - 'space-before-function-paren': 'off', - - 'vue/attributes-order': 'off', - 'vue/one-component-per-file': 'off', - 'vue/html-closing-bracket-newline': 'off', - 'vue/max-attributes-per-line': 'off', - 'vue/multiline-html-element-content-newline': 'off', - 'vue/singleline-html-element-content-newline': 'off', - 'vue/attribute-hyphenation': 'off', - 'vue/require-default-prop': 'off', - 'vue/require-explicit-emits': 'off', - 'vue/html-self-closing': [ - 'error', - { - html: { - void: 'always', - normal: 'never', - component: 'always' - }, - svg: 'always', - math: 'always' - } - ], - 'vue/multi-word-component-names': 'off' - } + '@typescript-eslint/no-floating-promises': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + 'no-case-declarations': 'off', + 'no-console': 'off', + 'n/prefer-global/process': 'off', + }, } diff --git a/.lintstagedrc.js b/.lintstagedrc.js deleted file mode 100644 index b8b6c4cb..00000000 --- a/.lintstagedrc.js +++ /dev/null @@ -1,8 +0,0 @@ -// .lintstagedrc.js -module.exports = { - '*.js': ['prettier --config prettier.config.js --write', 'eslint --fix --ext .js'], - '*.ts': ['prettier --config prettier.config.js --write', 'eslint --fix --ext .ts'], - '*.vue': ['prettier --config prettier.config.js --write', 'eslint --fix --ext .vue'], - '*.tsx': ['prettier --config prettier.config.js --write', 'eslint --fix --ext .tsx'], - '*.json': 'prettier --config prettier.config.js --write' -} diff --git a/.vscode/settings.json b/.vscode/settings.json index c4647826..ec278ee9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,5 @@ { "typescript.tsdk": "./node_modules/typescript/lib", - "volar.tsPlugin": true, - "volar.tsPluginStatus": false, "npm.packageManager": "pnpm", "editor.tabSize": 2, "prettier.printWidth": 140, // 超过最大值换行 @@ -60,33 +58,24 @@ "path-intellisense.mappings": { "@/": "${workspaceRoot}/src" }, - "[javascriptreact]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[typescript]": { - "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" - }, - "[typescriptreact]": { - "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" - }, - "[html]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[css]": { - "editor.defaultFormatter": "rvest.vs-code-prettier-eslint" - }, - "[less]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[scss]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "[markdown]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" - }, + "prettier.enable": false, + "editor.formatOnSave": false, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": true, + "source.organizeImports": false }, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "vue", + "html", + "markdown", + "json", + "jsonc", + "yaml" + ], "[vue]": { "editor.codeActionsOnSave": { "source.fixAll.eslint": true, @@ -136,27 +125,6 @@ "pnpm", "antd" ], - "vetur.format.scriptInitialIndent": true, - "vetur.format.styleInitialIndent": true, - "vetur.validation.script": false, - "MicroPython.executeButton": [ - { - "text": "▶", - "tooltip": "运行", - "alignment": "left", - "command": "extension.executeFile", - "priority": 3.5 - } - ], - "MicroPython.syncButton": [ - { - "text": "$(sync)", - "tooltip": "同步", - "alignment": "left", - "command": "extension.execute", - "priority": 4 - } - ], // 控制相关文件嵌套展示 "explorer.fileNesting.enabled": true, "explorer.fileNesting.expand": false, diff --git a/build/config/themeConfig.ts b/build/config/themeConfig.ts index 0d539967..b1b5bdd0 100644 --- a/build/config/themeConfig.ts +++ b/build/config/themeConfig.ts @@ -17,7 +17,7 @@ export interface GenerateColorsParams { export function generateAntColors(color: string, theme: GenerateTheme = 'default') { return generate(color, { - theme + theme, }) } @@ -31,7 +31,7 @@ export function getThemeColors(color?: string) { } export function generateColors({ color = primaryColor, mixLighten, mixDarken, tinycolor }: GenerateColorsParams) { - const arr = new Array(19).fill(0) + const arr = Array.from({ length: 19 }).fill(0) const lightens = arr.map((_t, i) => { return mixLighten(color, i / 5) }) @@ -46,7 +46,7 @@ export function generateColors({ color = primaryColor, mixLighten, mixDarken, ti .toRgbString() }) - const shortAlphaColors = alphaColors.map((item) => item.replace(/\s/g, '').replace(/0\./g, '.')) + const shortAlphaColors = alphaColors.map(item => item.replace(/\s/g, '').replace(/0\./g, '.')) const tinycolorLightens = arr .map((_t, i) => { @@ -54,7 +54,7 @@ export function generateColors({ color = primaryColor, mixLighten, mixDarken, ti .lighten(i * 5) .toHexString() }) - .filter((item) => item !== '#ffffff') + .filter(item => item !== '#ffffff') const tinycolorDarkens = arr .map((_t, i) => { @@ -62,8 +62,8 @@ export function generateColors({ color = primaryColor, mixLighten, mixDarken, ti .darken(i * 5) .toHexString() }) - .filter((item) => item !== '#000000') + .filter(item => item !== '#000000') return [...lightens, ...darkens, ...alphaColors, ...shortAlphaColors, ...tinycolorDarkens, ...tinycolorLightens].filter( - (item) => !item.includes('-') + item => !item.includes('-'), ) } diff --git a/build/generate/generateModifyVars.ts b/build/generate/generateModifyVars.ts index db206309..6357763d 100644 --- a/build/generate/generateModifyVars.ts +++ b/build/generate/generateModifyVars.ts @@ -1,6 +1,6 @@ -import { generateAntColors, primaryColor } from '../config/themeConfig' +import { resolve } from 'node:path' import { getThemeVariables } from 'ant-design-vue/dist/theme' -import { resolve } from 'path' +import { generateAntColors, primaryColor } from '../config/themeConfig' /** * less global variable @@ -11,16 +11,15 @@ export function generateModifyVars(dark = false) { const primaryColorObj: Record = {} - for (let index = 0; index < 10; index++) { + for (let index = 0; index < 10; index++) primaryColorObj[`primary-${index + 1}`] = palettes[index] - } const modifyVars = getThemeVariables({ dark }) return { ...modifyVars, // Used for global import to avoid the need to import each style file separately // reference: Avoid repeated references - hack: `${modifyVars.hack} @import (reference) "${resolve('src/design/config.less')}";`, + 'hack': `${modifyVars.hack} @import (reference) "${resolve('src/design/config.less')}";`, 'primary-color': primary, ...primaryColorObj, 'info-color': primary, @@ -28,10 +27,10 @@ export function generateModifyVars(dark = false) { 'success-color': '#55D187', // Success color 'error-color': '#ED6F6F', // False color 'warning-color': '#EFBD47', // Warning color - //'border-color-base': '#EEEEEE', + // 'border-color-base': '#EEEEEE', 'font-size-base': '14px', // Main font size 'border-radius-base': '2px', // Component/float fillet 'link-color': primary, // Link color - 'app-content-background': '#fafafa' // Link color + 'app-content-background': '#fafafa', // Link color } } diff --git a/build/generate/icon/index.ts b/build/generate/icon/index.ts index a3be71b9..5e160fb3 100644 --- a/build/generate/icon/index.ts +++ b/build/generate/icon/index.ts @@ -1,4 +1,4 @@ -import path from 'path' +import path from 'node:path' import fs from 'fs-extra' import inquirer from 'inquirer' import colors from 'picocolors' @@ -11,10 +11,10 @@ async function generateIcon() { const collections = Object.entries(raw).map(([id, v]) => ({ ...(v as any), - id + id, })) - const choices = collections.map((item) => ({ key: item.id, value: item.id, name: item.name })) + const choices = collections.map(item => ({ key: item.id, value: item.id, name: item.name })) inquirer .prompt([ @@ -23,39 +23,39 @@ async function generateIcon() { name: 'useType', choices: [ { key: 'local', value: 'local', name: 'Local' }, - { key: 'onLine', value: 'onLine', name: 'OnLine' } + { key: 'onLine', value: 'onLine', name: 'OnLine' }, ], - message: 'How to use icons?' + message: 'How to use icons?', }, { type: 'list', name: 'iconSet', - choices: choices, - message: 'Select the icon set that needs to be generated?' + choices, + message: 'Select the icon set that needs to be generated?', }, { type: 'input', name: 'output', message: 'Select the icon set that needs to be generated?', - default: 'src/components/Icon/data' - } + default: 'src/components/Icon/data', + }, ]) .then(async (answers) => { const { iconSet, output, useType } = answers const outputDir = path.resolve(process.cwd(), output) await fs.ensureDir(outputDir) - const genCollections = collections.filter((item) => [iconSet].includes(item.id)) + const genCollections = collections.filter(item => [iconSet].includes(item.id)) const prefixSet: string[] = [] for (const info of genCollections) { const data = await fs.readJSON(path.join(dir, 'json', `${info.id}.json`)) if (data) { const { prefix } = data const isLocal = useType === 'local' - const icons = Object.keys(data.icons).map((item) => `${isLocal ? prefix + ':' : ''}${item}`) + const icons = Object.keys(data.icons).map(item => `${isLocal ? `${prefix}:` : ''}${item}`) await fs.writeFileSync( - path.join(output, `icons.data.ts`), - `export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}` + path.join(output, 'icons.data.ts'), + `export default ${isLocal ? JSON.stringify(icons) : JSON.stringify({ prefix, icons })}`, ) prefixSet.push(prefix) } diff --git a/build/getConfigFileName.ts b/build/getConfigFileName.ts index 4db6b708..510c537b 100644 --- a/build/getConfigFileName.ts +++ b/build/getConfigFileName.ts @@ -2,6 +2,6 @@ * Get the configuration file variable name * @param env */ -export const getConfigFileName = (env: Record) => { +export function getConfigFileName(env: Record) { return `__PRODUCTION__${env.VITE_GLOB_APP_SHORT_NAME || '__APP'}__CONF__`.toUpperCase().replace(/\s/g, '') } diff --git a/build/script/buildConf.ts b/build/script/buildConf.ts index 73df033b..8d4e331f 100644 --- a/build/script/buildConf.ts +++ b/build/script/buildConf.ts @@ -1,9 +1,9 @@ /** * Generate additional configuration files when used for packaging. The file can be configured with some global variables, so that it can be changed directly externally without repackaging */ -import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant' import fs, { writeFileSync } from 'fs-extra' import colors from 'picocolors' +import { GLOB_CONFIG_FILE_NAME, OUTPUT_DIR } from '../constant' import { getEnvConfig, getRootPath } from '../utils' import { getConfigFileName } from '../getConfigFileName' @@ -33,10 +33,11 @@ function createConfig(params: CreateConfigParams) { fs.mkdirp(getRootPath(OUTPUT_DIR)) writeFileSync(getRootPath(`${OUTPUT_DIR}/${configFileName}`), configStr) - console.log(colors.cyan(`✨ [${pkg.name}]`) + ` - configuration file is build successfully:`) - console.log(colors.gray(OUTPUT_DIR + '/' + colors.green(configFileName)) + '\n') - } catch (error) { - console.log(colors.red('configuration file configuration file failed to package:\n' + error)) + console.log(`${colors.cyan(`✨ [${pkg.name}]`)} - configuration file is build successfully:`) + console.log(`${colors.gray(`${OUTPUT_DIR}/${colors.green(configFileName)}`)}\n`) + } + catch (error) { + console.log(colors.red(`configuration file configuration file failed to package:\n${error}`)) } } diff --git a/build/script/postBuild.ts b/build/script/postBuild.ts index bbe05ed1..5d3a7146 100644 --- a/build/script/postBuild.ts +++ b/build/script/postBuild.ts @@ -1,22 +1,22 @@ // #!/usr/bin/env node -import { runBuildConfig } from './buildConf' import colors from 'picocolors' import pkg from '../../package.json' +import { runBuildConfig } from './buildConf' -export const runBuild = async () => { +export async function runBuild() { try { const argvList = process.argv.splice(2) // Generate configuration file - if (!argvList.includes('disabled-config')) { + if (!argvList.includes('disabled-config')) runBuildConfig() - } console.log(`✨ ${colors.cyan(`[${pkg.name}]`)}` + ' - build successfully!') - } catch (error) { - console.log(colors.red('vite build error:\n' + error)) + } + catch (error) { + console.log(colors.red(`vite build error:\n${error}`)) process.exit(1) } } diff --git a/build/utils.ts b/build/utils.ts index 6550b637..67276d54 100644 --- a/build/utils.ts +++ b/build/utils.ts @@ -1,5 +1,5 @@ -import fs from 'fs' -import path from 'path' +import fs from 'node:fs' +import path from 'node:path' import dotenv from 'dotenv' export function isDevFn(mode: string): boolean { @@ -25,13 +25,14 @@ export function wrapperEnv(envConf: Recordable): ViteEnv { let realName = envConf[envName].replace(/\\n/g, '\n') realName = realName === 'true' ? true : realName === 'false' ? false : realName - if (envName === 'VITE_PORT') { + if (envName === 'VITE_PORT') realName = Number(realName) - } + if (envName === 'VITE_PROXY' && realName) { try { realName = JSON.parse(realName.replace(/'/g, '"')) - } catch (error) { + } + catch (error) { realName = '' } } @@ -70,15 +71,15 @@ export function getEnvConfig(match = 'VITE_GLOB_', confFiles = getConfFiles()) { try { const env = dotenv.parse(fs.readFileSync(path.resolve(process.cwd(), item))) envConfig = { ...envConfig, ...env } - } catch (e) { + } + catch (e) { console.error(`Error in parsing ${item}`, e) } }) const reg = new RegExp(`^(${match})`) Object.keys(envConfig).forEach((key) => { - if (!reg.test(key)) { + if (!reg.test(key)) Reflect.deleteProperty(envConfig, key) - } }) return envConfig } diff --git a/build/vite/optimize.ts b/build/vite/optimize.ts index f3c81daf..7310ddbf 100644 --- a/build/vite/optimize.ts +++ b/build/vite/optimize.ts @@ -28,7 +28,7 @@ const include = [ 'ant-design-vue', 'ant-design-vue/es/style', 'ant-design-vue/es/locale/zh_CN', - 'ant-design-vue/es/locale/en_US' + 'ant-design-vue/es/locale/en_US', ] const exclude = ['@iconify/json'] diff --git a/build/vite/plugin/compress.ts b/build/vite/plugin/compress.ts index 3dc0b4eb..2cf006e9 100644 --- a/build/vite/plugin/compress.ts +++ b/build/vite/plugin/compress.ts @@ -7,7 +7,7 @@ import compressPlugin from 'vite-plugin-compression' export function configCompressPlugin( compress: 'gzip' | 'brotli' | 'none' = 'none', - deleteOriginFile = false + deleteOriginFile = false, ): PluginOption | PluginOption[] { const compressList = compress.split(',') @@ -17,8 +17,8 @@ export function configCompressPlugin( plugins.push( compressPlugin({ ext: '.gz', - deleteOriginFile - }) + deleteOriginFile, + }), ) } @@ -27,8 +27,8 @@ export function configCompressPlugin( compressPlugin({ ext: '.br', algorithm: 'brotliCompress', - deleteOriginFile - }) + deleteOriginFile, + }), ) } return plugins diff --git a/build/vite/plugin/html.ts b/build/vite/plugin/html.ts index 6ea129c4..d35937f4 100644 --- a/build/vite/plugin/html.ts +++ b/build/vite/plugin/html.ts @@ -21,7 +21,7 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { inject: { // Inject data into ejs template data: { - title: VITE_GLOB_APP_TITLE + title: VITE_GLOB_APP_TITLE, }, // Embed the generated app.config.js file tags: isBuild @@ -29,12 +29,12 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) { { tag: 'script', attrs: { - src: getAppConfigSrc() - } - } + src: getAppConfigSrc(), + }, + }, ] - : [] - } + : [], + }, }) return htmlPlugin } diff --git a/build/vite/plugin/index.ts b/build/vite/plugin/index.ts index 5838adc6..9a20c6ae 100644 --- a/build/vite/plugin/index.ts +++ b/build/vite/plugin/index.ts @@ -1,9 +1,11 @@ -import { PluginOption } from 'vite' +import type { PluginOption } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import progress from 'vite-plugin-progress' import purgeIcons from 'vite-plugin-purge-icons' import VitePluginCertificate from 'vite-plugin-mkcert' +import UnoCSS from 'unocss/vite' +import { presetTypography, presetUno } from 'unocss' import { configPwaConfig } from './pwa' import { configHtmlPlugin } from './html' import { configCompressPlugin } from './compress' @@ -11,8 +13,6 @@ import { configStyleImportPlugin } from './styleImport' import { configVisualizerConfig } from './visualizer' import { configThemePlugin } from './theme' import { configSvgIconsPlugin } from './svgSprite' -import UnoCSS from 'unocss/vite' -import { presetTypography, presetUno } from 'unocss' export async function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { const { VITE_BUILD_COMPRESS, VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv @@ -24,13 +24,13 @@ export async function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { vueJsx(), // UnoCSS UnoCSS({ - presets: [presetUno(), presetTypography()] + presets: [presetUno(), presetTypography()], }), // 打包进度条 progress(), VitePluginCertificate({ - source: 'coding' - }) + source: 'coding', + }), ] // vite-vue-plugin-html diff --git a/build/vite/plugin/pwa.ts b/build/vite/plugin/pwa.ts index a0970af6..b131c333 100644 --- a/build/vite/plugin/pwa.ts +++ b/build/vite/plugin/pwa.ts @@ -17,15 +17,15 @@ export function configPwaConfig(env: ViteEnv) { { src: './resource/img/pwa-192x192.png', sizes: '192x192', - type: 'image/png' + type: 'image/png', }, { src: './resource/img/pwa-512x512.png', sizes: '512x512', - type: 'image/png' - } - ] - } + type: 'image/png', + }, + ], + }, }) return pwaPlugin } diff --git a/build/vite/plugin/styleImport.ts b/build/vite/plugin/styleImport.ts index 27b784f8..ca2d39ec 100644 --- a/build/vite/plugin/styleImport.ts +++ b/build/vite/plugin/styleImport.ts @@ -5,9 +5,9 @@ import { createStyleImportPlugin } from 'vite-plugin-style-import' export function configStyleImportPlugin(_isBuild: boolean) { - if (!_isBuild) { + if (!_isBuild) return [] - } + const styleImportPlugin = createStyleImportPlugin({ libs: [ { @@ -44,12 +44,12 @@ export function configStyleImportPlugin(_isBuild: boolean) { 'skeleton-title', 'skeleton-paragraph', 'skeleton-image', - 'skeleton-button' + 'skeleton-button', ] // 这里是需要额外引入样式的子组件列表 // 单独引入子组件时需引入组件样式,否则会在打包后导致子组件样式丢失 const replaceList = { - textarea: 'input', + 'textarea': 'input', 'typography-text': 'typography', 'typography-title': 'typography', 'typography-paragraph': 'typography', @@ -66,17 +66,17 @@ export function configStyleImportPlugin(_isBuild: boolean) { 'layout-header': 'layout', 'month-picker': 'date-picker', 'range-picker': 'date-picker', - 'image-preview-group': 'image' + 'image-preview-group': 'image', } return ignoreList.includes(name) ? '' : replaceList.hasOwnProperty(name) - ? `ant-design-vue/es/${replaceList[name]}/style/index` - : `ant-design-vue/es/${name}/style/index` - } - } - ] + ? `ant-design-vue/es/${replaceList[name]}/style/index` + : `ant-design-vue/es/${name}/style/index` + }, + }, + ], }) return styleImportPlugin } diff --git a/build/vite/plugin/svgSprite.ts b/build/vite/plugin/svgSprite.ts index f4d29b59..5b396800 100644 --- a/build/vite/plugin/svgSprite.ts +++ b/build/vite/plugin/svgSprite.ts @@ -3,16 +3,16 @@ * https://github.com/anncwb/vite-plugin-svg-icons */ +import path from 'node:path' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' -import path from 'path' -import { PluginOption } from 'vite' +import type { PluginOption } from 'vite' export function configSvgIconsPlugin(isBuild: boolean) { const svgIconsPlugin = createSvgIconsPlugin({ iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], svgoOptions: isBuild, // default - symbolId: 'icon-[dir]-[name]' + symbolId: 'icon-[dir]-[name]', }) return svgIconsPlugin as PluginOption } diff --git a/build/vite/plugin/theme.ts b/build/vite/plugin/theme.ts index e882efbe..9eef9fb7 100644 --- a/build/vite/plugin/theme.ts +++ b/build/vite/plugin/theme.ts @@ -2,17 +2,17 @@ * Vite plugin for website theme color switching * https://github.com/xingyuv/vite-vue-plugin-theme */ +import path from 'node:path' import type { PluginOption } from 'vite' -import path from 'path' -import { viteThemePlugin, antdDarkThemePlugin, mixLighten, mixDarken, tinycolor } from 'vite-vue-plugin-theme' -import { getThemeColors, generateColors } from '../../config/themeConfig' +import { antdDarkThemePlugin, mixDarken, mixLighten, tinycolor, viteThemePlugin } from 'vite-vue-plugin-theme' +import { generateColors, getThemeColors } from '../../config/themeConfig' import { generateModifyVars } from '../../generate/generateModifyVars' export function configThemePlugin(isBuild: boolean): PluginOption[] { const colors = generateColors({ mixDarken, mixLighten, - tinycolor + tinycolor, }) const plugin = [ viteThemePlugin({ @@ -37,15 +37,15 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] { } return s.startsWith('[data-theme') ? s : `[data-theme] ${s}` }, - colorVariables: [...getThemeColors(), ...colors] + colorVariables: [...getThemeColors(), ...colors], }), antdDarkThemePlugin({ preloadFiles: [ path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'), - //path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.dark.less'), - path.resolve(process.cwd(), 'src/design/index.less') + // path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.dark.less'), + path.resolve(process.cwd(), 'src/design/index.less'), ], - filter: (id) => (isBuild ? !id.endsWith('antd.less') : true), + filter: id => (isBuild ? !id.endsWith('antd.less') : true), // extractCss: false, darkModifyVars: { ...generateModifyVars(true), @@ -74,9 +74,9 @@ export function configThemePlugin(isBuild: boolean): PluginOption[] { 'alert-warning-icon-color': '#d89614', 'alert-error-border-color': '#58181c', 'alert-error-bg-color': '#2a1215', - 'alert-error-icon-color': '#a61d24' - } - }) + 'alert-error-icon-color': '#a61d24', + }, + }), ] return plugin as unknown as PluginOption[] diff --git a/build/vite/plugin/visualizer.ts b/build/vite/plugin/visualizer.ts index f97b0121..eb392a52 100644 --- a/build/vite/plugin/visualizer.ts +++ b/build/vite/plugin/visualizer.ts @@ -2,8 +2,8 @@ * Package file volume analysis */ import visualizer from 'rollup-plugin-visualizer' +import type { PluginOption } from 'vite' import { isReportMode } from '../../utils' -import { PluginOption } from 'vite' export function configVisualizerConfig() { if (isReportMode()) { @@ -11,7 +11,7 @@ export function configVisualizerConfig() { filename: './node_modules/.cache/visualizer/stats.html', open: true, gzipSize: true, - brotliSize: true + brotliSize: true, }) as PluginOption } return [] diff --git a/build/vite/proxy.ts b/build/vite/proxy.ts index c12f12c7..4559b98e 100644 --- a/build/vite/proxy.ts +++ b/build/vite/proxy.ts @@ -22,12 +22,12 @@ export function createProxy(list: ProxyList = []) { // https://github.com/http-party/node-http-proxy#options ret[prefix] = { - target: target, + target, changeOrigin: true, ws: true, - rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ''), + rewrite: path => path.replace(new RegExp(`^${prefix}`), ''), // https is require secure=false - ...(isHttps ? { secure: false } : {}) + ...(isHttps ? { secure: false } : {}), } } return ret diff --git a/commitlint.config.js b/commitlint.config.js index 27b7a886..906d79e9 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,25 +1,25 @@ -const fs = require('fs') -const path = require('path') -const { execSync } = require('child_process') +const fs = require('node:fs') +const path = require('node:path') +const { execSync } = require('node:child_process') const scopes = fs .readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true }) - .filter((dirent) => dirent.isDirectory()) - .map((dirent) => dirent.name.replace(/s$/, '')) + .filter(dirent => dirent.isDirectory()) + .map(dirent => dirent.name.replace(/s$/, '')) // precomputed scope const scopeComplete = execSync('git status --porcelain || true') .toString() .trim() .split('\n') - .find((r) => ~r.indexOf('M src')) + .find(r => ~r.indexOf('M src')) ?.replace(/(\/)/g, '%%') ?.match(/src%%((\w|-)*)/)?.[1] ?.replace(/s$/, '') /** @type {import('cz-git').UserConfig} */ module.exports = { - ignores: [(commit) => commit.includes('init')], + ignores: [commit => commit.includes('init')], extends: ['@commitlint/config-conventional'], rules: { 'body-leading-blank': [2, 'always'], @@ -31,8 +31,8 @@ module.exports = { 'type-enum': [ 2, 'always', - ['feat', 'fix', 'perf', 'style', 'docs', 'test', 'refactor', 'build', 'ci', 'chore', 'revert', 'wip', 'workflow', 'types', 'release'] - ] + ['feat', 'fix', 'perf', 'style', 'docs', 'test', 'refactor', 'build', 'ci', 'chore', 'revert', 'wip', 'workflow', 'types', 'release'], + ], }, prompt: { /** @use `yarn commit :f` */ @@ -41,7 +41,7 @@ module.exports = { r: 'docs: update README', s: 'style: update code format', b: 'build: bump dependencies', - c: 'chore: update config' + c: 'chore: update config', }, customScopesAlign: !scopeComplete ? 'top' : 'bottom', defaultScope: scopeComplete, @@ -53,7 +53,7 @@ module.exports = { typesAppend: [ { value: 'wip', name: 'wip: work in process' }, { value: 'workflow', name: 'workflow: workflow improvements' }, - { value: 'types', name: 'types: type definition file changes' } + { value: 'types', name: 'types: type definition file changes' }, ], // 中英文对照版 @@ -67,7 +67,7 @@ module.exports = { footerPrefixsSelect: '选择关联issue前缀 (可选):', customFooterPrefixs: '输入自定义issue前缀 :', footer: '列举关联issue (可选) 例如: #31, #I3244 :\n', - confirmCommit: '是否提交或修改commit ?' + confirmCommit: '是否提交或修改commit ?', }, types: [ { value: 'feat', name: 'feat: 新增功能' }, @@ -83,9 +83,9 @@ module.exports = { { value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改 (不影响源文件、测试用例)' }, { value: 'wip', name: 'wip: 正在开发中' }, { value: 'workflow', name: 'workflow: 工作流程改进' }, - { value: 'types', name: 'types: 类型定义文件修改' } + { value: 'types', name: 'types: 类型定义文件修改' }, ], emptyScopesAlias: 'empty: 不填写', - customScopesAlias: 'custom: 自定义' - } + customScopesAlias: 'custom: 自定义', + }, } diff --git a/index.html b/index.html index 09e0d2c7..b8d6c2d9 100644 --- a/index.html +++ b/index.html @@ -11,13 +11,13 @@
diff --git a/src/components/Application/src/AppProvider.vue b/src/components/Application/src/AppProvider.vue index 3b0fb23e..f3b3caef 100644 --- a/src/components/Application/src/AppProvider.vue +++ b/src/components/Application/src/AppProvider.vue @@ -1,5 +1,5 @@ diff --git a/src/components/Application/src/AppSizePicker.vue b/src/components/Application/src/AppSizePicker.vue index 6dd7ca02..ce9b3d9f 100644 --- a/src/components/Application/src/AppSizePicker.vue +++ b/src/components/Application/src/AppSizePicker.vue @@ -1,44 +1,29 @@ - + + diff --git a/src/components/Container/src/collapse/CollapseHeader.vue b/src/components/Container/src/collapse/CollapseHeader.vue index efaab3e2..96a696bb 100644 --- a/src/components/Container/src/collapse/CollapseHeader.vue +++ b/src/components/Container/src/collapse/CollapseHeader.vue @@ -1,5 +1,5 @@ diff --git a/src/components/ContextMenu/src/ContextMenu.vue b/src/components/ContextMenu/src/ContextMenu.vue index 44a329d0..98f0b3bd 100644 --- a/src/components/ContextMenu/src/ContextMenu.vue +++ b/src/components/ContextMenu/src/ContextMenu.vue @@ -1,9 +1,9 @@ + diff --git a/src/components/Cropper/src/Cropper.vue b/src/components/Cropper/src/Cropper.vue index 4e8dfc92..049ff2cb 100644 --- a/src/components/Cropper/src/Cropper.vue +++ b/src/components/Cropper/src/Cropper.vue @@ -1,18 +1,26 @@ - + + + diff --git a/src/components/FormDesign/src/components/VFormPreview/index.vue b/src/components/FormDesign/src/components/VFormPreview/index.vue index 5cfee306..4c699e4c 100644 --- a/src/components/FormDesign/src/components/VFormPreview/index.vue +++ b/src/components/FormDesign/src/components/VFormPreview/index.vue @@ -1,42 +1,23 @@ - + + diff --git a/src/components/FormDesign/src/components/VFormPreview/useForm.vue b/src/components/FormDesign/src/components/VFormPreview/useForm.vue index d50e8107..0c0d786f 100644 --- a/src/components/FormDesign/src/components/VFormPreview/useForm.vue +++ b/src/components/FormDesign/src/components/VFormPreview/useForm.vue @@ -1,30 +1,14 @@ - + + diff --git a/src/components/FormDesign/src/components/index.ts b/src/components/FormDesign/src/components/index.ts index e8f98aa1..ea8613b6 100644 --- a/src/components/FormDesign/src/components/index.ts +++ b/src/components/FormDesign/src/components/index.ts @@ -1,9 +1,4 @@ import type { Component } from 'vue' -import { ComponentType } from '@/components/Form/src/types' -import { IconPicker } from '@/components/Icon/index' -/** - * Component list, register here to setting it in the form - */ import { Input, Button, @@ -22,10 +17,16 @@ import { Rate, Divider, Calendar, - Transfer + Transfer, } from 'ant-design-vue' +import type { ComponentType } from '@/components/Form/src/types' +import { IconPicker } from '@/components/Icon/index' -//ant-desing本身的Form控件库 +/** + * Component list, register here to setting it in the form + */ + +// ant-desing本身的Form控件库 const componentMap = new Map() componentMap.set('Radio', Radio) diff --git a/src/components/FormDesign/src/core/formItemConfig.ts b/src/components/FormDesign/src/core/formItemConfig.ts index 8871e116..436ad857 100644 --- a/src/components/FormDesign/src/core/formItemConfig.ts +++ b/src/components/FormDesign/src/core/formItemConfig.ts @@ -1,26 +1,24 @@ /** * @description:表单配置 */ -import { IVFormComponent } from '../typings/v-form-component' import { isArray } from 'lodash-es' -import { componentMap as VbenCmp, add } from '@/components/Form/src/componentMap' -import { ComponentType } from '@/components/Form/src/types' - +import type { Component } from 'vue' +import type { IVFormComponent } from '../typings/v-form-component' import { componentMap as Cmp } from '../components' -import { Component } from 'vue' +import { componentMap as VbenCmp, add } from '@/components/Form/src/componentMap' +import type { ComponentType } from '@/components/Form/src/types' const componentMap = new Map() -//如果有其它控件,可以在这里初始化 +// 如果有其它控件,可以在这里初始化 -//注册Ant控件库 +// 注册Ant控件库 Cmp.forEach((value, key) => { componentMap.set(key, value) - if (VbenCmp[key] == null) { + if (VbenCmp[key] == null) add(key as ComponentType, value) - } }) -//注册vben控件库 +// 注册vben控件库 VbenCmp.forEach((value, key) => { componentMap.set(key, value) }) @@ -38,14 +36,15 @@ export function setFormDesignComponents(config: IVFormComponent | IVFormComponen componentMap[item.component] = component customComponents.push(Object.assign({ props: {} }, rest)) }) - } else { + } + else { const { componentInstance: component, ...rest } = config componentMap[config.component] = component customComponents.push(Object.assign({ props: {} }, rest)) } } -//外部设置的自定义控件 +// 外部设置的自定义控件 export const customComponents: IVFormComponent[] = [] // 左侧控件列表与初始化的控件属性 @@ -58,7 +57,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'line-md:iconify2', colProps: { span: 24 }, field: '', - componentProps: {} + componentProps: {}, }, { component: 'IconPicker', @@ -66,7 +65,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'line-md:iconify2', colProps: { span: 24 }, field: '', - componentProps: {} + componentProps: {}, }, { component: 'StrengthMeter', @@ -74,7 +73,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'wpf:password1', colProps: { span: 24 }, field: '', - componentProps: {} + componentProps: {}, }, { component: 'AutoComplete', @@ -87,14 +86,14 @@ export const baseComponents: IVFormComponent[] = [ options: [ { value: '/^(?:(?:\\+|00)86)?1[3-9]\\d{9}$/', - label: '手机号码' + label: '手机号码', }, { value: '/^((ht|f)tps?:\\/\\/)?[\\w-]+(\\.[\\w-]+)+:\\d{1,5}\\/?$/', - label: '网址带端口号' - } - ] - } + label: '网址带端口号', + }, + ], + }, }, { component: 'Divider', @@ -104,15 +103,15 @@ export const baseComponents: IVFormComponent[] = [ field: '', componentProps: { orientation: 'center', - dashed: true - } + dashed: true, + }, }, { component: 'Checkbox', label: '复选框', icon: 'ant-design:check-circle-outlined', colProps: { span: 24 }, - field: '' + field: '', }, { component: 'CheckboxGroup', @@ -124,14 +123,14 @@ export const baseComponents: IVFormComponent[] = [ options: [ { label: '选项1', - value: '1' + value: '1', }, { label: '选项2', - value: '2' - } - ] - } + value: '2', + }, + ], + }, }, { component: 'Input', @@ -140,8 +139,8 @@ export const baseComponents: IVFormComponent[] = [ field: '', colProps: { span: 24 }, componentProps: { - type: 'text' - } + type: 'text', + }, }, { component: 'InputNumber', @@ -149,7 +148,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'ant-design:field-number-outlined', field: '', colProps: { span: 24 }, - componentProps: { style: 'width:200px' } + componentProps: { style: 'width:200px' }, }, { component: 'InputTextArea', @@ -157,7 +156,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'ant-design:file-text-filled', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'Select', @@ -169,14 +168,14 @@ export const baseComponents: IVFormComponent[] = [ options: [ { label: '选项1', - value: '1' + value: '1', }, { label: '选项2', - value: '2' - } - ] - } + value: '2', + }, + ], + }, }, { @@ -185,7 +184,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'ant-design:check-circle-outlined', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'RadioGroup', @@ -197,14 +196,14 @@ export const baseComponents: IVFormComponent[] = [ options: [ { label: '选项1', - value: '1' + value: '1', }, { label: '选项2', - value: '2' - } - ] - } + value: '2', + }, + ], + }, }, { component: 'DatePicker', @@ -212,7 +211,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'healthicons:i-schedule-school-date-time-outline', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'RangePicker', @@ -221,8 +220,8 @@ export const baseComponents: IVFormComponent[] = [ field: '', colProps: { span: 24 }, componentProps: { - placeholder: ['开始日期', '结束日期'] - } + placeholder: ['开始日期', '结束日期'], + }, }, { component: 'MonthPicker', @@ -231,8 +230,8 @@ export const baseComponents: IVFormComponent[] = [ field: '', colProps: { span: 24 }, componentProps: { - placeholder: '请选择月份' - } + placeholder: '请选择月份', + }, }, { component: 'TimePicker', @@ -240,7 +239,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'healthicons:i-schedule-school-date-time', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'Slider', @@ -248,7 +247,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'vaadin:slider', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'Rate', @@ -256,7 +255,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'ic:outline-star-rate', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'Switch', @@ -264,7 +263,7 @@ export const baseComponents: IVFormComponent[] = [ icon: 'entypo:switch', field: '', colProps: { span: 24 }, - componentProps: {} + componentProps: {}, }, { component: 'TreeSelect', @@ -280,16 +279,16 @@ export const baseComponents: IVFormComponent[] = [ children: [ { label: '选项三', - value: '1-1' - } - ] + value: '1-1', + }, + ], }, { label: '选项2', - value: '2' - } - ] - } + value: '2', + }, + ], + }, }, { component: 'Upload', @@ -298,8 +297,8 @@ export const baseComponents: IVFormComponent[] = [ field: '', colProps: { span: 24 }, componentProps: { - api: () => 1 - } + api: () => 1, + }, }, { component: 'Cascader', @@ -315,16 +314,16 @@ export const baseComponents: IVFormComponent[] = [ children: [ { label: '选项三', - value: '1-1' - } - ] + value: '1-1', + }, + ], }, { label: '选项2', - value: '2' - } - ] - } + value: '2', + }, + ], + }, }, // { // component: 'Button', @@ -354,9 +353,9 @@ export const baseComponents: IVFormComponent[] = [ field: '', colProps: { span: 24 }, componentProps: { - slotName: 'slotName' - } - } + slotName: 'slotName', + }, + }, ] // https://next.antdv.com/components/transfer-cn @@ -367,30 +366,30 @@ const transferControl = { field: '', colProps: { span: 24 }, componentProps: { - render: (item) => item.title, + render: item => item.title, dataSource: [ { key: 'key-1', title: '标题1', description: '描述', disabled: false, - chosen: true + chosen: true, }, { key: 'key-2', title: 'title2', description: 'description2', - disabled: true + disabled: true, }, { key: 'key-3', title: '标题3', description: '描述3', disabled: false, - chosen: true - } - ] - } + chosen: true, + }, + ], + }, } baseComponents.push(transferControl) @@ -405,16 +404,16 @@ export const layoutComponents: IVFormComponent[] = [ columns: [ { span: 12, - children: [] + children: [], }, { span: 12, - children: [] - } + children: [], + }, ], colProps: { span: 24 }, options: { - gutter: 0 - } - } + gutter: 0, + }, + }, ] diff --git a/src/components/FormDesign/src/core/iconConfig.ts b/src/components/FormDesign/src/core/iconConfig.ts index 19a84e74..73bcaf39 100644 --- a/src/components/FormDesign/src/core/iconConfig.ts +++ b/src/components/FormDesign/src/core/iconConfig.ts @@ -213,7 +213,7 @@ const iconConfig = { 'yuque', 'youtube', 'zhihu-circle', - 'zhihu-square' + 'zhihu-square', ], outlined: [ 'account-book', @@ -582,7 +582,7 @@ const iconConfig = { 'zhihu', 'woman', 'zoom-out', - 'zoom-in' + 'zoom-in', ], twoTone: [ 'account-book', @@ -732,8 +732,8 @@ const iconConfig = { 'dollar', 'euro', 'gold', - 'canlendar' - ] + 'canlendar', + ], } export default iconConfig diff --git a/src/components/FormDesign/src/hooks/useFormDesignState.ts b/src/components/FormDesign/src/hooks/useFormDesignState.ts index 8e0cdc6f..353ce74f 100644 --- a/src/components/FormDesign/src/hooks/useFormDesignState.ts +++ b/src/components/FormDesign/src/hooks/useFormDesignState.ts @@ -1,6 +1,7 @@ -import { inject, Ref } from 'vue' -import { IFormDesignMethods } from '../typings/form-type' -import { IFormConfig } from '../typings/v-form-component' +import type { Ref } from 'vue' +import { inject } from 'vue' +import type { IFormDesignMethods } from '../typings/form-type' +import type { IFormConfig } from '../typings/v-form-component' /** * 获取formDesign状态 @@ -13,6 +14,6 @@ export function useFormDesignState() { export function useFormModelState() { const formModel = inject('formModel') as Ref<{}> - const setFormModel = inject('setFormModelMethod') as (key: String, value: any) => void + const setFormModel = inject('setFormModelMethod') as (key: string, value: any) => void return { formModel, setFormModel } } diff --git a/src/components/FormDesign/src/hooks/useFormInstanceMethods.ts b/src/components/FormDesign/src/hooks/useFormInstanceMethods.ts index fa2d638f..c6f95db9 100644 --- a/src/components/FormDesign/src/hooks/useFormInstanceMethods.ts +++ b/src/components/FormDesign/src/hooks/useFormInstanceMethods.ts @@ -1,10 +1,9 @@ -import { IAnyObject } from '../typings/base-type' -import { Ref, SetupContext } from 'vue' +import { getCurrentInstance, toRaw } from 'vue' +import type { Ref, SetupContext } from 'vue' import { cloneDeep, forOwn, isFunction } from 'lodash-es' -import { AForm, IVFormComponent } from '../typings/v-form-component' -import { getCurrentInstance } from 'vue' import { Form } from 'ant-design-vue' -import { toRaw } from 'vue' +import type { AForm, IVFormComponent } from '../typings/v-form-component' +import type { IAnyObject } from '../typings/base-type' export function useFormInstanceMethods(props: IAnyObject, formdata, context: Partial, _formInstance: Ref) { /** @@ -13,19 +12,18 @@ export function useFormInstanceMethods(props: IAnyObject, formdata, context: Par const bindContext = () => { const instance = getCurrentInstance() const vm = instance?.parent - if (!vm) return + if (!vm) + return ;(props.formConfig.schemas as IVFormComponent[]).forEach((item) => { // 绑定 props 中的上下文 forOwn(item.componentProps, (value: any, key) => { - if (isFunction(value)) { + if (isFunction(value)) item.componentProps![key] = value.bind(vm) - } }) // 绑定事件监听(v-on)的上下文 forOwn(item.on, (value: any, key) => { - if (isFunction(value)) { + if (isFunction(value)) item.componentProps![key] = value.bind(vm) - } }) }) } @@ -38,7 +36,7 @@ export function useFormInstanceMethods(props: IAnyObject, formdata, context: Par const { resetFields, validate, clearValidate, validateField } = useForm(formdata, []) const submit = async () => { - //const _result = await validate(); + // const _result = await validate(); const data = cloneDeep(toRaw(formdata.value)) emit?.('submit', data) @@ -51,6 +49,6 @@ export function useFormInstanceMethods(props: IAnyObject, formdata, context: Par validateField, resetFields, clearValidate, - submit + submit, } } diff --git a/src/components/FormDesign/src/hooks/useVFormMethods.ts b/src/components/FormDesign/src/hooks/useVFormMethods.ts index 62ef621b..795261cf 100644 --- a/src/components/FormDesign/src/hooks/useVFormMethods.ts +++ b/src/components/FormDesign/src/hooks/useVFormMethods.ts @@ -1,8 +1,8 @@ -import { Ref, SetupContext } from 'vue' -import { IVFormComponent, IFormConfig, AForm } from '../typings/v-form-component' -import { findFormItem, formItemsForEach } from '../utils' +import type { Ref, SetupContext } from 'vue' import { cloneDeep, isFunction } from 'lodash-es' -import { IAnyObject } from '../typings/base-type' +import type { AForm, IFormConfig, IVFormComponent } from '../typings/v-form-component' +import { findFormItem, formItemsForEach } from '../utils' +import type { IAnyObject } from '../typings/base-type' interface IFormInstanceMethods extends AForm { submit: () => Promise @@ -52,14 +52,14 @@ export function useVFormMethods( props: IProps, _context: Partial, formInstance: Ref, - formInstanceMethods: Partial + formInstanceMethods: Partial, ): IVFormMethods { /** * 根据field获取表单项 * @param {string} field * @return {IVFormComponent | undefined} */ - const get: IGet = (field) => findFormItem(props.formConfig.schemas, (item) => item.field === field) + const get: IGet = field => findFormItem(props.formConfig.schemas, item => item.field === field) /** * 根据表单field设置表单项字段值 @@ -69,7 +69,8 @@ export function useVFormMethods( */ const set: ISet = (field, key, value) => { const formItem = get(field) - if (formItem) formItem[key] = value + if (formItem) + formItem[key] = value } /** @@ -96,7 +97,8 @@ export function useVFormMethods( // props.formData[field] = value props.formModel[field] = value formInstance.value?.validateField(field, value, []) - } else { + } + else { const keys = Object.keys(field) keys.forEach((key) => { props.formModel[key] = field[key] @@ -162,10 +164,10 @@ export function useVFormMethods( formItemsForEach(schemas, (formItem) => { // 如果需要关联,则进行第二层遍历,查找表单中关联的字段,存到Set中 formItemsForEach(schemas, (item) => { - if (!linkOn[item.field!]) linkOn[item.field!] = new Set() - if (formItem.link?.includes(item.field!) && isFunction(formItem.update)) { + if (!linkOn[item.field!]) + linkOn[item.field!] = new Set() + if (formItem.link?.includes(item.field!) && isFunction(formItem.update)) linkOn[item.field!].add(formItem) - } }) linkOn[formItem.field!].add(formItem) }) @@ -183,6 +185,6 @@ export function useVFormMethods( setProps, getData, disable, - ...formInstanceMethods + ...formInstanceMethods, } } diff --git a/src/components/FormDesign/src/typings/form-type.ts b/src/components/FormDesign/src/typings/form-type.ts index 6e9bf505..ed675842 100644 --- a/src/components/FormDesign/src/typings/form-type.ts +++ b/src/components/FormDesign/src/typings/form-type.ts @@ -1,6 +1,6 @@ -import { Ref } from 'vue' -import { IAnyObject } from './base-type' -import { IFormConfig, IVFormComponent } from './v-form-component' +import type { Ref } from 'vue' +import type { IAnyObject } from './base-type' +import type { IFormConfig, IVFormComponent } from './v-form-component' export interface IToolbarMethods { showModal: (jsonData: IAnyObject) => void diff --git a/src/components/FormDesign/src/typings/v-form-component.ts b/src/components/FormDesign/src/typings/v-form-component.ts index b67712ae..b941592c 100644 --- a/src/components/FormDesign/src/typings/v-form-component.ts +++ b/src/components/FormDesign/src/typings/v-form-component.ts @@ -1,13 +1,14 @@ -import { IAnyObject } from './base-type' // import { ComponentOptions } from 'vue/types/options'; -import { ComponentOptions } from 'vue' -import { IVFormMethods } from '../hooks/useVFormMethods' -import { ColEx } from '@/components/Form/src/types' +import type { ComponentOptions } from 'vue' + +import type { SelectValue } from 'ant-design-vue/lib/select' +import type { validateOptions } from 'ant-design-vue/lib/form/useForm' +import type { RuleError } from 'ant-design-vue/lib/form/interface' +import type { IVFormMethods } from '../hooks/useVFormMethods' +import type { IAnyObject } from './base-type' +import type { ColEx } from '@/components/Form/src/types' +import type { FormItem } from '@/components/Form' -import { SelectValue } from 'ant-design-vue/lib/select' -import { validateOptions } from 'ant-design-vue/lib/form/useForm' -import { RuleError } from 'ant-design-vue/lib/form/interface' -import { FormItem } from '@/components/Form' type LayoutType = 'horizontal' | 'vertical' | 'inline' type labelLayout = 'flex' | 'Grid' export type PropsTabKey = 1 | 2 | 3 diff --git a/src/components/FormDesign/src/utils/index.ts b/src/components/FormDesign/src/utils/index.ts index 566ab8b4..ca36ed28 100644 --- a/src/components/FormDesign/src/utils/index.ts +++ b/src/components/FormDesign/src/utils/index.ts @@ -1,6 +1,7 @@ // import { VueConstructor } from 'vue'; -import { IVFormComponent, IFormConfig, IValidationRule } from '../typings/v-form-component' import { cloneDeep, isArray, isFunction, isNumber, uniqueId } from 'lodash-es' +import type { IFormConfig, IVFormComponent, IValidationRule } from '../typings/v-form-component' + // import { del } from '@vue/composition-api'; // import { withInstall } from '/@/utils'; @@ -40,14 +41,15 @@ export function generateKey(formItem?: IVFormComponent): string | boolean { */ export function remove(array: Array, value: number | ((item: T, index: number, array: Array) => boolean)): T | undefined { let removeVal: Array = [] - if (!isArray(array)) return undefined + if (!isArray(array)) + return undefined if (isNumber(value)) { removeVal = array.splice(value, 1) - } else { + } + else { const index = array.findIndex(value) - if (index !== -1) { + if (index !== -1) removeVal = array.splice(index, 1) - } } return removeVal.shift() } @@ -85,13 +87,15 @@ export function toLine(str: string) { * @param cb */ export function formItemsForEach(array: IVFormComponent[], cb: (item: IVFormComponent) => void) { - if (!isArray(array)) return + if (!isArray(array)) + return const traverse = (schemas: IVFormComponent[]) => { schemas.forEach((formItem: IVFormComponent) => { if (['Grid'].includes(formItem.component)) { // 栅格布局 - formItem.columns?.forEach((item) => traverse(item.children)) - } else { + formItem.columns?.forEach(item => traverse(item.children)) + } + else { cb(formItem) } }) @@ -104,17 +108,18 @@ export function formItemsForEach(array: IVFormComponent[], cb: (item: IVFormComp */ export const findFormItem: (schemas: IVFormComponent[], cb: (formItem: IVFormComponent) => boolean) => IVFormComponent | undefined = ( schemas, - cb + cb, ) => { let res const traverse = (schemas: IVFormComponent[]): boolean => { return schemas.some((formItem: IVFormComponent) => { const { component: type } = formItem // 处理栅格 - if (['Grid'].includes(type)) { - return formItem.columns?.some((item) => traverse(item.children)) - } - if (cb(formItem)) res = formItem + if (['Grid'].includes(type)) + return formItem.columns?.some(item => traverse(item.children)) + + if (cb(formItem)) + res = formItem return cb(formItem) }) } @@ -127,12 +132,12 @@ export const findFormItem: (schemas: IVFormComponent[], cb: (formItem: IVFormCom * @param formConfig {IFormConfig} * @returns {IFormConfig} */ -export const removeAttrs = (formConfig: IFormConfig): IFormConfig => { +export function removeAttrs(formConfig: IFormConfig): IFormConfig { const copyFormConfig = cloneDeep(formConfig) delete copyFormConfig.currentItem delete copyFormConfig.activeKey - copyFormConfig.schemas && - formItemsForEach(copyFormConfig.schemas, (item) => { + copyFormConfig.schemas + && formItemsForEach(copyFormConfig.schemas, (item) => { delete item.icon delete item.key }) @@ -144,11 +149,13 @@ export const removeAttrs = (formConfig: IFormConfig): IFormConfig => { * @param {(() => Promise) | any[]} options * @return {Promise} */ -export const handleAsyncOptions = async (options: (() => Promise) | any[]): Promise => { +export async function handleAsyncOptions(options: (() => Promise) | any[]): Promise { try { - if (isFunction(options)) return await options() + if (isFunction(options)) + return await options() return options - } catch { + } + catch { return [] } } @@ -157,13 +164,13 @@ export const handleAsyncOptions = async (options: (() => Promise) | any[] * 格式化表单项校验规则配置 * @param {IVFormComponent[]} schemas */ -export const formatRules = (schemas: IVFormComponent[]) => { +export function formatRules(schemas: IVFormComponent[]) { formItemsForEach(schemas, (item) => { if ('required' in item) { !isArray(item.rules) && (item.rules = []) item.rules.push({ required: true, message: item.message }) - delete item['required'] - delete item['message'] + delete item.required + delete item.message } }) } @@ -173,10 +180,11 @@ export const formatRules = (schemas: IVFormComponent[]) => { * @param {IValidationRule[]} rules * @return {IValidationRule[]} */ -export const strToReg = (rules: IValidationRule[]) => { +export function strToReg(rules: IValidationRule[]) { const newRules = cloneDeep(rules) return newRules.map((item) => { - if (item.pattern) item.pattern = runCode(item.pattern) + if (item.pattern) + item.pattern = runCode(item.pattern) return item }) } @@ -186,10 +194,11 @@ export const strToReg = (rules: IValidationRule[]) => { * @param code * @return {any} */ -export const runCode = (code: any): T => { +export function runCode(code: any): T { try { return new Function(`return ${code}`)() - } catch { + } + catch { return code } } @@ -199,14 +208,14 @@ export const runCode = (code: any): T => { */ // 编码表单 Conf -export const encodeConf = (designerRef: object) => { - // @ts-ignore +export function encodeConf(designerRef: object) { + // @ts-expect-error return JSON.stringify(designerRef.value.getOption()) } // 编码表单 Fields -export const encodeFields = (designerRef: object) => { - // @ts-ignore +export function encodeFields(designerRef: object) { + // @ts-expect-error const rule = designerRef.value.getRule() const fields: string[] = [] rule.forEach((item) => { @@ -216,7 +225,7 @@ export const encodeFields = (designerRef: object) => { } // 解码表单 Fields -export const decodeFields = (fields: string[]) => { +export function decodeFields(fields: string[]) { const rule: object[] = [] fields.forEach((item) => { rule.push(JSON.parse(item)) @@ -225,21 +234,21 @@ export const decodeFields = (fields: string[]) => { } // 设置表单的 Conf 和 Fields -export const setConfAndFields = (designerRef: object, conf: string, fields: string) => { - // @ts-ignore +export function setConfAndFields(designerRef: object, conf: string, fields: string) { + // @ts-expect-error designerRef.value.setOption(JSON.parse(conf)) - // @ts-ignore + // @ts-expect-error designerRef.value.setRule(decodeFields(fields)) } // 设置表单的 Conf 和 Fields -export const setConfAndFields2 = (detailPreview: object, conf: string, fields: string, value?: object) => { - // @ts-ignore +export function setConfAndFields2(detailPreview: object, conf: string, fields: string, value?: object) { + // @ts-expect-error detailPreview.value.option = JSON.parse(conf) - // @ts-ignore + // @ts-expect-error detailPreview.value.rule = decodeFields(fields) if (value) { - // @ts-ignore + // @ts-expect-error detailPreview.value.value = value } } diff --git a/src/components/FormDesign/src/utils/message.ts b/src/components/FormDesign/src/utils/message.ts index b32b953e..d3834b60 100644 --- a/src/components/FormDesign/src/utils/message.ts +++ b/src/components/FormDesign/src/utils/message.ts @@ -1,4 +1,5 @@ import { useMessage } from '@/hooks/web/useMessage' + const { createMessage } = useMessage() const message = Object.assign({ success: (msg: string) => { @@ -12,7 +13,7 @@ const message = Object.assign({ }, info: (msg: string) => { createMessage.info(msg) - } + }, }) export default message diff --git a/src/components/IFrame/index.ts b/src/components/IFrame/index.ts index 7fe1bae7..68cac90d 100644 --- a/src/components/IFrame/index.ts +++ b/src/components/IFrame/index.ts @@ -1,5 +1,4 @@ +import iFrame from './src/IFrame.vue' import { withInstall } from '@/utils' -import iFrame from './src/IFrame.vue' - export const IFrame = withInstall(iFrame) diff --git a/src/components/IFrame/src/IFrame.vue b/src/components/IFrame/src/IFrame.vue index e78ca806..52a3cccc 100644 --- a/src/components/IFrame/src/IFrame.vue +++ b/src/components/IFrame/src/IFrame.vue @@ -1,20 +1,15 @@ - + + + +