foucui 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/components/QiuAffix/index.vue +186 -0
- package/components/QiuAlert/index.vue +208 -0
- package/components/QiuAnchor/context.ts +18 -0
- package/components/QiuAnchor/index.vue +180 -0
- package/components/QiuAnchorLink/index.vue +67 -0
- package/components/QiuApp/index.vue +9 -0
- package/components/QiuAutocomplete/index.vue +408 -0
- package/components/QiuAvatar/index.vue +140 -0
- package/components/QiuBacktop/index.vue +121 -0
- package/components/QiuBadge/api/index.ts +389 -0
- package/components/QiuBadge/components/BadgeImagePickerDialog.vue +243 -0
- package/components/QiuBadge/components/BadgeLibraryManagerDialog.vue +30 -0
- package/components/QiuBadge/components/BadgeLibraryPanel.vue +182 -0
- package/components/QiuBadge/composables/useTableHostHeight.ts +53 -0
- package/components/QiuBadge/index.ts +18 -0
- package/components/QiuBadge/shared/BadgeTemplateRenderer.vue +32 -0
- package/components/QiuBadge/shared/assetUrl.ts +26 -0
- package/components/QiuBadge/shared/badgeTemplate.ts +309 -0
- package/components/QiuBadge/utils/chinaAreaData.ts +44 -0
- package/components/QiuBadge/utils/hostRegion.ts +22 -0
- package/components/QiuBadge/utils/pca-code.json +1 -0
- package/components/QiuBadge/utils/pdfFromElement.ts +348 -0
- package/components/QiuBadge/views/BadgeLibraryView.vue +32 -0
- package/components/QiuBadge/views/BadgeManageView.vue +1364 -0
- package/components/QiuBadge/views/BadgeTemplateEditorView.vue +10 -0
- package/components/QiuBadge/views/BadgeTemplateListView.vue +229 -0
- package/components/QiuBadge/views/DeskLabelTemplateListView.vue +227 -0
- package/components/QiuBadge/views/DeskLabelView.vue +683 -0
- package/components/QiuBadgeDot/index.vue +87 -0
- package/components/QiuButton/index.vue +247 -0
- package/components/QiuButtonGroup/index.vue +63 -0
- package/components/QiuCanvasKit/QiuCanvasEditor.vue +5503 -0
- package/components/QiuCanvasKit/QiuCanvasRenderer.vue +348 -0
- package/components/QiuCanvasKit/assetUrl.ts +11 -0
- package/components/QiuCanvasKit/components/DataModulesPanel.vue +352 -0
- package/components/QiuCanvasKit/export/html.ts +132 -0
- package/components/QiuCanvasKit/export/pdf.ts +48 -0
- package/components/QiuCanvasKit/export/png.ts +50 -0
- package/components/QiuCanvasKit/index.ts +20 -0
- package/components/QiuCanvasKit/modules/badgeCompat.ts +84 -0
- package/components/QiuCanvasKit/modules/dataRegistry.ts +207 -0
- package/components/QiuCanvasKit/modules/merge.ts +71 -0
- package/components/QiuCanvasKit/presets/badge.ts +67 -0
- package/components/QiuCanvasKit/presets/banner.ts +79 -0
- package/components/QiuCanvasKit/types.ts +138 -0
- package/components/QiuCard/index.vue +104 -0
- package/components/QiuCarousel/context.ts +16 -0
- package/components/QiuCarousel/index.vue +343 -0
- package/components/QiuCarouselItem/index.vue +47 -0
- package/components/QiuCascader/index.vue +879 -0
- package/components/QiuCascader/types.ts +48 -0
- package/components/QiuCheckbox/QiuCheckboxGroup.vue +78 -0
- package/components/QiuCheckbox/index.vue +231 -0
- package/components/QiuCheckbox/types.ts +8 -0
- package/components/QiuCode/index.vue +64 -0
- package/components/QiuCol/col.scss +55 -0
- package/components/QiuCol/index.vue +64 -0
- package/components/QiuCollapse/context.ts +10 -0
- package/components/QiuCollapse/index.vue +70 -0
- package/components/QiuCollapseItem/index.vue +167 -0
- package/components/QiuColorField/index.vue +296 -0
- package/components/QiuColorPicker/README.md +118 -0
- package/components/QiuColorPicker/index.vue +60 -0
- package/components/QiuColorfulCard/index.vue +101 -0
- package/components/QiuCombobox/index.vue +277 -0
- package/components/QiuConfigProvider/index.vue +31 -0
- package/components/QiuContextMenu/index.vue +209 -0
- package/components/QiuDate/index.vue +1134 -0
- package/components/QiuDescriptions/context.ts +20 -0
- package/components/QiuDescriptions/index.vue +115 -0
- package/components/QiuDescriptionsItem/index.vue +103 -0
- package/components/QiuDialog/index.vue +828 -0
- package/components/QiuDigitalCard/index.vue +159 -0
- package/components/QiuDivider/index.vue +185 -0
- package/components/QiuDot/index.vue +83 -0
- package/components/QiuDrawer/index.vue +350 -0
- package/components/QiuDropdown/QiuDropdownItem.vue +74 -0
- package/components/QiuDropdown/QiuDropdownMenu.vue +22 -0
- package/components/QiuDropdown/context.ts +9 -0
- package/components/QiuDropdown/index.vue +189 -0
- package/components/QiuEmpty/index.vue +73 -0
- package/components/QiuForm/index.vue +172 -0
- package/components/QiuForm/types.ts +39 -0
- package/components/QiuFormItem/index.vue +276 -0
- package/components/QiuFullscreen/index.vue +11 -0
- package/components/QiuGrid/index.vue +408 -0
- package/components/QiuHoverCard/index.vue +192 -0
- package/components/QiuIcon/index.vue +117 -0
- package/components/QiuIconPicker/iconify.libraries.ts +182 -0
- package/components/QiuIconPicker/icons.catalog.ts +3072 -0
- package/components/QiuIconPicker/index.vue +488 -0
- package/components/QiuImage/index.vue +177 -0
- package/components/QiuInput/index.vue +328 -0
- package/components/QiuInputNumber/index.vue +295 -0
- package/components/QiuInputOtp/index.vue +190 -0
- package/components/QiuKbd/index.vue +57 -0
- package/components/QiuLayoutContainer/index.vue +50 -0
- package/components/QiuLinkPreview/index.vue +224 -0
- package/components/QiuLoading/index.ts +176 -0
- package/components/QiuLoading/spinner.vue +820 -0
- package/components/QiuLoading/types.ts +44 -0
- package/components/QiuMention/index.vue +299 -0
- package/components/QiuMenu/QiuMenuRoot.vue +241 -0
- package/components/QiuMenu/components/QiuMenuItem.vue +340 -0
- package/components/QiuMenu/components/QiuSubMenu.vue +504 -0
- package/components/QiuMenu/context.ts +21 -0
- package/components/QiuMenu/index.vue +43 -0
- package/components/QiuMenuNav/QiuMenuNavItem.vue +100 -0
- package/components/QiuMenuNav/QiuMenuNavSub.vue +120 -0
- package/components/QiuMenuNav/context.ts +14 -0
- package/components/QiuMenuNav/index.vue +148 -0
- package/components/QiuMsg/QiuMsgItem.vue +180 -0
- package/components/QiuMsg/index.ts +158 -0
- package/components/QiuMsg/types.ts +23 -0
- package/components/QiuMsgBox/index.ts +147 -0
- package/components/QiuNotification/QiuNotificationItem.vue +168 -0
- package/components/QiuNotification/index.ts +155 -0
- package/components/QiuNotification/types.ts +14 -0
- package/components/QiuPage/index.vue +12 -0
- package/components/QiuPageHeader/index.vue +115 -0
- package/components/QiuPageMain/index.vue +78 -0
- package/components/QiuPagination/index.vue +421 -0
- package/components/QiuPasswordStrength/index.vue +101 -0
- package/components/QiuPopconfirm/index.vue +196 -0
- package/components/QiuPopover/index.vue +277 -0
- package/components/QiuProgress/index.vue +235 -0
- package/components/QiuQrcode/index.vue +302 -0
- package/components/QiuQueryForm/components/QiuQueryFormBottomPanel.vue +13 -0
- package/components/QiuQueryForm/components/QiuQueryFormLeftPanel.vue +37 -0
- package/components/QiuQueryForm/components/QiuQueryFormRightPanel.vue +37 -0
- package/components/QiuQueryForm/components/QiuQueryFormTopPanel.vue +13 -0
- package/components/QiuQueryForm/index.vue +117 -0
- package/components/QiuRadio/QiuRadioGroup.vue +75 -0
- package/components/QiuRadio/index.vue +191 -0
- package/components/QiuRadio/types.ts +9 -0
- package/components/QiuRate/index.vue +184 -0
- package/components/QiuRefresh/index.vue +32 -0
- package/components/QiuResult/index.vue +103 -0
- package/components/QiuRow/index.vue +60 -0
- package/components/QiuRow/types.ts +5 -0
- package/components/QiuScrollbar/index.vue +107 -0
- package/components/QiuSearchBar/index.vue +154 -0
- package/components/QiuSegmented/index.vue +120 -0
- package/components/QiuSelect/QiuOption.vue +93 -0
- package/components/QiuSelect/index.vue +452 -0
- package/components/QiuSelect/types.ts +15 -0
- package/components/QiuSkeleton/index.vue +78 -0
- package/components/QiuSlider/index.vue +266 -0
- package/components/QiuSpace/index.vue +95 -0
- package/components/QiuSparkline/index.vue +92 -0
- package/components/QiuStatistic/index.vue +4 -0
- package/components/QiuStatistics/index.vue +123 -0
- package/components/QiuStep/index.vue +220 -0
- package/components/QiuSteps/context.ts +25 -0
- package/components/QiuSteps/index.vue +84 -0
- package/components/QiuSwitch/index.vue +145 -0
- package/components/QiuTabBar/index.vue +218 -0
- package/components/QiuTabBar/types.ts +19 -0
- package/components/QiuTabPane/index.vue +82 -0
- package/components/QiuTable/columns.ts +16 -0
- package/components/QiuTable/export.ts +102 -0
- package/components/QiuTable/index.ts +24 -0
- package/components/QiuTable/index.vue +3503 -0
- package/components/QiuTable/registry.ts +75 -0
- package/components/QiuTable/styles/table.scss +1230 -0
- package/components/QiuTable/types.ts +413 -0
- package/components/QiuTable/useArea.ts +202 -0
- package/components/QiuTable/useColumns.ts +325 -0
- package/components/QiuTable/useEdit.ts +136 -0
- package/components/QiuTable/useExtras.ts +115 -0
- package/components/QiuTable/useHistory.ts +77 -0
- package/components/QiuTable/useMerge.ts +105 -0
- package/components/QiuTable/useResize.ts +86 -0
- package/components/QiuTable/useScrollSync.ts +152 -0
- package/components/QiuTable/useVirtual.ts +97 -0
- package/components/QiuTable/utils.ts +165 -0
- package/components/QiuTableColumn/index.vue +101 -0
- package/components/QiuTag/index.vue +143 -0
- package/components/QiuText/index.vue +99 -0
- package/components/QiuTime/index.vue +548 -0
- package/components/QiuTimeAgo/index.vue +103 -0
- package/components/QiuTimeline/index.vue +54 -0
- package/components/QiuTimelineItem/index.vue +140 -0
- package/components/QiuTips/index.vue +323 -0
- package/components/QiuTooltip/index.vue +237 -0
- package/components/QiuTransfer/index.vue +277 -0
- package/components/QiuTree/QiuTreeNode.vue +146 -0
- package/components/QiuTree/index.vue +143 -0
- package/components/QiuTree/types.ts +30 -0
- package/components/QiuTreeSelect/index.vue +259 -0
- package/components/QiuTrend/index.vue +92 -0
- package/components/QiuUpload/index.vue +628 -0
- package/components/QiuUploadCrop/index.vue +1267 -0
- package/components/QiuWatermark/index.vue +121 -0
- package/components/useBodyScrollLock.ts +28 -0
- package/dist/components/QiuAnchor/context.d.ts +15 -0
- package/dist/components/QiuAnchorLink/index.vue.d.ts +23 -0
- package/dist/components/QiuBadge/api/index.d.ts +110 -0
- package/dist/components/QiuBadge/components/BadgeImagePickerDialog.vue.d.ts +16 -0
- package/dist/components/QiuBadge/components/BadgeLibraryManagerDialog.vue.d.ts +9 -0
- package/dist/components/QiuBadge/components/BadgeLibraryPanel.vue.d.ts +5 -0
- package/dist/components/QiuBadge/composables/useTableHostHeight.d.ts +7 -0
- package/dist/components/QiuBadge/index.d.ts +18 -0
- package/dist/components/QiuBadge/shared/BadgeTemplateRenderer.vue.d.ts +14 -0
- package/dist/components/QiuBadge/shared/assetUrl.d.ts +1 -0
- package/dist/components/QiuBadge/shared/badgeTemplate.d.ts +132 -0
- package/dist/components/QiuBadge/utils/chinaAreaData.d.ts +9 -0
- package/dist/components/QiuBadge/utils/hostRegion.d.ts +3 -0
- package/dist/components/QiuBadge/utils/pca-code.json.d.ts +3 -0
- package/dist/components/QiuBadge/utils/pdfFromElement.d.ts +14 -0
- package/dist/components/QiuBadge/views/BadgeLibraryView.vue.d.ts +2 -0
- package/dist/components/QiuBadge/views/BadgeManageView.vue.d.ts +7 -0
- package/dist/components/QiuBadge/views/BadgeTemplateListView.vue.d.ts +4 -0
- package/dist/components/QiuBadge/views/DeskLabelTemplateListView.vue.d.ts +4 -0
- package/dist/components/QiuBadge/views/DeskLabelView.vue.d.ts +4 -0
- package/dist/components/QiuButton/index.vue.d.ts +52 -0
- package/dist/components/QiuCanvasKit/QiuCanvasEditor.vue.d.ts +24 -0
- package/dist/components/QiuCanvasKit/QiuCanvasRenderer.vue.d.ts +13 -0
- package/dist/components/QiuCanvasKit/assetUrl.d.ts +7 -0
- package/dist/components/QiuCanvasKit/components/DataModulesPanel.vue.d.ts +23 -0
- package/dist/components/QiuCanvasKit/export/html.d.ts +12 -0
- package/dist/components/QiuCanvasKit/export/pdf.d.ts +9 -0
- package/dist/components/QiuCanvasKit/export/png.d.ts +8 -0
- package/dist/components/QiuCanvasKit/index.d.ts +19 -0
- package/dist/components/QiuCanvasKit/modules/badgeCompat.d.ts +8 -0
- package/dist/components/QiuCanvasKit/modules/dataRegistry.d.ts +23 -0
- package/dist/components/QiuCanvasKit/modules/merge.d.ts +12 -0
- package/dist/components/QiuCanvasKit/presets/badge.d.ts +12 -0
- package/dist/components/QiuCanvasKit/presets/banner.d.ts +4 -0
- package/dist/components/QiuCanvasKit/types.d.ts +119 -0
- package/dist/components/QiuCarousel/context.d.ts +13 -0
- package/dist/components/QiuCarouselItem/index.vue.d.ts +20 -0
- package/dist/components/QiuCascader/types.d.ts +25 -0
- package/dist/components/QiuCheckbox/QiuCheckboxGroup.vue.d.ts +33 -0
- package/dist/components/QiuCheckbox/index.vue.d.ts +38 -0
- package/dist/components/QiuCheckbox/types.d.ts +7 -0
- package/dist/components/QiuCode/index.vue.d.ts +15 -0
- package/dist/components/QiuCollapse/context.d.ts +8 -0
- package/dist/components/QiuCollapseItem/index.vue.d.ts +30 -0
- package/dist/components/QiuColorField/index.vue.d.ts +23 -0
- package/dist/components/QiuColorPicker/index.vue.d.ts +21 -0
- package/dist/components/QiuCombobox/index.vue.d.ts +54 -0
- package/dist/components/QiuContextMenu/index.vue.d.ts +46 -0
- package/dist/components/QiuDescriptions/context.d.ts +16 -0
- package/dist/components/QiuDescriptionsItem/index.vue.d.ts +25 -0
- package/dist/components/QiuDigitalCard/index.vue.d.ts +45 -0
- package/dist/components/QiuDropdown/QiuDropdownItem.vue.d.ts +30 -0
- package/dist/components/QiuDropdown/QiuDropdownMenu.vue.d.ts +17 -0
- package/dist/components/QiuDropdown/context.d.ts +7 -0
- package/dist/components/QiuDropdown/index.vue.d.ts +46 -0
- package/dist/components/QiuForm/types.d.ts +31 -0
- package/dist/components/QiuHoverCard/index.vue.d.ts +44 -0
- package/dist/components/QiuIcon/index.vue.d.ts +18 -0
- package/dist/components/QiuIconPicker/iconify.libraries.d.ts +18 -0
- package/dist/components/QiuIconPicker/icons.catalog.d.ts +12 -0
- package/dist/components/QiuInput/index.vue.d.ts +71 -0
- package/dist/components/QiuInputNumber/index.vue.d.ts +38 -0
- package/dist/components/QiuInputOtp/index.vue.d.ts +28 -0
- package/dist/components/QiuKbd/index.vue.d.ts +22 -0
- package/dist/components/QiuLayoutContainer/index.vue.d.ts +29 -0
- package/dist/components/QiuLinkPreview/index.vue.d.ts +43 -0
- package/dist/components/QiuLoading/index.d.ts +26 -0
- package/dist/components/QiuLoading/spinner.vue.d.ts +14 -0
- package/dist/components/QiuLoading/types.d.ts +2 -0
- package/dist/components/QiuMention/index.vue.d.ts +35 -0
- package/dist/components/QiuMenu/QiuMenuRoot.vue.d.ts +36 -0
- package/dist/components/QiuMenu/context.d.ts +19 -0
- package/dist/components/QiuMenuNav/QiuMenuNavItem.vue.d.ts +26 -0
- package/dist/components/QiuMenuNav/QiuMenuNavSub.vue.d.ts +25 -0
- package/dist/components/QiuMenuNav/context.d.ts +12 -0
- package/dist/components/QiuMenuNav/index.vue.d.ts +35 -0
- package/dist/components/QiuMsg/QiuMsgItem.vue.d.ts +15 -0
- package/dist/components/QiuMsg/index.d.ts +30 -0
- package/dist/components/QiuMsg/types.d.ts +12 -0
- package/dist/components/QiuMsgBox/index.d.ts +14 -0
- package/dist/components/QiuNotification/QiuNotificationItem.vue.d.ts +16 -0
- package/dist/components/QiuNotification/index.d.ts +30 -0
- package/dist/components/QiuNotification/types.d.ts +12 -0
- package/dist/components/QiuPageMain/index.vue.d.ts +27 -0
- package/dist/components/QiuPagination/index.vue.d.ts +44 -0
- package/dist/components/QiuPasswordStrength/index.vue.d.ts +9 -0
- package/dist/components/QiuQrcode/index.vue.d.ts +20 -0
- package/dist/components/QiuRadio/QiuRadioGroup.vue.d.ts +33 -0
- package/dist/components/QiuRadio/types.d.ts +8 -0
- package/dist/components/QiuRow/types.d.ts +4 -0
- package/dist/components/QiuSearchBar/index.vue.d.ts +38 -0
- package/dist/components/QiuSelect/QiuOption.vue.d.ts +24 -0
- package/dist/components/QiuSelect/index.vue.d.ts +52 -0
- package/dist/components/QiuSelect/types.d.ts +13 -0
- package/dist/components/QiuSparkline/index.vue.d.ts +18 -0
- package/dist/components/QiuStep/index.vue.d.ts +31 -0
- package/dist/components/QiuSteps/context.d.ts +21 -0
- package/dist/components/QiuSwitch/index.vue.d.ts +25 -0
- package/dist/components/QiuTabBar/index.vue.d.ts +32 -0
- package/dist/components/QiuTabBar/types.d.ts +16 -0
- package/dist/components/QiuTabPane/index.vue.d.ts +25 -0
- package/dist/components/QiuTable/columns.d.ts +1 -0
- package/dist/components/QiuTable/export.d.ts +18 -0
- package/dist/components/QiuTable/index.d.ts +3 -0
- package/dist/components/QiuTable/index.vue.d.ts +322 -0
- package/dist/components/QiuTable/registry.d.ts +39 -0
- package/dist/components/QiuTable/types.d.ts +353 -0
- package/dist/components/QiuTable/useArea.d.ts +51 -0
- package/dist/components/QiuTable/useColumns.d.ts +67 -0
- package/dist/components/QiuTable/useEdit.d.ts +36 -0
- package/dist/components/QiuTable/useExtras.d.ts +38 -0
- package/dist/components/QiuTable/useHistory.d.ts +44 -0
- package/dist/components/QiuTable/useMerge.d.ts +28 -0
- package/dist/components/QiuTable/useResize.d.ts +19 -0
- package/dist/components/QiuTable/useScrollSync.d.ts +25 -0
- package/dist/components/QiuTable/useVirtual.d.ts +30 -0
- package/dist/components/QiuTable/utils.d.ts +54 -0
- package/dist/components/QiuTime/index.vue.d.ts +43 -0
- package/dist/components/QiuTimeAgo/index.vue.d.ts +35 -0
- package/dist/components/QiuTimelineItem/index.vue.d.ts +35 -0
- package/dist/components/QiuTooltip/index.vue.d.ts +38 -0
- package/dist/components/QiuTree/types.d.ts +13 -0
- package/dist/components/QiuTrend/index.vue.d.ts +34 -0
- package/dist/components/QiuUpload/index.vue.d.ts +86 -0
- package/dist/components/QiuUploadCrop/index.vue.d.ts +136 -0
- package/dist/components/useBodyScrollLock.d.ts +4 -0
- package/dist/foucui.css +1 -0
- package/dist/foucui.js +26509 -0
- package/dist/foucui.umd.cjs +125 -0
- package/dist/index.d.ts +46 -0
- package/dist/src/bridge/@/api/media.d.ts +7 -0
- package/dist/src/bridge/@/api/notice.d.ts +5 -0
- package/dist/src/bridge/@/config/index.d.ts +29 -0
- package/dist/src/bridge/@/config/media.config.d.ts +15 -0
- package/dist/src/bridge/@/config/security.config.d.ts +7 -0
- package/dist/src/bridge/@/i18n/index.d.ts +7 -0
- package/dist/src/bridge/@/store/modules/bing.d.ts +3 -0
- package/dist/src/bridge/@/store/modules/errorLog.d.ts +3 -0
- package/dist/src/bridge/@/store/modules/media.d.ts +4 -0
- package/dist/src/bridge/@/store/modules/routes.d.ts +3 -0
- package/dist/src/bridge/@/store/modules/settings.d.ts +3 -0
- package/dist/src/bridge/@/store/modules/tabs.d.ts +3 -0
- package/dist/src/bridge/@/store/modules/user.d.ts +3 -0
- package/dist/src/bridge/@/utils/convertToCamelCase.d.ts +2 -0
- package/dist/src/bridge/@/utils/index.d.ts +5 -0
- package/dist/src/bridge/@/utils/pageTitle.d.ts +1 -0
- package/dist/src/bridge/@/utils/routes.d.ts +11 -0
- package/dist/src/bridge/@/utils/validate.d.ts +13 -0
- package/dist/src/bridge/@qiu/plugins/shortcuts.d.ts +2 -0
- package/dist/src/i18n.d.ts +2 -0
- package/package.json +83 -0
- package/plugins/qiu.ts +83 -0
- package/plugins/shortcuts.ts +69 -0
- package/src/bridge/@/api/media.ts +8 -0
- package/src/bridge/@/api/notice.ts +5 -0
- package/src/bridge/@/config/index.ts +38 -0
- package/src/bridge/@/config/media.config.ts +37 -0
- package/src/bridge/@/config/security.config.ts +8 -0
- package/src/bridge/@/i18n/index.ts +6 -0
- package/src/bridge/@/store/modules/bing.ts +9 -0
- package/src/bridge/@/store/modules/errorLog.ts +9 -0
- package/src/bridge/@/store/modules/media.ts +10 -0
- package/src/bridge/@/store/modules/routes.ts +10 -0
- package/src/bridge/@/store/modules/settings.ts +9 -0
- package/src/bridge/@/store/modules/tabs.ts +9 -0
- package/src/bridge/@/store/modules/user.ts +9 -0
- package/src/bridge/@/utils/convertToCamelCase.ts +11 -0
- package/src/bridge/@/utils/index.ts +9 -0
- package/src/bridge/@/utils/pageTitle.ts +4 -0
- package/src/bridge/@/utils/routes.ts +14 -0
- package/src/bridge/@/utils/validate.ts +17 -0
- package/src/bridge/@qiu/plugins/shortcuts.ts +3 -0
- package/src/i18n.ts +8 -0
- package/src/icons/qiu-logo.svg +1 -0
- package/styles/dark.scss +194 -0
- package/styles/normalize.css +349 -0
- package/styles/plain.scss +423 -0
- package/styles/qiu-tokens.scss +40 -0
- package/styles/qiu.scss +1149 -0
- package/styles/technology.scss +452 -0
- package/styles/var.scss +382 -0
- package/styles/variables.scss +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# foucui
|
|
2
|
+
|
|
3
|
+
FouCui 自研 Vue3 组件库(独立可发布包)。包名 **`foucui@1.0.1+`**。
|
|
4
|
+
|
|
5
|
+
原包名迁移路径:`qiuui-vue` →(短暂 `qiuye`)→ **`foucui`**。
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add foucui
|
|
11
|
+
# 或 npm i foucui
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { setupFoucui, setupQiu } from 'foucui'
|
|
16
|
+
import 'foucui/dist/foucui.css'
|
|
17
|
+
import 'foucui/styles/qiu.scss'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`setupFoucui` / `setupQiuye` / `setupQiu` 行为一致。
|
|
21
|
+
|
|
22
|
+
## 画布套件 QiuCanvasKit
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {
|
|
26
|
+
QiuCanvasEditor,
|
|
27
|
+
QiuCanvasRenderer,
|
|
28
|
+
mergeTemplateText,
|
|
29
|
+
createBannerDoc,
|
|
30
|
+
downloadCanvasHtml,
|
|
31
|
+
} from 'foucui'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
业务端只 `from 'foucui'`,禁止 Vite alias 到组件库源码入口。
|
|
35
|
+
|
|
36
|
+
## 发布
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
cd web/qiu-ui
|
|
40
|
+
pnpm install
|
|
41
|
+
pnpm run build
|
|
42
|
+
npm publish --access public
|
|
43
|
+
```
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="rootRef" class="qiu-affix">
|
|
3
|
+
<div
|
|
4
|
+
v-if="fixed && !useSticky"
|
|
5
|
+
class="qiu-affix__placeholder"
|
|
6
|
+
:style="{ height: `${placeholderHeight}px` }"
|
|
7
|
+
/>
|
|
8
|
+
<div
|
|
9
|
+
ref="affixRef"
|
|
10
|
+
class="qiu-affix__content"
|
|
11
|
+
:class="{ 'is-fixed': fixed && !useSticky, 'is-sticky': useSticky }"
|
|
12
|
+
:style="contentStyle"
|
|
13
|
+
>
|
|
14
|
+
<slot />
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
defineOptions({ name: 'QiuAffix' })
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(
|
|
23
|
+
defineProps<{
|
|
24
|
+
offset?: number
|
|
25
|
+
position?: 'top' | 'bottom'
|
|
26
|
+
zIndex?: number
|
|
27
|
+
/** 滚动容器选择器;指定后优先用 sticky(适合 overflow 容器) */
|
|
28
|
+
target?: string
|
|
29
|
+
}>(),
|
|
30
|
+
{
|
|
31
|
+
offset: 0,
|
|
32
|
+
position: 'top',
|
|
33
|
+
zIndex: 100,
|
|
34
|
+
target: '',
|
|
35
|
+
}
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
const emit = defineEmits<{
|
|
39
|
+
change: [fixed: boolean]
|
|
40
|
+
scroll: [payload: { scrollTop: number; fixed: boolean }]
|
|
41
|
+
}>()
|
|
42
|
+
|
|
43
|
+
const rootRef = ref<HTMLElement | null>(null)
|
|
44
|
+
const affixRef = ref<HTMLElement | null>(null)
|
|
45
|
+
const fixed = ref(false)
|
|
46
|
+
const placeholderHeight = ref(0)
|
|
47
|
+
|
|
48
|
+
/** 有 target 时用 sticky,天然适配 overflow 滚动容器 */
|
|
49
|
+
const useSticky = computed(() => !!props.target)
|
|
50
|
+
|
|
51
|
+
const getScrollContainer = (): HTMLElement | Window => {
|
|
52
|
+
if (!props.target) return window
|
|
53
|
+
const el = document.querySelector(props.target)
|
|
54
|
+
return (el as HTMLElement) || window
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const update = () => {
|
|
58
|
+
if (useSticky.value) return
|
|
59
|
+
|
|
60
|
+
const root = rootRef.value
|
|
61
|
+
const affix = affixRef.value
|
|
62
|
+
if (!root || !affix) return
|
|
63
|
+
|
|
64
|
+
const container = getScrollContainer()
|
|
65
|
+
const rootRect = root.getBoundingClientRect()
|
|
66
|
+
placeholderHeight.value = affix.offsetHeight
|
|
67
|
+
|
|
68
|
+
let next = false
|
|
69
|
+
if (props.position === 'top') {
|
|
70
|
+
// 仅判断是否滚过阈值;滚回时自动解除(勿再加与之矛盾的 bottom 条件)
|
|
71
|
+
if (container === window) {
|
|
72
|
+
next = rootRect.top <= props.offset
|
|
73
|
+
} else {
|
|
74
|
+
const cTop = (container as HTMLElement).getBoundingClientRect().top
|
|
75
|
+
next = rootRect.top <= cTop + props.offset
|
|
76
|
+
}
|
|
77
|
+
} else if (container === window) {
|
|
78
|
+
next = rootRect.bottom >= window.innerHeight - props.offset
|
|
79
|
+
} else {
|
|
80
|
+
const cBottom = (container as HTMLElement).getBoundingClientRect().bottom
|
|
81
|
+
next = rootRect.bottom >= cBottom - props.offset
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (next !== fixed.value) {
|
|
85
|
+
fixed.value = next
|
|
86
|
+
emit('change', next)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const scrollTop =
|
|
90
|
+
container === window
|
|
91
|
+
? window.scrollY || document.documentElement.scrollTop
|
|
92
|
+
: (container as HTMLElement).scrollTop
|
|
93
|
+
emit('scroll', { scrollTop, fixed: fixed.value })
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const contentStyle = computed(() => {
|
|
97
|
+
if (useSticky.value) {
|
|
98
|
+
return {
|
|
99
|
+
position: 'sticky',
|
|
100
|
+
zIndex: String(props.zIndex),
|
|
101
|
+
...(props.position === 'top'
|
|
102
|
+
? { top: `${props.offset}px` }
|
|
103
|
+
: { bottom: `${props.offset}px` }),
|
|
104
|
+
} as Record<string, string>
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!fixed.value) return undefined
|
|
108
|
+
|
|
109
|
+
const container = getScrollContainer()
|
|
110
|
+
const style: Record<string, string> = {
|
|
111
|
+
position: 'fixed',
|
|
112
|
+
zIndex: String(props.zIndex),
|
|
113
|
+
width: `${rootRef.value?.offsetWidth ?? 0}px`,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (props.position === 'top') {
|
|
117
|
+
const top =
|
|
118
|
+
container === window
|
|
119
|
+
? props.offset
|
|
120
|
+
: (container as HTMLElement).getBoundingClientRect().top + props.offset
|
|
121
|
+
style.top = `${top}px`
|
|
122
|
+
} else {
|
|
123
|
+
const bottom =
|
|
124
|
+
container === window
|
|
125
|
+
? props.offset
|
|
126
|
+
: window.innerHeight -
|
|
127
|
+
(container as HTMLElement).getBoundingClientRect().bottom +
|
|
128
|
+
props.offset
|
|
129
|
+
style.bottom = `${bottom}px`
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (container !== window) {
|
|
133
|
+
const rect = (container as HTMLElement).getBoundingClientRect()
|
|
134
|
+
style.left = `${rect.left}px`
|
|
135
|
+
style.width = `${rect.width}px`
|
|
136
|
+
} else if (rootRef.value) {
|
|
137
|
+
style.left = `${rootRef.value.getBoundingClientRect().left}px`
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return style
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
let containerEl: HTMLElement | Window = window
|
|
144
|
+
|
|
145
|
+
const onScroll = () => update()
|
|
146
|
+
const onResize = () => update()
|
|
147
|
+
|
|
148
|
+
const bind = () => {
|
|
149
|
+
containerEl.removeEventListener('scroll', onScroll)
|
|
150
|
+
window.removeEventListener('resize', onResize)
|
|
151
|
+
if (useSticky.value) return
|
|
152
|
+
containerEl = getScrollContainer()
|
|
153
|
+
containerEl.addEventListener('scroll', onScroll, { passive: true })
|
|
154
|
+
window.addEventListener('resize', onResize, { passive: true })
|
|
155
|
+
update()
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
onMounted(() => {
|
|
159
|
+
nextTick(bind)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
onBeforeUnmount(() => {
|
|
163
|
+
containerEl.removeEventListener('scroll', onScroll)
|
|
164
|
+
window.removeEventListener('resize', onResize)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
watch(
|
|
168
|
+
() => [props.target, props.offset, props.position],
|
|
169
|
+
() => nextTick(bind)
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
defineExpose({ update })
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<style lang="scss" scoped>
|
|
176
|
+
.qiu-affix {
|
|
177
|
+
&__content {
|
|
178
|
+
box-sizing: border-box;
|
|
179
|
+
|
|
180
|
+
&.is-fixed,
|
|
181
|
+
&.is-sticky {
|
|
182
|
+
z-index: 10;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
</style>
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-show="visible"
|
|
4
|
+
class="qiu-alert"
|
|
5
|
+
:class="[
|
|
6
|
+
`qiu-alert--${normalizedType}`,
|
|
7
|
+
`qiu-alert--${effect}`,
|
|
8
|
+
{ 'is-center': center },
|
|
9
|
+
]"
|
|
10
|
+
role="alert"
|
|
11
|
+
v-bind="$attrs"
|
|
12
|
+
>
|
|
13
|
+
<qiu-icon v-if="showIcon" class="qiu-alert__icon" :icon="typeIcon" />
|
|
14
|
+
<div class="qiu-alert__content">
|
|
15
|
+
<div v-if="title || $slots.title" class="qiu-alert__title">
|
|
16
|
+
<slot name="title">{{ title }}</slot>
|
|
17
|
+
</div>
|
|
18
|
+
<div v-if="$slots.default || description" class="qiu-alert__description">
|
|
19
|
+
<slot>{{ description }}</slot>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
<button
|
|
23
|
+
v-if="closable"
|
|
24
|
+
type="button"
|
|
25
|
+
class="qiu-alert__close"
|
|
26
|
+
:aria-label="closeText || 'Close'"
|
|
27
|
+
@click="handleClose"
|
|
28
|
+
>
|
|
29
|
+
<span v-if="closeText">{{ closeText }}</span>
|
|
30
|
+
<qiu-icon v-else icon="close-line" />
|
|
31
|
+
</button>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts" setup>
|
|
36
|
+
defineOptions({
|
|
37
|
+
name: 'QiuAlert',
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const props = defineProps({
|
|
41
|
+
title: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '',
|
|
44
|
+
},
|
|
45
|
+
description: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: '',
|
|
48
|
+
},
|
|
49
|
+
type: {
|
|
50
|
+
type: String as () => 'success' | 'warning' | 'info' | 'error' | 'danger',
|
|
51
|
+
default: 'info',
|
|
52
|
+
},
|
|
53
|
+
closable: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false,
|
|
56
|
+
},
|
|
57
|
+
closeText: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: '',
|
|
60
|
+
},
|
|
61
|
+
showIcon: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
center: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
default: false,
|
|
68
|
+
},
|
|
69
|
+
effect: {
|
|
70
|
+
type: String as () => 'light' | 'dark',
|
|
71
|
+
default: 'light',
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const emit = defineEmits<{
|
|
76
|
+
close: []
|
|
77
|
+
}>()
|
|
78
|
+
|
|
79
|
+
const visible = ref(true)
|
|
80
|
+
|
|
81
|
+
const normalizedType = computed(() => (props.type === 'danger' ? 'error' : props.type))
|
|
82
|
+
|
|
83
|
+
const typeIcon = computed(() => {
|
|
84
|
+
const map: Record<string, string> = {
|
|
85
|
+
success: 'checkbox-circle-line',
|
|
86
|
+
warning: 'error-warning-line',
|
|
87
|
+
info: 'information-line',
|
|
88
|
+
error: 'close-circle-line',
|
|
89
|
+
}
|
|
90
|
+
return map[normalizedType.value] || map.info
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const handleClose = () => {
|
|
94
|
+
visible.value = false
|
|
95
|
+
emit('close')
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<style lang="scss" scoped>
|
|
100
|
+
.qiu-alert {
|
|
101
|
+
display: flex;
|
|
102
|
+
gap: 8px;
|
|
103
|
+
align-items: flex-start;
|
|
104
|
+
width: 100%;
|
|
105
|
+
padding: 8px 16px;
|
|
106
|
+
margin: 0;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
border-radius: var(--qiu-border-radius-base, 4px);
|
|
109
|
+
box-sizing: border-box;
|
|
110
|
+
transition: opacity 0.2s ease;
|
|
111
|
+
|
|
112
|
+
&.is-center {
|
|
113
|
+
justify-content: center;
|
|
114
|
+
text-align: center;
|
|
115
|
+
|
|
116
|
+
.qiu-alert__content {
|
|
117
|
+
flex: none;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&--light {
|
|
122
|
+
&.qiu-alert--success {
|
|
123
|
+
color: var(--qiu-color-success);
|
|
124
|
+
background-color: var(--qiu-color-success-light-9, #f0f9eb);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.qiu-alert--warning {
|
|
128
|
+
color: var(--qiu-color-warning);
|
|
129
|
+
background-color: var(--qiu-color-warning-light-9, #fdf6ec);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&.qiu-alert--info {
|
|
133
|
+
color: var(--qiu-color-info);
|
|
134
|
+
background-color: var(--qiu-color-info-light-9, #f4f4f5);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
&.qiu-alert--error {
|
|
138
|
+
color: var(--qiu-color-error);
|
|
139
|
+
background-color: var(--qiu-color-error-light-9, #fef0f0);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&--dark {
|
|
144
|
+
&.qiu-alert--success {
|
|
145
|
+
color: #fff;
|
|
146
|
+
background-color: var(--qiu-color-success);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&.qiu-alert--warning {
|
|
150
|
+
color: #fff;
|
|
151
|
+
background-color: var(--qiu-color-warning);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
&.qiu-alert--info {
|
|
155
|
+
color: #fff;
|
|
156
|
+
background-color: var(--qiu-color-info);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&.qiu-alert--error {
|
|
160
|
+
color: #fff;
|
|
161
|
+
background-color: var(--qiu-color-error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.qiu-alert__icon {
|
|
167
|
+
flex-shrink: 0;
|
|
168
|
+
margin-top: 2px;
|
|
169
|
+
font-size: 16px;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.qiu-alert__content {
|
|
173
|
+
flex: 1;
|
|
174
|
+
min-width: 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.qiu-alert__title {
|
|
178
|
+
font-size: 14px;
|
|
179
|
+
font-weight: 700;
|
|
180
|
+
line-height: 1.4;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.qiu-alert__description {
|
|
184
|
+
margin: 4px 0 0;
|
|
185
|
+
font-size: 13px;
|
|
186
|
+
line-height: 1.6;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.qiu-alert__close {
|
|
190
|
+
display: inline-flex;
|
|
191
|
+
flex-shrink: 0;
|
|
192
|
+
align-items: center;
|
|
193
|
+
justify-content: center;
|
|
194
|
+
padding: 0;
|
|
195
|
+
margin: 0;
|
|
196
|
+
font-size: 12px;
|
|
197
|
+
color: inherit;
|
|
198
|
+
cursor: pointer;
|
|
199
|
+
background: transparent;
|
|
200
|
+
border: none;
|
|
201
|
+
opacity: 0.7;
|
|
202
|
+
transition: opacity 0.2s ease;
|
|
203
|
+
|
|
204
|
+
&:hover {
|
|
205
|
+
opacity: 1;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InjectionKey, Ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
export interface QiuAnchorLinkRecord {
|
|
4
|
+
href: string
|
|
5
|
+
title: string
|
|
6
|
+
el: HTMLElement | null
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface QiuAnchorContext {
|
|
10
|
+
offset: Ref<number>
|
|
11
|
+
bound: Ref<string>
|
|
12
|
+
activeLink: Ref<string>
|
|
13
|
+
registerLink: (link: QiuAnchorLinkRecord) => void
|
|
14
|
+
unregisterLink: (href: string) => void
|
|
15
|
+
scrollToLink: (href: string) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const QIU_ANCHOR_KEY: InjectionKey<QiuAnchorContext> = Symbol('QiuAnchor')
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="qiu-anchor">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import type { QiuAnchorContext, QiuAnchorLinkRecord } from './context'
|
|
9
|
+
import { QIU_ANCHOR_KEY } from './context'
|
|
10
|
+
|
|
11
|
+
defineOptions({ name: 'QiuAnchor' })
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(
|
|
14
|
+
defineProps<{
|
|
15
|
+
offset?: number
|
|
16
|
+
/** 滚动容器选择器 */
|
|
17
|
+
bound?: string
|
|
18
|
+
}>(),
|
|
19
|
+
{
|
|
20
|
+
offset: 0,
|
|
21
|
+
bound: '',
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const links = ref<QiuAnchorLinkRecord[]>([])
|
|
26
|
+
const activeLink = ref('')
|
|
27
|
+
|
|
28
|
+
const isScrollable = (el: HTMLElement) => {
|
|
29
|
+
const style = window.getComputedStyle(el)
|
|
30
|
+
return /(auto|scroll)/.test(style.overflow + style.overflowY + style.overflowX)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const findScrollContainer = (el: Element): HTMLElement | Window => {
|
|
34
|
+
let node: HTMLElement | null = el.parentElement
|
|
35
|
+
while (node) {
|
|
36
|
+
if (isScrollable(node)) return node
|
|
37
|
+
node = node.parentElement
|
|
38
|
+
}
|
|
39
|
+
return window
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const getScrollContainer = (target?: Element): HTMLElement | Window => {
|
|
43
|
+
if (props.bound) {
|
|
44
|
+
const el = document.querySelector(props.bound)
|
|
45
|
+
return (el as HTMLElement) || window
|
|
46
|
+
}
|
|
47
|
+
if (target) return findScrollContainer(target)
|
|
48
|
+
return window
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const getScrollTop = (container: HTMLElement | Window) => {
|
|
52
|
+
if (container === window) return window.scrollY || document.documentElement.scrollTop
|
|
53
|
+
return (container as HTMLElement).scrollTop
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const scrollToLink = (href: string) => {
|
|
57
|
+
const id = href.replace(/^#/, '')
|
|
58
|
+
const target = document.getElementById(id)
|
|
59
|
+
if (!target) return
|
|
60
|
+
|
|
61
|
+
const container = getScrollContainer(target)
|
|
62
|
+
if (container === window) {
|
|
63
|
+
const top = target.getBoundingClientRect().top + getScrollTop(window) - props.offset
|
|
64
|
+
window.scrollTo({ top, behavior: 'smooth' })
|
|
65
|
+
} else {
|
|
66
|
+
const c = container as HTMLElement
|
|
67
|
+
const cRect = c.getBoundingClientRect()
|
|
68
|
+
const tRect = target.getBoundingClientRect()
|
|
69
|
+
const top = tRect.top - cRect.top + c.scrollTop - props.offset
|
|
70
|
+
c.scrollTo({ top, behavior: 'smooth' })
|
|
71
|
+
}
|
|
72
|
+
activeLink.value = href
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const registerLink = (link: QiuAnchorLinkRecord) => {
|
|
76
|
+
const idx = links.value.findIndex((l) => l.href === link.href)
|
|
77
|
+
if (idx >= 0) links.value[idx] = link
|
|
78
|
+
else links.value.push(link)
|
|
79
|
+
links.value.sort((a, b) => {
|
|
80
|
+
const elA = document.querySelector(a.href)
|
|
81
|
+
const elB = document.querySelector(b.href)
|
|
82
|
+
if (!elA || !elB) return 0
|
|
83
|
+
return elA.getBoundingClientRect().top - elB.getBoundingClientRect().top
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const unregisterLink = (href: string) => {
|
|
88
|
+
links.value = links.value.filter((l) => l.href !== href)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const resolveContainer = (): HTMLElement | Window => {
|
|
92
|
+
if (props.bound) {
|
|
93
|
+
const el = document.querySelector(props.bound)
|
|
94
|
+
return (el as HTMLElement) || window
|
|
95
|
+
}
|
|
96
|
+
// 未指定 bound 时自动探测:以第一个锚点目标元素的可滚动祖先作为滚动容器
|
|
97
|
+
for (const link of links.value) {
|
|
98
|
+
const el = document.querySelector(link.href)
|
|
99
|
+
if (el) return findScrollContainer(el)
|
|
100
|
+
}
|
|
101
|
+
return window
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const updateActive = () => {
|
|
105
|
+
const container = resolveContainer()
|
|
106
|
+
const scrollTop = getScrollTop(container)
|
|
107
|
+
const containerTop =
|
|
108
|
+
container === window ? 0 : (container as HTMLElement).getBoundingClientRect().top
|
|
109
|
+
|
|
110
|
+
let current = ''
|
|
111
|
+
for (const link of links.value) {
|
|
112
|
+
const id = link.href.replace(/^#/, '')
|
|
113
|
+
const el = document.getElementById(id)
|
|
114
|
+
if (!el) continue
|
|
115
|
+
const top =
|
|
116
|
+
container === window
|
|
117
|
+
? el.getBoundingClientRect().top + scrollTop
|
|
118
|
+
: el.getBoundingClientRect().top - containerTop + scrollTop
|
|
119
|
+
if (top - props.offset <= scrollTop + 1) current = link.href
|
|
120
|
+
}
|
|
121
|
+
if (current) activeLink.value = current
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
provide<QiuAnchorContext>(QIU_ANCHOR_KEY, {
|
|
125
|
+
offset: toRef(props, 'offset'),
|
|
126
|
+
bound: toRef(props, 'bound'),
|
|
127
|
+
activeLink,
|
|
128
|
+
registerLink,
|
|
129
|
+
unregisterLink,
|
|
130
|
+
scrollToLink,
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
let containerEl: HTMLElement | Window = window
|
|
134
|
+
|
|
135
|
+
const onScroll = () => updateActive()
|
|
136
|
+
|
|
137
|
+
const rebindScrollContainer = () => {
|
|
138
|
+
const next = resolveContainer()
|
|
139
|
+
if (next !== containerEl) {
|
|
140
|
+
containerEl.removeEventListener('scroll', onScroll)
|
|
141
|
+
containerEl = next
|
|
142
|
+
containerEl.addEventListener('scroll', onScroll, { passive: true })
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
onMounted(() => {
|
|
147
|
+
containerEl = resolveContainer()
|
|
148
|
+
containerEl.addEventListener('scroll', onScroll, { passive: true })
|
|
149
|
+
updateActive()
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
onBeforeUnmount(() => {
|
|
153
|
+
containerEl.removeEventListener('scroll', onScroll)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
watch(
|
|
157
|
+
() => props.bound,
|
|
158
|
+
() => {
|
|
159
|
+
rebindScrollContainer()
|
|
160
|
+
updateActive()
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
// 锚点链接注册完成后,若之前未探测到滚动容器则重新探测并切换事件监听
|
|
165
|
+
watch(
|
|
166
|
+
() => links.value.map((l) => l.href).join(','),
|
|
167
|
+
() => {
|
|
168
|
+
rebindScrollContainer()
|
|
169
|
+
updateActive()
|
|
170
|
+
},
|
|
171
|
+
{ flush: 'post' }
|
|
172
|
+
)
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<style lang="scss" scoped>
|
|
176
|
+
.qiu-anchor {
|
|
177
|
+
font-size: var(--qiu-font-size, 14px);
|
|
178
|
+
line-height: 1.5;
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a
|
|
3
|
+
class="qiu-anchor-link"
|
|
4
|
+
:class="{ 'is-active': isActive }"
|
|
5
|
+
:href="href"
|
|
6
|
+
@click.prevent="onClick"
|
|
7
|
+
>
|
|
8
|
+
<slot>{{ title }}</slot>
|
|
9
|
+
</a>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script lang="ts" setup>
|
|
13
|
+
import { QIU_ANCHOR_KEY } from '../QiuAnchor/context'
|
|
14
|
+
|
|
15
|
+
defineOptions({ name: 'QiuAnchorLink' })
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(
|
|
18
|
+
defineProps<{
|
|
19
|
+
href: string
|
|
20
|
+
title?: string
|
|
21
|
+
}>(),
|
|
22
|
+
{
|
|
23
|
+
title: '',
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const anchor = inject(QIU_ANCHOR_KEY, null)
|
|
28
|
+
const linkRef = ref<HTMLElement | null>(null)
|
|
29
|
+
|
|
30
|
+
const isActive = computed(() => anchor?.activeLink.value === props.href)
|
|
31
|
+
|
|
32
|
+
const onClick = () => {
|
|
33
|
+
anchor?.scrollToLink(props.href)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
anchor?.registerLink({
|
|
38
|
+
href: props.href,
|
|
39
|
+
title: props.title,
|
|
40
|
+
el: linkRef.value,
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
onBeforeUnmount(() => {
|
|
45
|
+
anchor?.unregisterLink(props.href)
|
|
46
|
+
})
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style lang="scss" scoped>
|
|
50
|
+
.qiu-anchor-link {
|
|
51
|
+
display: block;
|
|
52
|
+
padding: 4px 0 4px 12px;
|
|
53
|
+
color: var(--qiu-text-color-regular, var(--qiu-text-color-regular, #606266));
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
border-left: 2px solid transparent;
|
|
56
|
+
transition: color 0.15s, border-color 0.15s;
|
|
57
|
+
|
|
58
|
+
&:hover {
|
|
59
|
+
color: var(--qiu-color-primary, var(--qiu-color-primary, #0f766e));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&.is-active {
|
|
63
|
+
color: var(--qiu-color-primary, var(--qiu-color-primary, #0f766e));
|
|
64
|
+
border-left-color: var(--qiu-color-primary, var(--qiu-color-primary, #0f766e));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
</style>
|