@cloudbase/weda-ui 0.2.5 → 0.2.8

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.
Files changed (150) hide show
  1. package/package.json +4 -4
  2. package/src/.DS_Store +0 -0
  3. package/src/configs/components/container.json +2 -1
  4. package/src/configs/components/form/input.json +6 -0
  5. package/src/configs/components/form/richText.json +2 -1
  6. package/src/configs/components/form/uploader.json +10 -5
  7. package/src/configs/components/image.json +2 -1
  8. package/src/configs/components/link.json +2 -1
  9. package/src/configs/components/richtextview.json +2 -1
  10. package/src/configs/components/scrollVeiw.json +2 -1
  11. package/src/configs/components/swiper.json +2 -1
  12. package/src/configs/components/tabs.json +31 -86
  13. package/src/configs/components/text.json +2 -1
  14. package/src/configs/index.js +3 -5
  15. package/src/index.js +2 -3
  16. package/src/mp/components/form/input/index.js +5 -1
  17. package/src/mp/components/form/input/index.wxml +2 -1
  18. package/src/mp/components/form/select/index.js +2 -2
  19. package/src/mp/components/form/textarea/index.wxml +1 -0
  20. package/src/mp/components/form/uploader/index.js +50 -13
  21. package/src/mp/components/form/uploader/index.wxml +11 -1
  22. package/src/mp/components/image/index.js +57 -8
  23. package/src/mp/components/image/index.json +4 -1
  24. package/src/mp/components/image/index.wxml +4 -2
  25. package/src/mp/components/image/index.wxss +15 -0
  26. package/src/mp/components/richText/index.wxml +3 -1
  27. package/src/mp/components/tabs/index.js +22 -6
  28. package/src/mp/utils/deepEqual.js +42 -0
  29. package/src/web/actions/index.js +2 -4
  30. package/src/web/components/form/checkbox/index.jsx +8 -10
  31. package/src/web/components/form/formcell/index.jsx +1 -1
  32. package/src/web/components/form/input/index.jsx +16 -18
  33. package/src/web/components/form/radio/index.jsx +7 -7
  34. package/src/web/components/form/select/h5.jsx +1 -1
  35. package/src/web/components/form/select/region/{cities.json → cities.js} +2 -2
  36. package/src/web/components/form/select/region/index.js +3 -3
  37. package/src/web/components/form/select/region/{provinces.json → provinces.js} +2 -2
  38. package/src/web/components/form/select/region/{regions.json → regions.js} +2 -2
  39. package/src/web/components/form/switch/index.jsx +4 -9
  40. package/src/web/components/form/textarea/index.jsx +4 -12
  41. package/src/web/components/form/uploader/index.css +15 -0
  42. package/src/web/components/form/uploader/index.jsx +2 -2
  43. package/src/web/components/form/uploader/uploader.h5.jsx +237 -0
  44. package/src/web/components/form/uploader/{uploaderPc.jsx → uploader.pc.jsx} +76 -58
  45. package/src/web/components/image/image.jsx +79 -5
  46. package/src/web/components/image/index.css +18 -0
  47. package/src/web/components/image/index.jsx +1 -0
  48. package/src/web/components/index.js +26 -58
  49. package/src/web/components/richTextView/index.css +0 -10
  50. package/src/web/components/richTextView/index.jsx +1 -12
  51. package/src/web/components/tabs/{index.js → index.jsx} +3 -3
  52. package/src/web/components/tabs/{tabsH5.js → tabs.h5.jsx} +9 -47
  53. package/src/web/components/tabs/{tabsPc.js → tabs.pc.jsx} +13 -47
  54. package/src/web/components/uploaderView/index.jsx +1 -1
  55. package/src/web/index.js +2 -3
  56. package/src/web/utils/isObjectEqual.js +10 -1
  57. package/src/web/utils/useSyncValue.js +14 -0
  58. package/src/web/weda-ui.css +8 -0
  59. package/src/configs/components/markdown.json +0 -17
  60. package/src/mp/components/markdown/index.js +0 -27
  61. package/src/mp/components/markdown/index.json +0 -6
  62. package/src/mp/components/markdown/index.wxml +0 -1
  63. package/src/mp/components/markdown/towxml/audio-player/Audio.js +0 -99
  64. package/src/mp/components/markdown/towxml/audio-player/audio-player.js +0 -102
  65. package/src/mp/components/markdown/towxml/audio-player/audio-player.json +0 -5
  66. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxml +0 -14
  67. package/src/mp/components/markdown/towxml/audio-player/audio-player.wxss +0 -175
  68. package/src/mp/components/markdown/towxml/audio-player/loading.svg +0 -1
  69. package/src/mp/components/markdown/towxml/config.js +0 -285
  70. package/src/mp/components/markdown/towxml/decode.js +0 -26
  71. package/src/mp/components/markdown/towxml/decode.json +0 -12
  72. package/src/mp/components/markdown/towxml/decode.wxml +0 -1
  73. package/src/mp/components/markdown/towxml/decode.wxss +0 -0
  74. package/src/mp/components/markdown/towxml/img/img.js +0 -98
  75. package/src/mp/components/markdown/towxml/img/img.json +0 -3
  76. package/src/mp/components/markdown/towxml/img/img.wxml +0 -1
  77. package/src/mp/components/markdown/towxml/img/img.wxss +0 -0
  78. package/src/mp/components/markdown/towxml/index.js +0 -19
  79. package/src/mp/components/markdown/towxml/latex/latex.js +0 -53
  80. package/src/mp/components/markdown/towxml/latex/latex.json +0 -5
  81. package/src/mp/components/markdown/towxml/latex/latex.wxml +0 -1
  82. package/src/mp/components/markdown/towxml/latex/latex.wxss +0 -0
  83. package/src/mp/components/markdown/towxml/parse/highlight/highlight.js +0 -729
  84. package/src/mp/components/markdown/towxml/parse/highlight/index.js +0 -7
  85. package/src/mp/components/markdown/towxml/parse/highlight/languages/bash.js +0 -91
  86. package/src/mp/components/markdown/towxml/parse/highlight/languages/c-like.js +0 -244
  87. package/src/mp/components/markdown/towxml/parse/highlight/languages/c.js +0 -20
  88. package/src/mp/components/markdown/towxml/parse/highlight/languages/css.js +0 -138
  89. package/src/mp/components/markdown/towxml/parse/highlight/languages/dart.js +0 -135
  90. package/src/mp/components/markdown/towxml/parse/highlight/languages/go.js +0 -57
  91. package/src/mp/components/markdown/towxml/parse/highlight/languages/htmlbars.js +0 -79
  92. package/src/mp/components/markdown/towxml/parse/highlight/languages/java.js +0 -126
  93. package/src/mp/components/markdown/towxml/parse/highlight/languages/javascript.js +0 -263
  94. package/src/mp/components/markdown/towxml/parse/highlight/languages/json.js +0 -51
  95. package/src/mp/components/markdown/towxml/parse/highlight/languages/less.js +0 -177
  96. package/src/mp/components/markdown/towxml/parse/highlight/languages/nginx.js +0 -103
  97. package/src/mp/components/markdown/towxml/parse/highlight/languages/php.js +0 -152
  98. package/src/mp/components/markdown/towxml/parse/highlight/languages/python-repl.js +0 -27
  99. package/src/mp/components/markdown/towxml/parse/highlight/languages/python.js +0 -146
  100. package/src/mp/components/markdown/towxml/parse/highlight/languages/scss.js +0 -137
  101. package/src/mp/components/markdown/towxml/parse/highlight/languages/shell.js +0 -23
  102. package/src/mp/components/markdown/towxml/parse/highlight/languages/typescript.js +0 -198
  103. package/src/mp/components/markdown/towxml/parse/highlight/languages/xml.js +0 -143
  104. package/src/mp/components/markdown/towxml/parse/highlight/style/github.wxss +0 -99
  105. package/src/mp/components/markdown/towxml/parse/highlight/style/monokai.wxss +0 -70
  106. package/src/mp/components/markdown/towxml/parse/index.js +0 -106
  107. package/src/mp/components/markdown/towxml/parse/markdown/index.js +0 -53
  108. package/src/mp/components/markdown/towxml/parse/markdown/markdown.js +0 -5834
  109. package/src/mp/components/markdown/towxml/parse/markdown/plugins/emoji.js +0 -1773
  110. package/src/mp/components/markdown/towxml/parse/markdown/plugins/ins.js +0 -120
  111. package/src/mp/components/markdown/towxml/parse/markdown/plugins/latex.js +0 -193
  112. package/src/mp/components/markdown/towxml/parse/markdown/plugins/mark.js +0 -120
  113. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sub.js +0 -95
  114. package/src/mp/components/markdown/towxml/parse/markdown/plugins/sup.js +0 -95
  115. package/src/mp/components/markdown/towxml/parse/markdown/plugins/todo.js +0 -220
  116. package/src/mp/components/markdown/towxml/parse/markdown/plugins/yuml.js +0 -18
  117. package/src/mp/components/markdown/towxml/parse/parse2/Parser.js +0 -263
  118. package/src/mp/components/markdown/towxml/parse/parse2/Tokenizer.js +0 -507
  119. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/index.js +0 -104
  120. package/src/mp/components/markdown/towxml/parse/parse2/domhandler/node.js +0 -169
  121. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode.js +0 -54
  122. package/src/mp/components/markdown/towxml/parse/parse2/entities/decode_codepoint.js +0 -19
  123. package/src/mp/components/markdown/towxml/parse/parse2/entities/encode.js +0 -54
  124. package/src/mp/components/markdown/towxml/parse/parse2/entities/index.js +0 -30
  125. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/decode.js +0 -31
  126. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/entities.js +0 -2128
  127. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/legacy.js +0 -109
  128. package/src/mp/components/markdown/towxml/parse/parse2/entities/maps/xml.js +0 -2
  129. package/src/mp/components/markdown/towxml/parse/parse2/index.js +0 -8
  130. package/src/mp/components/markdown/towxml/style/main.wxss +0 -378
  131. package/src/mp/components/markdown/towxml/style/theme/dark.wxss +0 -73
  132. package/src/mp/components/markdown/towxml/style/theme/light.wxss +0 -63
  133. package/src/mp/components/markdown/towxml/table/table.js +0 -11
  134. package/src/mp/components/markdown/towxml/table/table.json +0 -6
  135. package/src/mp/components/markdown/towxml/table/table.wxml +0 -24
  136. package/src/mp/components/markdown/towxml/table/table.wxss +0 -0
  137. package/src/mp/components/markdown/towxml/todogroup/todogroup.js +0 -19
  138. package/src/mp/components/markdown/towxml/todogroup/todogroup.json +0 -6
  139. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxml +0 -13
  140. package/src/mp/components/markdown/towxml/todogroup/todogroup.wxss +0 -3
  141. package/src/mp/components/markdown/towxml/towxml.js +0 -17
  142. package/src/mp/components/markdown/towxml/towxml.json +0 -6
  143. package/src/mp/components/markdown/towxml/towxml.wxml +0 -5
  144. package/src/mp/components/markdown/towxml/towxml.wxss +0 -8
  145. package/src/mp/components/markdown/towxml/yuml/yuml.js +0 -51
  146. package/src/mp/components/markdown/towxml/yuml/yuml.json +0 -5
  147. package/src/mp/components/markdown/towxml/yuml/yuml.wxml +0 -5
  148. package/src/mp/components/markdown/towxml/yuml/yuml.wxss +0 -0
  149. package/src/web/components/form/uploader/uploaderH5.jsx +0 -192
  150. package/src/web/components/markdown/index.jsx +0 -40
