sh-view 1.7.5 → 2.0.0

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 (206) hide show
  1. package/.eslintrc.js +20 -21
  2. package/package.json +10 -10
  3. package/packages/assets/css/animated.scss +167 -2
  4. package/packages/assets/css/loader.scss +42 -42
  5. package/packages/assets/css/main.scss +41 -21
  6. package/packages/assets/css/theme.scss +83 -44
  7. package/packages/components/global-components/sh-alert/index.vue +173 -0
  8. package/packages/components/global-components/sh-badge/index.vue +227 -0
  9. package/packages/components/global-components/sh-card/index.vue +140 -122
  10. package/packages/components/global-components/sh-code-editor/index.vue +260 -260
  11. package/packages/components/global-components/sh-col/css/index.scss +76 -0
  12. package/packages/components/global-components/sh-col/index.vue +83 -0
  13. package/packages/components/global-components/sh-corner/index.vue +1 -9
  14. package/packages/components/global-components/sh-count-to/index.vue +102 -46
  15. package/packages/components/global-components/sh-date/index.vue +40 -0
  16. package/packages/components/global-components/sh-drawer/index.vue +518 -0
  17. package/packages/components/global-components/sh-drawer/scrollbar.js +76 -0
  18. package/packages/components/global-components/sh-empty/index.vue +43 -43
  19. package/packages/components/global-components/{sh-vxe-form → sh-form}/css/index.scss +6 -6
  20. package/packages/components/global-components/{sh-vxe-form → sh-form}/index.vue +114 -115
  21. package/packages/components/global-components/sh-form/js/methods.js +146 -0
  22. package/packages/components/global-components/{sh-vxe-form → sh-form}/mixin/defaultData.js +32 -33
  23. package/packages/components/global-components/sh-header/index.vue +293 -269
  24. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.svg +870 -0
  25. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.ttf +0 -0
  26. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.woff +0 -0
  27. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.woff2 +0 -0
  28. package/packages/components/global-components/sh-icon/css/default/icons.scss +2583 -0
  29. package/packages/components/global-components/sh-icon/css/default/index.scss +27 -0
  30. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.js +1 -0
  31. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.json +247 -0
  32. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.ttf +0 -0
  33. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.woff +0 -0
  34. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.woff2 +0 -0
  35. package/packages/components/global-components/sh-icon/css/font/icons.scss +135 -0
  36. package/packages/components/global-components/sh-icon/css/font/index.scss +16 -0
  37. package/packages/components/global-components/sh-icon/icon-default.vue +32 -0
  38. package/packages/components/global-components/sh-icon/{icons.vue → icon-font.vue} +32 -32
  39. package/packages/components/global-components/sh-icon/index.vue +28 -27
  40. package/packages/components/global-components/sh-image/index.vue +123 -0
  41. package/packages/components/global-components/sh-list/index.vue +141 -0
  42. package/packages/components/global-components/sh-loading/index.vue +49 -42
  43. package/packages/components/global-components/{sh-vxe-modal → sh-modal}/index.vue +209 -209
  44. package/packages/components/global-components/sh-noticebar/index.vue +201 -201
  45. package/packages/components/global-components/sh-poptip/index.vue +479 -0
  46. package/packages/components/global-components/sh-poptip/popper.js +115 -0
  47. package/packages/components/global-components/sh-progress/index.vue +290 -0
  48. package/packages/components/global-components/sh-pull-refresh/index.vue +290 -290
  49. package/packages/components/global-components/{sh-vxe-query → sh-query}/index.vue +317 -286
  50. package/packages/components/global-components/sh-result/index.vue +110 -88
  51. package/packages/components/global-components/sh-row/css/index.scss +21 -0
  52. package/packages/components/global-components/sh-row/index.vue +63 -0
  53. package/packages/components/global-components/sh-split/components/trigger.vue +33 -0
  54. package/packages/components/global-components/sh-split/index.vue +334 -0
  55. package/packages/components/global-components/sh-table/components/importModal.vue +351 -0
  56. package/packages/components/global-components/{sh-vxe-table → sh-table}/css/index.scss +4 -22
  57. package/packages/components/global-components/{sh-vxe-table → sh-table}/index.vue +329 -351
  58. package/packages/components/global-components/{sh-vxe-table → sh-table}/js/methods.js +91 -153
  59. package/packages/components/global-components/{sh-vxe-table → sh-table}/js/props.js +304 -313
  60. package/packages/components/global-components/{sh-vxe-table → sh-table}/mixin/defaultData.js +94 -116
  61. package/packages/components/global-components/sh-tabs/index.vue +315 -0
  62. package/packages/components/global-components/sh-tag/index.vue +163 -0
  63. package/packages/components/global-components/{sh-vxe-toolbar → sh-toolbar}/index.vue +177 -172
  64. package/packages/components/global-components/sh-tree/components/table-tree.vue +280 -0
  65. package/packages/components/global-components/sh-tree/css/index.scss +54 -0
  66. package/packages/components/global-components/sh-tree/index.vue +195 -0
  67. package/packages/components/global-components/sh-tree/mixin/treeProps.js +124 -0
  68. package/packages/components/global-components/sh-upload/index.vue +278 -418
  69. package/packages/components/global-components/sh-upload/js/ajax.js +80 -0
  70. package/packages/components/global-components/sh-upload/js/mixin.js +257 -0
  71. package/packages/components/global-components/sh-water-fall/index.vue +87 -87
  72. package/packages/components/index.js +85 -59
  73. package/packages/components/other-components/sh-cron-modal/css/index.scss +2 -2
  74. package/packages/components/other-components/sh-menu-card/index.vue +224 -224
  75. package/packages/css/index.js +4 -6
  76. package/packages/directive/index.js +19 -19
  77. package/packages/directive/module/click-out.js +14 -0
  78. package/packages/directive/module/draggable.js +42 -42
  79. package/packages/directive/module/line-clamp.js +22 -0
  80. package/packages/directive/module/prevent-click.js +18 -0
  81. package/packages/directive/module/resize.js +19 -0
  82. package/packages/directive/module/ripple.js +166 -0
  83. package/packages/index.js +39 -40
  84. package/packages/utils/transfer-queue.js +12 -0
  85. package/packages/vxeTable/css/index.scss +12 -98
  86. package/packages/vxeTable/css/variable.scss +7 -265
  87. package/packages/vxeTable/index.js +184 -184
  88. package/packages/vxeTable/plugins/export.js +450 -0
  89. package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +36 -36
  90. package/packages/vxeTable/render/cell/vxe-render-goption.vue +94 -93
  91. package/packages/vxeTable/render/cell/vxe-render-img.vue +21 -28
  92. package/packages/vxeTable/render/cell/vxe-render-input.vue +51 -51
  93. package/packages/vxeTable/render/cell/vxe-render-progress.vue +19 -19
  94. package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +36 -36
  95. package/packages/vxeTable/render/cell/vxe-render-select.vue +36 -36
  96. package/packages/vxeTable/render/cell/vxe-render-tree.vue +59 -59
  97. package/packages/vxeTable/render/globalRenders.jsx +498 -491
  98. package/packages/assets/icons/demo.css +0 -539
  99. package/packages/assets/icons/iconfont.css +0 -415
  100. package/packages/assets/icons/iconfont.js +0 -1
  101. package/packages/assets/icons/iconfont.json +0 -709
  102. package/packages/assets/icons/iconfont.ttf +0 -0
  103. package/packages/assets/icons/iconfont.woff +0 -0
  104. package/packages/assets/icons/iconfont.woff2 +0 -0
  105. package/packages/assets/img/image-error.png +0 -0
  106. package/packages/assets/img/square-image.png +0 -0
  107. package/packages/components/global-components/sh-iv-form/components/iv-group-item.vue +0 -57
  108. package/packages/components/global-components/sh-iv-form/components/iv-single-item.vue +0 -76
  109. package/packages/components/global-components/sh-iv-form/index.vue +0 -255
  110. package/packages/components/global-components/sh-layout/index.vue +0 -142
  111. package/packages/components/global-components/sh-upload/components/u-img.vue +0 -63
  112. package/packages/components/global-components/sh-upload/components/u-list.vue +0 -100
  113. package/packages/components/global-components/sh-vxe-form/js/methods.js +0 -170
  114. package/packages/components/global-components/sh-vxe-list/index.vue +0 -129
  115. package/packages/components/global-components/sh-vxe-table/components/importModal.vue +0 -377
  116. package/packages/components/global-components/sh-vxe-tree/components/table-tree.vue +0 -233
  117. package/packages/components/global-components/sh-vxe-tree/css/index.scss +0 -20
  118. package/packages/components/global-components/sh-vxe-tree/index.vue +0 -85
  119. package/packages/components/global-components/sh-vxe-tree/js/props.js +0 -120
  120. package/packages/components/global-components/sh-vxe-tree/js/treeMethods.js +0 -169
  121. package/packages/components/global-components/sh-vxe-tree/mixin/defaultData.js +0 -54
  122. package/packages/components/global-components/sh-vxe-tree/vxe-direct-tree.vue +0 -203
  123. package/packages/components/global-components/sh-vxe-tree/vxe-select-tree.vue +0 -291
  124. package/packages/components/other-components/sh-markdown/tinymce/langs/ar.js +0 -7
  125. package/packages/components/other-components/sh-markdown/tinymce/langs/az.js +0 -7
  126. package/packages/components/other-components/sh-markdown/tinymce/langs/bg_BG.js +0 -7
  127. package/packages/components/other-components/sh-markdown/tinymce/langs/bn_BD.js +0 -7
  128. package/packages/components/other-components/sh-markdown/tinymce/langs/ca.js +0 -7
  129. package/packages/components/other-components/sh-markdown/tinymce/langs/cs.js +0 -7
  130. package/packages/components/other-components/sh-markdown/tinymce/langs/cy.js +0 -7
  131. package/packages/components/other-components/sh-markdown/tinymce/langs/da.js +0 -7
  132. package/packages/components/other-components/sh-markdown/tinymce/langs/de.js +0 -7
  133. package/packages/components/other-components/sh-markdown/tinymce/langs/dv.js +0 -7
  134. package/packages/components/other-components/sh-markdown/tinymce/langs/el.js +0 -7
  135. package/packages/components/other-components/sh-markdown/tinymce/langs/eo.js +0 -7
  136. package/packages/components/other-components/sh-markdown/tinymce/langs/es.js +0 -7
  137. package/packages/components/other-components/sh-markdown/tinymce/langs/es_MX.js +0 -7
  138. package/packages/components/other-components/sh-markdown/tinymce/langs/et.js +0 -7
  139. package/packages/components/other-components/sh-markdown/tinymce/langs/eu.js +0 -7
  140. package/packages/components/other-components/sh-markdown/tinymce/langs/fa.js +0 -7
  141. package/packages/components/other-components/sh-markdown/tinymce/langs/fi.js +0 -7
  142. package/packages/components/other-components/sh-markdown/tinymce/langs/fr_FR.js +0 -7
  143. package/packages/components/other-components/sh-markdown/tinymce/langs/ga.js +0 -7
  144. package/packages/components/other-components/sh-markdown/tinymce/langs/gl.js +0 -7
  145. package/packages/components/other-components/sh-markdown/tinymce/langs/he_IL.js +0 -7
  146. package/packages/components/other-components/sh-markdown/tinymce/langs/hi.js +0 -7
  147. package/packages/components/other-components/sh-markdown/tinymce/langs/hr.js +0 -7
  148. package/packages/components/other-components/sh-markdown/tinymce/langs/hu_HU.js +0 -7
  149. package/packages/components/other-components/sh-markdown/tinymce/langs/hy.js +0 -7
  150. package/packages/components/other-components/sh-markdown/tinymce/langs/id.js +0 -7
  151. package/packages/components/other-components/sh-markdown/tinymce/langs/is_IS.js +0 -7
  152. package/packages/components/other-components/sh-markdown/tinymce/langs/it.js +0 -7
  153. package/packages/components/other-components/sh-markdown/tinymce/langs/ja.js +0 -7
  154. package/packages/components/other-components/sh-markdown/tinymce/langs/kab.js +0 -7
  155. package/packages/components/other-components/sh-markdown/tinymce/langs/kk.js +0 -7
  156. package/packages/components/other-components/sh-markdown/tinymce/langs/ko_KR.js +0 -7
  157. package/packages/components/other-components/sh-markdown/tinymce/langs/ku.js +0 -7
  158. package/packages/components/other-components/sh-markdown/tinymce/langs/lt.js +0 -7
  159. package/packages/components/other-components/sh-markdown/tinymce/langs/lv.js +0 -7
  160. package/packages/components/other-components/sh-markdown/tinymce/langs/nb_NO.js +0 -7
  161. package/packages/components/other-components/sh-markdown/tinymce/langs/ne.js +0 -7
  162. package/packages/components/other-components/sh-markdown/tinymce/langs/nl.js +0 -7
  163. package/packages/components/other-components/sh-markdown/tinymce/langs/nl_BE.js +0 -7
  164. package/packages/components/other-components/sh-markdown/tinymce/langs/oc.js +0 -7
  165. package/packages/components/other-components/sh-markdown/tinymce/langs/pl.js +0 -7
  166. package/packages/components/other-components/sh-markdown/tinymce/langs/pt_BR.js +0 -7
  167. package/packages/components/other-components/sh-markdown/tinymce/langs/ro.js +0 -7
  168. package/packages/components/other-components/sh-markdown/tinymce/langs/ru.js +0 -7
  169. package/packages/components/other-components/sh-markdown/tinymce/langs/sk.js +0 -7
  170. package/packages/components/other-components/sh-markdown/tinymce/langs/sl_SI.js +0 -7
  171. package/packages/components/other-components/sh-markdown/tinymce/langs/sq.js +0 -7
  172. package/packages/components/other-components/sh-markdown/tinymce/langs/sr.js +0 -7
  173. package/packages/components/other-components/sh-markdown/tinymce/langs/sv_SE.js +0 -7
  174. package/packages/components/other-components/sh-markdown/tinymce/langs/ta.js +0 -7
  175. package/packages/components/other-components/sh-markdown/tinymce/langs/tg.js +0 -7
  176. package/packages/components/other-components/sh-markdown/tinymce/langs/th_TH.js +0 -7
  177. package/packages/components/other-components/sh-markdown/tinymce/langs/tr.js +0 -7
  178. package/packages/components/other-components/sh-markdown/tinymce/langs/ug.js +0 -7
  179. package/packages/components/other-components/sh-markdown/tinymce/langs/uk.js +0 -7
  180. package/packages/components/other-components/sh-markdown/tinymce/langs/vi.js +0 -7
  181. package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.css +0 -72
  182. package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.min.css +0 -7
  183. package/packages/components/other-components/sh-markdown/tinymce/skins/content/default/content.min.css +0 -7
  184. package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.css +0 -72
  185. package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.min.css +0 -7
  186. package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.css +0 -68
  187. package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.min.css +0 -7
  188. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.css +0 -714
  189. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.css +0 -726
  190. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -7
  191. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.min.css +0 -7
  192. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.css +0 -29
  193. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.min.css +0 -7
  194. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
  195. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.css +0 -3047
  196. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.min.css +0 -7
  197. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.css +0 -673
  198. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +0 -7
  199. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -37
  200. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -7
  201. package/packages/directive/directives.js +0 -27
  202. package/packages/iview/css/index.scss +0 -32
  203. package/packages/iview/index.js +0 -25
  204. /package/packages/components/global-components/{sh-vxe-form → sh-form}/components/form-item.vue +0 -0
  205. /package/packages/components/global-components/{sh-vxe-form → sh-form}/js/props.js +0 -0
  206. /package/packages/components/global-components/{sh-vxe-table → sh-table}/js/excel_to_json.js +0 -0
