create-weapp-vite 2.0.76 → 2.0.78

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 (49) hide show
  1. package/README.md +16 -0
  2. package/dist/cli.js +28 -5
  3. package/dist/index.d.ts +5 -2
  4. package/dist/index.js +1 -1
  5. package/dist/{src-BhGRh_fC.js → src-CCWjAwFU.js} +67 -12
  6. package/package.json +3 -3
  7. package/templates/default/.vscode/settings.json +69 -0
  8. package/templates/default/project.config.json +1 -1
  9. package/templates/default/src/components/HelloWorld/HelloWorld.ts +4 -2
  10. package/templates/default/src/pages/index/index.ts +4 -2
  11. package/templates/default/src/pages/layouts/index.ts +3 -2
  12. package/templates/lib/.vscode/settings.json +69 -0
  13. package/templates/lib/package.json +1 -1
  14. package/templates/lib/src/components/HelloWorld/HelloWorld.ts +4 -2
  15. package/templates/lib/src/pages/index/index.ts +4 -2
  16. package/templates/lib/src/pages/layouts/index.ts +3 -2
  17. package/templates/tailwindcss/.vscode/settings.json +69 -0
  18. package/templates/tailwindcss/project.config.json +1 -1
  19. package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +4 -2
  20. package/templates/tailwindcss/src/pages/index/index.ts +4 -3
  21. package/templates/tailwindcss/src/pages/layouts/index.ts +3 -2
  22. package/templates/tdesign/.vscode/settings.json +69 -0
  23. package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +4 -2
  24. package/templates/tdesign/src/pages/index/index.ts +4 -3
  25. package/templates/tdesign/src/pages/layouts/index.ts +3 -2
  26. package/templates/vant/.vscode/settings.json +69 -0
  27. package/templates/vant/project.config.json +1 -1
  28. package/templates/vant/src/components/HelloWorld/HelloWorld.ts +4 -2
  29. package/templates/vant/src/pages/index/index.ts +4 -3
  30. package/templates/vant/src/pages/layouts/index.scss +1 -1
  31. package/templates/vant/src/pages/layouts/index.ts +3 -2
  32. package/templates/vant/src/pages/layouts/index.wxml +17 -5
  33. package/templates/wevu/.vscode/settings.json +69 -0
  34. package/templates/wevu/project.config.json +1 -1
  35. package/templates/wevu/src/app.vue +10 -7
  36. package/templates/wevu-tdesign/.vscode/settings.json +69 -0
  37. package/templates/wevu-tdesign/project.config.json +1 -1
  38. package/templates/wevu-tdesign/src/app.vue +6 -3
  39. package/templates/wevu-tdesign/src/components/FilterBar/index.vue +3 -2
  40. package/templates/wevu-tdesign/src/hooks/usePullDownRefresh.ts +6 -5
  41. package/templates/wevu-tdesign/src/pages/ability/index.vue +59 -55
  42. package/templates/wevu-tdesign/src/pages/data/index.vue +3 -2
  43. package/templates/wevu-tdesign/src/pages/form/index.vue +2 -20
  44. package/templates/wevu-tdesign/src/pages/index/index.vue +4 -3
  45. package/templates/wevu-tdesign/src/pages/layouts/index.vue +5 -4
  46. package/templates/wevu-tdesign/src/subpackages/ability/index.vue +4 -7
  47. package/templates/wevu-tdesign/src/subpackages/lab/class-binding/index.vue +5 -24
  48. package/templates/wevu-tdesign/src/subpackages/lab/index.vue +12 -10
  49. package/templates/wevu-tdesign/src/utils/changeEvent.ts +53 -0
@@ -1,3 +1,4 @@
1
+ import { wpi } from '@wevu/api'
1
2
  import { hello } from '@/utils/util'
2
3
 