@@ -1,67 +1,35 @@
1
1
  import '../wedatheme/style-package/index.css';
2
2
 
3
- import Button from './button';
4
- import Markdown from './markdown';
5
- import Text from './text';
6
- import Container from './container';
7
- import Image from './image';
8
- import Slot from './slot';
9
- import ScrollView from './scrollView';
10
- import Swiper from './swiper';
11
- import Modal from './modal';
12
- import RichText from './richText';
13
- import RichTextView from './richTextView';
14
- import Link from './link';
15
- import Drawer from './drawer';
16
- import UploaderView from './uploaderView';
3
+ export { default as Button } from './button';
4
+ export { default as Text } from './text';
5
+ export { default as Container } from './container';
6
+ export { default as Image } from './image';
7
+ export { default as Slot } from './slot';
8
+ export { default as ScrollView } from './scrollView';
9
+ export { default as Swiper } from './swiper';
10
+ export { default as Modal } from './modal';
11
+ export { default as RichText } from './richText';
12
+ export { default as RichTextView } from './richTextView';
13
+ export { default as Link } from './link';
14
+ export { default as Drawer } from './drawer';
15
+ export { default as UploaderView } from './uploaderView';
17
16
  // picker
18
- import Picker from './picker/picker';
19
- import DatePicker from './picker/datePicker';
20
- import TimePicker from './picker/timePicker';
17
+ export { default as Picker } from './picker/picker';
18
+ export { default as DatePicker } from './picker/datePicker';
19
+ export { default as TimePicker } from './picker/timePicker';
21
20
  // form