@@ -1,290 +1,290 @@
1
- <template>
2
- <div ref="scroller" class="sh-pull-refresh" :class="classes" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
3
- <div class="sh-pull-refresh-container" :style="getStyle">
4
- <div class="sh-pull-refresh-container-topbox" :style="getHeightStyle">
5
- <div class="sh-pull-refresh-container-topbox-text">
6
- <slot v-if="status === 'pulling'" name="pulling">{{ pullingTxt }}</slot>
7
- <slot v-if="status === 'loosing'" name="loosing">{{ loosingTxt }}</slot>
8
- <slot v-if="status === 'loading'" name="loading">
9
- <i class="sh-pull-refresh-container-topbox-icon vxe-icon-refresh roll"></i>
10
- {{ loadingTxt }}
11
- </slot>
12
- </div>
13
- </div>
14
- <slot></slot>
15
- </div>
16
- </div>
17
- </template>
18
-
19
- <script>
20
- export default {
21
- name: 'ShPullRefresh',
22
- props: {
23
- modelValue: {
24
- type: Boolean,
25
- default: false
26
- },
27
- pullingTxt: {
28
- type: String,
29
- default: '下拉刷新'
30
- },
31
- loosingTxt: {
32
- type: String,
33
- default: '释放刷新'
34
- },
35
- loadingTxt: {
36
- type: String,
37
- default: '加载中...'
38
- },
39
- // completeTxt: {
40
- // type: String,
41
- // default: ''
42
- // },
43
- headHeight: {
44
- type: [String, Number],
45
- default: 40
46
- },
47
- pullDistance: {
48
- type: [String, Number],
49
- default: 40
50
- },
51
- duration: {
52
- type: [String, Number],
53
- default: 0.3
54
- }
55
- },
56
- emits: ['change', 'refresh', 'update:modelValue'],
57
- data() {
58
- return {
59
- touch: {
60
- startX: 0,
61
- startY: 0,
62
- moveX: 0,
63
- moveY: 0,
64
- deltaX: 0,
65
- deltaY: 0,
66
- offsetX: 0,
67
- offsetY: 0,
68
- direction: ''
69
- },
70
- scrollParent: null,
71
- isPullRefresh: false,
72
- distance: 0,
73
- status: 'normal'
74
- }
75
- },
76
- computed: {
77
- classes() {
78
- const prefixCls = 'pull-refresh'
79
- return {
80
- [prefixCls]: true
81
- }
82
- },
83
- getPullStatus() {
84
- if (this.status === 'pulling') {
85
- return !this.slots.pulling ? this.pullingTxt : ''
86
- } else if (this.status === 'loosing') {
87
- return !this.slots.loosing ? this.loosingTxt : ''
88
- } else if (this.status === 'loading') {
89
- return !this.slots.loading ? this.loadingTxt : ''
90
- } else {
91
- return ''
92
- }
93
- },
94
- getStyle() {
95
- return {
96
- transitionDuration: `${this.duration}s`,
97
- transform: this.distance ? `translate3d(0,${this.distance}px, 0)` : ''
98
- }
99
- },
100
- getHeightStyle() {
101
- const styles = {}
102
- if (this.headHeight !== 40) styles.height = this.pxCheck(this.headHeight)
103
- return styles
104
- }
105
- },
106
- watch: {
107
- modelValue(val) {
108
- if (val) {
109
- this.setPullStatus(+this.headHeight, true)
110
- this.$nextTick(() => this.$emit('refresh'))
111
- } else {
112
- this.setPullStatus(0)
113
- }
114
- }
115
- },
116
- mounted() {
117
- this.initMounted()
118
- },
119
- methods: {
120
- initMounted() {
121
- this.scrollParent = this.getScrollParent()
122
- },
123
- pxCheck(value) {
124
- return isNaN(Number(value)) ? String(value) : `${value}px`
125
- },
126
- timing(distance) {
127
- const pullDistance = +(this.pullDistance || this.headHeight)
128
- let moveDistance = distance
129
- if (distance > pullDistance) {
130
- if (distance < pullDistance * 2) {
131
- moveDistance = (distance + pullDistance) / 2
132
- } else {
133
- moveDistance = pullDistance + distance / 4
134
- }
135
- }
136
- return Math.round(moveDistance)
137
- },
138
- setPullStatus(distance, isLoading) {
139
- const pullDistance = +(this.pullDistance || this.headHeight)
140
- this.distance = distance
141
- if (isLoading) {
142
- this.status = 'loading'
143
- } else if (distance === 0) {
144
- this.status = 'normal'
145
- } else if (distance < pullDistance) {
146
- this.status = 'pulling'
147
- } else {
148
- this.status = 'loosing'
149
- }
150
- this.$emit('change', { status: this.status, distance })
151
- },
152
- isElement(node) {
153
- return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === 1
154
- },
155
- isVertical() {
156
- return this.touch.direction === 'vertical'
157
- },
158
- isHorizontal() {
159
- return this.touch.direction === 'horizontal'
160
- },
161
- getDirection(x, y) {
162
- let MIN_DISTANCE = 10
163
- if (x > y && x > MIN_DISTANCE) {
164
- return 'horizontal'
165
- }
166
- if (y > x && y > MIN_DISTANCE) {
167
- return 'vertical'
168
- }
169
- return ''
170
- },
171
- resetTouch() {
172
- this.touch.deltaX = 0
173
- this.touch.deltaY = 0
174
- this.touch.offsetX = 0
175
- this.touch.offsetY = 0
176
- this.touch.direction = ''
177
- },
178
- startTouch(event) {
179
- this.resetTouch()
180
- this.touch.startX = event.touches[0].clientX
181
- this.touch.startY = event.touches[0].clientY
182
- },
183
- moveTouch(event) {
184
- const touch = event.touches[0]
185
- this.touch.deltaX = touch.clientX - this.touch.startX
186
- this.touch.deltaY = touch.clientY - this.touch.startY
187
- this.touch.moveX = touch.clientX
188
- this.touch.moveY = touch.clientY
189
- this.touch.offsetX = Math.abs(this.touch.deltaX)
190
- this.touch.offsetY = Math.abs(this.touch.deltaY)
191
- if (!this.touch.direction) {
192
- this.touch.direction = this.getDirection(this.touch.offsetX, this.touch.offsetY)
193
- }
194
- },
195
- getScrollParent(el, root = window) {
196
- let node = el
197
- const overflowScrollReg = /scroll|auto|overlay/i
198
- while (node && node !== root && this.isElement(node)) {
199
- const { overflowY } = window.getComputedStyle(node)
200
- if (overflowScrollReg.test(overflowY)) {
201
- return node
202
- }
203
- node = node.parentNode
204
- }
205
- return root
206
- },
207
- getScrollTopRoot() {
208
- return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
209
- },
210
- isCanTouch() {
211
- return this.status !== 'loading' && this.status !== 'complete'
212
- },
213
- isScrollTop() {
214
- if (this.scrollParent === window) {
215
- return this.getScrollTopRoot() === 0
216
- } else {
217
- return this.scrollParent && this.scrollParent.scrollTop === 0
218
- }
219
- },
220
- touchStart(event) {
221
- if (this.isCanTouch()) {
222
- if (this.isScrollTop()) {
223
- this.startTouch(event)
224
- this.isPullRefresh = true
225
- } else {
226
- this.distance = 0
227
- this.isPullRefresh = false
228
- }
229
- }
230
- },
231
- touchMove(event) {
232
- if (this.isCanTouch()) {
233
- this.moveTouch(event)
234
- if (this.isVertical() && this.touch.deltaY > 0 && this.isPullRefresh) {
235
- event.preventDefault()
236
- this.setPullStatus(this.timing(this.touch.deltaY))
237
- }
238
- }
239
- },
240
- touchEnd() {
241
- const that = this
242
- if (that.isPullRefresh && that.isCanTouch() && that.touch.deltaY) {
243
- if (that.status === 'loosing') {
244
- that.setPullStatus(+that.headHeight, true)
245
- that.$emit('update:modelValue', true)
246
- that.$nextTick(() => that.$emit('refresh'))
247
- } else {
248
- that.setPullStatus(0)
249
- }
250
- }
251
- setTimeout(() => {
252
- that.resetTouch()
253
- }, 0)
254
- }
255
- }
256
- }
257
- </script>
258
-
259
- <style scoped lang="scss">
260
- .sh-pull-refresh {
261
- height: 100%;
262
- overflow: hidden;
263
- &-container {
264
- position: relative;
265
- height: 100%;
266
- &-topbox {
267
- position: absolute;
268
- left: 0;
269
- width: 100%;
270
- height: 40px;
271
- transform: translateY(-100%);
272
- text-align: center;
273
- font-size: 14px;
274
- display: flex;
275
- align-items: center;
276
- justify-content: center;
277
- &-icon {
278
- margin-right: 4px;
279
- width: 16px;
280
- height: 16px;
281
- padding: 0;
282
- }
283
- &-text {
284
- font-size: var(--font-size-base);
285
- color: var(--theme-color);
286
- }
287
- }
288
- }
289
- }
290
- </style>
1
+ <template>
2
+ <div ref="scroller" class="sh-pull-refresh" :class="classes" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
3
+ <div class="sh-pull-refresh-container" :style="getStyle">
4
+ <div class="sh-pull-refresh-container-topbox" :style="getHeightStyle">
5
+ <div class="sh-pull-refresh-container-topbox-text">
6
+ <slot v-if="status === 'pulling'" name="pulling">{{ pullingTxt }}</slot>
7
+ <slot v-if="status === 'loosing'" name="loosing">{{ loosingTxt }}</slot>
8
+ <slot v-if="status === 'loading'" name="loading">
9
+ <i class="sh-pull-refresh-container-topbox-icon vxe-icon-refresh roll"></i>
10
+ {{ loadingTxt }}
11
+ </slot>
12
+ </div>
13
+ </div>
14
+ <slot></slot>
15
+ </div>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ name: 'ShPullRefresh',
22
+ props: {
23
+ modelValue: {
24
+ type: Boolean,
25
+ default: false
26
+ },
27
+ pullingTxt: {
28
+ type: String,
29
+ default: '下拉刷新'
30
+ },
31
+ loosingTxt: {
32
+ type: String,
33
+ default: '释放刷新'
34
+ },
35
+ loadingTxt: {
36
+ type: String,
37
+ default: '加载中...'
38
+ },
39
+ // completeTxt: {
40
+ // type: String,
41
+ // default: ''
42
+ // },
43
+ headHeight: {
44
+ type: [String, Number],
45
+ default: 40
46
+ },
47
+ pullDistance: {
48
+ type: [String, Number],
49
+ default: 40
50
+ },
51
+ duration: {
52
+ type: [String, Number],
53
+ default: 0.3
54
+ }
55
+ },
56
+ emits: ['change', 'refresh', 'update:modelValue'],
57
+ data() {
58
+ return {
59
+ touch: {
60
+ startX: 0,
61
+ startY: 0,
62
+ moveX: 0,
63
+ moveY: 0,
64
+ deltaX: 0,
65
+ deltaY: 0,
66
+ offsetX: 0,
67
+ offsetY: 0,
68
+ direction: ''
69
+ },
70
+ scrollParent: null,
71
+ isPullRefresh: false,
72
+ distance: 0,
73
+ status: 'normal'
74
+ }
75
+ },
76
+ computed: {
77
+ classes() {
78
+ const prefixCls = 'pull-refresh'
79
+ return {
80
+ [prefixCls]: true
81
+ }
82
+ },
83
+ getPullStatus() {
84
+ if (this.status === 'pulling') {
85
+ return !this.slots.pulling ? this.pullingTxt : ''
86
+ } else if (this.status === 'loosing') {
87
+ return !this.slots.loosing ? this.loosingTxt : ''
88
+ } else if (this.status === 'loading') {
89
+ return !this.slots.loading ? this.loadingTxt : ''
90
+ } else {
91
+ return ''
92
+ }
93
+ },
94
+ getStyle() {
95
+ return {
96
+ transitionDuration: `${this.duration}s`,
97
+ transform: this.distance ? `translate3d(0,${this.distance}px, 0)` : ''
98
+ }
99
+ },
100
+ getHeightStyle() {
101
+ const styles = {}
102
+ if (this.headHeight !== 40) styles.height = this.pxCheck(this.headHeight)
103
+ return styles
104
+ }
105
+ },
106
+ watch: {
107
+ modelValue(val) {
108
+ if (val) {
109
+ this.setPullStatus(+this.headHeight, true)
110
+ this.$nextTick(() => this.$emit('refresh'))
111
+ } else {
112
+ this.setPullStatus(0)
113
+ }
114
+ }
115
+ },
116
+ mounted() {
117
+ this.initMounted()
118
+ },
119
+ methods: {
120
+ initMounted() {
121
+ this.scrollParent = this.getScrollParent()
122
+ },
123
+ pxCheck(value) {
124
+ return isNaN(Number(value)) ? String(value) : `${value}px`
125
+ },
126
+ timing(distance) {
127
+ const pullDistance = +(this.pullDistance || this.headHeight)
128
+ let moveDistance = distance
129
+ if (distance > pullDistance) {
130
+ if (distance < pullDistance * 2) {
131
+ moveDistance = (distance + pullDistance) / 2
132
+ } else {
133
+ moveDistance = pullDistance + distance / 4
134
+ }
135
+ }
136
+ return Math.round(moveDistance)
137
+ },
138
+ setPullStatus(distance, isLoading) {
139
+ const pullDistance = +(this.pullDistance || this.headHeight)
140
+ this.distance = distance
141
+ if (isLoading) {
142
+ this.status = 'loading'
143
+ } else if (distance === 0) {
144
+ this.status = 'normal'
145
+ } else if (distance < pullDistance) {
146
+ this.status = 'pulling'
147
+ } else {
148
+ this.status = 'loosing'
149
+ }
150
+ this.$emit('change', { status: this.status, distance })
151
+ },
152
+ isElement(node) {
153
+ return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === 1
154
+ },
155
+ isVertical() {
156
+ return this.touch.direction === 'vertical'
157
+ },
158
+ isHorizontal() {
159
+ return this.touch.direction === 'horizontal'
160
+ },
161
+ getDirection(x, y) {
162
+ let MIN_DISTANCE = 10
163
+ if (x > y && x > MIN_DISTANCE) {
164
+ return 'horizontal'
165
+ }
166
+ if (y > x && y > MIN_DISTANCE) {
167
+ return 'vertical'
168
+ }
169
+ return ''
170
+ },
171
+ resetTouch() {
172
+ this.touch.deltaX = 0
173
+ this.touch.deltaY = 0
174
+ this.touch.offsetX = 0
175
+ this.touch.offsetY = 0
176
+ this.touch.direction = ''
177
+ },
178
+ startTouch(event) {
179
+ this.resetTouch()
180
+ this.touch.startX = event.touches[0].clientX
181
+ this.touch.startY = event.touches[0].clientY
182
+ },
183
+ moveTouch(event) {
184
+ const touch = event.touches[0]
185
+ this.touch.deltaX = touch.clientX - this.touch.startX
186
+ this.touch.deltaY = touch.clientY - this.touch.startY
187
+ this.touch.moveX = touch.clientX
188
+ this.touch.moveY = touch.clientY
189
+ this.touch.offsetX = Math.abs(this.touch.deltaX)
190
+ this.touch.offsetY = Math.abs(this.touch.deltaY)
191
+ if (!this.touch.direction) {
192
+ this.touch.direction = this.getDirection(this.touch.offsetX, this.touch.offsetY)
193
+ }
194
+ },
195
+ getScrollParent(el, root = window) {
196
+ let node = el
197
+ const overflowScrollReg = /scroll|auto|overlay/i
198
+ while (node && node !== root && this.isElement(node)) {
199
+ const { overflowY } = window.getComputedStyle(node)
200
+ if (overflowScrollReg.test(overflowY)) {
201
+ return node
202
+ }
203
+ node = node.parentNode
204
+ }
205
+ return root
206
+ },
207
+ getScrollTopRoot() {
208
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
209
+ },
210
+ isCanTouch() {
211
+ return this.status !== 'loading' && this.status !== 'complete'
212
+ },
213
+ isScrollTop() {
214
+ if (this.scrollParent === window) {
215
+ return this.getScrollTopRoot() === 0
216
+ } else {
217
+ return this.scrollParent && this.scrollParent.scrollTop === 0
218
+ }
219
+ },
220
+ touchStart(event) {
221
+ if (this.isCanTouch()) {
222
+ if (this.isScrollTop()) {
223
+ this.startTouch(event)
224
+ this.isPullRefresh = true
225
+ } else {
226
+ this.distance = 0
227
+ this.isPullRefresh = false
228
+ }
229
+ }
230
+ },
231
+ touchMove(event) {
232
+ if (this.isCanTouch()) {
233
+ this.moveTouch(event)
234
+ if (this.isVertical() && this.touch.deltaY > 0 && this.isPullRefresh) {
235
+ event.preventDefault()
236
+ this.setPullStatus(this.timing(this.touch.deltaY))
237
+ }
238
+ }
239
+ },
240
+ touchEnd() {
241
+ const that = this
242
+ if (that.isPullRefresh && that.isCanTouch() && that.touch.deltaY) {
243
+ if (that.status === 'loosing') {
244
+ that.setPullStatus(+that.headHeight, true)
245
+ that.$emit('update:modelValue', true)
246
+ that.$nextTick(() => that.$emit('refresh'))
247
+ } else {
248
+ that.setPullStatus(0)
249
+ }
250
+ }
251
+ setTimeout(() => {
252
+ that.resetTouch()
253
+ }, 0)
254
+ }
255
+ }
256
+ }
257
+ </script>
258
+
259
+ <style scoped lang="scss">
260
+ .sh-pull-refresh {
261
+ height: 100%;
262
+ overflow: hidden;
263
+ &-container {
264
+ position: relative;
265
+ height: 100%;
266
+ &-topbox {
267
+ position: absolute;
268
+ left: 0;
269
+ width: 100%;
270
+ height: 40px;
271
+ transform: translateY(-100%);
272
+ text-align: center;
273
+ font-size: 14px;
274
+ display: flex;
275
+ align-items: center;
276
+ justify-content: center;
277
+ &-icon {
278
+ margin-right: 4px;
279
+ width: 16px;
280
+ height: 16px;
281
+ padding: 0;
282
+ }
283
+ &-text {
284
+ font-size: var(--vxe-font-size);
285
+ color: var(--vxe-primary-color);
286
+ }
287
+ }
288
+ }
289
+ }
290
+ </style>