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.
- package/README.md +16 -0
- package/dist/cli.js +28 -5
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1 -1
- package/dist/{src-BhGRh_fC.js → src-CCWjAwFU.js} +67 -12
- package/package.json +3 -3
- package/templates/default/.vscode/settings.json +69 -0
- package/templates/default/project.config.json +1 -1
- package/templates/default/src/components/HelloWorld/HelloWorld.ts +4 -2
- package/templates/default/src/pages/index/index.ts +4 -2
- package/templates/default/src/pages/layouts/index.ts +3 -2
- package/templates/lib/.vscode/settings.json +69 -0
- package/templates/lib/package.json +1 -1
- package/templates/lib/src/components/HelloWorld/HelloWorld.ts +4 -2
- package/templates/lib/src/pages/index/index.ts +4 -2
- package/templates/lib/src/pages/layouts/index.ts +3 -2
- package/templates/tailwindcss/.vscode/settings.json +69 -0
- package/templates/tailwindcss/project.config.json +1 -1
- package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +4 -2
- package/templates/tailwindcss/src/pages/index/index.ts +4 -3
- package/templates/tailwindcss/src/pages/layouts/index.ts +3 -2
- package/templates/tdesign/.vscode/settings.json +69 -0
- package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +4 -2
- package/templates/tdesign/src/pages/index/index.ts +4 -3
- package/templates/tdesign/src/pages/layouts/index.ts +3 -2
- package/templates/vant/.vscode/settings.json +69 -0
- package/templates/vant/project.config.json +1 -1
- package/templates/vant/src/components/HelloWorld/HelloWorld.ts +4 -2
- package/templates/vant/src/pages/index/index.ts +4 -3
- package/templates/vant/src/pages/layouts/index.scss +1 -1
- package/templates/vant/src/pages/layouts/index.ts +3 -2
- package/templates/vant/src/pages/layouts/index.wxml +17 -5
- package/templates/wevu/.vscode/settings.json +69 -0
- package/templates/wevu/project.config.json +1 -1
- package/templates/wevu/src/app.vue +10 -7
- package/templates/wevu-tdesign/.vscode/settings.json +69 -0
- package/templates/wevu-tdesign/project.config.json +1 -1
- package/templates/wevu-tdesign/src/app.vue +6 -3
- package/templates/wevu-tdesign/src/components/FilterBar/index.vue +3 -2
- package/templates/wevu-tdesign/src/hooks/usePullDownRefresh.ts +6 -5
- package/templates/wevu-tdesign/src/pages/ability/index.vue +59 -55
- package/templates/wevu-tdesign/src/pages/data/index.vue +3 -2
- package/templates/wevu-tdesign/src/pages/form/index.vue +2 -20
- package/templates/wevu-tdesign/src/pages/index/index.vue +4 -3
- package/templates/wevu-tdesign/src/pages/layouts/index.vue +5 -4
- package/templates/wevu-tdesign/src/subpackages/ability/index.vue +4 -7
- package/templates/wevu-tdesign/src/subpackages/lab/class-binding/index.vue +5 -24
- package/templates/wevu-tdesign/src/subpackages/lab/index.vue +12 -10
- package/templates/wevu-tdesign/src/utils/changeEvent.ts +53 -0
|
@@ -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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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(
|
|
95
|
-
activeRange.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(
|
|
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
|
-
|
|
228
|
+
await wpi.switchTab({
|
|
228
229
|
url: action.path,
|
|
229
230
|
})
|
|
230
231
|
return
|
|
231
232
|
}
|
|
232
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
18
|
+
isActive.value = resolveBooleanChangeValue(event, !isActive.value)
|
|
38
19
|
}
|
|
39
20
|
|
|
40
21
|
function onErrorChange(event: unknown) {
|
|
41
|
-
hasError.value =
|
|
22
|
+
hasError.value = resolveBooleanChangeValue(event, !hasError.value)
|
|
42
23
|
}
|
|
43
24
|
|
|
44
25
|
function onRoundChange(event: unknown) {
|
|
45
|
-
isRound.value =
|
|
26
|
+
isRound.value = resolveBooleanChangeValue(event, !isRound.value)
|
|
46
27
|
}
|
|
47
28
|
|
|
48
29
|
function onGhostChange(event: unknown) {
|
|
49
|
-
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(
|
|
26
|
-
activeTab.value =
|
|
27
|
+
function handleTabChange(event: unknown) {
|
|
28
|
+
activeTab.value = resolveStringChangeValue(event, activeTab.value)
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
function handleRateChange(
|
|
30
|
-
rating.value =
|
|
31
|
+
function handleRateChange(event: unknown) {
|
|
32
|
+
rating.value = resolveNumberChangeValue(event, rating.value)
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
function handleSliderChange(
|
|
34
|
-
slider.value =
|
|
35
|
+
function handleSliderChange(event: unknown) {
|
|
36
|
+
slider.value = resolveNumberChangeValue(event, slider.value)
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
function handleToggleChange(
|
|
38
|
-
toggle.value =
|
|
39
|
+
function handleToggleChange(event: unknown) {
|
|
40
|
+
toggle.value = resolveBooleanChangeValue(event, !toggle.value)
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
function navigateTo(url: string) {
|
|
42
|
-
|
|
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
|
+
}
|