create-weapp-vite 2.0.77 → 2.0.79

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 (48) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/{src-6A45YX6O.js → src-BjkgG3qb.js} +7 -7
  4. package/package.json +2 -2
  5. package/templates/default/.vscode/settings.json +69 -0
  6. package/templates/default/package.json +2 -2
  7. package/templates/default/src/components/HelloWorld/HelloWorld.ts +4 -2
  8. package/templates/default/src/pages/index/index.ts +4 -2
  9. package/templates/default/src/pages/layouts/index.ts +3 -2
  10. package/templates/lib/.vscode/settings.json +69 -0
  11. package/templates/lib/package.json +3 -3
  12. package/templates/lib/src/components/HelloWorld/HelloWorld.ts +4 -2
  13. package/templates/lib/src/pages/index/index.ts +4 -2
  14. package/templates/lib/src/pages/layouts/index.ts +3 -2
  15. package/templates/tailwindcss/.vscode/settings.json +69 -0
  16. package/templates/tailwindcss/package.json +2 -2
  17. package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +4 -2
  18. package/templates/tailwindcss/src/pages/index/index.ts +4 -3
  19. package/templates/tailwindcss/src/pages/layouts/index.ts +3 -2
  20. package/templates/tdesign/.vscode/settings.json +69 -0
  21. package/templates/tdesign/package.json +2 -2
  22. package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +4 -2
  23. package/templates/tdesign/src/pages/index/index.ts +4 -3
  24. package/templates/tdesign/src/pages/layouts/index.ts +3 -2
  25. package/templates/vant/.vscode/settings.json +69 -0
  26. package/templates/vant/package.json +2 -2
  27. package/templates/vant/src/components/HelloWorld/HelloWorld.ts +4 -2
  28. package/templates/vant/src/pages/index/index.ts +4 -3
  29. package/templates/vant/src/pages/layouts/index.scss +1 -1
  30. package/templates/vant/src/pages/layouts/index.ts +3 -2
  31. package/templates/vant/src/pages/layouts/index.wxml +17 -5
  32. package/templates/wevu/.vscode/settings.json +69 -0
  33. package/templates/wevu/package.json +2 -2
  34. package/templates/wevu/src/app.vue +10 -7
  35. package/templates/wevu-tdesign/.vscode/settings.json +69 -0
  36. package/templates/wevu-tdesign/package.json +2 -2
  37. package/templates/wevu-tdesign/src/app.vue +6 -3
  38. package/templates/wevu-tdesign/src/components/FilterBar/index.vue +3 -2
  39. package/templates/wevu-tdesign/src/hooks/usePullDownRefresh.ts +6 -5
  40. package/templates/wevu-tdesign/src/pages/ability/index.vue +59 -55
  41. package/templates/wevu-tdesign/src/pages/data/index.vue +3 -2
  42. package/templates/wevu-tdesign/src/pages/form/index.vue +2 -20
  43. package/templates/wevu-tdesign/src/pages/index/index.vue +4 -3
  44. package/templates/wevu-tdesign/src/pages/layouts/index.vue +5 -4
  45. package/templates/wevu-tdesign/src/subpackages/ability/index.vue +4 -7
  46. package/templates/wevu-tdesign/src/subpackages/lab/class-binding/index.vue +5 -24
  47. package/templates/wevu-tdesign/src/subpackages/lab/index.vue +12 -10
  48. package/templates/wevu-tdesign/src/utils/changeEvent.ts +53 -0
@@ -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({
@@ -1,7 +1,9 @@
1
1
  <script setup lang="ts">
2
+ import { wpi } from '@wevu/api'
2
3
  import { computed, ref } from 'wevu'
3
4
 
4
5
  import SectionTitle from '@/components/SectionTitle/index.vue'
6
+ import { resolveBooleanChangeValue, resolveNumberChangeValue, resolveStringChangeValue } from '@/utils/changeEvent'
5
7
 
6
8
  definePageJson({
7
9
  navigationBarTitleText: '组件实验室',
@@ -22,24 +24,24 @@ const tabs = [
22
24
  { value: 'display', label: '展示' },
23
25
  ]
24
26
 
25
- function handleTabChange(e: any) {
26
- activeTab.value = String(e.detail.value)
27
+ function handleTabChange(event: unknown) {
28
+ activeTab.value = resolveStringChangeValue(event, activeTab.value)
27
29
  }
28
30
 
29
- function handleRateChange(e: any) {
30
- rating.value = Number(e.detail.value)
31
+ function handleRateChange(event: unknown) {
32
+ rating.value = resolveNumberChangeValue(event, rating.value)
31
33
  }
32
34
 
33
- function handleSliderChange(e: any) {
34
- slider.value = Number(e.detail.value)
35
+ function handleSliderChange(event: unknown) {
36
+ slider.value = resolveNumberChangeValue(event, slider.value)
35
37
  }
36
38
 
37
- function handleToggleChange(e: any) {
38
- toggle.value = Boolean(e.detail.value)
39
+ function handleToggleChange(event: unknown) {
40
+ toggle.value = resolveBooleanChangeValue(event, !toggle.value)
39
41
  }
40
42
 
41
- function navigateTo(url: string) {
42
- wx.navigateTo({
43
+ async function navigateTo(url: string) {
44
+ await wpi.navigateTo({
43
45
  url,
44
46
  })
45
47
  }
@@ -0,0 +1,53 @@
1
+ type PrimitiveValue = string | number | boolean
2
+
3
+ function hasSameType<T extends PrimitiveValue>(value: unknown, fallback: T): value is T {
4
+ return typeof value === typeof fallback
5
+ }
6
+
7
+ /**
8
+ * @description 从小程序组件变更事件中提取值,兼容值直传、detail 直传和 detail.value 结构。
9
+ */
10
+ export function resolveChangeValue<T extends PrimitiveValue>(event: unknown, fallback: T): T {
11
+ if (hasSameType(event, fallback)) {
12
+ return event
13
+ }
14
+
15
+ if (event && typeof event === 'object') {
16
+ const payload = event as Record<string, any>
17
+ if (hasSameType(payload.value, fallback)) {
18
+ return payload.value
19
+ }
20
+
21
+ const detail = payload.detail
22
+ if (hasSameType(detail, fallback)) {
23
+ return detail
24
+ }
25
+
26
+ if (detail && typeof detail === 'object' && hasSameType(detail.value, fallback)) {
27
+ return detail.value
28
+ }
29
+ }
30
+
31
+ return fallback
32
+ }
33
+
34
+ /**
35
+ * @description 从小程序组件变更事件中提取字符串值。
36
+ */
37
+ export function resolveStringChangeValue(event: unknown, fallback = '') {
38
+ return resolveChangeValue(event, fallback)
39
+ }
40
+
41
+ /**
42
+ * @description 从小程序组件变更事件中提取数字值。
43
+ */
44
+ export function resolveNumberChangeValue(event: unknown, fallback = 0) {
45
+ return Number(resolveChangeValue(event, fallback))
46
+ }
47
+
48
+ /**
49
+ * @description 从小程序组件变更事件中提取布尔值。
50
+ */
51
+ export function resolveBooleanChangeValue(event: unknown, fallback = false) {
52
+ return Boolean(resolveChangeValue(event, fallback))
53
+ }