create-weapp-vite 2.0.77 → 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 (42) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/{src-6A45YX6O.js → src-CCWjAwFU.js} +3 -3
  4. package/package.json +1 -1
  5. package/templates/default/.vscode/settings.json +69 -0
  6. package/templates/default/src/components/HelloWorld/HelloWorld.ts +4 -2
  7. package/templates/default/src/pages/index/index.ts +4 -2
  8. package/templates/default/src/pages/layouts/index.ts +3 -2
  9. package/templates/lib/.vscode/settings.json +69 -0
  10. package/templates/lib/package.json +1 -1
  11. package/templates/lib/src/components/HelloWorld/HelloWorld.ts +4 -2
  12. package/templates/lib/src/pages/index/index.ts +4 -2
  13. package/templates/lib/src/pages/layouts/index.ts +3 -2
  14. package/templates/tailwindcss/.vscode/settings.json +69 -0
  15. package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +4 -2
  16. package/templates/tailwindcss/src/pages/index/index.ts +4 -3
  17. package/templates/tailwindcss/src/pages/layouts/index.ts +3 -2
  18. package/templates/tdesign/.vscode/settings.json +69 -0
  19. package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +4 -2
  20. package/templates/tdesign/src/pages/index/index.ts +4 -3
  21. package/templates/tdesign/src/pages/layouts/index.ts +3 -2
  22. package/templates/vant/.vscode/settings.json +69 -0
  23. package/templates/vant/src/components/HelloWorld/HelloWorld.ts +4 -2
  24. package/templates/vant/src/pages/index/index.ts +4 -3
  25. package/templates/vant/src/pages/layouts/index.scss +1 -1
  26. package/templates/vant/src/pages/layouts/index.ts +3 -2
  27. package/templates/vant/src/pages/layouts/index.wxml +17 -5
  28. package/templates/wevu/.vscode/settings.json +69 -0
  29. package/templates/wevu/src/app.vue +10 -7
  30. package/templates/wevu-tdesign/.vscode/settings.json +69 -0
  31. package/templates/wevu-tdesign/src/app.vue +6 -3
  32. package/templates/wevu-tdesign/src/components/FilterBar/index.vue +3 -2
  33. package/templates/wevu-tdesign/src/hooks/usePullDownRefresh.ts +6 -5
  34. package/templates/wevu-tdesign/src/pages/ability/index.vue +59 -55
  35. package/templates/wevu-tdesign/src/pages/data/index.vue +3 -2
  36. package/templates/wevu-tdesign/src/pages/form/index.vue +2 -20
  37. package/templates/wevu-tdesign/src/pages/index/index.vue +4 -3
  38. package/templates/wevu-tdesign/src/pages/layouts/index.vue +5 -4
  39. package/templates/wevu-tdesign/src/subpackages/ability/index.vue +4 -7
  40. package/templates/wevu-tdesign/src/subpackages/lab/class-binding/index.vue +5 -24
  41. package/templates/wevu-tdesign/src/subpackages/lab/index.vue +12 -10
  42. package/templates/wevu-tdesign/src/utils/changeEvent.ts +53 -0
@@ -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"
@@ -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"
@@ -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
  }
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { wpi } from '@wevu/api'
2
3
  import { ref } from 'wevu'
3
4
 
4
5
  import SectionTitle from '@/components/SectionTitle/index.vue'
