sh-view 1.7.6 → 2.0.1

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 (256) hide show
  1. package/.eslintrc.js +20 -21
  2. package/dist/css/227.45fab5b7.css +1 -0
  3. package/dist/css/291.e7facf7d.css +1 -0
  4. package/dist/css/299.e98df6ce.css +1 -0
  5. package/dist/css/358.e641c5d1.css +1 -0
  6. package/dist/css/534.726e6699.css +1 -0
  7. package/dist/css/769.8008ac6c.css +1 -0
  8. package/dist/css/index.2bd4fb37.css +1 -0
  9. package/dist/css/index.2bd4fb37.css.gz +0 -0
  10. package/dist/fonts/iconfont.03e5a9f9.ttf +0 -0
  11. package/dist/fonts/iconfont.03e5a9f9.ttf.gz +0 -0
  12. package/dist/fonts/ionicons.31fd4446.ttf +0 -0
  13. package/dist/fonts/ionicons.31fd4446.ttf.gz +0 -0
  14. package/dist/fonts/ionicons.d03f2836.woff2 +0 -0
  15. package/dist/fonts/ionicons.dacd136b.woff +0 -0
  16. package/dist/fonts/ionicons.dacd136b.woff.gz +0 -0
  17. package/dist/img/ionicons.6e8059e8.svg +870 -0
  18. package/dist/img/ionicons.6e8059e8.svg.gz +0 -0
  19. package/dist/js/152.588ca5b4.js +1 -0
  20. package/dist/js/165.f026fdcd.js +1 -0
  21. package/dist/js/227.6d340a71.js +1 -0
  22. package/dist/js/257.285f071f.js +1 -0
  23. package/dist/js/264.32b3a9a5.js +1 -0
  24. package/dist/js/291.e100da5e.js +1 -0
  25. package/dist/js/299.2062f9ff.js +1 -0
  26. package/dist/js/322.ff97ab5e.js +1 -0
  27. package/dist/js/333.da633859.js +1 -0
  28. package/dist/js/341.d4433549.js +1 -0
  29. package/dist/js/358.81429379.js +1 -0
  30. package/dist/js/387.7b1e3b8a.js +1 -0
  31. package/dist/js/392.c53bf6c9.js +1 -0
  32. package/dist/js/400.03e3be15.js +1 -0
  33. package/dist/js/41.fca2504e.js +1 -0
  34. package/dist/js/444.a0350517.js +1 -0
  35. package/dist/js/452.7f75d556.js +2 -0
  36. package/dist/js/452.7f75d556.js.gz +0 -0
  37. package/dist/js/497.06080ae1.js +1 -0
  38. package/dist/js/514.2ea0055a.js +1 -0
  39. package/dist/js/534.40a67536.js +1 -0
  40. package/dist/js/558.6175bf20.js +15 -0
  41. package/dist/js/558.6175bf20.js.gz +0 -0
  42. package/dist/js/586.098ab36d.js +1 -0
  43. package/dist/js/593.df7d7c2e.js +1 -0
  44. package/dist/js/601.abf6f256.js +1 -0
  45. package/dist/js/654.99b45cd4.js +18 -0
  46. package/dist/js/654.99b45cd4.js.gz +0 -0
  47. package/dist/js/668.a15a0058.js +1 -0
  48. package/dist/js/704.52e87fec.js +1 -0
  49. package/dist/js/720.aceca876.js +1 -0
  50. package/dist/js/769.1376ca7f.js +1 -0
  51. package/dist/js/875.975891f5.js +1 -0
  52. package/dist/js/89.c7317ccb.js +1 -0
  53. package/dist/js/94.d54e8b09.js +1 -0
  54. package/dist/js/chunk-vendors.e05ef0ac.js +438 -0
  55. package/dist/js/chunk-vendors.e05ef0ac.js.gz +0 -0
  56. package/dist/js/index.b31868df.js +1 -0
  57. package/dist/js/index.b31868df.js.gz +0 -0
  58. package/package.json +10 -10
  59. package/packages/assets/css/animated.scss +167 -2
  60. package/packages/assets/css/loader.scss +42 -42
  61. package/packages/assets/css/main.scss +41 -21
  62. package/packages/assets/css/theme.scss +83 -44
  63. package/packages/components/global-components/sh-alert/index.vue +173 -0
  64. package/packages/components/global-components/sh-badge/index.vue +227 -0
  65. package/packages/components/global-components/sh-card/index.vue +140 -122
  66. package/packages/components/global-components/sh-code-editor/index.vue +260 -260
  67. package/packages/components/global-components/sh-col/css/index.scss +76 -0
  68. package/packages/components/global-components/sh-col/index.vue +83 -0
  69. package/packages/components/global-components/sh-corner/index.vue +1 -9
  70. package/packages/components/global-components/sh-count-to/index.vue +102 -46
  71. package/packages/components/global-components/sh-date/index.vue +40 -0
  72. package/packages/components/global-components/sh-drawer/index.vue +518 -0
  73. package/packages/components/global-components/sh-drawer/scrollbar.js +76 -0
  74. package/packages/components/global-components/sh-empty/index.vue +43 -43
  75. package/packages/components/global-components/{sh-vxe-form → sh-form}/css/index.scss +6 -6
  76. package/packages/components/global-components/{sh-vxe-form → sh-form}/index.vue +114 -115
  77. package/packages/components/global-components/{sh-vxe-form → sh-form}/js/methods.js +146 -157
  78. package/packages/components/global-components/{sh-vxe-form → sh-form}/mixin/defaultData.js +32 -33
  79. package/packages/components/global-components/sh-header/index.vue +293 -269
  80. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.svg +870 -0
  81. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.ttf +0 -0
  82. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.woff +0 -0
  83. package/packages/components/global-components/sh-icon/css/default/fonts/ionicons.woff2 +0 -0
  84. package/packages/components/global-components/sh-icon/css/default/icons.scss +2583 -0
  85. package/packages/components/global-components/sh-icon/css/default/index.scss +27 -0
  86. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.js +1 -0
  87. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.json +247 -0
  88. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.ttf +0 -0
  89. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.woff +0 -0
  90. package/packages/components/global-components/sh-icon/css/font/fonts/iconfont.woff2 +0 -0
  91. package/packages/components/global-components/sh-icon/css/font/icons.scss +135 -0
  92. package/packages/components/global-components/sh-icon/css/font/index.scss +16 -0
  93. package/packages/components/global-components/sh-icon/icon-default.vue +32 -0
  94. package/packages/components/global-components/sh-icon/{icons.vue → icon-font.vue} +32 -32
  95. package/packages/components/global-components/sh-icon/index.vue +28 -27
  96. package/packages/components/global-components/sh-image/index.vue +123 -0
  97. package/packages/components/global-components/sh-list/index.vue +141 -0
  98. package/packages/components/global-components/sh-loading/index.vue +49 -42
  99. package/packages/components/global-components/{sh-vxe-modal → sh-modal}/index.vue +209 -209
  100. package/packages/components/global-components/sh-noticebar/index.vue +201 -201
  101. package/packages/components/global-components/sh-poptip/index.vue +479 -0
  102. package/packages/components/global-components/sh-poptip/popper.js +115 -0
  103. package/packages/components/global-components/sh-progress/index.vue +290 -0
  104. package/packages/components/global-components/sh-pull-refresh/index.vue +290 -290
  105. package/packages/components/global-components/{sh-vxe-query → sh-query}/index.vue +317 -310
  106. package/packages/components/global-components/sh-result/index.vue +110 -88
  107. package/packages/components/global-components/sh-row/css/index.scss +21 -0
  108. package/packages/components/global-components/sh-row/index.vue +63 -0
  109. package/packages/components/global-components/sh-split/components/trigger.vue +33 -0
  110. package/packages/components/global-components/sh-split/index.vue +334 -142
  111. package/packages/components/global-components/sh-table/components/importModal.vue +351 -0
  112. package/packages/components/global-components/{sh-vxe-table → sh-table}/css/index.scss +4 -22
  113. package/packages/components/global-components/{sh-vxe-table → sh-table}/index.vue +329 -351
  114. package/packages/components/global-components/{sh-vxe-table → sh-table}/js/methods.js +33 -88
  115. package/packages/components/global-components/{sh-vxe-table → sh-table}/js/props.js +304 -313
  116. package/packages/components/global-components/{sh-vxe-table → sh-table}/mixin/defaultData.js +94 -116
  117. package/packages/components/global-components/sh-tabs/index.vue +322 -0
  118. package/packages/components/global-components/sh-tag/index.vue +163 -0
  119. package/packages/components/global-components/{sh-vxe-toolbar → sh-toolbar}/index.vue +177 -172
  120. package/packages/components/global-components/sh-tree/components/table-tree.vue +280 -0
  121. package/packages/components/global-components/sh-tree/css/index.scss +54 -0
  122. package/packages/components/global-components/sh-tree/index.vue +195 -0
  123. package/packages/components/global-components/sh-tree/mixin/treeProps.js +124 -0
  124. package/packages/components/global-components/sh-upload/index.vue +278 -275
  125. package/packages/components/global-components/sh-water-fall/index.vue +87 -87
  126. package/packages/components/index.js +85 -59
  127. package/packages/components/other-components/sh-cron-modal/css/index.scss +2 -2
  128. package/packages/components/other-components/sh-menu-card/index.vue +224 -224
  129. package/packages/css/index.js +4 -6
  130. package/packages/directive/index.js +19 -19
  131. package/packages/directive/module/click-out.js +14 -0
  132. package/packages/directive/module/draggable.js +42 -42
  133. package/packages/directive/module/line-clamp.js +22 -0
  134. package/packages/directive/module/prevent-click.js +18 -0
  135. package/packages/directive/module/resize.js +19 -0
  136. package/packages/directive/module/ripple.js +166 -0
  137. package/packages/index.js +39 -40
  138. package/packages/utils/transfer-queue.js +12 -0
  139. package/packages/vxeTable/css/index.scss +12 -98
  140. package/packages/vxeTable/css/variable.scss +7 -265
  141. package/packages/vxeTable/index.js +184 -183
  142. package/packages/vxeTable/plugins/export.js +450 -0
  143. package/packages/vxeTable/render/cell/vxe-render-checkgroup.vue +36 -36
  144. package/packages/vxeTable/render/cell/vxe-render-goption.vue +94 -93
  145. package/packages/vxeTable/render/cell/vxe-render-img.vue +21 -28
  146. package/packages/vxeTable/render/cell/vxe-render-input.vue +51 -51
  147. package/packages/vxeTable/render/cell/vxe-render-progress.vue +19 -19
  148. package/packages/vxeTable/render/cell/vxe-render-radiogroup.vue +36 -36
  149. package/packages/vxeTable/render/cell/vxe-render-select.vue +36 -36
  150. package/packages/vxeTable/render/cell/vxe-render-tree.vue +59 -59
  151. package/packages/vxeTable/render/globalRenders.jsx +498 -491
  152. package/packages/assets/icons/demo.css +0 -539
  153. package/packages/assets/icons/iconfont.css +0 -415
  154. package/packages/assets/icons/iconfont.js +0 -1
  155. package/packages/assets/icons/iconfont.json +0 -709
  156. package/packages/assets/icons/iconfont.ttf +0 -0
  157. package/packages/assets/icons/iconfont.woff +0 -0
  158. package/packages/assets/icons/iconfont.woff2 +0 -0
  159. package/packages/assets/img/image-error.png +0 -0
  160. package/packages/assets/img/square-image.png +0 -0
  161. package/packages/components/global-components/sh-iv-form/components/iv-group-item.vue +0 -57
  162. package/packages/components/global-components/sh-iv-form/components/iv-single-item.vue +0 -76
  163. package/packages/components/global-components/sh-iv-form/index.vue +0 -255
  164. package/packages/components/global-components/sh-vxe-list/index.vue +0 -149
  165. package/packages/components/global-components/sh-vxe-table/components/importModal.vue +0 -377
  166. package/packages/components/global-components/sh-vxe-tree/components/table-tree.vue +0 -233
  167. package/packages/components/global-components/sh-vxe-tree/css/index.scss +0 -20
  168. package/packages/components/global-components/sh-vxe-tree/index.vue +0 -85
  169. package/packages/components/global-components/sh-vxe-tree/js/props.js +0 -120
  170. package/packages/components/global-components/sh-vxe-tree/js/treeMethods.js +0 -169
  171. package/packages/components/global-components/sh-vxe-tree/mixin/defaultData.js +0 -54
  172. package/packages/components/global-components/sh-vxe-tree/vxe-direct-tree.vue +0 -203
  173. package/packages/components/global-components/sh-vxe-tree/vxe-select-tree.vue +0 -291
  174. package/packages/components/other-components/sh-markdown/tinymce/langs/ar.js +0 -7
  175. package/packages/components/other-components/sh-markdown/tinymce/langs/az.js +0 -7
  176. package/packages/components/other-components/sh-markdown/tinymce/langs/bg_BG.js +0 -7
  177. package/packages/components/other-components/sh-markdown/tinymce/langs/bn_BD.js +0 -7
  178. package/packages/components/other-components/sh-markdown/tinymce/langs/ca.js +0 -7
  179. package/packages/components/other-components/sh-markdown/tinymce/langs/cs.js +0 -7
  180. package/packages/components/other-components/sh-markdown/tinymce/langs/cy.js +0 -7
  181. package/packages/components/other-components/sh-markdown/tinymce/langs/da.js +0 -7
  182. package/packages/components/other-components/sh-markdown/tinymce/langs/de.js +0 -7
  183. package/packages/components/other-components/sh-markdown/tinymce/langs/dv.js +0 -7
  184. package/packages/components/other-components/sh-markdown/tinymce/langs/el.js +0 -7
  185. package/packages/components/other-components/sh-markdown/tinymce/langs/eo.js +0 -7
  186. package/packages/components/other-components/sh-markdown/tinymce/langs/es.js +0 -7
  187. package/packages/components/other-components/sh-markdown/tinymce/langs/es_MX.js +0 -7
  188. package/packages/components/other-components/sh-markdown/tinymce/langs/et.js +0 -7
  189. package/packages/components/other-components/sh-markdown/tinymce/langs/eu.js +0 -7
  190. package/packages/components/other-components/sh-markdown/tinymce/langs/fa.js +0 -7
  191. package/packages/components/other-components/sh-markdown/tinymce/langs/fi.js +0 -7
  192. package/packages/components/other-components/sh-markdown/tinymce/langs/fr_FR.js +0 -7
  193. package/packages/components/other-components/sh-markdown/tinymce/langs/ga.js +0 -7
  194. package/packages/components/other-components/sh-markdown/tinymce/langs/gl.js +0 -7
  195. package/packages/components/other-components/sh-markdown/tinymce/langs/he_IL.js +0 -7
  196. package/packages/components/other-components/sh-markdown/tinymce/langs/hi.js +0 -7
  197. package/packages/components/other-components/sh-markdown/tinymce/langs/hr.js +0 -7
  198. package/packages/components/other-components/sh-markdown/tinymce/langs/hu_HU.js +0 -7
  199. package/packages/components/other-components/sh-markdown/tinymce/langs/hy.js +0 -7
  200. package/packages/components/other-components/sh-markdown/tinymce/langs/id.js +0 -7
  201. package/packages/components/other-components/sh-markdown/tinymce/langs/is_IS.js +0 -7
  202. package/packages/components/other-components/sh-markdown/tinymce/langs/it.js +0 -7
  203. package/packages/components/other-components/sh-markdown/tinymce/langs/ja.js +0 -7
  204. package/packages/components/other-components/sh-markdown/tinymce/langs/kab.js +0 -7
  205. package/packages/components/other-components/sh-markdown/tinymce/langs/kk.js +0 -7
  206. package/packages/components/other-components/sh-markdown/tinymce/langs/ko_KR.js +0 -7
  207. package/packages/components/other-components/sh-markdown/tinymce/langs/ku.js +0 -7
  208. package/packages/components/other-components/sh-markdown/tinymce/langs/lt.js +0 -7
  209. package/packages/components/other-components/sh-markdown/tinymce/langs/lv.js +0 -7
  210. package/packages/components/other-components/sh-markdown/tinymce/langs/nb_NO.js +0 -7
  211. package/packages/components/other-components/sh-markdown/tinymce/langs/ne.js +0 -7
  212. package/packages/components/other-components/sh-markdown/tinymce/langs/nl.js +0 -7
  213. package/packages/components/other-components/sh-markdown/tinymce/langs/nl_BE.js +0 -7
  214. package/packages/components/other-components/sh-markdown/tinymce/langs/oc.js +0 -7
  215. package/packages/components/other-components/sh-markdown/tinymce/langs/pl.js +0 -7
  216. package/packages/components/other-components/sh-markdown/tinymce/langs/pt_BR.js +0 -7
  217. package/packages/components/other-components/sh-markdown/tinymce/langs/ro.js +0 -7
  218. package/packages/components/other-components/sh-markdown/tinymce/langs/ru.js +0 -7
  219. package/packages/components/other-components/sh-markdown/tinymce/langs/sk.js +0 -7
  220. package/packages/components/other-components/sh-markdown/tinymce/langs/sl_SI.js +0 -7
  221. package/packages/components/other-components/sh-markdown/tinymce/langs/sq.js +0 -7
  222. package/packages/components/other-components/sh-markdown/tinymce/langs/sr.js +0 -7
  223. package/packages/components/other-components/sh-markdown/tinymce/langs/sv_SE.js +0 -7
  224. package/packages/components/other-components/sh-markdown/tinymce/langs/ta.js +0 -7
  225. package/packages/components/other-components/sh-markdown/tinymce/langs/tg.js +0 -7
  226. package/packages/components/other-components/sh-markdown/tinymce/langs/th_TH.js +0 -7
  227. package/packages/components/other-components/sh-markdown/tinymce/langs/tr.js +0 -7
  228. package/packages/components/other-components/sh-markdown/tinymce/langs/ug.js +0 -7
  229. package/packages/components/other-components/sh-markdown/tinymce/langs/uk.js +0 -7
  230. package/packages/components/other-components/sh-markdown/tinymce/langs/vi.js +0 -7
  231. package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.css +0 -72
  232. package/packages/components/other-components/sh-markdown/tinymce/skins/content/dark/content.min.css +0 -7
  233. package/packages/components/other-components/sh-markdown/tinymce/skins/content/default/content.min.css +0 -7
  234. package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.css +0 -72
  235. package/packages/components/other-components/sh-markdown/tinymce/skins/content/document/content.min.css +0 -7
  236. package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.css +0 -68
  237. package/packages/components/other-components/sh-markdown/tinymce/skins/content/writer/content.min.css +0 -7
  238. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.css +0 -714
  239. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.css +0 -726
  240. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.inline.min.css +0 -7
  241. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.min.css +0 -7
  242. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.css +0 -29
  243. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/content.mobile.min.css +0 -7
  244. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
  245. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.css +0 -3047
  246. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.min.css +0 -7
  247. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.css +0 -673
  248. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.mobile.min.css +0 -7
  249. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.css +0 -37
  250. package/packages/components/other-components/sh-markdown/tinymce/skins/ui/oxide-dark/skin.shadowdom.min.css +0 -7
  251. package/packages/directive/directives.js +0 -27
  252. package/packages/iview/css/index.scss +0 -32
  253. package/packages/iview/index.js +0 -25
  254. /package/packages/components/global-components/{sh-vxe-form → sh-form}/components/form-item.vue +0 -0
  255. /package/packages/components/global-components/{sh-vxe-form → sh-form}/js/props.js +0 -0
  256. /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>