6d903f69892f2b847dddcd5f5a60cb28e0826b3ab48fd6f85ccd30bdc2da8889e5674b66be27edee4d2eb26cfe04ea1a42bde35b8ae29c47d2dfe36d6cefcc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { defineComponent, inject, computed, toRef, openBlock, createElementBlock, mergeProps, unref, createElementVNode, normalizeClass, normalizeStyle, createCommentVNode } from 'vue';
  2. import { useWindowSize } from '@vueuse/core';
  3. import { maskProps } from './mask.mjs';
  4. import { tourKey } from './helper.mjs';
  5. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  6. import { useLockscreen } from '../../../hooks/use-lockscreen/index.mjs';
  7. const __default__ = defineComponent({
  8. name: "ElTourMask",
  9. inheritAttrs: false
  10. });
  11. const _sfc_main = /* @__PURE__ */ defineComponent({
  12. ...__default__,
  13. props: maskProps,
  14. setup(__props) {
  15. const props = __props;
  16. const { ns } = inject(tourKey);
  17. const radius = computed(() => {
  18. var _a, _b;
  19. return (_b = (_a = props.pos) == null ? void 0 : _a.radius) != null ? _b : 2;
  20. });
  21. const roundInfo = computed(() => {
  22. const v = radius.value;
  23. const baseInfo = `a${v},${v} 0 0 1`;
  24. return {
  25. topRight: `${baseInfo} ${v},${v}`,
  26. bottomRight: `${baseInfo} ${-v},${v}`,
  27. bottomLeft: `${baseInfo} ${-v},${-v}`,
  28. topLeft: `${baseInfo} ${v},${-v}`
  29. };
  30. });
  31. const { width: windowWidth, height: windowHeight } = useWindowSize();
  32. const path = computed(() => {
  33. const width = windowWidth.value;
  34. const height = windowHeight.value;
  35. const info = roundInfo.value;
  36. const _path = `M${width},0 L0,0 L0,${height} L${width},${height} L${width},0 Z`;
  37. const _radius = radius.value;
  38. return props.pos ? `${_path} M${props.pos.left + _radius},${props.pos.top} h${props.pos.width - _radius * 2} ${info.topRight} v${props.pos.height - _radius * 2} ${info.bottomRight} h${-props.pos.width + _radius * 2} ${info.bottomLeft} v${-props.pos.height + _radius * 2} ${info.topLeft} z` : _path;
  39. });
  40. const maskStyle = computed(() => ({
  41. position: "fixed",
  42. left: 0,
  43. right: 0,
  44. top: 0,
  45. bottom: 0,
  46. zIndex: props.zIndex,
  47. pointerEvents: props.pos && props.targetAreaClickable ? "none" : "auto"
  48. }));
  49. const pathStyle = computed(() => ({
  50. fill: props.fill,
  51. pointerEvents: "auto",
  52. cursor: "auto"
  53. }));
  54. useLockscreen(toRef(props, "visible"), {
  55. ns
  56. });
  57. return (_ctx, _cache) => {
  58. return _ctx.visible ? (openBlock(), createElementBlock("div", mergeProps({
  59. key: 0,
  60. class: unref(ns).e("mask"),
  61. style: unref(maskStyle)
  62. }, _ctx.$attrs), [
  63. (openBlock(), createElementBlock("svg", { style: {
  64. width: "100%",
  65. height: "100%"
  66. } }, [
  67. createElementVNode("path", {
  68. class: normalizeClass(unref(ns).e("hollow")),
  69. style: normalizeStyle(unref(pathStyle)),
  70. d: unref(path)
  71. }, null, 14, ["d"])
  72. ]))
  73. ], 16)) : createCommentVNode("v-if", true);
  74. };
  75. }
  76. });
  77. var ElTourMask = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "mask.vue"]]);
  78. export { ElTourMask as default };
  79. //# sourceMappingURL=mask2.mjs.map