22
- import Form from './form/form';
23
- import Input from './form/input';
24
- import Textarea from './form/textarea';
25
- import Checkbox from './form/checkbox';
26
- import Radio from './form/radio';
27
- import Switch from './form/switch';
28
- import Select from './form/select';
29
- import Uploader from './form/uploader';
30
- import Tips from './form/tips';
31
- import Tabs from './tabs';
21
+ export { default as Form } from './form/form';
22
+ export { default as Input } from './form/input';
23
+ export { default as Textarea } from './form/textarea';
24
+ export { default as Checkbox } from './form/checkbox';
25
+ export { default as Radio } from './form/radio';
26
+ export { default as Switch } from './form/switch';
27
+ export { default as Select } from './form/select';
28
+ export { default as Uploader } from './form/uploader';
29
+ export { default as Tips } from './form/tips';
30
+ export { default as Tabs } from './tabs';
32
31
  // open
33
32
  // import Auth from './auth';
34
33
 
35
34
  import 'weui/dist/style/weui.css';
36
35
  import '../weda-ui.css';
37
-
38
- export default {
39
- Button,
40
- Markdown,
41
- Text,
42
- Container,
43
- Image,
44
- Picker,
45
- DatePicker,
46
- TimePicker,
47
- Input,
48
- Textarea,
49
- Radio,
50
- Checkbox,
51
- Switch,
52
- Form,
53
- Select,
54
- // Auth,
55
- Slot,
56
- Uploader,
57
- ScrollView,
58
- Swiper,
59
- Tips,
60
- Modal,
61
- RichText,
62
- RichTextView,
63
- UploaderView,
64
- Link,
65
- Drawer,
66
- Tabs,
67
- };
@@ -1,13 +1,3 @@
1
- .weda-RichTextView {
2
- width: 100%;
3
- }
4
-
5
- @media (min-width: 1024px) {
6
- .weda-RichTextView {
7
- height: 100px;
8
- }
9
- }
10
-
11
1
  .weda-RichTextView blockquote {
12
2
  margin: 0 0 10px;
13
3
  padding: 15px 20px;
@@ -86,15 +86,4 @@ RichTextView.propTypes = {
86
86
  */
87
87
  style: PropTypes.object,
88
88
  id: PropTypes.string
89
- };
90
-
91
- /**
92
- * 默认属性
93
- */
94
- RichTextView.defaultProps = {
95
- value: '',
96
- style: {
97
- width: '100%',
98
- height: '100%',
99
- },
100
- };
89
+ };
@@ -1,10 +1,10 @@
1
1
  import * as React from 'react';