@@ -43,57 +44,56 @@ const capabilityCards = ref([
43
44
 
44
45
  const subscribeTemplateId = ''
45
46
 
46
- function handleCapability(key: string) {
47
- switch (key) {
48
- case 'scan':
49
- wx.scanCode({
50
- success: (result) => {
51
- showToast(`识别结果:${result.result || '已完成'}`)
52
- },
53
- fail: () => {
54
- showToast('扫码失败,请重试', 'warning')
55
- },
56
- })
57
- break
58
- case 'location':
59
- wx.getLocation({
60
- type: 'wgs84',
61
- success: (result) => {
62
- showToast(`定位成功:${result.latitude.toFixed(2)}, ${result.longitude.toFixed(2)}`)
63
- },
64
- fail: () => {
65
- showToast('未获取定位权限', 'warning')
66
- },
67
- })
68
- break
69
- case 'clipboard':
70
- wx.setClipboardData({
71
- data: 'weapp-vite + wevu + TDesign',
72
- success: () => showToast('已写入剪贴板'),
73
- })
74
- break
75
- case 'share':
76
- wx.showShareMenu({
77
- withShareTicket: true,
78
- success: () => showToast('已开启分享菜单'),
79
- fail: () => showToast('分享菜单开启失败', 'warning'),
80
- })
81
- break
82
- case 'image':
83
- wx.chooseImage({
84
- count: 3,
85
- success: (result) => {
86
- showToast(`已选择 ${result.tempFilePaths.length} 张图片`)
87
- },
88
- fail: () => showToast('未选择图片', 'warning'),
89
- })
90
- break
91
- default:
92
- break
47
+ async function handleCapability(key: string) {
48
+ try {
49
+ switch (key) {
50
+ case 'scan': {
51
+ const result = await wpi.scanCode()
52
+ showToast(`识别结果:${result.result || '已完成'}`)
53
+ break
54
+ }
55
+ case 'location': {
56
+ const result = await wpi.getLocation({
57
+ type: 'wgs84',
58
+ })
59
+ showToast(`定位成功:${result.latitude.toFixed(2)}, ${result.longitude.toFixed(2)}`)
60
+ break
61
+ }
62
+ case 'clipboard':
63
+ await wpi.setClipboardData({
64
+ data: 'weapp-vite + wevu + TDesign',
65
+ })
66
+ showToast('已写入剪贴板')
67
+ break
68
+ case 'share':
69
+ await wpi.showShareMenu({
70
+ withShareTicket: true,
71
+ })
72
+ showToast('已开启分享菜单')
73
+ break
74
+ case 'image': {
75
+ const result = await wpi.chooseImage({
76
+ count: 3,
77
+ })
78
+ showToast(`已选择 ${result.tempFilePaths.length} 张图片`)
79
+ break
80
+ }
81
+ default:
82
+ break
83
+ }
84
+ }
85
+ catch {
86
+ const warningMap: Record<string, string> = {
87
+ scan: '扫码失败,请重试',
88
+ location: '未获取定位权限',
89
+ share: '分享菜单开启失败',
90
+ image: '未选择图片',
91
+ }
92
+ showToast(warningMap[key] || '操作失败,请重试', 'warning')
93
93
  }
94
94
  }
95
95
 
96
- function requestSubscribe() {
96
+ async function requestSubscribe() {
97
97
  if (!subscribeTemplateId) {
98
98
  alert({
99
99
  title: '订阅消息',
@@ -102,15 +102,19 @@ function requestSubscribe() {
102
102
  })
103
103
  return
104
104
  }
105
- wx.requestSubscribeMessage({
106
- tmplIds: [subscribeTemplateId],
107
- success: () => showToast('订阅成功'),
108
- fail: () => showToast('订阅失败', 'warning'),
109
- })
105
+ try {
106
+ await wpi.requestSubscribeMessage({
107
+ tmplIds: [subscribeTemplateId],
108
+ })
109
+ showToast('订阅成功')
110
+ }
111
+ catch {
112
+ showToast('订阅失败', 'warning')
113
+ }
110
114
  }
111
115
 
112
- function navigateTo(url: string) {
113
- wx.navigateTo({
116
+ async function navigateTo(url: string) {
117
+ await wpi.navigateTo({
114
118
  url,
115
119
  })
116
120
  }
@@ -4,6 +4,7 @@ import { computed, ref, watch } from 'wevu'
4
4
  import KpiBoard from '@/components/KpiBoard/index.vue'
5
5
  import SectionTitle from '@/components/SectionTitle/index.vue'
6
6
  import TrendCard from '@/components/TrendCard/index.vue'
7
+ import { resolveStringChangeValue } from '@/utils/changeEvent'
7
8
 
8
9
  definePageJson({
9
10
  navigationBarTitleText: '数据',
@@ -91,8 +92,8 @@ const reportLines = computed(() => [
91
92
  '重点事项:提升转化 > 优化留存',
92
93
  ])
93
94
 
94
- function onRangeChange(e: WechatMiniprogram.CustomEvent<{ value: string }>) {
95
- activeRange.value = e.detail.value
95
+ function onRangeChange(event: unknown) {
96
+ activeRange.value = resolveStringChangeValue(event, activeRange.value)
96
97
  }
97
98
 
98
99
  watch(activeRange, () => {
@@ -9,6 +9,7 @@ import ResultCard from '@/components/ResultCard/index.vue'
9
9
  import SectionTitle from '@/components/SectionTitle/index.vue'
10
10
  import { useFormBinder } from '@/hooks/useFormBinder'
11
11
  import { useToast } from '@/hooks/useToast'
12
+ import { resolveBooleanChangeValue } from '@/utils/changeEvent'
12
13
 
13
14
  definePageJson({
14
15
  navigationBarTitleText: '表单',
@@ -79,25 +80,6 @@ const summaryRows = computed(() => [
79
80
  { label: '风险级别', value: riskLevel.value },
80
81
  ])
81
82
 
82
- function resolveSwitchValue(event: unknown, fallback: boolean) {
83
- if (typeof event === 'boolean') {
84
- return event
85
- }
86
- if (event && typeof event === 'object') {
87
- const payload = event as Record<string, any>
88
- if (typeof payload.detail === 'boolean') {
89
- return payload.detail
90
- }
91
- if (payload.detail && typeof payload.detail === 'object' && typeof payload.detail.value === 'boolean') {
92
- return payload.detail.value
93
- }
94
- if (typeof payload.value === 'boolean') {
95
- return payload.value
96
- }
97
- }
98
- return fallback
99
- }
100
-
101
83
  watch(
102
84
  () => formState.urgent,
103
85
  (value) => {
@@ -127,7 +109,7 @@ function toggleUrgent() {
127
109
  }
128
110
 
129
111
  function handleUrgentChange(event: unknown) {
130
- setUrgent(resolveSwitchValue(event, !formState.urgent))
112
+ setUrgent(resolveBooleanChangeValue(event, !formState.urgent))
131
113
  }
132
114
 
133
115
  function stopUrgentTap() {
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { QuickActionItem } from '@/types/action'
3
3
 
4
+ import { wpi } from '@wevu/api'
4
5
  import { computed, getCurrentInstance, ref, resolveLayoutBridge, resolveLayoutHost, watch } from 'wevu'
5
6
  import KpiBoard from '@/components/KpiBoard/index.vue'
6
7
  import QuickActionGrid from '@/components/QuickActionGrid/index.vue'
@@ -218,18 +219,18 @@ void runLayoutToastE2E
218
219
 
219
220
  usePullDownRefresh(refreshDashboard)
220
221
 
221
- function onQuickAction(action: QuickActionItem) {
222
+ async function onQuickAction(action: QuickActionItem) {
222
223
  if (!action.path) {
223
224
  showToast('该入口暂未配置')
224
225
  return
225
226
  }
226
227
  if (action.type === 'tab') {
227
- wx.switchTab({
228
+ await wpi.switchTab({
228
229
  url: action.path,
229
230
  })
230
231
  return
231
232
  }
232
- wx.navigateTo({
233
+ await wpi.navigateTo({
233
234
  url: action.path,
234
235
  })
235
236
  }
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { wpi } from '@wevu/api'
2
3
  import { ref, setPageLayout } from 'wevu'
3
4
 
4
5
  import SectionTitle from '@/components/SectionTitle/index.vue'
@@ -51,14 +52,14 @@ function clearLayout() {
51
52
  showToast('已关闭布局')
52
53
  }
53
54
 
54
- function openLayoutFeedbackDemo() {
55
- wx.navigateTo({
55
+ async function openLayoutFeedbackDemo() {
56
+ await wpi.navigateTo({
56
57
  url: '/pages/layout-feedback/index',
57
58
  })
58
59
  }
59
60
 
60
- function openLayoutStoreDemo() {
61
- wx.navigateTo({
61
+ async function openLayoutStoreDemo() {
62
+ await wpi.navigateTo({
62
63
  url: '/pages/layout-store/index',
63
64
  })
64
65
  }
@@ -1,4 +1,5 @@
1
1
  <script setup lang="ts">
2
+ import { wpi } from '@wevu/api'
2
3
  import { computed, onShow, ref } from 'wevu'
3
4
 
4
5
  import SectionTitle from '@/components/SectionTitle/index.vue'
@@ -32,16 +33,12 @@ const layoutRows = computed(() => {
32
33
  ]
33
34
  })
34
35
 
35
- function loadSystemInfo() {
36
- wx.getSystemInfo({
37
- success: (result) => {
38
- systemInfo.value = result
39
- },
40
- })
36
+ async function loadSystemInfo() {
37
+ systemInfo.value = await wpi.getSystemInfo()
41
38
  }
42
39
 
43
40
  onShow(() => {
44
- loadSystemInfo()
41
+ void loadSystemInfo()
45
42
  })
46
43
  </script>
47
44
 
@@ -2,6 +2,7 @@
2
2
  import { computed, reactive, ref, watch } from 'wevu'
3
3
 
4
4
  import SectionTitle from '@/components/SectionTitle/index.vue'
5
+ import { resolveBooleanChangeValue } from '@/utils/changeEvent'
5
6
 
6
7
  definePageJson({
7
8
  navigationBarTitleText: 'Class 绑定',
@@ -13,40 +14,20 @@ const hasError = ref(false)
13
14
  const isRound = ref(false)
14
15
  const isGhost = ref(false)
15
16
 
16
- function resolveSwitchValue(event: unknown, fallback: boolean) {
17
- if (typeof event === 'boolean') {
18
- return event
19
- }
20
- if (event && typeof event === 'object') {
21
- const payload = event as Record<string, any>
22
- const detail = payload.detail
23
- if (typeof detail === 'boolean') {
24
- return detail
25
- }
26
- if (detail && typeof detail === 'object' && typeof detail.value === 'boolean') {
27
- return detail.value
28
- }
29
- if (typeof payload.value === 'boolean') {
30
- return payload.value
31
- }
32
- }
33
- return fallback
34
- }
35
-
36
17
  function onActiveChange(event: unknown) {
37
- isActive.value = resolveSwitchValue(event, !isActive.value)
18
+ isActive.value = resolveBooleanChangeValue(event, !isActive.value)
38
19
  }
39
20
 
40
21
  function onErrorChange(event: unknown) {
41
- hasError.value = resolveSwitchValue(event, !hasError.value)
22
+ hasError.value = resolveBooleanChangeValue(event, !hasError.value)
42
23
  }
43
24
 
44
25
  function onRoundChange(event: unknown) {
45
- isRound.value = resolveSwitchValue(event, !isRound.value)
26
+ isRound.value = resolveBooleanChangeValue(event, !isRound.value)
46
27
  }
47
28
 
48
29
  function onGhostChange(event: unknown) {
49
- isGhost.value = resolveSwitchValue(event, !isGhost.value)
30
+ isGhost.value = resolveBooleanChangeValue(event, !isGhost.value)
50
31
  }
51
32
 
52
33
  const classObject = reactive({