unika-components 1.0.4 → 1.0.5

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.
@@ -0,0 +1,13 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ [x: string]: any;
3
+ }, {
4
+ styleProps: import("vue").ComputedRef<Pick<any, string>>;
5
+ handleClick: () => void;
6
+ isPlaying: import("vue").Ref<boolean>;
7
+ togglePlay: () => void;
8
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
9
+ [x: string]: any;
10
+ }>>, {
11
+ [x: string]: any;
12
+ }, {}>;
13
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import UniMusic from './UniMusic.vue';
2
+ export default UniMusic;
@@ -167,6 +167,29 @@ export declare const backgroundDefaultProps: {
167
167
  left: string;
168
168
  top: string;
169
169
  };
170
+ export declare const musicDefaultProps: {
171
+ actionType: string;
172
+ url: string;
173
+ height: string;
174
+ width: string;
175
+ paddingLeft: string;
176
+ paddingRight: string;
177
+ paddingTop: string;
178
+ paddingBottom: string;
179
+ borderStyle: string;
180
+ borderColor: string;
181
+ borderWidth: string;
182
+ borderRadius: string;
183
+ boxShadow: string;
184
+ opacity: number;
185
+ position: string;
186
+ left: string;
187
+ top: string;
188
+ right: string;
189
+ musicSrc: string;
190
+ name: string;
191
+ isPlaying: boolean;
192
+ };
170
193
  export declare const componentsDefaultProps: {
171
194
  'uni-text': {
172
195
  props: {
@@ -259,6 +282,31 @@ export declare const componentsDefaultProps: {
259
282
  top: string;
260
283
  };
261
284
  };
285
+ 'uni-music': {
286
+ props: {
287
+ actionType: string;
288
+ url: string;
289
+ height: string;
290
+ width: string;
291
+ paddingLeft: string;
292
+ paddingRight: string;
293
+ paddingTop: string;
294
+ paddingBottom: string;
295
+ borderStyle: string;
296
+ borderColor: string;
297
+ borderWidth: string;
298
+ borderRadius: string;
299
+ boxShadow: string;
300
+ opacity: number;
301
+ position: string;
302
+ left: string;
303
+ top: string;
304
+ right: string;
305
+ musicSrc: string;
306
+ name: string;
307
+ isPlaying: boolean;
308
+ };
309
+ };
262
310
  };
263
311
  export declare const isEditingProp: {
264
312
  isEditing: {
@@ -5,8 +5,9 @@ import UniShape from './components/UniShape';
5
5
  import LongPage from './components/LongPage';
6
6
  import SwiperPage from './components/SwiperPage';
7
7
  import UniBackground from './components/UniBackground';
8
+ import UniMusic from './components/UniMusic';
8
9
  declare const install: (app: App) => void;
9
- export { UniText, UniImage, UniShape, LongPage, SwiperPage, UniBackground, install };
10
+ export { UniText, UniImage, UniShape, LongPage, SwiperPage, UniBackground, UniMusic, install };
10
11
  declare const _default: {
11
12
  install: (app: App<any>) => void;
12
13
  };
@@ -1,8 +1,4 @@
1
1
 
2
- .uni-image-component {
3
- max-width: 100%;
4
- }
5
-
6
2
  h2.uni-text-component, p.uni-text-component {
7
3
  margin-bottom: 0;
8
4
  }
@@ -14,6 +10,10 @@ button.uni-text-component {
14
10
  box-sizing: border-box;
15
11
  white-space: pre-wrap;
16
12
  }
13
+
14
+ .uni-image-component {
15
+ max-width: 100%;
16
+ }
17
17
 
18
18
  .uni-background-component {
19
19
  width: 100%;
@@ -38,3 +38,98 @@ button.uni-text-component {
38
38
  position:absolute;
39
39
  z-index:99999999;
40
40
  }
41
+
42
+ #audio {
43
+ position: absolute;
44
+ right: 10px;
45
+ top: 10px;
46
+ z-index: 103;
47
+ width: 30px;
48
+ height: 30px;
49
+ display: -webkit-box;
50
+ display: -ms-flexbox;
51
+ display: flex;
52
+ -webkit-box-align: center;
53
+ -ms-flex-align: center;
54
+ align-items: center;
55
+ }
56
+ #audio .audio {
57
+ width: 100%;
58
+ height: 100%;
59
+ display: -webkit-box;
60
+ display: -ms-flexbox;
61
+ display: flex;
62
+ -webkit-box-align: center;
63
+ -ms-flex-align: center;
64
+ align-items: center;
65
+ -webkit-box-pack: center;
66
+ -ms-flex-pack: center;
67
+ justify-content: center;
68
+ color: #fff;
69
+ background: #666;
70
+ border-radius: 50%;
71
+ overflow: hidden;
72
+ will-change: transform;
73
+ }
74
+ #audio .audio .music-icon {
75
+ display: block;
76
+ width: 100%;
77
+ height: 100%;
78
+ }
79
+ #audio .icon-cancel {
80
+ position: absolute;
81
+ width: 100%;
82
+ height: 100%;
83
+ border-radius: 50%;
84
+ overflow: hidden;
85
+ padding: 14px 0;
86
+ }
87
+ #audio .icon-cancel .icon-h {
88
+ -webkit-transform: rotate(45deg);
89
+ transform: rotate(45deg);
90
+ width: 100%;
91
+ height: 2px;
92
+ background: #fff;
93
+ }
94
+ #audio .mrotate {
95
+ -webkit-animation: mrotate 5s linear infinite;
96
+ animation: mrotate 5s linear infinite;
97
+ }
98
+ .video-play-audio {
99
+ position: absolute;
100
+ left: -9999px;
101
+ top: -9999px;
102
+ width: 0;
103
+ height: 0;
104
+ z-index: -1;
105
+ opacity: 1;
106
+ overflow: hidden;
107
+ }
108
+
109
+ .music-img {
110
+ position: relative;
111
+ display: inline-block;
112
+ width: 100%;
113
+ height: 100%;
114
+ }
115
+
116
+ .uni-music-component {
117
+ }
118
+
119
+ /* 无限旋转 */
120
+ @keyframes mrotate {
121
+ from {
122
+ transform: rotate(0deg);
123
+ }
124
+ to {
125
+ transform: rotate(360deg);
126
+ }
127
+ }
128
+ @-webkit-keyframes mrotate {
129
+ from {
130
+ -webkit-transform: rotate(0deg);
131
+ }
132
+ to {
133
+ -webkit-transform: rotate(360deg);
134
+ }
135
+ }
@@ -1,4 +1,4 @@
1
- import { computed, defineComponent, openBlock, createBlock, resolveDynamicComponent, withModifiers, normalizeStyle, withCtx, createTextVNode, toDisplayString, createElementBlock, Fragment, renderList, normalizeProps, guardReactiveProps, resolveComponent, createElementVNode, createVNode, createCommentVNode, pushScopeId, popScopeId } from 'vue';
1
+ import { computed, defineComponent, openBlock, createBlock, resolveDynamicComponent, withModifiers, normalizeStyle, withCtx, createTextVNode, toDisplayString, createElementBlock, Fragment, renderList, normalizeProps, guardReactiveProps, resolveComponent, createElementVNode, createVNode, createCommentVNode, pushScopeId, popScopeId, ref, onMounted, normalizeClass } from 'vue';
2
2
 
