@robot-admin/naive-ui-components 0.4.3 → 0.4.4
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/dist/C_ActionBar.cjs +1 -5
- package/dist/C_ActionBar.js +1 -4
- package/dist/C_ActionBar.js.map +1 -0
- package/dist/C_ActionBar2.js +1 -195
- package/dist/C_ActionBar2.js.map +1 -1
- package/dist/C_AntV.cjs +1 -8
- package/dist/C_AntV.js +1 -4
- package/dist/C_AntV.js.map +1 -0
- package/dist/C_AntV2.js +4 -3149
- package/dist/C_AntV2.js.map +1 -1
- package/dist/C_Barcode.cjs +1 -4
- package/dist/C_Barcode.js +1 -3
- package/dist/C_Barcode.js.map +1 -0
- package/dist/C_Barcode2.js +1 -67
- package/dist/C_Barcode2.js.map +1 -1
- package/dist/C_Captcha.cjs +1 -4
- package/dist/C_Captcha.js +1 -3
- package/dist/C_Captcha.js.map +1 -0
- package/dist/C_Captcha2.js +1 -154
- package/dist/C_Captcha2.js.map +1 -1
- package/dist/C_Cascade.cjs +1 -4
- package/dist/C_Cascade.js +1 -3
- package/dist/C_Cascade.js.map +1 -0
- package/dist/C_Cascade2.js +1 -102
- package/dist/C_Cascade2.js.map +1 -1
- package/dist/C_City.cjs +1 -4
- package/dist/C_City.js +1 -3
- package/dist/C_City.js.map +1 -0
- package/dist/C_City2.js +1 -840
- package/dist/C_City2.js.map +1 -1
- package/dist/C_Code.cjs +1 -5
- package/dist/C_Code.js +1 -4
- package/dist/C_Code.js.map +1 -0
- package/dist/C_Code2.js +1 -346
- package/dist/C_Code2.js.map +1 -1
- package/dist/C_CollapsePanel.cjs +1 -6
- package/dist/C_CollapsePanel.js +1 -4
- package/dist/C_CollapsePanel.js.map +1 -0
- package/dist/C_CollapsePanel2.js +1 -318
- package/dist/C_CollapsePanel2.js.map +1 -1
- package/dist/C_Cron.cjs +1 -15
- package/dist/C_Cron.js +1 -4
- package/dist/C_Cron.js.map +1 -0
- package/dist/C_Cron2.js +1 -1209
- package/dist/C_Cron2.js.map +1 -1
- package/dist/C_Date.cjs +1 -4
- package/dist/C_Date.js +1 -3
- package/dist/C_Date.js.map +1 -0
- package/dist/C_Date2.js +1 -218
- package/dist/C_Date2.js.map +1 -1
- package/dist/C_Draggable.cjs +1 -5
- package/dist/C_Draggable.js +1 -3
- package/dist/C_Draggable.js.map +1 -0
- package/dist/C_Draggable2.js +1 -294
- package/dist/C_Draggable2.js.map +1 -1
- package/dist/C_Editor.cjs +1 -4
- package/dist/C_Editor.js +1 -3
- package/dist/C_Editor.js.map +1 -0
- package/dist/C_Editor2.js +1 -159
- package/dist/C_Editor2.js.map +1 -1
- package/dist/C_FilePreview.cjs +1 -7
- package/dist/C_FilePreview.js +1 -4
- package/dist/C_FilePreview.js.map +1 -0
- package/dist/C_FilePreview2.js +1 -1031
- package/dist/C_FilePreview2.js.map +1 -1
- package/dist/C_Form.cjs +1 -16
- package/dist/C_Form.js +1 -5
- package/dist/C_Form.js.map +1 -0
- package/dist/C_Form2.js +1 -2569
- package/dist/C_Form2.js.map +1 -1
- package/dist/C_FormSearch.cjs +1 -6
- package/dist/C_FormSearch.js +1 -3
- package/dist/C_FormSearch.js.map +1 -0
- package/dist/C_FormSearch2.js +1 -355
- package/dist/C_FormSearch2.js.map +1 -1
- package/dist/C_FormulaEditor.cjs +1 -13
- package/dist/C_FormulaEditor.js +1 -4
- package/dist/C_FormulaEditor.js.map +1 -0
- package/dist/C_FormulaEditor2.js +1 -1432
- package/dist/C_FormulaEditor2.js.map +1 -1
- package/dist/C_FullCalendar.cjs +1 -9
- package/dist/C_FullCalendar.js +1 -3
- package/dist/C_FullCalendar.js.map +1 -0
- package/dist/C_FullCalendar2.js +1 -376
- package/dist/C_FullCalendar2.js.map +1 -1
- package/dist/C_GlobalSearch.cjs +1 -5
- package/dist/C_GlobalSearch.js +1 -3
- package/dist/C_GlobalSearch.js.map +1 -0
- package/dist/C_GlobalSearch2.js +1 -335
- package/dist/C_GlobalSearch2.js.map +1 -1
- package/dist/C_Guide.cjs +1 -5
- package/dist/C_Guide.js +1 -4
- package/dist/C_Guide.js.map +1 -0
- package/dist/C_Guide2.js +1 -60
- package/dist/C_Guide2.js.map +1 -1
- package/dist/C_Icon.cjs +1 -4
- package/dist/C_Icon.js +1 -3
- package/dist/C_Icon.js.map +1 -0
- package/dist/C_Icon2.js +1 -285
- package/dist/C_Icon2.js.map +1 -1
- package/dist/C_ImageCropper.cjs +1 -6
- package/dist/C_ImageCropper.js +1 -4
- package/dist/C_ImageCropper.js.map +1 -0
- package/dist/C_ImageCropper2.js +1 -722
- package/dist/C_ImageCropper2.js.map +1 -1
- package/dist/C_Language.cjs +1 -5
- package/dist/C_Language.js +1 -4
- package/dist/C_Language.js.map +1 -0
- package/dist/C_Language2.js +1 -78
- package/dist/C_Language2.js.map +1 -1
- package/dist/C_Map.cjs +1 -7
- package/dist/C_Map.js +1 -3
- package/dist/C_Map.js.map +1 -0
- package/dist/C_Map2.js +1 -198
- package/dist/C_Map2.js.map +1 -1
- package/dist/C_Markdown.cjs +1 -4
- package/dist/C_Markdown.js +1 -3
- package/dist/C_Markdown.js.map +1 -0
- package/dist/C_Markdown2.js +1 -185
- package/dist/C_Markdown2.js.map +1 -1
- package/dist/C_NotificationCenter.cjs +1 -20
- package/dist/C_NotificationCenter.js +1 -4
- package/dist/C_NotificationCenter.js.map +1 -0
- package/dist/C_NotificationCenter2.js +1 -1383
- package/dist/C_NotificationCenter2.js.map +1 -1
- package/dist/C_Progress.cjs +1 -4
- package/dist/C_Progress.js +1 -3
- package/dist/C_Progress.js.map +1 -0
- package/dist/C_Progress2.js +1 -102
- package/dist/C_Progress2.js.map +1 -1
- package/dist/C_QRCode.cjs +1 -5
- package/dist/C_QRCode.js +1 -3
- package/dist/C_QRCode.js.map +1 -0
- package/dist/C_QRCode2.js +1 -217
- package/dist/C_QRCode2.js.map +1 -1
- package/dist/C_Signature.cjs +1 -8
- package/dist/C_Signature.js +1 -4
- package/dist/C_Signature.js.map +1 -0
- package/dist/C_Signature2.js +1 -617
- package/dist/C_Signature2.js.map +1 -1
- package/dist/C_SplitPane.cjs +1 -6
- package/dist/C_SplitPane.js +1 -4
- package/dist/C_SplitPane.js.map +1 -0
- package/dist/C_SplitPane2.js +1 -355
- package/dist/C_SplitPane2.js.map +1 -1
- package/dist/C_Steps.cjs +1 -4
- package/dist/C_Steps.js +1 -3
- package/dist/C_Steps.js.map +1 -0
- package/dist/C_Steps2.js +1 -81
- package/dist/C_Steps2.js.map +1 -1
- package/dist/C_Table.cjs +1 -20
- package/dist/C_Table.js +1 -6
- package/dist/C_Table.js.map +1 -0
- package/dist/C_Table2.js +1 -3023
- package/dist/C_Table2.js.map +1 -1
- package/dist/C_Theme.cjs +1 -5
- package/dist/C_Theme.js +1 -4
- package/dist/C_Theme.js.map +1 -0
- package/dist/C_Theme2.js +1 -63
- package/dist/C_Theme2.js.map +1 -1
- package/dist/C_Time.cjs +1 -5
- package/dist/C_Time.js +1 -3
- package/dist/C_Time.js.map +1 -0
- package/dist/C_Time2.js +1 -198
- package/dist/C_Time2.js.map +1 -1
- package/dist/C_Tree.cjs +1 -7
- package/dist/C_Tree.js +1 -4
- package/dist/C_Tree.js.map +1 -0
- package/dist/C_Tree2.js +1 -440
- package/dist/C_Tree2.js.map +1 -1
- package/dist/C_Upload.cjs +1 -12
- package/dist/C_Upload.js +1 -4
- package/dist/C_Upload.js.map +1 -0
- package/dist/C_Upload2.js +2 -1365
- package/dist/C_Upload2.js.map +1 -1
- package/dist/C_VideoPlayer.cjs +1 -23
- package/dist/C_VideoPlayer.js +1 -3
- package/dist/C_VideoPlayer.js.map +1 -0
- package/dist/C_VideoPlayer2.js +3 -1932
- package/dist/C_VideoPlayer2.js.map +1 -1
- package/dist/C_VtableGantt.cjs +1 -6
- package/dist/C_VtableGantt.js +1 -4
- package/dist/C_VtableGantt.js.map +1 -0
- package/dist/C_VtableGantt2.js +1 -872
- package/dist/C_VtableGantt2.js.map +1 -1
- package/dist/C_WaterFall.cjs +1 -13
- package/dist/C_WaterFall.js +1 -3
- package/dist/C_WaterFall.js.map +1 -0
- package/dist/C_WaterFall2.js +1 -364
- package/dist/C_WaterFall2.js.map +1 -1
- package/dist/C_WorkFlow.cjs +1 -8
- package/dist/C_WorkFlow.js +1 -4
- package/dist/C_WorkFlow.js.map +1 -0
- package/dist/C_WorkFlow2.js +1 -1983
- package/dist/C_WorkFlow2.js.map +1 -1
- package/dist/chunk.js +1 -18
- package/dist/city.js +1 -4816
- package/dist/constants.d.ts +2 -2
- package/dist/constants2.d.ts +3 -3
- package/dist/constants3.d.ts +3 -3
- package/dist/constants4.d.ts +5 -5
- package/dist/constants5.d.ts +2 -2
- package/dist/data.d.ts +1 -1
- package/dist/export-helper.js +1 -9
- package/dist/index.cjs +2 -413
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -231
- package/dist/index.js.map +1 -1
- package/dist/index.vue.d.ts +2 -2
- package/dist/index10.vue.d.ts +5 -5
- package/dist/index12.vue.d.ts +3 -3
- package/dist/index13.vue.d.ts +3 -3
- package/dist/index14.vue.d.ts +3 -3
- package/dist/index16.vue.d.ts +3 -3
- package/dist/index3.vue.d.ts +3 -3
- package/dist/index5.vue.d.ts +1 -1
- package/dist/index7.vue.d.ts +4 -4
- package/dist/index8.vue.d.ts +2 -2
- package/dist/resolver.cjs +2 -89
- package/dist/resolver.cjs.map +1 -0
- package/dist/resolver.js +1 -86
- package/dist/resolver.js.map +1 -1
- package/dist/storage.js +1 -30
- package/dist/storage.js.map +1 -1
- package/dist/useCollapsePanel.d.ts +2 -2
- package/dist/useCropperCore.d.ts +8 -8
- package/dist/useDraggableLayout.d.ts +4 -4
- package/dist/useDynamicFormState.d.ts +7 -7
- package/dist/useEdgeInteraction.d.ts +1 -1
- package/dist/useFullscreen.d.ts +2 -2
- package/dist/useInfiniteScroll.d.ts +1 -1
- package/dist/useModalEdit.d.ts +1 -1
- package/dist/useQRCode.d.ts +3 -3
- package/dist/useSearchState.d.ts +2 -2
- package/dist/useSignatureHistory.d.ts +1 -1
- package/dist/useSplitResize.d.ts +6 -6
- package/dist/useTimeSelection.d.ts +2 -2
- package/dist/useTreeOperations.d.ts +6 -6
- package/dist/useWorkflowValidation.d.ts +4 -4
- package/package.json +1 -2
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants2.d.ts.map +0 -1
- package/dist/constants3.d.ts.map +0 -1
- package/dist/constants4.d.ts.map +0 -1
- package/dist/constants5.d.ts.map +0 -1
- package/dist/data.d.ts.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.vue.d.ts.map +0 -1
- package/dist/index10.vue.d.ts.map +0 -1
- package/dist/index11.vue.d.ts.map +0 -1
- package/dist/index12.vue.d.ts.map +0 -1
- package/dist/index13.vue.d.ts.map +0 -1
- package/dist/index14.vue.d.ts.map +0 -1
- package/dist/index15.vue.d.ts.map +0 -1
- package/dist/index16.vue.d.ts.map +0 -1
- package/dist/index2.vue.d.ts.map +0 -1
- package/dist/index3.vue.d.ts.map +0 -1
- package/dist/index4.vue.d.ts.map +0 -1
- package/dist/index5.vue.d.ts.map +0 -1
- package/dist/index6.vue.d.ts.map +0 -1
- package/dist/index7.vue.d.ts.map +0 -1
- package/dist/index8.vue.d.ts.map +0 -1
- package/dist/index9.vue.d.ts.map +0 -1
- package/dist/resolver.d.cts.map +0 -1
- package/dist/resolver.d.ts.map +0 -1
- package/dist/useCalendarEvents.d.ts.map +0 -1
- package/dist/useCollapsePanel.d.ts.map +0 -1
- package/dist/useCropperCore.d.ts.map +0 -1
- package/dist/useDraggableLayout.d.ts.map +0 -1
- package/dist/useDynamicFormState.d.ts.map +0 -1
- package/dist/useEdgeInteraction.d.ts.map +0 -1
- package/dist/useFullscreen.d.ts.map +0 -1
- package/dist/useGlobalSearch.d.ts.map +0 -1
- package/dist/useInfiniteScroll.d.ts.map +0 -1
- package/dist/useModalEdit.d.ts.map +0 -1
- package/dist/useQRCode.d.ts.map +0 -1
- package/dist/useSearchState.d.ts.map +0 -1
- package/dist/useSignatureHistory.d.ts.map +0 -1
- package/dist/useSplitResize.d.ts.map +0 -1
- package/dist/useTimeSelection.d.ts.map +0 -1
- package/dist/useTreeOperations.d.ts.map +0 -1
- package/dist/useWorkflowValidation.d.ts.map +0 -1
package/dist/C_Progress.cjs
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_C_Progress = require('./C_Progress.js');
|
|
3
|
-
|
|
4
|
-
exports.C_Progress = require_C_Progress.C_Progress_default;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./C_Progress.js`);exports.C_Progress=e.t;
|
package/dist/C_Progress.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"C_Progress.js","names":["isAnimation","showIndicator"],"sources":["../src/components/C_Progress/index.vue","../src/components/C_Progress/index.vue","../src/components/C_Progress/index.vue"],"sourcesContent":["/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n","<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n"],"mappings":"iiBEmDA,IAAM,EAAQ,EAWR,GAAA,EAAA,EAAA,WAAkB,CAClB,GAAA,EAAA,EAAA,KACJ,MAAM,QAAQ,EAAM,WAAW,CAAG,CAAC,GAAG,EAAM,WAAW,CAAG,EAC3D,CAEK,GAAA,EAAA,EAAA,cAAkC,CAAC,CAAC,EAAM,UAAU,CAEpD,GAAA,EAAA,EAAA,cACG,EAAM,OAAS,kBAClB,MAAM,QAAQ,EAAE,MAAM,CACpB,EAAE,MACF,CAAC,EAAE,MAAM,CACX,MAAM,QAAQ,EAAE,MAAM,CACpB,EAAE,MAAM,GACR,EAAE,MACR,CAEI,GAAA,EAAA,EAAA,eAAgC,CACpC,KAAM,EAAM,KACZ,aAAc,EAAM,aACpB,UAAW,EAAM,UACjB,MAAO,EAAM,MACb,iBAAkB,EAAM,iBACxB,UAAW,EAAM,UACjB,gBAAiB,EAAM,gBACvB,OAAQ,EAAM,OACd,mBAAoB,EAAM,mBAC1B,mBAAoB,EAAM,mBAC1B,aAAc,EAAM,aACpB,UAAW,EAAM,UACjB,UAAW,EAAM,UACjB,OAAQ,EAAM,OACd,YAAa,EAAM,YACnB,KAAM,EAAM,KACb,EAAE,QAEH,EAAA,EAAA,WACQ,EAAM,WACX,GAAW,CACL,EAAM,YAEA,EAAM,OAAS,mBAAqB,MAAM,QAAQ,EAAO,GAClE,EAAE,MAAQ,CAAC,GAAG,EAAO,EAFrB,EAAE,MAAQ,GAKd,CAAE,UAAW,GAAM,KAAM,GAAM,CAChC,EAED,EAAA,EAAA,eAAgB,CACd,GAAI,EAAM,aAAe,EAAM,OAAS,kBAAmB,CACzD,IAAM,EAAc,MAAM,QAAQ,EAAM,WAAW,CAC/C,EAAM,WAAW,GACjB,EAAM,WAEV,GAAI,EAAc,EAAG,CACnB,IAAM,EAAY,YAAY,KAAK,CAE7B,EAAW,GAAgB,CAC/B,IAAM,EAAU,EAAM,EAChB,EAAW,KAAK,IAAI,EAAU,EAAM,KAAM,EAAE,CAClD,EAAE,MAAQ,KAAK,MAAM,EAAW,EAAY,CAExC,EAAW,GACb,sBAAsB,EAAQ,EAIlC,sBAAsB,EAAQ,IAGlC,yDApHY,EAAA,UAAA,EAAA,EAAA,EAAA,YAPF,EAOE,MAPW,CACpB,WAAY,EAAA,MACZ,WAAYA,EAAAA,uCAEGC,EAAAA,eAAiB,EAAA,MAAA,MAAmB,+BACzB,EAAA,EAAA,EAAA,YAAA,EAAA,OAAA,YAAA,CAAA,CAAA"}
|
package/dist/C_Progress2.js
CHANGED
|
@@ -1,103 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { computed, createBlock, createSlots, defineComponent, mergeProps, onMounted, openBlock, ref, renderSlot, unref, useSlots, watch, withCtx } from "vue";
|
|
3
|
-
|
|
4
|
-
//#region src/components/C_Progress/index.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
|
-
name: "C_Progress",
|
|
7
|
-
__name: "index",
|
|
8
|
-
props: {
|
|
9
|
-
percentage: { default: 0 },
|
|
10
|
-
isAnimation: {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
default: false
|
|
13
|
-
},
|
|
14
|
-
time: { default: 3e3 },
|
|
15
|
-
type: {},
|
|
16
|
-
borderRadius: {},
|
|
17
|
-
circleGap: {},
|
|
18
|
-
color: {},
|
|
19
|
-
fillBorderRadius: {},
|
|
20
|
-
gapDegree: {},
|
|
21
|
-
gapOffsetDegree: {},
|
|
22
|
-
height: {},
|
|
23
|
-
indicatorPlacement: { default: "outside" },
|
|
24
|
-
indicatorTextColor: {},
|
|
25
|
-
offsetDegree: {},
|
|
26
|
-
railColor: {},
|
|
27
|
-
railStyle: {},
|
|
28
|
-
showIndicator: {
|
|
29
|
-
type: Boolean,
|
|
30
|
-
default: true
|
|
31
|
-
},
|
|
32
|
-
status: { default: "default" },
|
|
33
|
-
strokeWidth: { default: 7 },
|
|
34
|
-
unit: { default: "%" }
|
|
35
|
-
},
|
|
36
|
-
setup(__props) {
|
|
37
|
-
const props = __props;
|
|
38
|
-
const slots = useSlots();
|
|
39
|
-
const p = ref(Array.isArray(props.percentage) ? [...props.percentage] : 0);
|
|
40
|
-
const hasIndicatorSlot = computed(() => !!slots.indicator);
|
|
41
|
-
const processedPercentage = computed(() => {
|
|
42
|
-
return props.type === "multiple-circle" ? Array.isArray(p.value) ? p.value : [p.value] : Array.isArray(p.value) ? p.value[0] : p.value;
|
|
43
|
-
});
|
|
44
|
-
const progressProps = computed(() => ({
|
|
45
|
-
type: props.type,
|
|
46
|
-
borderRadius: props.borderRadius,
|
|
47
|
-
circleGap: props.circleGap,
|
|
48
|
-
color: props.color,
|
|
49
|
-
fillBorderRadius: props.fillBorderRadius,
|
|
50
|
-
gapDegree: props.gapDegree,
|
|
51
|
-
gapOffsetDegree: props.gapOffsetDegree,
|
|
52
|
-
height: props.height,
|
|
53
|
-
indicatorPlacement: props.indicatorPlacement,
|
|
54
|
-
indicatorTextColor: props.indicatorTextColor,
|
|
55
|
-
offsetDegree: props.offsetDegree,
|
|
56
|
-
railColor: props.railColor,
|
|
57
|
-
railStyle: props.railStyle,
|
|
58
|
-
status: props.status,
|
|
59
|
-
strokeWidth: props.strokeWidth,
|
|
60
|
-
unit: props.unit
|
|
61
|
-
}));
|
|
62
|
-
watch(() => props.percentage, (newVal) => {
|
|
63
|
-
if (!props.isAnimation) p.value = newVal;
|
|
64
|
-
else if (props.type === "multiple-circle" && Array.isArray(newVal)) p.value = [...newVal];
|
|
65
|
-
}, {
|
|
66
|
-
immediate: true,
|
|
67
|
-
deep: true
|
|
68
|
-
});
|
|
69
|
-
onMounted(() => {
|
|
70
|
-
if (props.isAnimation && props.type !== "multiple-circle") {
|
|
71
|
-
const targetValue = Array.isArray(props.percentage) ? props.percentage[0] : props.percentage;
|
|
72
|
-
if (targetValue > 0) {
|
|
73
|
-
const startTime = performance.now();
|
|
74
|
-
const animate = (now) => {
|
|
75
|
-
const elapsed = now - startTime;
|
|
76
|
-
const progress = Math.min(elapsed / props.time, 1);
|
|
77
|
-
p.value = Math.round(progress * targetValue);
|
|
78
|
-
if (progress < 1) requestAnimationFrame(animate);
|
|
79
|
-
};
|
|
80
|
-
requestAnimationFrame(animate);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
return (_ctx, _cache) => {
|
|
85
|
-
return openBlock(), createBlock(unref(NProgress), mergeProps(progressProps.value, {
|
|
86
|
-
percentage: processedPercentage.value,
|
|
87
|
-
processing: _ctx.isAnimation
|
|
88
|
-
}), createSlots({ _: 2 }, [_ctx.showIndicator && hasIndicatorSlot.value ? {
|
|
89
|
-
name: "default",
|
|
90
|
-
fn: withCtx(() => [renderSlot(_ctx.$slots, "indicator")]),
|
|
91
|
-
key: "0"
|
|
92
|
-
} : void 0]), 1040, ["percentage", "processing"]);
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/components/C_Progress/index.vue
|
|
99
|
-
var C_Progress_default = index_vue_vue_type_script_setup_true_lang_default;
|
|
100
|
-
|
|
101
|
-
//#endregion
|
|
102
|
-
export { C_Progress_default as t };
|
|
1
|
+
import{NProgress as e}from"naive-ui";import{computed as t,createBlock as n,createSlots as r,defineComponent as i,mergeProps as a,onMounted as o,openBlock as s,ref as c,renderSlot as l,unref as u,useSlots as d,watch as f,withCtx as p}from"vue";var m=i({name:`C_Progress`,__name:`index`,props:{percentage:{default:0},isAnimation:{type:Boolean,default:!1},time:{default:3e3},type:{},borderRadius:{},circleGap:{},color:{},fillBorderRadius:{},gapDegree:{},gapOffsetDegree:{},height:{},indicatorPlacement:{default:`outside`},indicatorTextColor:{},offsetDegree:{},railColor:{},railStyle:{},showIndicator:{type:Boolean,default:!0},status:{default:`default`},strokeWidth:{default:7},unit:{default:`%`}},setup(i){let m=i,h=d(),g=c(Array.isArray(m.percentage)?[...m.percentage]:0),_=t(()=>!!h.indicator),v=t(()=>m.type===`multiple-circle`?Array.isArray(g.value)?g.value:[g.value]:Array.isArray(g.value)?g.value[0]:g.value),y=t(()=>({type:m.type,borderRadius:m.borderRadius,circleGap:m.circleGap,color:m.color,fillBorderRadius:m.fillBorderRadius,gapDegree:m.gapDegree,gapOffsetDegree:m.gapOffsetDegree,height:m.height,indicatorPlacement:m.indicatorPlacement,indicatorTextColor:m.indicatorTextColor,offsetDegree:m.offsetDegree,railColor:m.railColor,railStyle:m.railStyle,status:m.status,strokeWidth:m.strokeWidth,unit:m.unit}));return f(()=>m.percentage,e=>{m.isAnimation?m.type===`multiple-circle`&&Array.isArray(e)&&(g.value=[...e]):g.value=e},{immediate:!0,deep:!0}),o(()=>{if(m.isAnimation&&m.type!==`multiple-circle`){let e=Array.isArray(m.percentage)?m.percentage[0]:m.percentage;if(e>0){let t=performance.now(),n=r=>{let i=r-t,a=Math.min(i/m.time,1);g.value=Math.round(a*e),a<1&&requestAnimationFrame(n)};requestAnimationFrame(n)}}}),(t,i)=>(s(),n(u(e),a(y.value,{percentage:v.value,processing:t.isAnimation}),r({_:2},[t.showIndicator&&_.value?{name:`default`,fn:p(()=>[l(t.$slots,`indicator`)]),key:`0`}:void 0]),1040,[`percentage`,`processing`]))}});export{m as t};
|
|
103
2
|
//# sourceMappingURL=C_Progress2.js.map
|
package/dist/C_Progress2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"C_Progress2.js","names":["isAnimation","showIndicator"],"sources":["../src/components/C_Progress/index.vue","../src/components/C_Progress/index.vue","../src/components/C_Progress/index.vue"],"sourcesContent":["/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n","<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ECmDA,MAAM,QAAQ;EAWd,MAAM,QAAQ,UAAU;EACxB,MAAM,IAAI,IACR,MAAM,QAAQ,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,WAAW,GAAG,EAC3D;EAED,MAAM,mBAAmB,eAAe,CAAC,CAAC,MAAM,UAAU;EAE1D,MAAM,sBAAsB,eAAe;AACzC,UAAO,MAAM,SAAS,oBAClB,MAAM,QAAQ,EAAE,MAAM,GACpB,EAAE,QACF,CAAC,EAAE,MAAM,GACX,MAAM,QAAQ,EAAE,MAAM,GACpB,EAAE,MAAM,KACR,EAAE;IACR;EAEF,MAAM,gBAAgB,gBAAgB;GACpC,MAAM,MAAM;GACZ,cAAc,MAAM;GACpB,WAAW,MAAM;GACjB,OAAO,MAAM;GACb,kBAAkB,MAAM;GACxB,WAAW,MAAM;GACjB,iBAAiB,MAAM;GACvB,QAAQ,MAAM;GACd,oBAAoB,MAAM;GAC1B,oBAAoB,MAAM;GAC1B,cAAc,MAAM;GACpB,WAAW,MAAM;GACjB,WAAW,MAAM;GACjB,QAAQ,MAAM;GACd,aAAa,MAAM;GACnB,MAAM,MAAM;GACb,EAAE;AAEH,cACQ,MAAM,aACX,WAAW;AACV,OAAI,CAAC,MAAM,YACT,GAAE,QAAQ;YACD,MAAM,SAAS,qBAAqB,MAAM,QAAQ,OAAO,CAClE,GAAE,QAAQ,CAAC,GAAG,OAAO;KAGzB;GAAE,WAAW;GAAM,MAAM;GAAM,CAChC;AAED,kBAAgB;AACd,OAAI,MAAM,eAAe,MAAM,SAAS,mBAAmB;IACzD,MAAM,cAAc,MAAM,QAAQ,MAAM,WAAW,GAC/C,MAAM,WAAW,KACjB,MAAM;AAEV,QAAI,cAAc,GAAG;KACnB,MAAM,YAAY,YAAY,KAAK;KAEnC,MAAM,WAAW,QAAgB;MAC/B,MAAM,UAAU,MAAM;MACtB,MAAM,WAAW,KAAK,IAAI,UAAU,MAAM,MAAM,EAAE;AAClD,QAAE,QAAQ,KAAK,MAAM,WAAW,YAAY;AAE5C,UAAI,WAAW,EACb,uBAAsB,QAAQ;;AAIlC,2BAAsB,QAAQ;;;IAGlC;;uBA5HA,YAQY,MAAA,UAAA,EARZ,WACU,cAOE,OAPW;IACpB,YAAY,oBAAA;IACZ,YAAYA,KAAAA;8BAEGC,KAAAA,iBAAiB,iBAAA;UAAmB;sBACzB,CAAzB,WAAyB,KAAA,QAAA,YAAA"}
|
|
1
|
+
{"version":3,"file":"C_Progress2.js","names":["isAnimation","showIndicator"],"sources":["../src/components/C_Progress/index.vue","../src/components/C_Progress/index.vue","../src/components/C_Progress/index.vue"],"sourcesContent":["/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n","<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-01\r\n * @Description: 进度条组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <NProgress\r\n v-bind=\"progressProps\"\r\n :percentage=\"processedPercentage\"\r\n :processing=\"isAnimation\"\r\n >\r\n <template v-if=\"showIndicator && hasIndicatorSlot\" #default>\r\n <slot name=\"indicator\" />\r\n </template>\r\n </NProgress>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { ref, computed, watch, useSlots, onMounted } from \"vue\";\r\nimport { NProgress } from \"naive-ui\";\r\nimport type { CSSProperties } from \"vue\";\r\n\r\ndefineOptions({ name: \"C_Progress\" });\r\n\r\ntype CSS = CSSProperties | string;\r\n\r\ninterface Props {\r\n percentage: number | number[];\r\n isAnimation?: boolean;\r\n time?: number;\r\n type?: \"line\" | \"circle\" | \"multiple-circle\" | \"dashboard\";\r\n borderRadius?: number | string;\r\n circleGap?: number;\r\n color?: string | string[] | { stops: string[] } | Array<{ stops: string[] }>;\r\n fillBorderRadius?: number | string;\r\n gapDegree?: number;\r\n gapOffsetDegree?: number;\r\n height?: number;\r\n indicatorPlacement?: \"inside\" | \"outside\";\r\n indicatorTextColor?: string;\r\n offsetDegree?: number;\r\n railColor?: string | string[];\r\n railStyle?: string | CSS | Array<string | CSS>;\r\n showIndicator?: boolean;\r\n status?: \"default\" | \"success\" | \"error\" | \"warning\" | \"info\";\r\n strokeWidth?: number;\r\n unit?: string;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n percentage: 0,\r\n isAnimation: false,\r\n time: 3000,\r\n indicatorPlacement: \"outside\",\r\n showIndicator: true,\r\n status: \"default\",\r\n strokeWidth: 7,\r\n unit: \"%\",\r\n});\r\n\r\nconst slots = useSlots();\r\nconst p = ref<number | number[]>(\r\n Array.isArray(props.percentage) ? [...props.percentage] : 0,\r\n);\r\n\r\nconst hasIndicatorSlot = computed(() => !!slots.indicator);\r\n\r\nconst processedPercentage = computed(() => {\r\n return props.type === \"multiple-circle\"\r\n ? Array.isArray(p.value)\r\n ? p.value\r\n : [p.value]\r\n : Array.isArray(p.value)\r\n ? p.value[0]\r\n : p.value;\r\n});\r\n\r\nconst progressProps = computed(() => ({\r\n type: props.type,\r\n borderRadius: props.borderRadius,\r\n circleGap: props.circleGap,\r\n color: props.color,\r\n fillBorderRadius: props.fillBorderRadius,\r\n gapDegree: props.gapDegree,\r\n gapOffsetDegree: props.gapOffsetDegree,\r\n height: props.height,\r\n indicatorPlacement: props.indicatorPlacement,\r\n indicatorTextColor: props.indicatorTextColor,\r\n offsetDegree: props.offsetDegree,\r\n railColor: props.railColor,\r\n railStyle: props.railStyle,\r\n status: props.status,\r\n strokeWidth: props.strokeWidth,\r\n unit: props.unit,\r\n}));\r\n\r\nwatch(\r\n () => props.percentage,\r\n (newVal) => {\r\n if (!props.isAnimation) {\r\n p.value = newVal;\r\n } else if (props.type === \"multiple-circle\" && Array.isArray(newVal)) {\r\n p.value = [...newVal];\r\n }\r\n },\r\n { immediate: true, deep: true },\r\n);\r\n\r\nonMounted(() => {\r\n if (props.isAnimation && props.type !== \"multiple-circle\") {\r\n const targetValue = Array.isArray(props.percentage)\r\n ? props.percentage[0]\r\n : props.percentage;\r\n\r\n if (targetValue > 0) {\r\n const startTime = performance.now();\r\n\r\n const animate = (now: number) => {\r\n const elapsed = now - startTime;\r\n const progress = Math.min(elapsed / props.time, 1);\r\n p.value = Math.round(progress * targetValue);\r\n\r\n if (progress < 1) {\r\n requestAnimationFrame(animate);\r\n }\r\n };\r\n\r\n requestAnimationFrame(animate);\r\n }\r\n }\r\n});\r\n</script>\r\n"],"mappings":"+rBEmDA,IAAM,EAAQ,EAWR,EAAQ,GAAU,CAClB,EAAI,EACR,MAAM,QAAQ,EAAM,WAAW,CAAG,CAAC,GAAG,EAAM,WAAW,CAAG,EAC3D,CAEK,EAAmB,MAAe,CAAC,CAAC,EAAM,UAAU,CAEpD,EAAsB,MACnB,EAAM,OAAS,kBAClB,MAAM,QAAQ,EAAE,MAAM,CACpB,EAAE,MACF,CAAC,EAAE,MAAM,CACX,MAAM,QAAQ,EAAE,MAAM,CACpB,EAAE,MAAM,GACR,EAAE,MACR,CAEI,EAAgB,OAAgB,CACpC,KAAM,EAAM,KACZ,aAAc,EAAM,aACpB,UAAW,EAAM,UACjB,MAAO,EAAM,MACb,iBAAkB,EAAM,iBACxB,UAAW,EAAM,UACjB,gBAAiB,EAAM,gBACvB,OAAQ,EAAM,OACd,mBAAoB,EAAM,mBAC1B,mBAAoB,EAAM,mBAC1B,aAAc,EAAM,aACpB,UAAW,EAAM,UACjB,UAAW,EAAM,UACjB,OAAQ,EAAM,OACd,YAAa,EAAM,YACnB,KAAM,EAAM,KACb,EAAE,QAEH,MACQ,EAAM,WACX,GAAW,CACL,EAAM,YAEA,EAAM,OAAS,mBAAqB,MAAM,QAAQ,EAAO,GAClE,EAAE,MAAQ,CAAC,GAAG,EAAO,EAFrB,EAAE,MAAQ,GAKd,CAAE,UAAW,GAAM,KAAM,GAAM,CAChC,CAED,MAAgB,CACd,GAAI,EAAM,aAAe,EAAM,OAAS,kBAAmB,CACzD,IAAM,EAAc,MAAM,QAAQ,EAAM,WAAW,CAC/C,EAAM,WAAW,GACjB,EAAM,WAEV,GAAI,EAAc,EAAG,CACnB,IAAM,EAAY,YAAY,KAAK,CAE7B,EAAW,GAAgB,CAC/B,IAAM,EAAU,EAAM,EAChB,EAAW,KAAK,IAAI,EAAU,EAAM,KAAM,EAAE,CAClD,EAAE,MAAQ,KAAK,MAAM,EAAW,EAAY,CAExC,EAAW,GACb,sBAAsB,EAAQ,EAIlC,sBAAsB,EAAQ,IAGlC,aA5HA,EAQY,EAAA,EAAA,CARZ,EACU,EAOE,MAPW,CACpB,WAAY,EAAA,MACZ,WAAYA,EAAAA,uBAEGC,EAAAA,eAAiB,EAAA,MAAA,MAAmB,mBACzB,CAAzB,EAAyB,EAAA,OAAA,YAAA,CAAA,CAAA"}
|
package/dist/C_QRCode.cjs
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
const require_C_QRCode = require('./C_QRCode.js');
|
|
3
|
-
|
|
4
|
-
exports.C_QRCode = require_C_QRCode.C_QRCode_default;
|
|
5
|
-
exports.useQRCode = require_C_QRCode.useQRCode;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./C_QRCode.js`);exports.C_QRCode=e.t,exports.useQRCode=e.n;
|
package/dist/C_QRCode.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"C_QRCode.js","names":["QRCode","showBorder","mode","size","showLabel","label"],"sources":["../src/components/C_QRCode/composables/useQRCode.ts","../src/components/C_QRCode/index.vue","../src/components/C_QRCode/index.vue","../src/components/C_QRCode/index.vue"],"sourcesContent":["import { ref, computed, watch } from \"vue\";\r\nimport QRCode from \"qrcode\";\r\nimport type { Ref } from \"vue\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n RenderMode,\r\n} from \"../types\";\r\n\r\ninterface UseQRCodeOptions {\r\n value: Ref<string>;\r\n size: Ref<number>;\r\n color: Ref<string>;\r\n bgColor: Ref<string>;\r\n errorCorrectionLevel: Ref<ErrorCorrectionLevel>;\r\n margin: Ref<number>;\r\n mode: Ref<RenderMode>;\r\n logo: Ref<LogoOptions | undefined>;\r\n}\r\n\r\nfunction drawLogo(\r\n canvas: HTMLCanvasElement,\r\n logo: LogoOptions,\r\n qrSize: number,\r\n): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return reject(new Error(\"Canvas context 不可用\"));\r\n\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n const ratio = logo.size ?? 0.2;\r\n const logoSize = Math.floor(qrSize * ratio);\r\n const padding = logo.padding ?? 4;\r\n const borderRadius = logo.borderRadius ?? 4;\r\n\r\n const x = (canvas.width - logoSize) / 2;\r\n const y = (canvas.height - logoSize) / 2;\r\n\r\n ctx.save();\r\n const bgX = x - padding;\r\n const bgY = y - padding;\r\n const bgSize = logoSize + padding * 2;\r\n const r = borderRadius + padding;\r\n\r\n ctx.beginPath();\r\n ctx.moveTo(bgX + r, bgY);\r\n ctx.arcTo(bgX + bgSize, bgY, bgX + bgSize, bgY + bgSize, r);\r\n ctx.arcTo(bgX + bgSize, bgY + bgSize, bgX, bgY + bgSize, r);\r\n ctx.arcTo(bgX, bgY + bgSize, bgX, bgY, r);\r\n ctx.arcTo(bgX, bgY, bgX + bgSize, bgY, r);\r\n ctx.closePath();\r\n ctx.fillStyle = logo.bgColor ?? \"#ffffff\";\r\n ctx.fill();\r\n\r\n ctx.beginPath();\r\n ctx.moveTo(x + borderRadius, y);\r\n ctx.arcTo(x + logoSize, y, x + logoSize, y + logoSize, borderRadius);\r\n ctx.arcTo(x + logoSize, y + logoSize, x, y + logoSize, borderRadius);\r\n ctx.arcTo(x, y + logoSize, x, y, borderRadius);\r\n ctx.arcTo(x, y, x + logoSize, y, borderRadius);\r\n ctx.closePath();\r\n ctx.clip();\r\n ctx.drawImage(img, x, y, logoSize, logoSize);\r\n ctx.restore();\r\n\r\n resolve();\r\n };\r\n img.onerror = () => reject(new Error(`Logo 加载失败: ${logo.src}`));\r\n img.src = logo.src;\r\n });\r\n}\r\n\r\nexport function useQRCode(\r\n canvasRef: Ref<HTMLCanvasElement | null>,\r\n options: UseQRCodeOptions,\r\n) {\r\n const svgHtml = ref(\"\");\r\n const error = ref<Error | null>(null);\r\n const loading = ref(false);\r\n\r\n const effectiveLevel = computed<ErrorCorrectionLevel>(() => {\r\n if (options.logo.value) {\r\n const level = options.errorCorrectionLevel.value;\r\n if (level === \"L\" || level === \"M\") return \"Q\";\r\n return level;\r\n }\r\n return options.errorCorrectionLevel.value;\r\n });\r\n\r\n const qrOptions = computed(() => ({\r\n width: options.size.value,\r\n margin: options.margin.value,\r\n errorCorrectionLevel: effectiveLevel.value,\r\n color: {\r\n dark: options.color.value,\r\n light: options.bgColor.value,\r\n },\r\n }));\r\n\r\n async function renderCanvas() {\r\n const canvas = canvasRef.value;\r\n if (!canvas || !options.value.value) return;\r\n await QRCode.toCanvas(canvas, options.value.value, qrOptions.value);\r\n if (options.logo.value) {\r\n await drawLogo(canvas, options.logo.value, options.size.value);\r\n }\r\n }\r\n\r\n async function renderSvg() {\r\n if (!options.value.value) {\r\n svgHtml.value = \"\";\r\n return;\r\n }\r\n const svgString = await QRCode.toString(options.value.value, {\r\n ...qrOptions.value,\r\n type: \"svg\",\r\n });\r\n svgHtml.value = svgString;\r\n }\r\n\r\n async function render() {\r\n if (!options.value.value) return;\r\n loading.value = true;\r\n error.value = null;\r\n try {\r\n if (options.mode.value === \"canvas\") {\r\n await renderCanvas();\r\n } else {\r\n await renderSvg();\r\n }\r\n } catch (e) {\r\n error.value = e instanceof Error ? e : new Error(String(e));\r\n console.error(\"二维码渲染失败:\", e);\r\n } finally {\r\n loading.value = false;\r\n }\r\n }\r\n\r\n async function toDataURL(\r\n type: ExportType = \"png\",\r\n quality = 0.92,\r\n ): Promise<string> {\r\n if (type === \"svg\") {\r\n const svgStr = await QRCode.toString(options.value.value, {\r\n ...qrOptions.value,\r\n type: \"svg\",\r\n });\r\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgStr)}`;\r\n }\r\n const tempCanvas = document.createElement(\"canvas\");\r\n await QRCode.toCanvas(tempCanvas, options.value.value, qrOptions.value);\r\n if (options.logo.value) {\r\n await drawLogo(tempCanvas, options.logo.value, options.size.value);\r\n }\r\n const mimeType = type === \"jpeg\" ? \"image/jpeg\" : \"image/png\";\r\n return tempCanvas.toDataURL(mimeType, quality);\r\n }\r\n\r\n async function download(filename = \"qrcode\", type: ExportType = \"png\") {\r\n const dataUrl = await toDataURL(type);\r\n const link = document.createElement(\"a\");\r\n link.download = `${filename}.${type}`;\r\n link.href = dataUrl;\r\n link.click();\r\n }\r\n\r\n watch(\r\n [\r\n options.value,\r\n options.size,\r\n options.color,\r\n options.bgColor,\r\n options.errorCorrectionLevel,\r\n options.margin,\r\n options.mode,\r\n options.logo,\r\n ],\r\n () => render(),\r\n { deep: true },\r\n );\r\n\r\n return { svgHtml, error, loading, render, toDataURL, download };\r\n}\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n","<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n"],"mappings":"gHAqBA,SAAS,EACP,EACA,EACA,EACe,CACf,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAM,EAAM,EAAO,WAAW,KAAK,CACnC,GAAI,CAAC,EAAK,OAAO,EAAW,MAAM,qBAAqB,CAAC,CAExD,IAAM,EAAM,IAAI,MAChB,EAAI,YAAc,YAClB,EAAI,WAAe,CACjB,IAAM,EAAQ,EAAK,MAAQ,GACrB,EAAW,KAAK,MAAM,EAAS,EAAM,CACrC,EAAU,EAAK,SAAW,EAC1B,EAAe,EAAK,cAAgB,EAEpC,GAAK,EAAO,MAAQ,GAAY,EAChC,GAAK,EAAO,OAAS,GAAY,EAEvC,EAAI,MAAM,CACV,IAAM,EAAM,EAAI,EACV,EAAM,EAAI,EACV,EAAS,EAAW,EAAU,EAC9B,EAAI,EAAe,EAEzB,EAAI,WAAW,CACf,EAAI,OAAO,EAAM,EAAG,EAAI,CACxB,EAAI,MAAM,EAAM,EAAQ,EAAK,EAAM,EAAQ,EAAM,EAAQ,EAAE,CAC3D,EAAI,MAAM,EAAM,EAAQ,EAAM,EAAQ,EAAK,EAAM,EAAQ,EAAE,CAC3D,EAAI,MAAM,EAAK,EAAM,EAAQ,EAAK,EAAK,EAAE,CACzC,EAAI,MAAM,EAAK,EAAK,EAAM,EAAQ,EAAK,EAAE,CACzC,EAAI,WAAW,CACf,EAAI,UAAY,EAAK,SAAW,UAChC,EAAI,MAAM,CAEV,EAAI,WAAW,CACf,EAAI,OAAO,EAAI,EAAc,EAAE,CAC/B,EAAI,MAAM,EAAI,EAAU,EAAG,EAAI,EAAU,EAAI,EAAU,EAAa,CACpE,EAAI,MAAM,EAAI,EAAU,EAAI,EAAU,EAAG,EAA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AA,YAAAA,EAAAA,EAAAA,EAAAA,oBAElB,MAFN,GAAA,EAAA,EAAA,iBACKA,EAAAA,MAAK,CAAA,EAAA,GAAA,EAAA,EAAA,oBAAA,OAAA,GAAA,CAAA,CAAA"}
|
package/dist/C_QRCode2.js
CHANGED
|
@@ -1,218 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, openBlock, ref, toDisplayString, toRef, unref, vShow, watch, withDirectives } from "vue";
|
|
3
|
-
import QRCode from "qrcode";
|
|
4
|
-
|
|
5
|
-
//#region src/components/C_QRCode/composables/useQRCode.ts
|
|
6
|
-
function drawLogo(canvas, logo, qrSize) {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
const ctx = canvas.getContext("2d");
|
|
9
|
-
if (!ctx) return reject(/* @__PURE__ */ new Error("Canvas context 不可用"));
|
|
10
|
-
const img = new Image();
|
|
11
|
-
img.crossOrigin = "anonymous";
|
|
12
|
-
img.onload = () => {
|
|
13
|
-
const ratio = logo.size ?? .2;
|
|
14
|
-
const logoSize = Math.floor(qrSize * ratio);
|
|
15
|
-
const padding = logo.padding ?? 4;
|
|
16
|
-
const borderRadius = logo.borderRadius ?? 4;
|
|
17
|
-
const x = (canvas.width - logoSize) / 2;
|
|
18
|
-
const y = (canvas.height - logoSize) / 2;
|
|
19
|
-
ctx.save();
|
|
20
|
-
const bgX = x - padding;
|
|
21
|
-
const bgY = y - padding;
|
|
22
|
-
const bgSize = logoSize + padding * 2;
|
|
23
|
-
const r = borderRadius + padding;
|
|
24
|
-
ctx.beginPath();
|
|
25
|
-
ctx.moveTo(bgX + r, bgY);
|
|
26
|
-
ctx.arcTo(bgX + bgSize, bgY, bgX + bgSize, bgY + bgSize, r);
|
|
27
|
-
ctx.arcTo(bgX + bgSize, bgY + bgSize, bgX, bgY + bgSize, r);
|
|
28
|
-
ctx.arcTo(bgX, bgY + bgSize, bgX, bgY, r);
|
|
29
|
-
ctx.arcTo(bgX, bgY, bgX + bgSize, bgY, r);
|
|
30
|
-
ctx.closePath();
|
|
31
|
-
ctx.fillStyle = logo.bgColor ?? "#ffffff";
|
|
32
|
-
ctx.fill();
|
|
33
|
-
ctx.beginPath();
|
|
34
|
-
ctx.moveTo(x + borderRadius, y);
|
|
35
|
-
ctx.arcTo(x + logoSize, y, x + logoSize, y + logoSize, borderRadius);
|
|
36
|
-
ctx.arcTo(x + logoSize, y + logoSize, x, y + logoSize, borderRadius);
|
|
37
|
-
ctx.arcTo(x, y + logoSize, x, y, borderRadius);
|
|
38
|
-
ctx.arcTo(x, y, x + logoSize, y, borderRadius);
|
|
39
|
-
ctx.closePath();
|
|
40
|
-
ctx.clip();
|
|
41
|
-
ctx.drawImage(img, x, y, logoSize, logoSize);
|
|
42
|
-
ctx.restore();
|
|
43
|
-
resolve();
|
|
44
|
-
};
|
|
45
|
-
img.onerror = () => reject(/* @__PURE__ */ new Error(`Logo 加载失败: ${logo.src}`));
|
|
46
|
-
img.src = logo.src;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
function useQRCode(canvasRef, options) {
|
|
50
|
-
const svgHtml = ref("");
|
|
51
|
-
const error = ref(null);
|
|
52
|
-
const loading = ref(false);
|
|
53
|
-
const effectiveLevel = computed(() => {
|
|
54
|
-
if (options.logo.value) {
|
|
55
|
-
const level = options.errorCorrectionLevel.value;
|
|
56
|
-
if (level === "L" || level === "M") return "Q";
|
|
57
|
-
return level;
|
|
58
|
-
}
|
|
59
|
-
return options.errorCorrectionLevel.value;
|
|
60
|
-
});
|
|
61
|
-
const qrOptions = computed(() => ({
|
|
62
|
-
width: options.size.value,
|
|
63
|
-
margin: options.margin.value,
|
|
64
|
-
errorCorrectionLevel: effectiveLevel.value,
|
|
65
|
-
color: {
|
|
66
|
-
dark: options.color.value,
|
|
67
|
-
light: options.bgColor.value
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
async function renderCanvas() {
|
|
71
|
-
const canvas = canvasRef.value;
|
|
72
|
-
if (!canvas || !options.value.value) return;
|
|
73
|
-
await QRCode.toCanvas(canvas, options.value.value, qrOptions.value);
|
|
74
|
-
if (options.logo.value) await drawLogo(canvas, options.logo.value, options.size.value);
|
|
75
|
-
}
|
|
76
|
-
async function renderSvg() {
|
|
77
|
-
if (!options.value.value) {
|
|
78
|
-
svgHtml.value = "";
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
svgHtml.value = await QRCode.toString(options.value.value, {
|
|
82
|
-
...qrOptions.value,
|
|
83
|
-
type: "svg"
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
async function render() {
|
|
87
|
-
if (!options.value.value) return;
|
|
88
|
-
loading.value = true;
|
|
89
|
-
error.value = null;
|
|
90
|
-
try {
|
|
91
|
-
if (options.mode.value === "canvas") await renderCanvas();
|
|
92
|
-
else await renderSvg();
|
|
93
|
-
} catch (e) {
|
|
94
|
-
error.value = e instanceof Error ? e : new Error(String(e));
|
|
95
|
-
console.error("二维码渲染失败:", e);
|
|
96
|
-
} finally {
|
|
97
|
-
loading.value = false;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async function toDataURL(type = "png", quality = .92) {
|
|
101
|
-
if (type === "svg") {
|
|
102
|
-
const svgStr = await QRCode.toString(options.value.value, {
|
|
103
|
-
...qrOptions.value,
|
|
104
|
-
type: "svg"
|
|
105
|
-
});
|
|
106
|
-
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgStr)}`;
|
|
107
|
-
}
|
|
108
|
-
const tempCanvas = document.createElement("canvas");
|
|
109
|
-
await QRCode.toCanvas(tempCanvas, options.value.value, qrOptions.value);
|
|
110
|
-
if (options.logo.value) await drawLogo(tempCanvas, options.logo.value, options.size.value);
|
|
111
|
-
const mimeType = type === "jpeg" ? "image/jpeg" : "image/png";
|
|
112
|
-
return tempCanvas.toDataURL(mimeType, quality);
|
|
113
|
-
}
|
|
114
|
-
async function download(filename = "qrcode", type = "png") {
|
|
115
|
-
const dataUrl = await toDataURL(type);
|
|
116
|
-
const link = document.createElement("a");
|
|
117
|
-
link.download = `${filename}.${type}`;
|
|
118
|
-
link.href = dataUrl;
|
|
119
|
-
link.click();
|
|
120
|
-
}
|
|
121
|
-
watch([
|
|
122
|
-
options.value,
|
|
123
|
-
options.size,
|
|
124
|
-
options.color,
|
|
125
|
-
options.bgColor,
|
|
126
|
-
options.errorCorrectionLevel,
|
|
127
|
-
options.margin,
|
|
128
|
-
options.mode,
|
|
129
|
-
options.logo
|
|
130
|
-
], () => render(), { deep: true });
|
|
131
|
-
return {
|
|
132
|
-
svgHtml,
|
|
133
|
-
error,
|
|
134
|
-
loading,
|
|
135
|
-
render,
|
|
136
|
-
toDataURL,
|
|
137
|
-
download
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/components/C_QRCode/index.vue?vue&type=script&setup=true&lang.ts
|
|
143
|
-
const _hoisted_1 = { class: "c-qrcode" };
|
|
144
|
-
const _hoisted_2 = ["innerHTML"];
|
|
145
|
-
const _hoisted_3 = {
|
|
146
|
-
key: 0,
|
|
147
|
-
class: "qrcode-label"
|
|
148
|
-
};
|
|
149
|
-
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
150
|
-
name: "C_QRCode",
|
|
151
|
-
__name: "index",
|
|
152
|
-
props: {
|
|
153
|
-
value: {},
|
|
154
|
-
size: { default: 200 },
|
|
155
|
-
color: { default: "#000000" },
|
|
156
|
-
bgColor: { default: "#FFFFFF" },
|
|
157
|
-
errorCorrectionLevel: { default: "M" },
|
|
158
|
-
margin: { default: 2 },
|
|
159
|
-
mode: { default: "canvas" },
|
|
160
|
-
logo: { default: void 0 },
|
|
161
|
-
showBorder: {
|
|
162
|
-
type: Boolean,
|
|
163
|
-
default: true
|
|
164
|
-
},
|
|
165
|
-
label: { default: "" },
|
|
166
|
-
showLabel: {
|
|
167
|
-
type: Boolean,
|
|
168
|
-
default: false
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
emits: ["error"],
|
|
172
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
173
|
-
const props = __props;
|
|
174
|
-
const emit = __emit;
|
|
175
|
-
const canvasRef = ref(null);
|
|
176
|
-
const { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {
|
|
177
|
-
value: toRef(props, "value"),
|
|
178
|
-
size: toRef(props, "size"),
|
|
179
|
-
color: toRef(props, "color"),
|
|
180
|
-
bgColor: toRef(props, "bgColor"),
|
|
181
|
-
errorCorrectionLevel: toRef(props, "errorCorrectionLevel"),
|
|
182
|
-
margin: toRef(props, "margin"),
|
|
183
|
-
mode: toRef(props, "mode"),
|
|
184
|
-
logo: toRef(props, "logo")
|
|
185
|
-
});
|
|
186
|
-
watch(error, (e) => {
|
|
187
|
-
if (e) emit("error", e);
|
|
188
|
-
});
|
|
189
|
-
onMounted(() => render());
|
|
190
|
-
__expose({
|
|
191
|
-
toDataURL: (type, quality) => toDataURL(type, quality),
|
|
192
|
-
download: (filename, type) => download(filename, type),
|
|
193
|
-
refresh: () => render()
|
|
194
|
-
});
|
|
195
|
-
return (_ctx, _cache) => {
|
|
196
|
-
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("div", { class: normalizeClass(["qrcode-wrapper", { "with-border": _ctx.showBorder }]) }, [withDirectives(createElementVNode("canvas", {
|
|
197
|
-
ref_key: "canvasRef",
|
|
198
|
-
ref: canvasRef
|
|
199
|
-
}, null, 512), [[vShow, _ctx.mode === "canvas"]]), _ctx.mode === "svg" ? (openBlock(), createElementBlock("div", {
|
|
200
|
-
key: 0,
|
|
201
|
-
class: "qrcode-svg",
|
|
202
|
-
style: normalizeStyle({
|
|
203
|
-
width: `${_ctx.size}px`,
|
|
204
|
-
height: `${_ctx.size}px`
|
|
205
|
-
}),
|
|
206
|
-
innerHTML: unref(svgHtml)
|
|
207
|
-
}, null, 12, _hoisted_2)) : createCommentVNode("v-if", true)], 2), _ctx.showLabel && _ctx.label ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(_ctx.label), 1)) : createCommentVNode("v-if", true)]);
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
//#endregion
|
|
213
|
-
//#region src/components/C_QRCode/index.vue
|
|
214
|
-
var C_QRCode_default = /* @__PURE__ */ export_helper_default(index_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-7a4201b5"]]);
|
|
215
|
-
|
|
216
|
-
//#endregion
|
|
217
|
-
export { useQRCode as n, C_QRCode_default as t };
|
|
1
|
+
import{t as e}from"./export-helper.js";import{computed as t,createCommentVNode as n,createElementBlock as r,createElementVNode as i,defineComponent as a,normalizeClass as o,normalizeStyle as s,onMounted as c,openBlock as l,ref as u,toDisplayString as d,toRef as f,unref as p,vShow as m,watch as h,withDirectives as g}from"vue";import _ from"qrcode";function v(e,t,n){return new Promise((r,i)=>{let a=e.getContext(`2d`);if(!a)return i(Error(`Canvas context 不可用`));let o=new Image;o.crossOrigin=`anonymous`,o.onload=()=>{let i=t.size??.2,s=Math.floor(n*i),c=t.padding??4,l=t.borderRadius??4,u=(e.width-s)/2,d=(e.height-s)/2;a.save();let f=u-c,p=d-c,m=s+c*2,h=l+c;a.beginPath(),a.moveTo(f+h,p),a.arcTo(f+m,p,f+m,p+m,h),a.arcTo(f+m,p+m,f,p+m,h),a.arcTo(f,p+m,f,p,h),a.arcTo(f,p,f+m,p,h),a.closePath(),a.fillStyle=t.bgColor??`#ffffff`,a.fill(),a.beginPath(),a.moveTo(u+l,d),a.arcTo(u+s,d,u+s,d+s,l),a.arcTo(u+s,d+s,u,d+s,l),a.arcTo(u,d+s,u,d,l),a.arcTo(u,d,u+s,d,l),a.closePath(),a.clip(),a.drawImage(o,u,d,s,s),a.restore(),r()},o.onerror=()=>i(Error(`Logo 加载失败: ${t.src}`)),o.src=t.src})}function y(e,n){let r=u(``),i=u(null),a=u(!1),o=t(()=>{if(n.logo.value){let e=n.errorCorrectionLevel.value;return e===`L`||e===`M`?`Q`:e}return n.errorCorrectionLevel.value}),s=t(()=>({width:n.size.value,margin:n.margin.value,errorCorrectionLevel:o.value,color:{dark:n.color.value,light:n.bgColor.value}}));async function c(){let t=e.value;!t||!n.value.value||(await _.toCanvas(t,n.value.value,s.value),n.logo.value&&await v(t,n.logo.value,n.size.value))}async function l(){if(!n.value.value){r.value=``;return}r.value=await _.toString(n.value.value,{...s.value,type:`svg`})}async function d(){if(n.value.value){a.value=!0,i.value=null;try{n.mode.value===`canvas`?await c():await l()}catch(e){i.value=e instanceof Error?e:Error(String(e)),console.error(`二维码渲染失败:`,e)}finally{a.value=!1}}}async function f(e=`png`,t=.92){if(e===`svg`){let e=await _.toString(n.value.value,{...s.value,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}let r=document.createElement(`canvas`);await _.toCanvas(r,n.value.value,s.value),n.logo.value&&await v(r,n.logo.value,n.size.value);let i=e===`jpeg`?`image/jpeg`:`image/png`;return r.toDataURL(i,t)}async function p(e=`qrcode`,t=`png`){let n=await f(t),r=document.createElement(`a`);r.download=`${e}.${t}`,r.href=n,r.click()}return h([n.value,n.size,n.color,n.bgColor,n.errorCorrectionLevel,n.margin,n.mode,n.logo],()=>d(),{deep:!0}),{svgHtml:r,error:i,loading:a,render:d,toDataURL:f,download:p}}const b={class:`c-qrcode`},x=[`innerHTML`],S={key:0,class:`qrcode-label`};var C=e(a({name:`C_QRCode`,__name:`index`,props:{value:{},size:{default:200},color:{default:`#000000`},bgColor:{default:`#FFFFFF`},errorCorrectionLevel:{default:`M`},margin:{default:2},mode:{default:`canvas`},logo:{default:void 0},showBorder:{type:Boolean,default:!0},label:{default:``},showLabel:{type:Boolean,default:!1}},emits:[`error`],setup(e,{expose:t,emit:a}){let _=e,v=a,C=u(null),{svgHtml:w,error:T,render:E,toDataURL:D,download:O}=y(C,{value:f(_,`value`),size:f(_,`size`),color:f(_,`color`),bgColor:f(_,`bgColor`),errorCorrectionLevel:f(_,`errorCorrectionLevel`),margin:f(_,`margin`),mode:f(_,`mode`),logo:f(_,`logo`)});return h(T,e=>{e&&v(`error`,e)}),c(()=>E()),t({toDataURL:(e,t)=>D(e,t),download:(e,t)=>O(e,t),refresh:()=>E()}),(e,t)=>(l(),r(`div`,b,[i(`div`,{class:o([`qrcode-wrapper`,{"with-border":e.showBorder}])},[g(i(`canvas`,{ref_key:`canvasRef`,ref:C},null,512),[[m,e.mode===`canvas`]]),e.mode===`svg`?(l(),r(`div`,{key:0,class:`qrcode-svg`,style:s({width:`${e.size}px`,height:`${e.size}px`}),innerHTML:p(w)},null,12,x)):n(`v-if`,!0)],2),e.showLabel&&e.label?(l(),r(`div`,S,d(e.label),1)):n(`v-if`,!0)]))}}),[[`__scopeId`,`data-v-7a4201b5`]]);export{y as n,C as t};
|
|
218
2
|
//# sourceMappingURL=C_QRCode2.js.map
|
package/dist/C_QRCode2.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"C_QRCode2.js","names":["showBorder","mode","size","showLabel","label"],"sources":["../src/components/C_QRCode/composables/useQRCode.ts","../src/components/C_QRCode/index.vue","../src/components/C_QRCode/index.vue","../src/components/C_QRCode/index.vue"],"sourcesContent":["import { ref, computed, watch } from \"vue\";\r\nimport QRCode from \"qrcode\";\r\nimport type { Ref } from \"vue\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n RenderMode,\r\n} from \"../types\";\r\n\r\ninterface UseQRCodeOptions {\r\n value: Ref<string>;\r\n size: Ref<number>;\r\n color: Ref<string>;\r\n bgColor: Ref<string>;\r\n errorCorrectionLevel: Ref<ErrorCorrectionLevel>;\r\n margin: Ref<number>;\r\n mode: Ref<RenderMode>;\r\n logo: Ref<LogoOptions | undefined>;\r\n}\r\n\r\nfunction drawLogo(\r\n canvas: HTMLCanvasElement,\r\n logo: LogoOptions,\r\n qrSize: number,\r\n): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return reject(new Error(\"Canvas context 不可用\"));\r\n\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n const ratio = logo.size ?? 0.2;\r\n const logoSize = Math.floor(qrSize * ratio);\r\n const padding = logo.padding ?? 4;\r\n const borderRadius = logo.borderRadius ?? 4;\r\n\r\n const x = (canvas.width - logoSize) / 2;\r\n const y = (canvas.height - logoSize) / 2;\r\n\r\n ctx.save();\r\n const bgX = x - padding;\r\n const bgY = y - padding;\r\n const bgSize = logoSize + padding * 2;\r\n const r = borderRadius + padding;\r\n\r\n ctx.beginPath();\r\n ctx.moveTo(bgX + r, bgY);\r\n ctx.arcTo(bgX + bgSize, bgY, bgX + bgSize, bgY + bgSize, r);\r\n ctx.arcTo(bgX + bgSize, bgY + bgSize, bgX, bgY + bgSize, r);\r\n ctx.arcTo(bgX, bgY + bgSize, bgX, bgY, r);\r\n ctx.arcTo(bgX, bgY, bgX + bgSize, bgY, r);\r\n ctx.closePath();\r\n ctx.fillStyle = logo.bgColor ?? \"#ffffff\";\r\n ctx.fill();\r\n\r\n ctx.beginPath();\r\n ctx.moveTo(x + borderRadius, y);\r\n ctx.arcTo(x + logoSize, y, x + logoSize, y + logoSize, borderRadius);\r\n ctx.arcTo(x + logoSize, y + logoSize, x, y + logoSize, borderRadius);\r\n ctx.arcTo(x, y + logoSize, x, y, borderRadius);\r\n ctx.arcTo(x, y, x + logoSize, y, borderRadius);\r\n ctx.closePath();\r\n ctx.clip();\r\n ctx.drawImage(img, x, y, logoSize, logoSize);\r\n ctx.restore();\r\n\r\n resolve();\r\n };\r\n img.onerror = () => reject(new Error(`Logo 加载失败: ${logo.src}`));\r\n img.src = logo.src;\r\n });\r\n}\r\n\r\nexport function useQRCode(\r\n canvasRef: Ref<HTMLCanvasElement | null>,\r\n options: UseQRCodeOptions,\r\n) {\r\n const svgHtml = ref(\"\");\r\n const error = ref<Error | null>(null);\r\n const loading = ref(false);\r\n\r\n const effectiveLevel = computed<ErrorCorrectionLevel>(() => {\r\n if (options.logo.value) {\r\n const level = options.errorCorrectionLevel.value;\r\n if (level === \"L\" || level === \"M\") return \"Q\";\r\n return level;\r\n }\r\n return options.errorCorrectionLevel.value;\r\n });\r\n\r\n const qrOptions = computed(() => ({\r\n width: options.size.value,\r\n margin: options.margin.value,\r\n errorCorrectionLevel: effectiveLevel.value,\r\n color: {\r\n dark: options.color.value,\r\n light: options.bgColor.value,\r\n },\r\n }));\r\n\r\n async function renderCanvas() {\r\n const canvas = canvasRef.value;\r\n if (!canvas || !options.value.value) return;\r\n await QRCode.toCanvas(canvas, options.value.value, qrOptions.value);\r\n if (options.logo.value) {\r\n await drawLogo(canvas, options.logo.value, options.size.value);\r\n }\r\n }\r\n\r\n async function renderSvg() {\r\n if (!options.value.value) {\r\n svgHtml.value = \"\";\r\n return;\r\n }\r\n const svgString = await QRCode.toString(options.value.value, {\r\n ...qrOptions.value,\r\n type: \"svg\",\r\n });\r\n svgHtml.value = svgString;\r\n }\r\n\r\n async function render() {\r\n if (!options.value.value) return;\r\n loading.value = true;\r\n error.value = null;\r\n try {\r\n if (options.mode.value === \"canvas\") {\r\n await renderCanvas();\r\n } else {\r\n await renderSvg();\r\n }\r\n } catch (e) {\r\n error.value = e instanceof Error ? e : new Error(String(e));\r\n console.error(\"二维码渲染失败:\", e);\r\n } finally {\r\n loading.value = false;\r\n }\r\n }\r\n\r\n async function toDataURL(\r\n type: ExportType = \"png\",\r\n quality = 0.92,\r\n ): Promise<string> {\r\n if (type === \"svg\") {\r\n const svgStr = await QRCode.toString(options.value.value, {\r\n ...qrOptions.value,\r\n type: \"svg\",\r\n });\r\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgStr)}`;\r\n }\r\n const tempCanvas = document.createElement(\"canvas\");\r\n await QRCode.toCanvas(tempCanvas, options.value.value, qrOptions.value);\r\n if (options.logo.value) {\r\n await drawLogo(tempCanvas, options.logo.value, options.size.value);\r\n }\r\n const mimeType = type === \"jpeg\" ? \"image/jpeg\" : \"image/png\";\r\n return tempCanvas.toDataURL(mimeType, quality);\r\n }\r\n\r\n async function download(filename = \"qrcode\", type: ExportType = \"png\") {\r\n const dataUrl = await toDataURL(type);\r\n const link = document.createElement(\"a\");\r\n link.download = `${filename}.${type}`;\r\n link.href = dataUrl;\r\n link.click();\r\n }\r\n\r\n watch(\r\n [\r\n options.value,\r\n options.size,\r\n options.color,\r\n options.bgColor,\r\n options.errorCorrectionLevel,\r\n options.margin,\r\n options.mode,\r\n options.logo,\r\n ],\r\n () => render(),\r\n { deep: true },\r\n );\r\n\r\n return { svgHtml, error, loading, render, toDataURL, download };\r\n}\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n","<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n"],"mappings":";;;;;AAqBA,SAAS,SACP,QACA,MACA,QACe;AACf,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,MAAM,OAAO,WAAW,KAAK;AACnC,MAAI,CAAC,IAAK,QAAO,uBAAO,IAAI,MAAM,qBAAqB,CAAC;EAExD,MAAM,MAAM,IAAI,OAAO;AACvB,MAAI,cAAc;AAClB,MAAI,eAAe;GACjB,MAAM,QAAQ,KAAK,QAAQ;GAC3B,MAAM,WAAW,KAAK,MAAM,SAAS,MAAM;GAC3C,MAAM,UAAU,KAAK,WAAW;GAChC,MAAM,eAAe,KAAK,gBAAgB;GAE1C,MAAM,KAAK,OAAO,QAAQ,YAAY;GACtC,MAAM,KAAK,OAAO,SAAS,YAAY;AAEvC,OAAI,MAAM;GACV,MAAM,MAAM,IAA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,QAAQ;GACxB,CAAC;;uBAnFA,mBAaM,OAbN,YAaM,CAZJ,mBAQM,OAAA,EARD,OAAK,eAAA,CAAC,kBAAgB,EAAA,eAA0BA,KAAAA,YAAU,CAAA,CAAA,oBAC7D,mBAAqD,UAAA;aAAd;IAAJ,KAAI;2BAAvBC,KAAAA,SAAI,SAAA,IAEZA,KAAAA,SAAI,sBADZ,mBAKE,OAAA;;IAHA,OAAM;IACL,OAAK,eAAA;KAAA,OAAA,GAAcC,KAAAA,KAAI;KAAA,QAAA,GAAiBA,KAAAA,KAAI;KAAA,CAAA;IAC7C,WAAQ,MAAA,QAAA;sEAGDC,KAAAA,aAAaC,KAAAA,sBAAxB,mBAEM,OAFN,YAEM,gBADDA,KAAAA,MAAK,EAAA,EAAA"}
|
|
1
|
+
{"version":3,"file":"C_QRCode2.js","names":["showBorder","mode","size","showLabel","label"],"sources":["../src/components/C_QRCode/composables/useQRCode.ts","../src/components/C_QRCode/index.vue","../src/components/C_QRCode/index.vue","../src/components/C_QRCode/index.vue"],"sourcesContent":["import { ref, computed, watch } from \"vue\";\r\nimport QRCode from \"qrcode\";\r\nimport type { Ref } from \"vue\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n RenderMode,\r\n} from \"../types\";\r\n\r\ninterface UseQRCodeOptions {\r\n value: Ref<string>;\r\n size: Ref<number>;\r\n color: Ref<string>;\r\n bgColor: Ref<string>;\r\n errorCorrectionLevel: Ref<ErrorCorrectionLevel>;\r\n margin: Ref<number>;\r\n mode: Ref<RenderMode>;\r\n logo: Ref<LogoOptions | undefined>;\r\n}\r\n\r\nfunction drawLogo(\r\n canvas: HTMLCanvasElement,\r\n logo: LogoOptions,\r\n qrSize: number,\r\n): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return reject(new Error(\"Canvas context 不可用\"));\r\n\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n const ratio = logo.size ?? 0.2;\r\n const logoSize = Math.floor(qrSize * ratio);\r\n const padding = logo.padding ?? 4;\r\n const borderRadius = logo.borderRadius ?? 4;\r\n\r\n const x = (canvas.width - logoSize) / 2;\r\n const y = (canvas.height - logoSize) / 2;\r\n\r\n ctx.save();\r\n const bgX = x - padding;\r\n const bgY = y - padding;\r\n const bgSize = logoSize + padding * 2;\r\n const r = borderRadius + padding;\r\n\r\n ctx.beginPath();\r\n ctx.moveTo(bgX + r, bgY);\r\n ctx.arcTo(bgX + bgSize, bgY, bgX + bgSize, bgY + bgSize, r);\r\n ctx.arcTo(bgX + bgSize, bgY + bgSize, bgX, bgY + bgSize, r);\r\n ctx.arcTo(bgX, bgY + bgSize, bgX, bgY, r);\r\n ctx.arcTo(bgX, bgY, bgX + bgSize, bgY, r);\r\n ctx.closePath();\r\n ctx.fillStyle = logo.bgColor ?? \"#ffffff\";\r\n ctx.fill();\r\n\r\n ctx.beginPath();\r\n ctx.moveTo(x + borderRadius, y);\r\n ctx.arcTo(x + logoSize, y, x + logoSize, y + logoSize, borderRadius);\r\n ctx.arcTo(x + logoSize, y + logoSize, x, y + logoSize, borderRadius);\r\n ctx.arcTo(x, y + logoSize, x, y, borderRadius);\r\n ctx.arcTo(x, y, x + logoSize, y, borderRadius);\r\n ctx.closePath();\r\n ctx.clip();\r\n ctx.drawImage(img, x, y, logoSize, logoSize);\r\n ctx.restore();\r\n\r\n resolve();\r\n };\r\n img.onerror = () => reject(new Error(`Logo 加载失败: ${logo.src}`));\r\n img.src = logo.src;\r\n });\r\n}\r\n\r\nexport function useQRCode(\r\n canvasRef: Ref<HTMLCanvasElement | null>,\r\n options: UseQRCodeOptions,\r\n) {\r\n const svgHtml = ref(\"\");\r\n const error = ref<Error | null>(null);\r\n const loading = ref(false);\r\n\r\n const effectiveLevel = computed<ErrorCorrectionLevel>(() => {\r\n if (options.logo.value) {\r\n const level = options.errorCorrectionLevel.value;\r\n if (level === \"L\" || level === \"M\") return \"Q\";\r\n return level;\r\n }\r\n return options.errorCorrectionLevel.value;\r\n });\r\n\r\n const qrOptions = computed(() => ({\r\n width: options.size.value,\r\n margin: options.margin.value,\r\n errorCorrectionLevel: effectiveLevel.value,\r\n color: {\r\n dark: options.color.value,\r\n light: options.bgColor.value,\r\n },\r\n }));\r\n\r\n async function renderCanvas() {\r\n const canvas = canvasRef.value;\r\n if (!canvas || !options.value.value) return;\r\n await QRCode.toCanvas(canvas, options.value.value, qrOptions.value);\r\n if (options.logo.value) {\r\n await drawLogo(canvas, options.logo.value, options.size.value);\r\n }\r\n }\r\n\r\n async function renderSvg() {\r\n if (!options.value.value) {\r\n svgHtml.value = \"\";\r\n return;\r\n }\r\n const svgString = await QRCode.toString(options.value.value, {\r\n ...qrOptions.value,\r\n type: \"svg\",\r\n });\r\n svgHtml.value = svgString;\r\n }\r\n\r\n async function render() {\r\n if (!options.value.value) return;\r\n loading.value = true;\r\n error.value = null;\r\n try {\r\n if (options.mode.value === \"canvas\") {\r\n await renderCanvas();\r\n } else {\r\n await renderSvg();\r\n }\r\n } catch (e) {\r\n error.value = e instanceof Error ? e : new Error(String(e));\r\n console.error(\"二维码渲染失败:\", e);\r\n } finally {\r\n loading.value = false;\r\n }\r\n }\r\n\r\n async function toDataURL(\r\n type: ExportType = \"png\",\r\n quality = 0.92,\r\n ): Promise<string> {\r\n if (type === \"svg\") {\r\n const svgStr = await QRCode.toString(options.value.value, {\r\n ...qrOptions.value,\r\n type: \"svg\",\r\n });\r\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgStr)}`;\r\n }\r\n const tempCanvas = document.createElement(\"canvas\");\r\n await QRCode.toCanvas(tempCanvas, options.value.value, qrOptions.value);\r\n if (options.logo.value) {\r\n await drawLogo(tempCanvas, options.logo.value, options.size.value);\r\n }\r\n const mimeType = type === \"jpeg\" ? \"image/jpeg\" : \"image/png\";\r\n return tempCanvas.toDataURL(mimeType, quality);\r\n }\r\n\r\n async function download(filename = \"qrcode\", type: ExportType = \"png\") {\r\n const dataUrl = await toDataURL(type);\r\n const link = document.createElement(\"a\");\r\n link.download = `${filename}.${type}`;\r\n link.href = dataUrl;\r\n link.click();\r\n }\r\n\r\n watch(\r\n [\r\n options.value,\r\n options.size,\r\n options.color,\r\n options.bgColor,\r\n options.errorCorrectionLevel,\r\n options.margin,\r\n options.mode,\r\n options.logo,\r\n ],\r\n () => render(),\r\n { deep: true },\r\n );\r\n\r\n return { svgHtml, error, loading, render, toDataURL, download };\r\n}\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n","/* unplugin-vue-components disabled */<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n","<!--\r\n * @Author: ChenYu ycyplus@gmail.com\r\n * @Date: 2025-06-16\r\n * @Description: 二维码组件\r\n * @Migration: naive-ui-components 组件库迁移版本\r\n * Copyright (c) 2025 by CHENY, All Rights Reserved.\r\n-->\r\n<template>\r\n <div class=\"c-qrcode\">\r\n <div class=\"qrcode-wrapper\" :class=\"{ 'with-border': showBorder }\">\r\n <canvas v-show=\"mode === 'canvas'\" ref=\"canvasRef\" />\r\n <div\r\n v-if=\"mode === 'svg'\"\r\n class=\"qrcode-svg\"\r\n :style=\"{ width: `${size}px`, height: `${size}px` }\"\r\n v-html=\"svgHtml\"\r\n />\r\n </div>\r\n <div v-if=\"showLabel && label\" class=\"qrcode-label\">\r\n {{ label }}\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<script setup lang=\"ts\">\r\nimport { ref, toRef, watch, onMounted } from \"vue\";\r\nimport { useQRCode } from \"./composables/useQRCode\";\r\nimport type {\r\n ErrorCorrectionLevel,\r\n ExportType,\r\n LogoOptions,\r\n QRCodeExpose,\r\n RenderMode,\r\n} from \"./types\";\r\n\r\ndefineOptions({ name: \"C_QRCode\" });\r\n\r\ninterface Props {\r\n value: string;\r\n size?: number;\r\n color?: string;\r\n bgColor?: string;\r\n errorCorrectionLevel?: ErrorCorrectionLevel;\r\n margin?: number;\r\n mode?: RenderMode;\r\n logo?: LogoOptions;\r\n showBorder?: boolean;\r\n label?: string;\r\n showLabel?: boolean;\r\n}\r\n\r\nconst props = withDefaults(defineProps<Props>(), {\r\n size: 200,\r\n color: \"#000000\",\r\n bgColor: \"#FFFFFF\",\r\n errorCorrectionLevel: \"M\",\r\n margin: 2,\r\n mode: \"canvas\",\r\n logo: undefined,\r\n showBorder: true,\r\n label: \"\",\r\n showLabel: false,\r\n});\r\n\r\nconst emit = defineEmits<{\r\n error: [error: Error];\r\n}>();\r\n\r\nconst canvasRef = ref<HTMLCanvasElement | null>(null);\r\n\r\nconst { svgHtml, error, render, toDataURL, download } = useQRCode(canvasRef, {\r\n value: toRef(props, \"value\"),\r\n size: toRef(props, \"size\"),\r\n color: toRef(props, \"color\"),\r\n bgColor: toRef(props, \"bgColor\"),\r\n errorCorrectionLevel: toRef(props, \"errorCorrectionLevel\"),\r\n margin: toRef(props, \"margin\"),\r\n mode: toRef(props, \"mode\"),\r\n logo: toRef(props, \"logo\"),\r\n});\r\n\r\nwatch(error, (e) => {\r\n if (e) emit(\"error\", e);\r\n});\r\n\r\nonMounted(() => render());\r\n\r\ndefineExpose<QRCodeExpose>({\r\n toDataURL: (type?: ExportType, quality?: number) => toDataURL(type, quality),\r\n download: (filename?: string, type?: ExportType) => download(filename, type),\r\n refresh: () => render(),\r\n});\r\n</script>\r\n\r\n<style lang=\"scss\" scoped>\r\n@use \"./index.scss\";\r\n</style>\r\n"],"mappings":"6VAqBA,SAAS,EACP,EACA,EACA,EACe,CACf,OAAO,IAAI,SAAS,EAAS,IAAW,CACtC,IAAM,EAAM,EAAO,WAAW,KAAK,CACnC,GAAI,CAAC,EAAK,OAAO,EAAW,MAAM,qBAAqB,CAAC,CAExD,IAAM,EAAM,IAAI,MAChB,EAAI,YAAc,YAClB,EAAI,WAAe,CACjB,IAAM,EAAQ,EAAK,MAAQ,GACrB,EAAW,KAAK,MAAM,EAAS,EAAM,CACrC,EAAU,EAAK,SAAW,EAC1B,EAAe,EAAK,cAAgB,EAEpC,GAAK,EAAO,MAAQ,GAAY,EAChC,GAAK,EAAO,OAAS,GAAY,EAEvC,EAAI,MAAM,CACV,IAAM,EAAM,EAAI,EACV,EAAM,EAAI,EACV,EAAS,EAAW,EAAU,EAC9B,EAAI,EAAe,EAEzB,EAAI,WAAW,CACf,EAAI,OAAO,EAAM,EAAG,EAAI,CACxB,EAAI,MAAM,EAAM,EAAQ,EAAK,EAAM,EAAQ,EAAM,EAAQ,EAAE,CAC3D,EAAI,MAAM,EAAM,EAAQ,E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AA,EAAA,+BAGDC,EAAAA,WAAaC,EAAAA,OAAAA,GAAAA,CAAxB,EAEM,MAFN,EAEM,EADDA,EAAAA,MAAK,CAAA,EAAA,EAAA,EAAA,OAAA,GAAA,CAAA,CAAA"}
|
package/dist/C_Signature.cjs
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
2
|
-
require('./C_Icon.js');
|
|
3
|
-
const require_C_Signature = require('./C_Signature.js');
|
|
4
|
-
|
|
5
|
-
exports.C_Signature = require_C_Signature.C_Signature_default;
|
|
6
|
-
exports.useSignatureCanvas = require_C_Signature.useSignatureCanvas;
|
|
7
|
-
exports.useSignatureExport = require_C_Signature.useSignatureExport;
|
|
8
|
-
exports.useSignatureHistory = require_C_Signature.useSignatureHistory;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./C_Icon.js`);const e=require(`./C_Signature.js`);exports.C_Signature=e.t,exports.useSignatureCanvas=e.i,exports.useSignatureExport=e.n,exports.useSignatureHistory=e.r;
|
package/dist/C_Signature.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { i as useSignatureCanvas, n as useSignatureExport, r as useSignatureHistory, t as C_Signature_default } from "./C_Signature2.js";
|
|
3
|
-
|
|
4
|
-
export { C_Signature_default as C_Signature, useSignatureCanvas, useSignatureExport, useSignatureHistory };
|
|
1
|
+
import"./C_Icon2.js";import{i as e,n as t,r as n,t as r}from"./C_Signature2.js";export{r as C_Signature,e as useSignatureCanvas,t as useSignatureExport,n as useSignatureHistory};
|