2
2
  import { usePlatform } from '../../utils/platform';
3
- import TabsH5 from './tabsH5';
4
- import TabsPc from './tabsPc';
3
+ import TabsH5 from './tabs.h5';
4
+ import TabsPc from './tabs.pc';
5
5
 
6
6
  export default function Tabs(props) {
7
7
  const platform = usePlatform();
8
8
 
9
9
  return platform === 'h5' ? <TabsH5 {...props} /> : <TabsPc {...props} />;
10
- }
10
+ }
@@ -1,58 +1,19 @@
1
- import React, { useState, useMemo } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
3
 
4
4
  import './index.css';
5
5
  import classNames from '../../utils/classnames';
6
+ import { useSyncValue } from '../../utils/useSyncValue';
6
7
 
7
8
  export default function TabsH5({
8
9
  tabs,
10
+ selectedIndex,
9
11
  events,
10
12
  className,
11
- panel1,
12
- panel2,
13
- panel3,
14
- panel4,
15
- panel5,
16
- panel6,
17
- panel7,
18
- panel8,
19
- panel9,
20
- panel10,
21
- panel11,
22
- panel12,
23
- panel13,
24
- panel14,
25
- panel15,
26
- panel16,
27
- panel17,
28
- panel18,
29
- panel19,
30
- panel20,
31
- style
13
+ style,
14
+ ...restProps
32
15
  }) {
33
- const cachePanel = {
34
- panel1,
35
- panel2,
36
- panel3,
37
- panel4,
38
- panel5,
39
- panel6,
40
- panel7,
41
- panel8,
42
- panel9,
43
- panel10,
44
- panel11,
45
- panel12,
46
- panel13,
47
- panel14,
48
- panel15,
49
- panel16,
50
- panel17,
51
- panel18,
52
- panel19,
53
- panel20
54
- };
55
- const [currentIndex, setCurrentIndex] = useState(0);
16
+ const [currentIndex, setCurrentIndex] = useSyncValue(selectedIndex);
56
17
  const stickyStyle = useMemo(() => {
57
18
  const length = tabs.length;
58
19
  return {
@@ -81,7 +42,7 @@ export default function TabsH5({
81
42
  key={name || index}
82
43
  onClick={(event) => {
83
44
  setCurrentIndex(index);
84
- events && events.change(tabs[index], { event });
45
+ events && events.change({id: index, label: title}, { event });
85
46
  }}
86
47
  >
87
48
  {title}
@@ -98,7 +59,7 @@ export default function TabsH5({
98
59
  <div className={classNames({
99
60
  'weda-tabs__panel': true,
100
61
  })}>
101
- {cachePanel[`panel${currentIndex + 1}`]}
62
+ {restProps[`panel${currentIndex + 1}`]}
102
63
  </div>
103
64
  </div>
104
65
  );
@@ -109,6 +70,7 @@ TabsH5.propTypes = {
109
70
  tabs: PropTypes.array,
110
71
  className: PropTypes.string,
111
72
  style: PropTypes.object,
73
+ selectedIndex: PropTypes.number,
112
74
  events: PropTypes.objectOf(PropTypes.func),
113
75
  panel1: PropTypes.node,
114
76
  panel2: PropTypes.node,
@@ -2,73 +2,38 @@ import * as React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
3
  import { Tabs as TeaTabs, TabPanel, ConfigProvider } from 'tea-component';
4
4
  import classNames from '../../utils/classnames';
5
+ import { useSyncValue } from '../../utils/useSyncValue';
5
6
 
6
7
 
7
8
  export default function TabsPc({
8
9
  tabs,
10
+ selectedIndex,
9
11
  events,
10
12
  className,
11
- panel1,
12
- panel2,
13
- panel3,
14
- panel4,
15
- panel5,
16
- panel6,
17
- panel7,
18
- panel8,
19
- panel9,
20
- panel10,
21
- panel11,
22
- panel12,
23
- panel13,
24
- panel14,
25
- panel15,
26
- panel16,
27
- panel17,
28
- panel18,
29
- panel19,
30
- panel20,
31
- style
13
+ style,
14
+ ...restProps
32
15
  }) {
33
16
 
34
- const cachePanel = {
35
- panel1,
36
- panel2,
37
- panel3,
38
- panel4,
39
- panel5,
40
- panel6,
41
- panel7,
42
- panel8,
43
- panel9,
44
- panel10,
45
- panel11,
46
- panel12,
47
- panel13,
48
- panel14,
49
- panel15,
50
- panel16,
51
- panel17,
52
- panel18,
53
- panel19,
54
- panel20
55
- };
56
-
17
+ const [activeIndex, setActiveIndex] = useSyncValue(selectedIndex);
57
18
  const _tabs = Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
58
19
  return {
59
- id: item.name ?? index,
20
+ id: index,
60
21
  label: item.title
61
22
  };
62
23
  });
63
24
 
64
25
 
65
26
 
27
+ // React.useEffect(() => {
28
+ // console.log('render');
29
+ // });
66
30
  const onActive = (e) => {
31
+ setActiveIndex(e.id);
67
32
  events && events.change(e);
68
33
  };
69
34
  return (
70
35
  <ConfigProvider classPrefix="wedatea2td">
71
- <TeaTabs style={style} tabs={_tabs} onActive={onActive} className={classNames(
36
+ <TeaTabs style={style} tabs={_tabs} activeId={activeIndex} onActive={onActive} className={classNames(
72
37
  "weda-tabs_pc",
73
38
  {
74
39
  [className]: className
@@ -81,7 +46,7 @@ export default function TabsPc({
81
46
  id={item.id}
82
47
  label={item.label}
83
48
  >
84
- {cachePanel[`panel${index + 1}`]}
49
+ {restProps[`panel${index + 1}`]}
85
50
  </TabPanel>
86
51
  )
87
52
  )}
@@ -93,6 +58,7 @@ export default function TabsPc({
93
58
  TabsPc.propTypes = {
94
59
  tabs: PropTypes.array,
95
60
  className: PropTypes.string,
61
+ selectedIndex: PropTypes.number,
96
62
  style: PropTypes.object,
97
63
  events: PropTypes.objectOf(PropTypes.func),
98
64
  panel1: PropTypes.node,
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import * as PropTypes from 'prop-types';
3
- import { TcbImage } from '../form/uploader/uploaderPc';
3
+ import { TcbImage } from '../form/uploader/uploader.pc';
4
4
  import classNames from '../../utils/classnames';
5
5
  import './index.css';
6
6
 
package/src/web/index.js CHANGED
@@ -1,5 +1,4 @@
1
- import components from './components';
2
-
3
- import actions from './actions';
1
+ import * as components from './components';
2
+ import * as actions from './actions';
4
3
 
5
4
  export default { components, actions };
@@ -1,5 +1,14 @@
1
1
  import isEqual from 'lodash.isequal';
2
2
 
3
- export default function (a, b) {
3
+ export function serde(a) {
4
+ return JSON.parse(JSON.stringify(a));
5
+ }
6
+
7
+ const isObj = (a) => typeof a === 'object' && a !== null;
8
+
9
+ export default function (a, b, shouldSerde = false) {
10
+ if(shouldSerde && isObj(a) && isObj(b)) { // for Proxy created by mbox
11
+ return isEqual(serde(a), serde(b));
12
+ }
4
13
  return isEqual(a, b);
5
14
  }
@@ -0,0 +1,14 @@
1
+ import { useEffect, useState } from "react";
2
+ import { usePrevious } from "react-use";
3
+
4
+ export function useSyncValue(defaultValue, comparotor = Object.is) {
5
+ const [stateValue, setStateValue] = useState(defaultValue);
6
+ const prevValue = usePrevious(defaultValue);
7
+ useEffect(() => {
8
+ if (!comparotor(prevValue, defaultValue)) {
9
+ setStateValue(defaultValue);
10
+ }
11
+ }, [defaultValue]);
12
+ return [stateValue, setStateValue];
13
+ }
14
+
@@ -55,3 +55,11 @@ body .weda-ui {
55
55
  background-color: unset !important;
56
56
  }
57
57
  }
58
+
59
+ .weda-ui.weda-radio .weui-check,
60
+ .weda-ui.weda-checkbox .weui-check {
61
+ position: absolute;
62
+ left: -9999px;
63
+ width: 0;
64
+ height: 0;
65
+ }
@@ -1,17 +0,0 @@
1
- {
2
- "$schema": "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/schema/lcds_component.json",
3
- "data": {
4
- "properties": {
5
- "source": {
6
- "title": "markdown 内容",
7
- "type": "textarea",
8
- "default": "> 这是 `markdown` 文本"
9
- }
10
- }
11
- },
12
- "meta": {
13
- "title": "Markdown",
14
- "description": "markdown 预览",
15
- "category": "展示"
16
- }
17
- }
@@ -1,27 +0,0 @@
1
- const towxml = require('./towxml/index');
2
-
3
- Component({
4
- options: {
5
- virtualHost: true,
6
- },
7
- data: {
8
- nodes: {},
9
- },
10
- properties: {
11
- source: {
12
- type: String,
13
- value: '> 这是 `markdown` 文本',
14
- },
15
- },
16
- methods: {
17
- updateNodes() {
18
- const nodes = towxml(this.properties.source, 'markdown', {});
19
- this.setData({ nodes });
20
- },
21
- },
22
- observers: {
23
- source() {
24
- this.updateNodes();
25
- },
26
- },
27
- });
@@ -1,6 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- "towxml": "./towxml/towxml"
5
- }
6
- }
@@ -1 +0,0 @@
1
- <towxml className="weda-ui" nodes="{{nodes}}"></towxml>
@@ -1,99 +0,0 @@
1
- const fillIn = (val) => `${val < 10 ? '0' : ''}${val}`;
2
- const formatTime = (_time) => {
3
- const time = Math.round(_time);
4
- const second = Math.round(time % 60);
5
- const minute = Math.floor((time / 60) % 60);
6
- const hour = Math.floor(time / 60 / 60);
7
- return `${fillIn(hour)}:${fillIn(minute)}:${fillIn(second)}`;
8
- };
9
-
10
- class Audio {
11
- constructor(obj) {
12
- const _ts = this;
13
- const option = (_ts.option = obj.attr);
14
-
15
- (_ts.loop = option.loop === 'true'), (_ts.autoplay = option.autoplay === 'true');
16
- _ts.create();
17
- _ts.index = 0;
18
- }
19
- create() {
20
- const _ts = this;
21
- const { option } = _ts;
22
- const audio = (_ts.audio = wx.createInnerAudioContext());
23
- audio.src = option.src;
24
-
25
- // 说明可以播放了
26
- audio.onCanplay(() => {
27
- if (_ts.autoplay && !_ts.index) {
28
- _ts.play();
29
- }
30
- if (!_ts.autoplay && !_ts.index) {
31
- _ts.eventCanplay();
32
- }
33
- });
34
-
35
- // 更新时间
36
- audio.onTimeUpdate(() => {
37
- // _ts.status = 'update';
38
- _ts.duration = audio.duration;
39
- _ts.currentTime = audio.currentTime;
40
-
41
- // 定义播放结束
42
- if (_ts.duration - _ts.currentTime < 0.5) {
43
- _ts.index++;
44
- if (_ts.loop) {
45
- audio.stop();
46
- } else {
47
- _ts.stop();
48
- }
49
- audio.seek(0);
50
- }
51
- _ts.eventTimeUpdate(formatTime(_ts.duration), formatTime(_ts.currentTime));
52
- });
53
-
54
- //
55
- audio.onSeeked(() => {
56
- if (_ts.loop) {
57
- _ts.play();
58
- }
59
- });
60
- }
61
- // 播放
62
- play() {
63
- const _ts = this;
64
- _ts.status = 'play';
65
- _ts.audio.play();
66
- _ts.eventPlay();
67
- }
68
- // 暂停
69
- pause() {
70
- const _ts = this;
71
- _ts.status = 'pause';
72
- _ts.audio.pause();
73
- _ts.eventPause();
74
- }
75
- // 停止
76
- stop() {
77
- const _ts = this;
78
- _ts.status = 'stop';
79
- _ts.audio.stop();
80
- _ts.eventStop();
81
- }
82
- // 销毁
83
- destroy() {
84
- const _ts = this;
85
- _ts.stop();
86
- _ts.audio.destroy();
87
- }
88
- eventCanplay() {}
89
- eventTimeUpdate() {}
90
- eventEnded() {}
91
- eventError() {}
92
- eventPause() {}
93
- eventPlay() {}
94
- eventSeeked() {}
95
- eventSeeking() {}
96
- eventStop() {}
97
- eventWaiting() {}
98
- }
99
- module.exports = Audio;
@@ -1,102 +0,0 @@
1
- const Audio = require('./Audio');
2
- Component({
3
- options: {
4
- styleIsolation: 'shared',
5
- },
6
- properties: {
7
- data: {
8
- type: Object,
9
- value: {},
10
- },
11
- },
12
- lifetimes: {
13
- // 页面生命周期
14
- attached() {
15
- const _ts = this;
16
- const audio = (_ts.audio = new Audio(this.data.data));
17
-
18
- audio.eventPlay = function () {
19
- _ts.setData({ tips: { state: 'h2w__audio--play', text: 'Playing' } });
20
- };
21
- audio.eventCanplay = function () {
22
- _ts.setData({ tips: { state: 'h2w__audio--readyed', text: 'Readyed' } });
23
- };
24
- audio.eventTimeUpdate = function (duration, currentTime) {
25
- _ts.setData({
26
- time: {
27
- currentTime,
28
- duration,
29
- schedule: `${(Math.round(_ts.audio.currentTime) / Math.round(_ts.audio.duration)) * 100}%`,
30
- },
31
- });
32
- };
33
- audio.eventPause = function () {
34
- _ts.setData({ tips: { state: 'h2w__audio--pause', text: 'Pause' } });
35
- };
36
- audio.eventStop = function () {
37
- _ts.setData({ tips: { state: 'h2w__audio--end', text: 'End' } });
38
- };
39
-
40
- // // 更新播放状态
41
- // _ts.audio.onTimeUpdate = function(duration,currentTime){
42
- // _ts.setData({
43
- // playerData:{
44
- // state:'h2w__audio--play',
45
- // tips:'Playing',
46
- // currentTime:currentTime,
47
- // duration:duration,
48
- // schedule:_ts.audio.currentTime / _ts.audio.duration * 100 + '%'
49
- // }
50
- // });
51
- // };
52
-
53
- // _ts.audio.onPause = function(){
54
- // _ts.setData({playerData:{state:'h2w__audio--pause',tips:'Pause'}});
55
- // };
56
-
57
- // _ts.audio.onCanplay = function(){
58
- // _ts.setData({playerData:{state:'h2w__audio--readyed',tips:'Readyed'}});
59
- // };
60
-
61
- // _ts.audio.onError = function(){
62
- // _ts.setData({playerData:{state:'h2w__audio--error',tips:'Error'}});
63
- // };
64
-
65
- // _ts.audio.onEnded = ()=>{
66
- // _ts.setData({playerData:{state:'h2w__audio--end',tips:'End'}});
67
- // };
68
- },
69
- moved() {
70
- _ts.audio.destroy();
71
- },
72
- detached: () => {},
73
- },
74
- data: {
75
- tips: {
76
- state: '',
77
- text: '--',
78
- },
79
- time: {
80
- currentTime: '00:00:00',
81
- duration: '00:00:00',
82
- schedule: '0%',
83
- },
84
- },
85
- methods: {
86
- playAndPause() {
87
- const _ts = this;
88
- const { audio } = _ts;
89
-
90
- // console.log(audio);
91
-
92
- audio.isTouch = true;
93
- if (audio.status === 'update' || audio.status === 'play') {
94
- // console.log('pause');
95
- audio.pause();
96
- } else {
97
- // console.log('play');
98
- audio.play();
99
- }
100
- },
101
- },
102
- });
@@ -1,5 +0,0 @@
1
- {
2
- "component": true,
3
- "usingComponents": {
4
- }
5
- }
@@ -1,14 +0,0 @@
1
- <view class="h2w__audio {{tips.state || 'h2w__audio--loading'}}" bind:tap="playAndPause">
2
- <view class="h2w__audioIcon"></view>
3
- <view class="h2w__audioCover">
4
- <image class="h2w__audioLoading" src="loading.svg"></image>
5
- <image class="h2w__audioCoverImg" src="{{data.attr.poster}}"></image>
6
- </view>
7
- <view class="h2w__audioInfo">
8
- <view class="h2w__audioTips">{{tips.text || 'Error'}}</view>
9
- <view class="h2w__audioSchedule" style="width:{{time.schedule}};"></view>
10
- <view class="h2w__audioTitle">{{data.attr.name}}</view>
11
- <view class="h2w__audioAuthor">{{data.attr.author}}</view>
12
- <view class="h2w__audioTime">{{time.currentTime || '00:00:00'}} / {{time.duration || '00:00:00'}}</view>
13
- </view>
14
- </view>