3
3
  /** Detect free variable `global` from Node.js. */
4
4
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
@@ -3437,6 +3437,12 @@ const backgroundDefaultProps = {
3437
3437
  left: '0px',
3438
3438
  top: '0px'
3439
3439
  };
3440
+ const musicDefaultProps = {
3441
+ musicSrc: '',
3442
+ name: '',
3443
+ isPlaying: false,
3444
+ ...commonDefaultProps
3445
+ };
3440
3446
  // this contains all default props for all the components
3441
3447
  // useful for inserting new component into the store
3442
3448
  const componentsDefaultProps = {
@@ -3451,6 +3457,9 @@ const componentsDefaultProps = {
3451
3457
  },
3452
3458
  'uni-background': {
3453
3459
  props: backgroundDefaultProps
3460
+ },
3461
+ 'uni-music': {
3462
+ props: musicDefaultProps
3454
3463
  }
3455
3464
  };
3456
3465
  const isEditingProp = {
@@ -3498,12 +3507,12 @@ const extraProps = {
3498
3507
  },
3499
3508
  ...isEditingProp
3500
3509
  };
3501
- const defaultProps$2 = transformToComponentProps(componentsDefaultProps['uni-text'].props, extraProps);
3510
+ const defaultProps$3 = transformToComponentProps(componentsDefaultProps['uni-text'].props, extraProps);
3502
3511
  // array that contains style props
