mask2.mjs 2.9 KB

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