3
4
  Page({
@@ -34,7 +35,7 @@ Page({
34
35
  },
35
36
  async copy(e: WechatMiniprogram.BaseEvent) {
36
37
  if (e.mark?.url) {
37
- await wx.setClipboardData({
38
+ await wpi.setClipboardData({
38
39
  data: e.mark.url,
39
40
  })
40
41
  // eslint-disable-next-line no-console
@@ -45,8 +46,8 @@ Page({
45
46
  // eslint-disable-next-line no-console
46
47
  console.log(hello())
47
48
  },
48
- goToLayouts() {
49
- wx.navigateTo({
49
+ async goToLayouts() {
50
+ await wpi.navigateTo({
50
51
  url: '/pages/layouts/index',
51
52
  })
52
53
  },
@@ -1,3 +1,4 @@
1
+ import { wpi } from '@wevu/api'
1
2
  import { setPageLayout } from 'weapp-vite/runtime'
2
3
 
3
4
  Page({
@@ -27,7 +28,7 @@ Page({
27
28
  this.setData({ currentLayout: 'none' })
28
29
  setPageLayout(false)
29
30
  },
30
- backHome() {
31
- wx.switchTab({ url: '/pages/index/index' })
31
+ async backHome() {
32
+ await wpi.switchTab({ url: '/pages/index/index' })
32
33
  },
33
34
  })
@@ -1,4 +1,73 @@
1
1
  {
2
+ "prettier.enable": false,
3
+ "editor.formatOnSave": false,
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll.eslint": "explicit",
6
+ "source.organizeImports": "never"
7
+ },
8
+ "eslint.rules.customizations": [
9
+ {
10
+ "rule": "format/*",
11
+ "severity": "off"
12
+ },
13
+ {
14
+ "rule": "*-indent",
15
+ "severity": "off"
16
+ },
17
+ {
18
+ "rule": "*-spacing",
19
+ "severity": "off"
20
+ },
21
+ {
22
+ "rule": "*-spaces",
23
+ "severity": "off"
24
+ },
25
+ {
26
+ "rule": "*-order",
27
+ "severity": "off"
28
+ },
29
+ {
30
+ "rule": "*-dangle",
31
+ "severity": "off"
32
+ },
33
+ {
34
+ "rule": "*-newline",
35
+ "severity": "off"
36
+ },
37
+ {
38
+ "rule": "*quotes",
39
+ "severity": "off"
40
+ },
41
+ {
42
+ "rule": "*semi",
43
+ "severity": "off"
44
+ }
45
+ ],
46
+ "eslint.validate": [
47
+ "javascript",
48
+ "javascriptreact",
49
+ "typescript",
50
+ "typescriptreact",
51
+ "vue",
52
+ "html",
53
+ "markdown",
54
+ "json",
55
+ "jsonc",
56
+ "yaml",
57
+ "toml",
58
+ "xml",
59
+ "gql",
60
+ "graphql",
61
+ "astro",
62
+ "css",
63
+ "less",
64
+ "scss",
65
+ "pcss",
66
+ "postcss"
67
+ ],
68
+ "css.validate": false,
69
+ "less.validate": false,
70
+ "scss.validate": false,
2
71
  "files.associations": {
3
72
  "*.wxml": "html",
4
73
  "*.wxss": "css"
@@ -1,3 +1,5 @@
1
+ import { wpi } from '@wevu/api'
2
+
1
3
  interface HelloWorldLink {
2
4
  text: string
3
5
  url: string
@@ -48,8 +50,8 @@ Component({
48
50
  }
49
51
 
50
52
  try {
51
- await wx.setClipboardData({ data: url })
52
- wx.showToast({
53
+ await wpi.setClipboardData({ data: url })
54
+ await wpi.showToast({
53
55
  title: '链接已复制',
54
56
  icon: 'success',
55
57
  duration: 1500,
@@ -1,3 +1,4 @@
1
+ import { wpi } from '@wevu/api'
1
2
  import ActionSheet, { ActionSheetTheme } from 'tdesign-miniprogram/action-sheet/index'
2
3
  import { hello } from '@/utils/util'
3
4
 
@@ -69,7 +70,7 @@ Page({
69
70
  },
70
71
  async copy(e: WechatMiniprogram.BaseEvent) {
71
72
  if (e.mark?.url) {
72
- await wx.setClipboardData({
73
+ await wpi.setClipboardData({
73
74
  data: e.mark.url,
74
75
  })
75
76
  // eslint-disable-next-line no-console
@@ -84,8 +85,8 @@ Page({
84
85
  // eslint-disable-next-line no-console
85
86
  console.log(hello())
86
87
  },
87
- goToLayouts() {
88
- wx.navigateTo({
88
+ async goToLayouts() {
89
+ await wpi.navigateTo({
89
90
  url: '/pages/layouts/index',
90
91
  })
91
92
  },
@@ -1,3 +1,4 @@
1
+ import { wpi } from '@wevu/api'
1
2
  import Toast from 'tdesign-miniprogram/toast/index'
2
3
  import { setPageLayout } from 'weapp-vite/runtime'
3
4
 
@@ -26,7 +27,7 @@ Page({
26
27
  setPageLayout(false)
27
28
  Toast({ context: this, selector: '#t-toast', message: '已关闭布局' })
28
29
  },
29
- backHome() {
30
- wx.navigateTo({ url: '/pages/index/index' })
30
+ async backHome() {
31
+ await wpi.navigateTo({ url: '/pages/index/index' })
31
32
  },
32
33
  })
@@ -1,4 +1,73 @@
1
1
  {
2
+ "prettier.enable": false,
3
+ "editor.formatOnSave": false,
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll.eslint": "explicit",
6
+ "source.organizeImports": "never"
7
+ },
8
+ "eslint.rules.customizations": [
9
+ {
10
+ "rule": "format/*",
11
+ "severity": "off"
12
+ },
13
+ {
14
+ "rule": "*-indent",
15
+ "severity": "off"
16
+ },
17
+ {
18
+ "rule": "*-spacing",
19
+ "severity": "off"
20
+ },
21
+ {
22
+ "rule": "*-spaces",
23
+ "severity": "off"
24
+ },
25
+ {
26
+ "rule": "*-order",
27
+ "severity": "off"
28
+ },
29
+ {
30
+ "rule": "*-dangle",
31
+ "severity": "off"
32
+ },
33
+ {
34
+ "rule": "*-newline",
35
+ "severity": "off"
36
+ },
37
+ {
38
+ "rule": "*quotes",
39
+ "severity": "off"
40
+ },
41
+ {
42
+ "rule": "*semi",
43
+ "severity": "off"
44
+ }
45
+ ],
46
+ "eslint.validate": [
47
+ "javascript",
48
+ "javascriptreact",
49
+ "typescript",
50
+ "typescriptreact",
51
+ "vue",
52
+ "html",
53
+ "markdown",
54
+ "json",
55
+ "jsonc",
56
+ "yaml",
57
+ "toml",
58
+ "xml",
59
+ "gql",
60
+ "graphql",
61
+ "astro",
62
+ "css",
63
+ "less",
64
+ "scss",
65
+ "pcss",
66
+ "postcss"
67
+ ],
68
+ "css.validate": false,
69
+ "less.validate": false,
70
+ "scss.validate": false,
2
71
  "files.associations": {
3
72
  "*.wxml": "html",
4
73
  "*.wxss": "css"
@@ -40,4 +40,4 @@
40
40
  "include": []
41
41
  },
42
42
  "appid": "wx6ffee4673b257014"
43
- }
43
+ }
@@ -1,3 +1,5 @@
1
+ import { wpi } from '@wevu/api'
2
+
1
3
  interface HelloWorldLink {
2
4
  text: string
3
5
  url: string
@@ -45,8 +47,8 @@ Component({
45
47
  }
46
48
 
47
49
  try {
48
- await wx.setClipboardData({ data: url })
49
- wx.showToast({
50
+ await wpi.setClipboardData({ data: url })
51
+ await wpi.showToast({
50
52
  title: '链接已复制',
51
53
  icon: 'success',
52
54
  duration: 1500,
@@ -1,4 +1,5 @@
1
1
  import Dialog from '@vant/weapp/dialog/dialog'
2
+ import { wpi } from '@wevu/api'
2
3
  import { hello } from '@/utils/util'
3
4
 
4
5
  Page({
@@ -35,7 +36,7 @@ Page({
35
36
  },
36
37
  async copy(e: WechatMiniprogram.BaseEvent) {
37
38
  if (e.mark?.url) {
38
- await wx.setClipboardData({
39
+ await wpi.setClipboardData({
39
40
  data: e.mark.url,
40
41
  })
41
42
  // eslint-disable-next-line no-console
@@ -54,8 +55,8 @@ Page({
54
55
  // eslint-disable-next-line no-console
55
56
  console.log(hello())
56
57
  },
57
- goToLayouts() {
58
- wx.navigateTo({
58
+ async goToLayouts() {
59
+ await wpi.navigateTo({
59
60
  url: '/pages/layouts/index',
60
61
  })
61
62
  },
@@ -1,3 +1,3 @@
1
- .layout-btn {
1
+ .layout-actions__item + .layout-actions__item {
2
2
  margin-top: 24rpx;
3
3
  }
@@ -1,4 +1,5 @@
1
1
  import Dialog from '@vant/weapp/dialog/dialog'
2
+ import { wpi } from '@wevu/api'
2
3
  import { setPageLayout } from 'weapp-vite/runtime'
3
4
 
4
5
  Page({
@@ -29,7 +30,7 @@ Page({
29
30
  message: `当前状态:${this.data.currentLayout}`,
30
31
  })
31
32
  },
32
- backHome() {
33
- wx.navigateTo({ url: '/pages/index/index' })
33
+ async backHome() {
34
+ await wpi.navigateTo({ url: '/pages/index/index' })
34
35
  },
35
36
  })
@@ -6,11 +6,23 @@
6
6
  </view>
7
7
 
8
8
  <view class="mt-4 rounded-2xl bg-white p-5 shadow-sm">
9
- <van-button type="primary" bind:tap="applyDefaultLayout">使用 default 布局</van-button>
10
- <van-button custom-class="layout-btn" type="danger" plain bind:tap="applyAdminLayout">切到 admin 布局</van-button>
11
- <van-button custom-class="layout-btn" type="default" plain bind:tap="clearLayout">关闭布局</van-button>
12
- <van-button custom-class="layout-btn" type="success" plain bind:tap="showState">查看当前状态</van-button>
13
- <van-button custom-class="layout-btn" type="default" bind:tap="backHome">返回首页</van-button>
9
+ <view class="layout-actions">
10
+ <view class="layout-actions__item">
11
+ <van-button block type="primary" bind:tap="applyDefaultLayout">使用 default 布局</van-button>
12
+ </view>
13
+ <view class="layout-actions__item">
14
+ <van-button block type="danger" plain bind:tap="applyAdminLayout">切到 admin 布局</van-button>
15
+ </view>
16
+ <view class="layout-actions__item">
17
+ <van-button block type="default" plain bind:tap="clearLayout">关闭布局</van-button>
18
+ </view>
19
+ <view class="layout-actions__item">
20
+ <van-button block type="success" plain bind:tap="showState">查看当前状态</van-button>
21
+ </view>
22
+ <view class="layout-actions__item">
23
+ <van-button block type="default" bind:tap="backHome">返回首页</van-button>
24
+ </view>
25
+ </view>
14
26
  </view>
15
27
 
16
28
  <van-dialog id="van-dialog" />
@@ -1,4 +1,73 @@
1
1
  {
2
+ "prettier.enable": false,
3
+ "editor.formatOnSave": false,
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll.eslint": "explicit",
6
+ "source.organizeImports": "never"
7
+ },
8
+ "eslint.rules.customizations": [
9
+ {
10
+ "rule": "format/*",
11
+ "severity": "off"
12
+ },
13
+ {
14
+ "rule": "*-indent",
15
+ "severity": "off"
16
+ },
17
+ {
18
+ "rule": "*-spacing",
19
+ "severity": "off"
20
+ },
21
+ {
22
+ "rule": "*-spaces",
23
+ "severity": "off"
24
+ },
25
+ {
26
+ "rule": "*-order",
27
+ "severity": "off"
28
+ },
29
+ {
30
+ "rule": "*-dangle",
31
+ "severity": "off"
32
+ },
33
+ {
34
+ "rule": "*-newline",
35
+ "severity": "off"
36
+ },
37
+ {
38
+ "rule": "*quotes",
39
+ "severity": "off"
40
+ },
41
+ {
42
+ "rule": "*semi",
43
+ "severity": "off"
44
+ }
45
+ ],
46
+ "eslint.validate": [
47
+ "javascript",
48
+ "javascriptreact",
49
+ "typescript",
50
+ "typescriptreact",
51
+ "vue",
52
+ "html",
53
+ "markdown",
54
+ "json",
55
+ "jsonc",
56
+ "yaml",
57
+ "toml",
58
+ "xml",
59
+ "gql",
60
+ "graphql",
61
+ "astro",
62
+ "css",
63
+ "less",
64
+ "scss",
65
+ "pcss",
66
+ "postcss"
67
+ ],
68
+ "css.validate": false,
69
+ "less.validate": false,
70
+ "scss.validate": false,
2
71
  "files.associations": {
3
72
  "*.wxml": "html",
4
73
  "*.wxss": "css"
@@ -40,4 +40,4 @@
40
40
  "include": []
41
41
  },
42
42
  "appid": "wx6ffee4673b257014"
43
- }
43
+ }
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { wpi } from '@wevu/api'
2
3
  import autoRoutes from 'weapp-vite/auto-routes'
3
4
  import { onHide, onLaunch, onShow } from 'wevu'
4
5
  import { createRouter } from 'wevu/router'
@@ -16,6 +17,8 @@ defineAppJson({
16
17
  sitemapLocation: 'sitemap.json',
17
18
  })
18
19
 
20
+ const logger = wpi.getLogManager({ level: 1 })
21
+
19
22
  const router = createRouter({
20
23
  routes: autoRoutes.entries.map(path => ({
21
24
  name: path,
@@ -24,7 +27,7 @@ const router = createRouter({
24
27
  })
25
28
 
26
29
  router.beforeEach((to, from) => {
27
- wx.getLogManager({ level: 1 }).info('[wevu-template-router] beforeEach', {
30
+ logger.info('[wevu-template-router] beforeEach', {
28
31
  to: to?.fullPath,
29
32
  from: from.fullPath,
30
33
  })
@@ -32,7 +35,7 @@ router.beforeEach((to, from) => {
32
35
  })
33
36
 
34
37
  router.beforeResolve((to, from) => {
35
- wx.getLogManager({ level: 1 }).info('[wevu-template-router] beforeResolve', {
38
+ logger.info('[wevu-template-router] beforeResolve', {
36
39
  to: to?.fullPath,
37
40
  from: from.fullPath,
38
41
  })
@@ -40,7 +43,7 @@ router.beforeResolve((to, from) => {
40
43
  })
41
44
 
42
45
  router.afterEach((to, from, failure) => {
43
- wx.getLogManager({ level: 1 }).info('[wevu-template-router] afterEach', {
46
+ logger.info('[wevu-template-router] afterEach', {
44
47
  to: to?.fullPath,
45
48
  from: from.fullPath,
46
49
  failureType: failure?.type,
@@ -48,7 +51,7 @@ router.afterEach((to, from, failure) => {
48
51
  })
49
52
 
50
53
  router.onError((error, context) => {
51
- wx.getLogManager({ level: 1 }).info('[wevu-template-router] onError', {
54
+ logger.info('[wevu-template-router] onError', {
52
55
  error: error instanceof Error ? error.message : String(error),
53
56
  mode: context.mode,
54
57
  to: context.to?.fullPath,
@@ -58,15 +61,15 @@ router.onError((error, context) => {
58
61
  })
59
62
 
60
63
  onShow(() => {
61
- wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app show')
64
+ logger.info('[weapp-vite-wevu-template] app show')
62
65
  })
63
66
 
64
67
  onHide(() => {
65
- wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app hide')
68
+ logger.info('[weapp-vite-wevu-template] app hide')
66
69
  })
67
70
 
68
71
  onLaunch(() => {
69
- wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app launch')
72
+ logger.info('[weapp-vite-wevu-template] app launch')
70
73
  })
71
74
  </script>
72
75
 
@@ -1,4 +1,73 @@
1
1
  {
2
+ "prettier.enable": false,
3
+ "editor.formatOnSave": false,
4
+ "editor.codeActionsOnSave": {
5
+ "source.fixAll.eslint": "explicit",
6
+ "source.organizeImports": "never"
7
+ },
8
+ "eslint.rules.customizations": [
9
+ {
10
+ "rule": "format/*",
11
+ "severity": "off"
12
+ },
13
+ {
14
+ "rule": "*-indent",
15
+ "severity": "off"
16
+ },
17
+ {
18
+ "rule": "*-spacing",
19
+ "severity": "off"
20
+ },
21
+ {
22
+ "rule": "*-spaces",
23
+ "severity": "off"
24
+ },
25
+ {
26
+ "rule": "*-order",
27
+ "severity": "off"
28
+ },
29
+ {
30
+ "rule": "*-dangle",
31
+ "severity": "off"
32
+ },
33
+ {
34
+ "rule": "*-newline",
35
+ "severity": "off"
36
+ },
37
+ {
38
+ "rule": "*quotes",
39
+ "severity": "off"
40
+ },
41
+ {
42
+ "rule": "*semi",
43
+ "severity": "off"
44
+ }
45
+ ],
46
+ "eslint.validate": [
47
+ "javascript",
48
+ "javascriptreact",
49
+ "typescript",
50
+ "typescriptreact",
51
+ "vue",
52
+ "html",
53
+ "markdown",
54
+ "json",
55
+ "jsonc",
56
+ "yaml",
57
+ "toml",
58
+ "xml",
59
+ "gql",
60
+ "graphql",
61
+ "astro",
62
+ "css",
63
+ "less",
64
+ "scss",
65
+ "pcss",
66
+ "postcss"
67
+ ],
68
+ "css.validate": false,
69
+ "less.validate": false,
70
+ "scss.validate": false,
2
71
  "files.associations": {
3
72
  "*.wxml": "html",
4
73
  "*.wxss": "css"
@@ -40,4 +40,4 @@
40
40
  "include": []
41
41
  },
42
42
  "appid": "wx6ffee4673b257014"
43
- }
43
+ }
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { wpi } from '@wevu/api'
2
3
  import { onHide, onLaunch, onShow } from 'wevu'
3
4
 
4
5
  defineAppJson({
@@ -71,16 +72,18 @@ defineAppJson({
71
72
  sitemapLocation: 'sitemap.json',
72
73
  })
73
74
 
75
+ const logger = wpi.getLogManager({ level: 1 })
76
+
74
77
  onShow(() => {
75
- wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app show')
78
+ logger.info('[weapp-vite-wevu-template] app show')
76
79
  })
77
80
 
78
81
  onHide(() => {
79
- wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app hide')
82
+ logger.info('[weapp-vite-wevu-template] app hide')
80
83
  })
81
84
 
82
85
  onLaunch(() => {
83
- wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app launch')
86
+ logger.info('[weapp-vite-wevu-template] app launch')
84
87
  })
85
88
  </script>
86
89
 
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from 'wevu'
3
+ import { resolveStringChangeValue } from '@/utils/changeEvent'
3
4
 
4
5
  const props = withDefaults(defineProps<{
5
6
  query?: string
@@ -28,8 +29,8 @@ interface FilterItem {
28
29
 
29
30
  const filterItems = computed(() => (Array.isArray(props.filters) ? props.filters : []))
30
31
 
31
- function onQueryChange(e: WechatMiniprogram.CustomEvent<{ value: string }>) {
32
- emit('update:query', e.detail.value)
32
+ function onQueryChange(event: unknown) {
33
+ emit('update:query', resolveStringChangeValue(event, props.query))
33
34
  }
34
35
 
35
36
  function onSelect(value: string) {
@@ -1,11 +1,12 @@
1
+ import { wpi } from '@wevu/api'
1
2
  import { onPullDownRefresh } from 'wevu'
2
3
 
3
4
  export function usePullDownRefresh(refresh: () => void | Promise<void>) {
4
- onPullDownRefresh(() => {
5
- const result = refresh()
6
- if (result && typeof (result as Promise<void>).catch === 'function') {
7
- ;(result as Promise<void>).catch(() => {})
5
+ onPullDownRefresh(async () => {
6
+ try {
7
+ await refresh()
8
8
  }
9
- wx.stopPullDownRefresh()
9
+ catch {}
10
+ await wpi.stopPullDownRefresh()
10
11
  })
11
12
  }