create-weapp-vite 2.0.22 → 2.0.24
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/dist/{chunk-LMYAXMKW.js → chunk-7C6JGBBY.js} +2 -2
- package/dist/cli.js +8 -3
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/templates/wevu/README.md +1 -0
- package/templates/wevu/auto-import-components.json +4 -1
- package/templates/wevu/components.d.ts +25 -0
- package/templates/wevu/src/components/HelloWorld/index.vue +442 -14
- package/templates/wevu/src/components/InfoBanner/index.vue +79 -0
- package/templates/wevu/src/pages/index/index.vue +244 -12
- package/templates/wevu/tsconfig.app.json +6 -1
- package/templates/wevu/typed-components.d.ts +25 -0
- package/templates/wevu/vite.config.ts +6 -0
- package/templates/wevu-tdesign/components.d.ts +241 -241
|
@@ -1,28 +1,201 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, watch } from 'wevu'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface HelloActionPayload {
|
|
5
|
+
type: 'toggle' | 'copy' | 'select' | 'stats'
|
|
6
|
+
value?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type HighlightTone = 'up' | 'down' | 'flat'
|
|
10
|
+
|
|
11
|
+
interface HighlightItem {
|
|
12
|
+
key: string
|
|
13
|
+
label: string
|
|
14
|
+
value: string | number
|
|
15
|
+
tone?: HighlightTone
|
|
16
|
+
note?: string
|
|
17
|
+
}
|
|
5
18
|
|
|
6
19
|
definePageJson({
|
|
7
|
-
navigationBarTitleText: '
|
|
20
|
+
navigationBarTitleText: '首页示例',
|
|
8
21
|
})
|
|
9
22
|
|
|
10
23
|
const count = ref(0)
|
|
11
24
|
const message = ref('Hello WeVU!')
|
|
25
|
+
const activeGroup = ref('概览')
|
|
26
|
+
|
|
12
27
|
const todos = ref([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
{
|
|
29
|
+
id: 'sfc',
|
|
30
|
+
title: '自动编译 SFC 到小程序四件套',
|
|
31
|
+
group: 'template' as const,
|
|
32
|
+
done: true,
|
|
33
|
+
level: 'advanced' as const,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'components',
|
|
37
|
+
title: '自动注入 usingComponents 与组件类型提示',
|
|
38
|
+
group: 'template' as const,
|
|
39
|
+
done: true,
|
|
40
|
+
level: 'base' as const,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'pipeline',
|
|
44
|
+
title: 'WXML/WXSS/WXS 全链路处理与平台适配',
|
|
45
|
+
group: 'engineering' as const,
|
|
46
|
+
done: true,
|
|
47
|
+
level: 'advanced' as const,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'events',
|
|
51
|
+
title: '支持 @tap.catch / @tap.stop 等事件语义',
|
|
52
|
+
group: 'core' as const,
|
|
53
|
+
done: true,
|
|
54
|
+
level: 'base' as const,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'reactivity',
|
|
58
|
+
title: '通过 wevu 使用 ref/computed/watch 写业务逻辑',
|
|
59
|
+
group: 'core' as const,
|
|
60
|
+
done: true,
|
|
61
|
+
level: 'advanced' as const,
|
|
62
|
+
},
|
|
16
63
|
])
|
|
17
64
|
|
|
18
65
|
const doubled = computed(() => count.value * 2)
|
|
19
66
|
|
|
67
|
+
const pageClass = computed(() => {
|
|
68
|
+
return {
|
|
69
|
+
'page-empty': count.value === 0,
|
|
70
|
+
'page-energetic': count.value > 0,
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const pageStyle = computed(() => {
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
background: count.value > 0 ? '#eaf0ff' : '#f6f7ff',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
borderTop: count.value > 0 ? '4rpx solid #4c6ef5' : '4rpx solid transparent',
|
|
81
|
+
},
|
|
82
|
+
]
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const cardClass = computed(() => {
|
|
86
|
+
return [
|
|
87
|
+
{
|
|
88
|
+
'card-active': count.value > 0,
|
|
89
|
+
},
|
|
90
|
+
count.value >= 3 ? 'card-boost' : '',
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const cardStyle = computed(() => {
|
|
95
|
+
return [
|
|
96
|
+
{
|
|
97
|
+
borderColor: count.value > 0 ? '#4c6ef5' : 'transparent',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
borderWidth: count.value > 0 ? '2rpx' : '1rpx',
|
|
101
|
+
},
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const primaryBtnClass = computed(() => {
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
'btn-boost': count.value > 0,
|
|
109
|
+
},
|
|
110
|
+
count.value >= 3 ? 'btn-boost-strong' : '',
|
|
111
|
+
]
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
const primaryBtnStyle = computed(() => {
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
opacity: count.value > 0 ? 0.88 : 1,
|
|
118
|
+
},
|
|
119
|
+
count.value > 0
|
|
120
|
+
? {
|
|
121
|
+
boxShadow: '0 8rpx 20rpx rgba(76, 110, 245, 0.28)',
|
|
122
|
+
}
|
|
123
|
+
: null,
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const helloHighlights = computed<HighlightItem[]>(() => {
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
key: 'count',
|
|
131
|
+
label: '当前计数',
|
|
132
|
+
value: count.value,
|
|
133
|
+
tone: 'up' as const,
|
|
134
|
+
note: '来自 ref 状态',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: 'double',
|
|
138
|
+
label: '双倍值',
|
|
139
|
+
value: doubled.value,
|
|
140
|
+
tone: 'flat' as const,
|
|
141
|
+
note: '来自 computed',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
key: 'feature',
|
|
145
|
+
label: '能力条目',
|
|
146
|
+
value: todos.value.length,
|
|
147
|
+
tone: 'flat' as const,
|
|
148
|
+
note: '模板清单',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
key: 'title',
|
|
152
|
+
label: '标题长度',
|
|
153
|
+
value: message.value.length,
|
|
154
|
+
tone: message.value.length > 10 ? 'up' : 'down',
|
|
155
|
+
note: '来自 v-model',
|
|
156
|
+
},
|
|
157
|
+
]
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
function showToast(title: string) {
|
|
161
|
+
wx.showToast({
|
|
162
|
+
title,
|
|
163
|
+
icon: 'none',
|
|
164
|
+
duration: 1200,
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
20
168
|
function increment() {
|
|
21
169
|
count.value += 1
|
|
22
170
|
}
|
|
23
171
|
|
|
24
172
|
function reset() {
|
|
25
173
|
count.value = 0
|
|
174
|
+
showToast('计数已重置')
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function handleHelloAction(payload: HelloActionPayload) {
|
|
178
|
+
if (payload.type === 'copy' && payload.value) {
|
|
179
|
+
wx.setClipboardData({
|
|
180
|
+
data: payload.value,
|
|
181
|
+
})
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (payload.type === 'toggle') {
|
|
186
|
+
showToast(`面板状态:${payload.value === 'true' ? '展开' : '收起'}`)
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (payload.type === 'select' && payload.value) {
|
|
191
|
+
activeGroup.value = payload.value
|
|
192
|
+
showToast(`当前焦点:${payload.value}`)
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (payload.type === 'stats' && payload.value) {
|
|
197
|
+
console.log(`[wevu] hello progress: ${payload.value}%`)
|
|
198
|
+
}
|
|
26
199
|
}
|
|
27
200
|
|
|
28
201
|
watch(count, (newValue, oldValue) => {
|
|
@@ -31,10 +204,30 @@ watch(count, (newValue, oldValue) => {
|
|
|
31
204
|
</script>
|
|
32
205
|
|
|
33
206
|
<template>
|
|
34
|
-
<view class="page">
|
|
35
|
-
<
|
|
207
|
+
<view class="page" :class="pageClass" :style="pageStyle">
|
|
208
|
+
<InfoBanner
|
|
209
|
+
:title="message"
|
|
210
|
+
:description="`group=${activeGroup}, count=${count}, doubled=${doubled}`"
|
|
211
|
+
badge="Demo"
|
|
212
|
+
/>
|
|
213
|
+
|
|
214
|
+
<HelloWorld
|
|
215
|
+
:title="`欢迎,${message}`"
|
|
216
|
+
:subtitle="`HelloWorld 示例面板(当前分组:${activeGroup})`"
|
|
217
|
+
:highlights="helloHighlights"
|
|
218
|
+
:features="todos"
|
|
219
|
+
@action="handleHelloAction"
|
|
220
|
+
>
|
|
221
|
+
<template #footer>
|
|
222
|
+
<view class="hello-footer">
|
|
223
|
+
<text class="hello-footer-text">
|
|
224
|
+
此区域来自父组件 slot,展示 wevu + weapp-vite 组合能力。
|
|
225
|
+
</text>
|
|
226
|
+
</view>
|
|
227
|
+
</template>
|
|
228
|
+
</HelloWorld>
|
|
36
229
|
|
|
37
|
-
<view class="card">
|
|
230
|
+
<view class="card" :class="cardClass" :style="cardStyle">
|
|
38
231
|
<view class="row">
|
|
39
232
|
<text class="label">
|
|
40
233
|
当前计数:{{ count }}
|
|
@@ -45,10 +238,10 @@ watch(count, (newValue, oldValue) => {
|
|
|
45
238
|
</view>
|
|
46
239
|
|
|
47
240
|
<view class="row actions">
|
|
48
|
-
<button class="btn primary" @tap="increment">
|
|
241
|
+
<button class="btn primary" :class="primaryBtnClass" :style="primaryBtnStyle" @tap.catch="increment">
|
|
49
242
|
+1
|
|
50
243
|
</button>
|
|
51
|
-
<button class="btn danger" @tap="reset">
|
|
244
|
+
<button class="btn danger" @tap.stop="reset">
|
|
52
245
|
重置
|
|
53
246
|
</button>
|
|
54
247
|
</view>
|
|
@@ -67,7 +260,7 @@ watch(count, (newValue, oldValue) => {
|
|
|
67
260
|
</view>
|
|
68
261
|
<view class="todo">
|
|
69
262
|
<view v-for="(todo, index) in todos" :key="index" class="todo-item">
|
|
70
|
-
<text>• {{ todo }}</text>
|
|
263
|
+
<text>• {{ todo.title }}</text>
|
|
71
264
|
</view>
|
|
72
265
|
</view>
|
|
73
266
|
</view>
|
|
@@ -77,17 +270,36 @@ watch(count, (newValue, oldValue) => {
|
|
|
77
270
|
<style>
|
|
78
271
|
.page {
|
|
79
272
|
box-sizing: border-box;
|
|
80
|
-
|
|
273
|
+
min-height: 100vh;
|
|
274
|
+
padding: 0 32rpx 64rpx;
|
|
275
|
+
background: #f6f7ff;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.page-empty {
|
|
279
|
+
opacity: 0.98;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.page-energetic {
|
|
283
|
+
background: #f1f4ff;
|
|
81
284
|
}
|
|
82
285
|
|
|
83
286
|
.card {
|
|
84
287
|
padding: 32rpx;
|
|
85
288
|
margin-top: 24rpx;
|
|
86
289
|
background: #fff;
|
|
290
|
+
border: 2rpx solid transparent;
|
|
87
291
|
border-radius: 24rpx;
|
|
88
292
|
box-shadow: 0 12rpx 32rpx rgb(44 44 84 / 10%);
|
|
89
293
|
}
|
|
90
294
|
|
|
295
|
+
.card-active {
|
|
296
|
+
box-shadow: 0 14rpx 36rpx rgb(76 110 245 / 14%);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.card-boost {
|
|
300
|
+
transform: translateY(-2rpx);
|
|
301
|
+
}
|
|
302
|
+
|
|
91
303
|
.row {
|
|
92
304
|
display: flex;
|
|
93
305
|
gap: 16rpx;
|
|
@@ -116,6 +328,14 @@ watch(count, (newValue, oldValue) => {
|
|
|
116
328
|
background: #4c6ef5;
|
|
117
329
|
}
|
|
118
330
|
|
|
331
|
+
.btn-boost {
|
|
332
|
+
transform: scale(1.02);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.btn-boost-strong {
|
|
336
|
+
transform: scale(1.04);
|
|
337
|
+
}
|
|
338
|
+
|
|
119
339
|
.btn.danger {
|
|
120
340
|
background: #f03e3e;
|
|
121
341
|
}
|
|
@@ -135,4 +355,16 @@ watch(count, (newValue, oldValue) => {
|
|
|
135
355
|
font-size: 26rpx;
|
|
136
356
|
color: #4f4f7a;
|
|
137
357
|
}
|
|
358
|
+
|
|
359
|
+
.hello-footer {
|
|
360
|
+
padding: 12rpx 14rpx;
|
|
361
|
+
margin-top: 16rpx;
|
|
362
|
+
background: #eef2ff;
|
|
363
|
+
border-radius: 12rpx;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.hello-footer-text {
|
|
367
|
+
font-size: 22rpx;
|
|
368
|
+
color: #4f5ea0;
|
|
369
|
+
}
|
|
138
370
|
</style>
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"paths": {
|
|
16
16
|
"@/*": [
|
|
17
17
|
"./src/*"
|
|
18
|
+
],
|
|
19
|
+
"weapp-vite/typed-components": [
|
|
20
|
+
"./typed-components.d.ts"
|
|
18
21
|
]
|
|
19
22
|
},
|
|
20
23
|
"resolveJsonModule": true,
|
|
@@ -53,6 +56,8 @@
|
|
|
53
56
|
"src/**/*.json",
|
|
54
57
|
"src/**/*.d.ts",
|
|
55
58
|
"types/**/*.d.ts",
|
|
56
|
-
"env.d.ts"
|
|
59
|
+
"env.d.ts",
|
|
60
|
+
"components.d.ts",
|
|
61
|
+
"typed-components.d.ts"
|
|
57
62
|
]
|
|
58
63
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
// biome-ignore lint: disable
|
|
4
|
+
// oxlint-disable
|
|
5
|
+
// ------
|
|
6
|
+
// 由 weapp-vite 自动生成,请勿编辑。
|
|
7
|
+
declare module 'weapp-vite/typed-components' {
|
|
8
|
+
export interface ComponentProps {
|
|
9
|
+
HelloWorld: {
|
|
10
|
+
readonly compact?: boolean;
|
|
11
|
+
readonly features?: any[];
|
|
12
|
+
readonly highlights?: any[];
|
|
13
|
+
readonly subtitle?: string;
|
|
14
|
+
readonly title?: string;
|
|
15
|
+
};
|
|
16
|
+
InfoBanner: {
|
|
17
|
+
readonly badge?: string;
|
|
18
|
+
readonly description?: string;
|
|
19
|
+
readonly title?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export type ComponentPropName = keyof ComponentProps;
|
|
23
|
+
export type ComponentProp<Name extends string> = Name extends ComponentPropName ? ComponentProps[Name] : Record<string, any>;
|
|
24
|
+
export const componentProps: ComponentProps;
|
|
25
|
+
}
|
|
@@ -3,6 +3,12 @@ import { defineConfig } from 'weapp-vite/config'
|
|
|
3
3
|
export default defineConfig(() => ({
|
|
4
4
|
weapp: {
|
|
5
5
|
srcRoot: 'src',
|
|
6
|
+
autoImportComponents: {
|
|
7
|
+
globs: ['components/**/*.vue', 'components/**/*.wxml'],
|
|
8
|
+
typedComponents: true,
|
|
9
|
+
vueComponents: true,
|
|
10
|
+
vueComponentsModule: 'wevu',
|
|
11
|
+
},
|
|
6
12
|
},
|
|
7
13
|
// weapp-vite 内置的 Vue 支持会自动处理 .vue 文件,不需要额外插件
|
|
8
14
|
}))
|