3503
- var script$5 = defineComponent({
3512
+ var script$6 = defineComponent({
3504
3513
  name: 'uni-text',
3505
3514
  props: {
3506
- ...defaultProps$2
3515
+ ...defaultProps$3
3507
3516
  },
3508
3517
  setup(props) {
3509
3518
  const styleProps = useStylePick(props);
@@ -3515,7 +3524,7 @@ var script$5 = defineComponent({
3515
3524
  }
3516
3525
  });
3517
3526
 
3518
- function render$5(_ctx, _cache, $props, $setup, $data, $options) {
3527
+ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
3519
3528
  return (openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
3520
3529
  onClick: withModifiers(_ctx.handleClick, ["prevent"]),
3521
3530
  style: normalizeStyle(_ctx.styleProps),
@@ -3528,16 +3537,16 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
3528
3537
  }, 8 /* PROPS */, ["onClick", "style"]))
3529
3538
  }
3530
3539
 
3531
- script$5.render = render$5;
3532
- script$5.__scopeId = "data-v-55ed80cb";
3533
- script$5.__file = "src/components/UniText/UniText.vue";
3540
+ script$6.render = render$6;
3541
+ script$6.__scopeId = "data-v-55ed80cb";
3542
+ script$6.__file = "src/components/UniText/UniText.vue";
3534
3543
 
3535
- script$5.install = (app) => {
3536
- app.component(script$5.name, script$5);
3544
+ script$6.install = (app) => {
3545
+ app.component(script$6.name, script$6);
3537
3546
  };
3538
3547
 
3539
3548
  // array that contains style props
3540
- var script$4 = defineComponent({
3549
+ var script$5 = defineComponent({
3541
3550
  name: 'uni-image',
3542
3551
  props: transformToComponentProps(componentsDefaultProps['uni-image'].props, isEditingProp),
3543
3552
  setup(props) {
@@ -3550,32 +3559,32 @@ var script$4 = defineComponent({
3550
3559
  }
3551
3560
  });
3552
3561
 
3553
- const _hoisted_1$3 = ["src"];
3562
+ const _hoisted_1$4 = ["src"];
3554
3563
 
3555
- function render$4(_ctx, _cache, $props, $setup, $data, $options) {
3564
+ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
3556
3565
  return (openBlock(), createElementBlock("img", {
3557
3566
  src: _ctx.imageSrc,
3558
3567
  style: normalizeStyle(_ctx.styleProps),
3559
3568
  onClick: _cache[0] || (_cache[0] = withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
3560
3569
  class: "uni-image-component",
3561
3570
  draggable: false
3562
- }, null, 12 /* STYLE, PROPS */, _hoisted_1$3))
3571
+ }, null, 12 /* STYLE, PROPS */, _hoisted_1$4))
3563
3572
  }
3564
3573
 
3565
- script$4.render = render$4;
3566
- script$4.__scopeId = "data-v-03caca2f";
3567
- script$4.__file = "src/components/UniImage/UniImage.vue";
3574
+ script$5.render = render$5;
3575
+ script$5.__scopeId = "data-v-03caca2f";
3576
+ script$5.__file = "src/components/UniImage/UniImage.vue";
3568
3577
 
3569
- script$4.install = (app) => {
3570
- app.component(script$4.name, script$4);
3578
+ script$5.install = (app) => {
3579
+ app.component(script$5.name, script$5);
3571
3580
  };
3572
3581
 
3573
- const defaultProps$1 = transformToComponentProps(componentsDefaultProps['uni-shape'].props, isEditingProp);
3582
+ const defaultProps$2 = transformToComponentProps(componentsDefaultProps['uni-shape'].props, isEditingProp);
3574
3583
  // array that contains style props
3575
- var script$3 = defineComponent({
3584
+ var script$4 = defineComponent({
3576
3585
  name: 'uni-shape',
3577
3586
  props: {
3578
- ...defaultProps$1
3587
+ ...defaultProps$2
3579
3588
  },
3580
3589
  setup(props) {
3581
3590
  const styleProps = useStylePick(props);
@@ -3587,7 +3596,7 @@ var script$3 = defineComponent({
3587
3596
  }
3588
3597
  });
3589
3598
 
3590
- function render$3(_ctx, _cache, $props, $setup, $data, $options) {
3599
+ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
3591
3600
  return (openBlock(), createElementBlock("div", {
3592
3601
  onClick: _cache[0] || (_cache[0] = withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
3593
3602
  style: normalizeStyle(_ctx.styleProps),
@@ -3596,14 +3605,14 @@ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
3596
3605
  }, null, 4 /* STYLE */))
3597
3606
  }
3598
3607
 
3599
- script$3.render = render$3;
3600
- script$3.__file = "src/components/UniShape/UniShape.vue";
3608
+ script$4.render = render$4;
3609
+ script$4.__file = "src/components/UniShape/UniShape.vue";
3601
3610
 
3602
- script$3.install = (app) => {
3603
- app.component(script$3.name, script$3);
3611
+ script$4.install = (app) => {
3612
+ app.component(script$4.name, script$4);
3604
3613
  };
3605
3614
 
3606
- var script$2 = defineComponent({
3615
+ var script$3 = defineComponent({
3607
3616
  name: 'long-page',
3608
3617
  props: {
3609
3618
  work: {
@@ -3616,9 +3625,9 @@ var script$2 = defineComponent({
3616
3625
  }
3617
3626
  });
3618
3627
 
3619
- const _hoisted_1$2 = ["id"];
3628
+ const _hoisted_1$3 = ["id"];
3620
3629
 
3621
- function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3630
+ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
3622
3631
  return (openBlock(), createElementBlock("div", {
3623
3632
  class: "final-page",
3624
3633
  style: normalizeStyle(_ctx.work && {width: _ctx.work.width, height: _ctx.work.height} )
@@ -3629,20 +3638,20 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3629
3638
  id: `component-${item.id}`
3630
3639
  }, [
3631
3640
  (openBlock(), createBlock(resolveDynamicComponent(item.name), normalizeProps(guardReactiveProps(item.props)), null, 16 /* FULL_PROPS */))
3632
- ], 8 /* PROPS */, _hoisted_1$2))
3641
+ ], 8 /* PROPS */, _hoisted_1$3))
3633
3642
  }), 128 /* KEYED_FRAGMENT */))
3634
3643
  ], 4 /* STYLE */))
3635
3644
  }
3636
3645
 
3637
- script$2.render = render$2;
3638
- script$2.__file = "src/components/LongPage/LongPage.vue";
3646
+ script$3.render = render$3;
3647
+ script$3.__file = "src/components/LongPage/LongPage.vue";
3639
3648
 
3640
3649
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3641
- script$2.install = (app) => {
3642
- app.component(script$2.name, script$2);
3650
+ script$3.install = (app) => {
3651
+ app.component(script$3.name, script$3);
3643
3652
  };
3644
3653
 
3645
- var script$1 = defineComponent({
3654
+ var script$2 = defineComponent({
3646
3655
  name: 'swiper-page',
3647
3656
  props: {
3648
3657
  page: {
@@ -3655,16 +3664,16 @@ var script$1 = defineComponent({
3655
3664
  }
3656
3665
  });
3657
3666
 
3658
- const _hoisted_1$1 = { class: "swiper-wrapper" };
3667
+ const _hoisted_1$2 = { class: "swiper-wrapper" };
3659
3668
 
3660
- function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3669
+ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3661
3670
  const _component_final_page = resolveComponent("final-page");
3662
3671
 
3663
3672
  return (openBlock(), createElementBlock("div", {
3664
3673
  style: normalizeStyle(_ctx.styleProps),
3665
3674
  class: "swiper-container"
3666
3675
  }, [
3667
- createElementVNode("div", _hoisted_1$1, [
3676
+ createElementVNode("div", _hoisted_1$2, [
3668
3677
  (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.slides, (slide, index) => {
3669
3678
  return (openBlock(), createElementBlock("div", {
3670
3679
  class: "swiper-slide",
@@ -3679,24 +3688,24 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3679
3688
  ], 4 /* STYLE */))
3680
3689
  }
3681
3690
 
3682
- script$1.render = render$1;
3683
- script$1.__file = "src/components/SwiperPage/SwiperPage.vue";
3691
+ script$2.render = render$2;
3692
+ script$2.__file = "src/components/SwiperPage/SwiperPage.vue";
3684
3693
 
3685
3694
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3686
- script$1.install = (app) => {
3687
- app.component(script$1.name, script$1);
3695
+ script$2.install = (app) => {
3696
+ app.component(script$2.name, script$2);
3688
3697
  };
3689
3698
 
3690
- const defaultProps = transformToComponentProps(componentsDefaultProps['uni-background'].props, isEditingProp);
3699
+ const defaultProps$1 = transformToComponentProps(componentsDefaultProps['uni-background'].props, isEditingProp);
3691
3700
  // array that contains style props
3692
- var script = defineComponent({
3701
+ var script$1 = defineComponent({
3693
3702
  name: 'uni-background',
3694
3703
  props: {
3695
3704
  watermark: {
3696
3705
  type: Boolean,
3697
3706
  default: false
3698
3707
  },
3699
- ...defaultProps
3708
+ ...defaultProps$1
3700
3709
  },
3701
3710
  components: {},
3702
3711
  setup(props) {
@@ -3712,11 +3721,11 @@ var script = defineComponent({
3712
3721
  }
3713
3722
  });
3714
3723
 
3715
- const _withScopeId = n => (pushScopeId("data-v-04e7238d"),n=n(),popScopeId(),n);
3716
- const _hoisted_1 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/createElementVNode("div", { style: {} }, null, -1 /* HOISTED */));
3717
- const _hoisted_2 = ["src"];
3724
+ const _withScopeId$1 = n => (pushScopeId("data-v-04e7238d"),n=n(),popScopeId(),n);
3725
+ const _hoisted_1$1 = /*#__PURE__*/ _withScopeId$1(() => /*#__PURE__*/createElementVNode("div", { style: {} }, null, -1 /* HOISTED */));
3726
+ const _hoisted_2$1 = ["src"];
3718
3727
 
3719
- function render(_ctx, _cache, $props, $setup, $data, $options) {
3728
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3720
3729
  const _component_a_watermark = resolveComponent("a-watermark");
3721
3730
 
3722
3731
  return (openBlock(), createElementBlock("div", {
@@ -3730,7 +3739,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
3730
3739
  class: "watermark"
3731
3740
  }, {
3732
3741
  default: withCtx(() => [
3733
- _hoisted_1
3742
+ _hoisted_1$1
3734
3743
  ]),
3735
3744
  _: 1 /* STABLE */
3736
3745
  }))
@@ -3740,14 +3749,126 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
3740
3749
  key: 1,
3741
3750
  src: _ctx.backgroundImage,
3742
3751
  class: "bg-img"
3743
- }, null, 8 /* PROPS */, _hoisted_2))
3752
+ }, null, 8 /* PROPS */, _hoisted_2$1))
3744
3753
  : createCommentVNode("v-if", true)
3745
3754
  ], 4 /* STYLE */))
3746
3755
  }
3747
3756
 
3757
+ script$1.render = render$1;
3758
+ script$1.__scopeId = "data-v-04e7238d";
3759
+ script$1.__file = "src/components/UniBackground/UniBackground.vue";
3760
+
3761
+ script$1.install = (app) => {
3762
+ app.component(script$1.name, script$1);
3763
+ };
3764
+
3765
+ const defaultProps = transformToComponentProps(componentsDefaultProps['uni-music'].props, isEditingProp);
3766
+ // array that contains style props
3767
+ var script = defineComponent({
3768
+ name: 'uni-music',
3769
+ props: {
3770
+ ...defaultProps
3771
+ },
3772
+ setup(props) {
3773
+ // 重用并且简化
3774
+ // 抽离并且获得 styleProps
3775
+ const styleProps = useStylePick(props);
3776
+ const handleClick = useComponentClick(props);
3777
+ const isPlaying = ref(false);
3778
+ const audioPlayer = ref(null);
3779
+ const togglePlay = () => {
3780
+ if (!audioPlayer.value)
3781
+ return;
3782
+ isPlaying.value = !isPlaying.value;
3783
+ if (isPlaying.value) {
3784
+ audioPlayer.value && audioPlayer.value.play();
3785
+ }
3786
+ else {
3787
+ audioPlayer.value && audioPlayer.value.pause();
3788
+ }
3789
+ };
3790
+ onMounted(() => {
3791
+ audioPlayer.value = document.querySelector('audio');
3792
+ if (audioPlayer.value && props.isPlaying) {
3793
+ audioPlayer.value.load();
3794
+ audioPlayer.value.play().catch(() => {
3795
+ const playError = ref(true);
3796
+ const event = ['click']; // "touchstart"
3797
+ const pageClick = () => {
3798
+ if (audioPlayer.value && playError.value) {
3799
+ playError.value = false;
3800
+ audioPlayer.value.load();
3801
+ audioPlayer.value.play().catch(() => {
3802
+ playError.value = true;
3803
+ });
3804
+ event.forEach((item) => {
3805
+ document.removeEventListener(item, pageClick);
3806
+ });
3807
+ }
3808
+ };
3809
+ event.forEach((item) => {
3810
+ document.addEventListener(item, pageClick);
3811
+ });
3812
+ });
3813
+ }
3814
+ });
3815
+ return {
3816
+ styleProps,
3817
+ handleClick,
3818
+ isPlaying,
3819
+ togglePlay
3820
+ };
3821
+ }
3822
+ });
3823
+
3824
+ const _withScopeId = n => (pushScopeId("data-v-99922522"),n=n(),popScopeId(),n);
3825
+ const _hoisted_1 = {
3826
+ id: "audio",
3827
+ class: "uni-music-component"
3828
+ };
3829
+ const _hoisted_2 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/createElementVNode("img", {
3830
+ src: "https://unika-static-dev.oss-ap-southeast-7.aliyuncs.com/components/music2.png",
3831
+ class: "music-icon"
3832
+ }, null, -1 /* HOISTED */));
3833
+ const _hoisted_3 = { class: "icon-cancel" };
3834
+ const _hoisted_4 = {
3835
+ key: 0,
3836
+ class: "icon-h"
3837
+ };
3838
+ const _hoisted_5 = ["src"];
3839
+
3840
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
3841
+ return (openBlock(), createElementBlock("div", {
3842
+ style: normalizeStyle(_ctx.styleProps)
3843
+ }, [
3844
+ createElementVNode("div", _hoisted_1, [
3845
+ createElementVNode("div", {
3846
+ class: normalizeClass({ mrotate: _ctx.isPlaying, audio: true }),
3847
+ onClick: _cache[0] || (_cache[0] = (...args) => (_ctx.togglePlay && _ctx.togglePlay(...args)))
3848
+ }, [
3849
+ _hoisted_2,
3850
+ createElementVNode("div", _hoisted_3, [
3851
+ (!_ctx.isPlaying)
3852
+ ? (openBlock(), createElementBlock("div", _hoisted_4))
3853
+ : createCommentVNode("v-if", true)
3854
+ ])
3855
+ ], 2 /* CLASS */),
3856
+ createElementVNode("audio", {
3857
+ style: {"display":"none"},
3858
+ ref: "audioPlayer",
3859
+ src: _ctx.musicSrc,
3860
+ autoplay: "",
3861
+ controls: "",
3862
+ loop: "",
3863
+ preload: "auto"
3864
+ }, null, 8 /* PROPS */, _hoisted_5)
3865
+ ])
3866
+ ], 4 /* STYLE */))
3867
+ }
3868
+
3748
3869
  script.render = render;
3749
- script.__scopeId = "data-v-04e7238d";
3750
- script.__file = "src/components/UniBackground/UniBackground.vue";
3870
+ script.__scopeId = "data-v-99922522";
3871
+ script.__file = "src/components/UniMusic/UniMusic.vue";
3751
3872
 
3752
3873
  script.install = (app) => {
3753
3874
  app.component(script.name, script);
@@ -3755,12 +3876,13 @@ script.install = (app) => {
3755
3876
 
3756
3877
  // export { textDefaultProps , textStylePropNames, TextComponentProps,
3757
3878
  const components = [
3879
+ script$6,
3758
3880
  script$5,
3759
3881
  script$4,
3760
3882
  script$3,
3761
3883
  script$2,
3762
3884
  script$1,
3763
- script
3885
+ script,
3764
3886
  ];
3765
3887
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
3766
3888
  const install = (app) => {
@@ -3772,4 +3894,4 @@ var index = {
3772
3894
  install
3773
3895
  };
3774
3896
 
3775
- export { script$2 as LongPage, script$1 as SwiperPage, script as UniBackground, script$4 as UniImage, script$3 as UniShape, script$5 as UniText, index as default, install };
3897
+ export { script$3 as LongPage, script$2 as SwiperPage, script$1 as UniBackground, script$5 as UniImage, script as UniMusic, script$4 as UniShape, script$6 as UniText, index as default, install };
@@ -3441,6 +3441,12 @@
3441
3441
  left: '0px',
3442
3442
  top: '0px'
3443
3443
  };
3444
+ const musicDefaultProps = {
3445
+ musicSrc: '',
3446
+ name: '',
3447
+ isPlaying: false,
3448
+ ...commonDefaultProps
3449
+ };
3444
3450
  // this contains all default props for all the components
3445
3451
  // useful for inserting new component into the store
3446
3452
  const componentsDefaultProps = {
@@ -3455,6 +3461,9 @@
3455
3461
  },
3456
3462
  'uni-background': {
3457
3463
  props: backgroundDefaultProps
3464
+ },
3465
+ 'uni-music': {
3466
+ props: musicDefaultProps
3458
3467
  }
3459
3468
  };
3460
3469
  const isEditingProp = {
@@ -3502,12 +3511,12 @@
3502
3511
  },
3503
3512
  ...isEditingProp
3504
3513
  };
3505
- const defaultProps$2 = transformToComponentProps(componentsDefaultProps['uni-text'].props, extraProps);
3514
+ const defaultProps$3 = transformToComponentProps(componentsDefaultProps['uni-text'].props, extraProps);
3506
3515
  // array that contains style props
3507
- var script$5 = vue.defineComponent({
3516
+ var script$6 = vue.defineComponent({
3508
3517
  name: 'uni-text',
3509
3518
  props: {
3510
- ...defaultProps$2
3519
+ ...defaultProps$3
3511
3520
  },
3512
3521
  setup(props) {
3513
3522
  const styleProps = useStylePick(props);
@@ -3519,7 +3528,7 @@
3519
3528
  }
3520
3529
  });
3521
3530
 
3522
- function render$5(_ctx, _cache, $props, $setup, $data, $options) {
3531
+ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
3523
3532
  return (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.tag), {
3524
3533
  onClick: vue.withModifiers(_ctx.handleClick, ["prevent"]),
3525
3534
  style: vue.normalizeStyle(_ctx.styleProps),
@@ -3532,16 +3541,16 @@
3532
3541
  }, 8 /* PROPS */, ["onClick", "style"]))
3533
3542
  }
3534
3543
 
3535
- script$5.render = render$5;
3536
- script$5.__scopeId = "data-v-55ed80cb";
3537
- script$5.__file = "src/components/UniText/UniText.vue";
3544
+ script$6.render = render$6;
3545
+ script$6.__scopeId = "data-v-55ed80cb";
3546
+ script$6.__file = "src/components/UniText/UniText.vue";
3538
3547
 
3539
- script$5.install = (app) => {
3540
- app.component(script$5.name, script$5);
3548
+ script$6.install = (app) => {
3549
+ app.component(script$6.name, script$6);
3541
3550
  };
3542
3551
 
3543
3552
  // array that contains style props
3544
- var script$4 = vue.defineComponent({
3553
+ var script$5 = vue.defineComponent({
3545
3554
  name: 'uni-image',
3546
3555
  props: transformToComponentProps(componentsDefaultProps['uni-image'].props, isEditingProp),
3547
3556
  setup(props) {
@@ -3554,32 +3563,32 @@
3554
3563
  }
3555
3564
  });
3556
3565
 
3557
- const _hoisted_1$3 = ["src"];
3566
+ const _hoisted_1$4 = ["src"];
3558
3567
 
3559
- function render$4(_ctx, _cache, $props, $setup, $data, $options) {
3568
+ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
3560
3569
  return (vue.openBlock(), vue.createElementBlock("img", {
3561
3570
  src: _ctx.imageSrc,
3562
3571
  style: vue.normalizeStyle(_ctx.styleProps),
3563
3572
  onClick: _cache[0] || (_cache[0] = vue.withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
3564
3573
  class: "uni-image-component",
3565
3574
  draggable: false
3566
- }, null, 12 /* STYLE, PROPS */, _hoisted_1$3))
3575
+ }, null, 12 /* STYLE, PROPS */, _hoisted_1$4))
3567
3576
  }
3568
3577
 
3569
- script$4.render = render$4;
3570
- script$4.__scopeId = "data-v-03caca2f";
3571
- script$4.__file = "src/components/UniImage/UniImage.vue";
3578
+ script$5.render = render$5;
3579
+ script$5.__scopeId = "data-v-03caca2f";
3580
+ script$5.__file = "src/components/UniImage/UniImage.vue";
3572
3581
 
3573
- script$4.install = (app) => {
3574
- app.component(script$4.name, script$4);
3582
+ script$5.install = (app) => {
3583
+ app.component(script$5.name, script$5);
3575
3584
  };
3576
3585
 
3577
- const defaultProps$1 = transformToComponentProps(componentsDefaultProps['uni-shape'].props, isEditingProp);
3586
+ const defaultProps$2 = transformToComponentProps(componentsDefaultProps['uni-shape'].props, isEditingProp);
3578
3587
  // array that contains style props
3579
- var script$3 = vue.defineComponent({
3588
+ var script$4 = vue.defineComponent({
3580
3589
  name: 'uni-shape',
3581
3590
  props: {
3582
- ...defaultProps$1
3591
+ ...defaultProps$2
3583
3592
  },
3584
3593
  setup(props) {
3585
3594
  const styleProps = useStylePick(props);
@@ -3591,7 +3600,7 @@
3591
3600
  }
3592
3601
  });
3593
3602
 
3594
- function render$3(_ctx, _cache, $props, $setup, $data, $options) {
3603
+ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
3595
3604
  return (vue.openBlock(), vue.createElementBlock("div", {
3596
3605
  onClick: _cache[0] || (_cache[0] = vue.withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
3597
3606
  style: vue.normalizeStyle(_ctx.styleProps),
@@ -3600,14 +3609,14 @@
3600
3609
  }, null, 4 /* STYLE */))
3601
3610
  }
3602
3611
 
3603
- script$3.render = render$3;
3604
- script$3.__file = "src/components/UniShape/UniShape.vue";
3612
+ script$4.render = render$4;
3613
+ script$4.__file = "src/components/UniShape/UniShape.vue";
3605
3614
 
3606
- script$3.install = (app) => {
3607
- app.component(script$3.name, script$3);
3615
+ script$4.install = (app) => {
3616
+ app.component(script$4.name, script$4);
3608
3617
  };
3609
3618
 
3610
- var script$2 = vue.defineComponent({
3619
+ var script$3 = vue.defineComponent({
3611
3620
  name: 'long-page',
3612
3621
  props: {
3613
3622
  work: {
@@ -3620,9 +3629,9 @@
3620
3629
  }
3621
3630
  });
3622
3631
 
3623
- const _hoisted_1$2 = ["id"];
3632
+ const _hoisted_1$3 = ["id"];
3624
3633
 
3625
- function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3634
+ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
3626
3635
  return (vue.openBlock(), vue.createElementBlock("div", {
3627
3636
  class: "final-page",
3628
3637
  style: vue.normalizeStyle(_ctx.work && {width: _ctx.work.width, height: _ctx.work.height} )
@@ -3633,20 +3642,20 @@
3633
3642
  id: `component-${item.id}`
3634
3643
  }, [
3635
3644
  (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(item.name), vue.normalizeProps(vue.guardReactiveProps(item.props)), null, 16 /* FULL_PROPS */))
3636
- ], 8 /* PROPS */, _hoisted_1$2))
3645
+ ], 8 /* PROPS */, _hoisted_1$3))
3637
3646
  }), 128 /* KEYED_FRAGMENT */))
3638
3647
  ], 4 /* STYLE */))
3639
3648
  }
3640
3649
 
3641
- script$2.render = render$2;
3642
- script$2.__file = "src/components/LongPage/LongPage.vue";
3650
+ script$3.render = render$3;
3651
+ script$3.__file = "src/components/LongPage/LongPage.vue";
3643
3652
 
3644
3653
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3645
- script$2.install = (app) => {
3646
- app.component(script$2.name, script$2);
3654
+ script$3.install = (app) => {
3655
+ app.component(script$3.name, script$3);
3647
3656
  };
3648
3657
 
3649
- var script$1 = vue.defineComponent({
3658
+ var script$2 = vue.defineComponent({
3650
3659
  name: 'swiper-page',
3651
3660
  props: {
3652
3661
  page: {
@@ -3659,16 +3668,16 @@
3659
3668
  }
3660
3669
  });
3661
3670
 
3662
- const _hoisted_1$1 = { class: "swiper-wrapper" };
3671
+ const _hoisted_1$2 = { class: "swiper-wrapper" };
3663
3672
 
3664
- function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3673
+ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3665
3674
  const _component_final_page = vue.resolveComponent("final-page");
3666
3675
 
3667
3676
  return (vue.openBlock(), vue.createElementBlock("div", {
3668
3677
  style: vue.normalizeStyle(_ctx.styleProps),
3669
3678
  class: "swiper-container"
3670
3679
  }, [
3671
- vue.createElementVNode("div", _hoisted_1$1, [
3680
+ vue.createElementVNode("div", _hoisted_1$2, [
3672
3681
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.slides, (slide, index) => {
3673
3682
  return (vue.openBlock(), vue.createElementBlock("div", {
3674
3683
  class: "swiper-slide",
@@ -3683,24 +3692,24 @@
3683
3692
  ], 4 /* STYLE */))
3684
3693
  }
3685
3694
 
3686
- script$1.render = render$1;
3687
- script$1.__file = "src/components/SwiperPage/SwiperPage.vue";
3695
+ script$2.render = render$2;
3696
+ script$2.__file = "src/components/SwiperPage/SwiperPage.vue";
3688
3697
 
3689
3698
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3690
- script$1.install = (app) => {
3691
- app.component(script$1.name, script$1);
3699
+ script$2.install = (app) => {
3700
+ app.component(script$2.name, script$2);
3692
3701
  };
3693
3702
 
3694
- const defaultProps = transformToComponentProps(componentsDefaultProps['uni-background'].props, isEditingProp);
3703
+ const defaultProps$1 = transformToComponentProps(componentsDefaultProps['uni-background'].props, isEditingProp);
3695
3704
  // array that contains style props
3696
- var script = vue.defineComponent({
3705
+ var script$1 = vue.defineComponent({
3697
3706
  name: 'uni-background',
3698
3707
  props: {
3699
3708
  watermark: {
3700
3709
  type: Boolean,
3701
3710
  default: false
3702
3711
  },
3703
- ...defaultProps
3712
+ ...defaultProps$1
3704
3713
  },
3705
3714
  components: {},
3706
3715
  setup(props) {
@@ -3716,11 +3725,11 @@
3716
3725
  }
3717
3726
  });
3718
3727
 
3719
- const _withScopeId = n => (vue.pushScopeId("data-v-04e7238d"),n=n(),vue.popScopeId(),n);
3720
- const _hoisted_1 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/vue.createElementVNode("div", { style: {} }, null, -1 /* HOISTED */));
3721
- const _hoisted_2 = ["src"];
3728
+ const _withScopeId$1 = n => (vue.pushScopeId("data-v-04e7238d"),n=n(),vue.popScopeId(),n);
3729
+ const _hoisted_1$1 = /*#__PURE__*/ _withScopeId$1(() => /*#__PURE__*/vue.createElementVNode("div", { style: {} }, null, -1 /* HOISTED */));
3730
+ const _hoisted_2$1 = ["src"];
3722
3731
 
3723
- function render(_ctx, _cache, $props, $setup, $data, $options) {
3732
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3724
3733
  const _component_a_watermark = vue.resolveComponent("a-watermark");
3725
3734
 
3726
3735
  return (vue.openBlock(), vue.createElementBlock("div", {
@@ -3734,7 +3743,7 @@
3734
3743
  class: "watermark"
3735
3744
  }, {
3736
3745
  default: vue.withCtx(() => [
3737
- _hoisted_1
3746
+ _hoisted_1$1
3738
3747
  ]),
3739
3748
  _: 1 /* STABLE */
3740
3749
  }))
@@ -3744,14 +3753,126 @@
3744
3753
  key: 1,
3745
3754
  src: _ctx.backgroundImage,
3746
3755
  class: "bg-img"
3747
- }, null, 8 /* PROPS */, _hoisted_2))
3756
+ }, null, 8 /* PROPS */, _hoisted_2$1))
3748
3757
  : vue.createCommentVNode("v-if", true)
3749
3758
  ], 4 /* STYLE */))
3750
3759
  }
3751
3760
 
3761
+ script$1.render = render$1;
3762
+ script$1.__scopeId = "data-v-04e7238d";
3763
+ script$1.__file = "src/components/UniBackground/UniBackground.vue";
3764
+
3765
+ script$1.install = (app) => {
3766
+ app.component(script$1.name, script$1);
3767
+ };
3768
+
3769
+ const defaultProps = transformToComponentProps(componentsDefaultProps['uni-music'].props, isEditingProp);
3770
+ // array that contains style props
3771
+ var script = vue.defineComponent({
3772
+ name: 'uni-music',
3773
+ props: {
3774
+ ...defaultProps
3775
+ },
3776
+ setup(props) {
3777
+ // 重用并且简化
3778
+ // 抽离并且获得 styleProps
3779
+ const styleProps = useStylePick(props);
3780
+ const handleClick = useComponentClick(props);
3781
+ const isPlaying = vue.ref(false);
3782
+ const audioPlayer = vue.ref(null);
3783
+ const togglePlay = () => {
3784
+ if (!audioPlayer.value)
3785
+ return;
3786
+ isPlaying.value = !isPlaying.value;
3787
+ if (isPlaying.value) {
3788
+ audioPlayer.value && audioPlayer.value.play();
3789
+ }
3790
+ else {
3791
+ audioPlayer.value && audioPlayer.value.pause();
3792
+ }
3793
+ };
3794
+ vue.onMounted(() => {
3795
+ audioPlayer.value = document.querySelector('audio');
3796
+ if (audioPlayer.value && props.isPlaying) {
3797
+ audioPlayer.value.load();
3798
+ audioPlayer.value.play().catch(() => {
3799
+ const playError = vue.ref(true);
3800
+ const event = ['click']; // "touchstart"
3801
+ const pageClick = () => {
3802
+ if (audioPlayer.value && playError.value) {
3803
+ playError.value = false;
3804
+ audioPlayer.value.load();
3805
+ audioPlayer.value.play().catch(() => {
3806
+ playError.value = true;
3807
+ });
3808
+ event.forEach((item) => {
3809
+ document.removeEventListener(item, pageClick);
3810
+ });
3811
+ }
3812
+ };
3813
+ event.forEach((item) => {
3814
+ document.addEventListener(item, pageClick);
3815
+ });
3816
+ });
3817
+ }
3818
+ });
3819
+ return {
3820
+ styleProps,
3821
+ handleClick,
3822
+ isPlaying,
3823
+ togglePlay
3824
+ };
3825
+ }
3826
+ });
3827
+
3828
+ const _withScopeId = n => (vue.pushScopeId("data-v-99922522"),n=n(),vue.popScopeId(),n);
3829
+ const _hoisted_1 = {
3830
+ id: "audio",
3831
+ class: "uni-music-component"
3832
+ };
3833
+ const _hoisted_2 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/vue.createElementVNode("img", {
3834
+ src: "https://unika-static-dev.oss-ap-southeast-7.aliyuncs.com/components/music2.png",
3835
+ class: "music-icon"
3836
+ }, null, -1 /* HOISTED */));
3837
+ const _hoisted_3 = { class: "icon-cancel" };
3838
+ const _hoisted_4 = {
3839
+ key: 0,
3840
+ class: "icon-h"
3841
+ };
3842
+ const _hoisted_5 = ["src"];
3843
+
3844
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
3845
+ return (vue.openBlock(), vue.createElementBlock("div", {
3846
+ style: vue.normalizeStyle(_ctx.styleProps)
3847
+ }, [
3848
+ vue.createElementVNode("div", _hoisted_1, [
3849
+ vue.createElementVNode("div", {
3850
+ class: vue.normalizeClass({ mrotate: _ctx.isPlaying, audio: true }),
3851
+ onClick: _cache[0] || (_cache[0] = (...args) => (_ctx.togglePlay && _ctx.togglePlay(...args)))
3852
+ }, [
3853
+ _hoisted_2,
3854
+ vue.createElementVNode("div", _hoisted_3, [
3855
+ (!_ctx.isPlaying)
3856
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4))
3857
+ : vue.createCommentVNode("v-if", true)
3858
+ ])
3859
+ ], 2 /* CLASS */),
3860
+ vue.createElementVNode("audio", {
3861
+ style: {"display":"none"},
3862
+ ref: "audioPlayer",
3863
+ src: _ctx.musicSrc,
3864
+ autoplay: "",
3865
+ controls: "",
3866
+ loop: "",
3867
+ preload: "auto"
3868
+ }, null, 8 /* PROPS */, _hoisted_5)
3869
+ ])
3870
+ ], 4 /* STYLE */))
3871
+ }
3872
+
3752
3873
  script.render = render;
3753
- script.__scopeId = "data-v-04e7238d";
3754
- script.__file = "src/components/UniBackground/UniBackground.vue";
3874
+ script.__scopeId = "data-v-99922522";
3875
+ script.__file = "src/components/UniMusic/UniMusic.vue";
3755
3876
 
3756
3877
  script.install = (app) => {
3757
3878
  app.component(script.name, script);
@@ -3759,12 +3880,13 @@
3759
3880
 
3760
3881
  // export { textDefaultProps , textStylePropNames, TextComponentProps,
3761
3882
  const components = [
3883
+ script$6,
3762
3884
  script$5,
3763
3885
  script$4,
3764
3886
  script$3,
3765
3887
  script$2,
3766
3888
  script$1,
3767
- script
3889
+ script,
3768
3890
  ];
3769
3891
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
3770
3892
  const install = (app) => {
@@ -3776,12 +3898,13 @@
3776
3898
  install
3777
3899
  };
3778
3900
 
3779
- exports.LongPage = script$2;
3780
- exports.SwiperPage = script$1;
3781
- exports.UniBackground = script;
3782
- exports.UniImage = script$4;
3783
- exports.UniShape = script$3;
3784
- exports.UniText = script$5;
3901
+ exports.LongPage = script$3;
3902
+ exports.SwiperPage = script$2;
3903
+ exports.UniBackground = script$1;
3904
+ exports.UniImage = script$5;
3905
+ exports.UniMusic = script;
3906
+ exports.UniShape = script$4;
3907
+ exports.UniText = script$6;
3785
3908
  exports["default"] = index;
3786
3909
  exports.install = install;
3787
3910
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unika-components",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "private": false,
5
5
  "main": "dist/unika-components.umd.js",
6
6
  "module": "dist/unika-components.esm.js",