create-weapp-vite 2.0.55 → 2.0.57

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 (40) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/{src-nL81L3Ai.js → src-hBW5b5RM.js} +2 -2
  4. package/package.json +1 -1
  5. package/templates/default/package.json +1 -1
  6. package/templates/lib/package.json +1 -1
  7. package/templates/tailwindcss/package.json +1 -1
  8. package/templates/tdesign/package.json +1 -1
  9. package/templates/vant/package.json +1 -1
  10. package/templates/wevu/package.json +1 -1
  11. package/templates/wevu/src/app.vue +7 -7
  12. package/templates/wevu/src/layouts/admin.vue +4 -6
  13. package/templates/wevu/src/layouts/default.vue +6 -6
  14. package/templates/wevu/src/pages/layouts/index.vue +4 -6
  15. package/templates/wevu-tdesign/package.json +1 -1
  16. package/templates/wevu-tdesign/src/app.vue +3 -3
  17. package/templates/wevu-tdesign/src/hooks/useDialog.ts +56 -14
  18. package/templates/wevu-tdesign/src/hooks/useToast.ts +42 -15
  19. package/templates/wevu-tdesign/src/layouts/admin.vue +10 -6
  20. package/templates/wevu-tdesign/src/layouts/default.vue +12 -6
  21. package/templates/wevu-tdesign/src/pages/ability/index.vue +2 -6
  22. package/templates/wevu-tdesign/src/pages/form/index.vue +0 -2
  23. package/templates/wevu-tdesign/src/pages/index/index.vue +2 -4
  24. package/templates/wevu-tdesign/src/pages/layouts/index.vue +2 -4
  25. package/templates/wevu-tdesign/src/pages/list/index.vue +0 -2
  26. package/templates/default/auto-import-components.json +0 -3
  27. package/templates/default/src/vite-env.d.ts +0 -1
  28. package/templates/lib/auto-import-components.json +0 -3
  29. package/templates/lib/src/vite-env.d.ts +0 -1
  30. package/templates/tailwindcss/auto-import-components.json +0 -3
  31. package/templates/tailwindcss/src/vite-env.d.ts +0 -1
  32. package/templates/tdesign/auto-import-components.json +0 -84
  33. package/templates/tdesign/src/vite-env.d.ts +0 -1
  34. package/templates/vant/auto-import-components.json +0 -71
  35. package/templates/vant/src/vite-env.d.ts +0 -1
  36. package/templates/wevu/auto-import-components.json +0 -4
  37. package/templates/wevu/src/vite-env.d.ts +0 -1
  38. package/templates/wevu-tdesign/auto-import-components.json +0 -84
  39. package/templates/wevu-tdesign/mini-program.html-data.json +0 -6784
  40. package/templates/wevu-tdesign/src/vite-env.d.ts +0 -1
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as TemplateName, t as createProject } from "./src-nL81L3Ai.js";
1
+ import { n as TemplateName, t as createProject } from "./src-hBW5b5RM.js";
2
2
  import logger from "@weapp-core/logger";
3
3
  import fs from "fs-extra";
4
4
  import path from "node:path";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as TemplateName, t as createProject } from "./src-nL81L3Ai.js";
1
+ import { n as TemplateName, t as createProject } from "./src-hBW5b5RM.js";
2
2
  export { TemplateName, createProject };
@@ -4,10 +4,10 @@ import fs from "fs-extra";
4
4
  import path from "pathe";
5
5
  import https from "node:https";
6
6
  //#region ../weapp-vite/package.json
7
- var version$1 = "6.11.1";
7
+ var version$1 = "6.11.3";
8
8
  //#endregion
9
9
  //#region ../wevu/package.json
10
- var version = "6.11.1";
10
+ var version = "6.11.3";
11
11
  //#endregion
12
12
  //#region src/enums.ts
13
13
  let TemplateName = /* @__PURE__ */ function(TemplateName) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-weapp-vite",
3
3
  "type": "module",
4
- "version": "2.0.55",
4
+ "version": "2.0.57",
5
5
  "description": "create-weapp-vite",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-template",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-lib-template",
3
3
  "type": "module",
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
5
  "private": true,
6
6
  "description": "weapp-vite 组件库(lib 模式)模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-tailwindcss-template",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite + tailwindcss 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-tailwindcss-tdesign-template",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite + tailwindcss + tdesign 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-tailwindcss-vant-template",
3
3
  "type": "module",
4
- "version": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite + tailwindcss 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-wevu-template",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "private": true,
6
6
  "description": "weapp-vite + wevu (Vue SFC) 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -24,7 +24,7 @@ const router = createRouter({
24
24
  })
25
25
 
26
26
  router.beforeEach((to, from) => {
27
- console.log('[wevu-template-router] beforeEach', {
27
+ wx.getLogManager({ level: 1 }).info('[wevu-template-router] beforeEach', {
28
28
  to: to?.fullPath,
29
29
  from: from.fullPath,
30
30
  })
@@ -32,7 +32,7 @@ router.beforeEach((to, from) => {
32
32
  })
33
33
 
34
34
  router.beforeResolve((to, from) => {
35
- console.log('[wevu-template-router] beforeResolve', {
35
+ wx.getLogManager({ level: 1 }).info('[wevu-template-router] beforeResolve', {
36
36
  to: to?.fullPath,
37
37
  from: from.fullPath,
38
38
  })
@@ -40,7 +40,7 @@ router.beforeResolve((to, from) => {
40
40
  })
41
41
 
42
42
  router.afterEach((to, from, failure) => {
43
- console.log('[wevu-template-router] afterEach', {
43
+ wx.getLogManager({ level: 1 }).info('[wevu-template-router] afterEach', {
44
44
  to: to?.fullPath,
45
45
  from: from.fullPath,
46
46
  failureType: failure?.type,
@@ -48,7 +48,7 @@ router.afterEach((to, from, failure) => {
48
48
  })
49
49
 
50
50
  router.onError((error, context) => {
51
- console.log('[wevu-template-router] onError', {
51
+ wx.getLogManager({ level: 1 }).info('[wevu-template-router] onError', {
52
52
  error: error instanceof Error ? error.message : String(error),
53
53
  mode: context.mode,
54
54
  to: context.to?.fullPath,
@@ -58,15 +58,15 @@ router.onError((error, context) => {
58
58
  })
59
59
 
60
60
  onShow(() => {
61
- console.log('[weapp-vite-wevu-template] app show')
61
+ wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app show')
62
62
  })
63
63
 
64
64
  onHide(() => {
65
- console.log('[weapp-vite-wevu-template] app hide')
65
+ wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app hide')
66
66
  })
67
67
 
68
68
  onLaunch(() => {
69
- console.log('[weapp-vite-wevu-template] app launch')
69
+ wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app launch')
70
70
  })
71
71
  </script>
72
72
 
@@ -3,6 +3,10 @@ const props = defineProps<{
3
3
  subtitle?: string
4
4
  title?: string
5
5
  }>()
6
+
7
+ defineComponentJson({
8
+ component: true,
9
+ })
6
10
  </script>
7
11
 
8
12
  <template>
@@ -67,9 +71,3 @@ const props = defineProps<{
67
71
  padding-bottom: 32rpx;
68
72
  }
69
73
  </style>
70
-
71
- <json>
72
- {
73
- "component": true
74
- }
75
- </json>
@@ -1,3 +1,9 @@
1
+ <script setup lang="ts">
2
+ defineComponentJson({
3
+ component: true,
4
+ })
5
+ </script>
6
+
1
7
  <template>
2
8
  <view class="layout-default">
3
9
  <slot />
@@ -9,9 +15,3 @@
9
15
  min-height: 100%;
10
16
  }
11
17
  </style>
12
-
13
- <json>
14
- {
15
- "component": true
16
- }
17
- </json>
@@ -45,6 +45,10 @@ function clearLayout() {
45
45
  async function backHome() {
46
46
  await router.push('/pages/index/index')
47
47
  }
48
+
49
+ definePageJson({
50
+ navigationBarTitleText: '页面布局',
51
+ })
48
52
  </script>
49
53
 
50
54
  <template>
@@ -163,9 +167,3 @@ async function backHome() {
163
167
  background: #dbeafe;
164
168
  }
165
169
  </style>
166
-
167
- <json>
168
- {
169
- "navigationBarTitleText": "页面布局"
170
- }
171
- </json>
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-wevu-tailwindcss-tdesign-template",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "private": true,
6
6
  "description": "weapp-vite + wevu (Vue SFC) 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -70,15 +70,15 @@ defineAppJson({
70
70
  })
71
71
 
72
72
  onShow(() => {
73
- console.log('[weapp-vite-wevu-template] app show')
73
+ wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app show')
74
74
  })
75
75
 
76
76
  onHide(() => {
77
- console.log('[weapp-vite-wevu-template] app hide')
77
+ wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app hide')
78
78
  })
79
79
 
80
80
  onLaunch(() => {
81
- console.log('[weapp-vite-wevu-template] app launch')
81
+ wx.getLogManager({ level: 1 }).info('[weapp-vite-wevu-template] app launch')
82
82
  })
83
83
  </script>
84
84
 
@@ -2,31 +2,73 @@ import Dialog from 'tdesign-miniprogram/dialog/index'
2
2
  import { getCurrentInstance } from 'wevu'
3
3
 
4
4
  export interface DialogOptions {
5
+ context?: any
5
6
  selector?: string
6
7
  }
7
8
 
8
9
  export interface AlertOptions {
9
- title: string
10
+ confirmBtn?: string
10
11
  content: string
12
+ context?: any
13
+ selector?: string
14
+ title: string
15
+ }
16
+
17
+ export interface ConfirmOptions {
18
+ cancelBtn?: string
11
19
  confirmBtn?: string
20
+ content: string
21
+ context?: any
22
+ selector?: string
23
+ title: string
12
24
  }
13
25
 
14
- export function useDialog(options: DialogOptions = {}) {
15
- const mpContext = getCurrentInstance()
16
- const selector = options.selector ?? '#t-dialog'
26
+ function resolveDialogContext(context?: any) {
27
+ return context ?? getCurrentInstance()
28
+ }
29
+
30
+ export function alertDialog(payload: AlertOptions) {
31
+ const context = resolveDialogContext(payload.context)
32
+ if (!context) {
33
+ return
34
+ }
35
+ const { selector = '#t-dialog', ...rest } = payload
36
+ return Dialog.alert({
37
+ selector,
38
+ context: context as any,
39
+ ...rest,
40
+ })
41
+ }
17
42
 
18
- function alert(payload: AlertOptions) {
19
- if (!mpContext) {
20
- return
21
- }
22
- Dialog.alert({
23
- selector,
24
- context: mpContext as any,
25
- ...payload,
26
- })
43
+ export function confirmDialog(payload: ConfirmOptions) {
44
+ const context = resolveDialogContext(payload.context)
45
+ if (!context) {
46
+ return
27
47
  }
48
+ const { selector = '#t-dialog', ...rest } = payload
49
+ return Dialog.confirm({
50
+ selector,
51
+ context: context as any,
52
+ ...rest,
53
+ })
54
+ }
28
55
 
56
+ export function useDialog(options: DialogOptions = {}) {
57
+ const context = options.context ?? getCurrentInstance()
29
58
  return {
30
- alert,
59
+ alert(payload: AlertOptions) {
60
+ return alertDialog({
61
+ ...payload,
62
+ context: payload.context ?? context,
63
+ selector: payload.selector ?? options.selector,
64
+ })
65
+ },
66
+ confirm(payload: ConfirmOptions) {
67
+ return confirmDialog({
68
+ ...payload,
69
+ context: payload.context ?? context,
70
+ selector: payload.selector ?? options.selector,
71
+ })
72
+ },
31
73
  }
32
74
  }
@@ -3,32 +3,59 @@ import { getCurrentInstance } from 'wevu'
3
3
 
4
4
  export type ToastTheme = 'success' | 'warning' | 'error' | 'default' | 'loading'
5
5
 
6
+ export interface ShowToastPayload {
7
+ context?: any
8
+ duration?: number
9
+ icon?: string
10
+ message?: string
11
+ placement?: string
12
+ selector?: string
13
+ theme?: ToastTheme
14
+ title?: string
15
+ }
16
+
6
17
  export interface ToastOptions {
7
18
  selector?: string
8
19
  duration?: number
9
20
  theme?: ToastTheme
10
21
  }
11
22
 
12
- export function useToast(options: ToastOptions = {}) {
23
+ export function showToast(payload: string | ShowToastPayload, theme?: ToastTheme) {
13
24
  const mpContext = getCurrentInstance()
25
+ const normalized = typeof payload === 'string'
26
+ ? { message: payload, theme }
27
+ : payload
28
+
29
+ const context = normalized.context ?? mpContext
30
+ if (!context) {
31
+ return
32
+ }
33
+
34
+ const { selector = '#t-toast', theme: nextTheme, title, message, ...rest } = normalized
35
+ Toast({
36
+ selector,
37
+ context: context as any,
38
+ message: message ?? title ?? '',
39
+ ...rest,
40
+ ...(nextTheme && nextTheme !== 'default' ? { theme: nextTheme } : {}),
41
+ } as any)
42
+ }
43
+
44
+ export function useToast(options: ToastOptions = {}) {
45
+ const context = getCurrentInstance()
14
46
  const selector = options.selector ?? '#t-toast'
15
47
  const duration = options.duration ?? 1200
16
48
  const defaultTheme = options.theme ?? 'success'
17
49
 
18
- function showToast(message: string, theme: ToastTheme = defaultTheme) {
19
- if (!mpContext) {
20
- return
21
- }
22
- Toast({
23
- selector,
24
- context: mpContext as any,
25
- message,
26
- ...(theme === 'default' ? {} : { theme }),
27
- duration,
28
- })
29
- }
30
-
31
50
  return {
32
- showToast,
51
+ showToast(message: string, theme: ToastTheme = defaultTheme) {
52
+ return showToast({
53
+ context,
54
+ selector,
55
+ message,
56
+ duration,
57
+ ...(theme === 'default' ? {} : { theme }),
58
+ })
59
+ },
33
60
  }
34
61
  }
@@ -3,6 +3,14 @@ const props = defineProps<{
3
3
  subtitle?: string
4
4
  title?: string
5
5
  }>()
6
+
7
+ defineComponentJson({
8
+ component: true,
9
+ usingComponents: {
10
+ 't-dialog': 'tdesign-miniprogram/dialog/dialog',
11
+ 't-toast': 'tdesign-miniprogram/toast/toast',
12
+ },
13
+ })
6
14
  </script>
7
15
 
8
16
  <template>
@@ -21,6 +29,8 @@ const props = defineProps<{
21
29
  <view class="pb-[32rpx]">
22
30
  <slot />
23
31
  </view>
32
+ <t-toast id="t-toast" />
33
+ <t-dialog id="t-dialog" />
24
34
  </view>
25
35
  </template>
26
36
 
@@ -29,9 +39,3 @@ const props = defineProps<{
29
39
  min-height: 100%;
30
40
  }
31
41
  </style>
32
-
33
- <json>
34
- {
35
- "component": true
36
- }
37
- </json>
@@ -1,6 +1,18 @@
1
+ <script setup lang="ts">
2
+ defineComponentJson({
3
+ component: true,
4
+ usingComponents: {
5
+ 't-dialog': 'tdesign-miniprogram/dialog/dialog',
6
+ 't-toast': 'tdesign-miniprogram/toast/toast',
7
+ },
8
+ })
9
+ </script>
10
+
1
11
  <template>
2
12
  <view class="layout-default">
3
13
  <slot />
14
+ <t-toast id="t-toast" />
15
+ <t-dialog id="t-dialog" />
4
16
  </view>
5
17
  </template>
6
18
 
@@ -9,9 +21,3 @@
9
21
  min-height: 100%;
10
22
  }
11
23
  </style>
12
-
13
- <json>
14
- {
15
- "component": true
16
- }
17
- </json>
@@ -43,8 +43,7 @@ const capabilityCards = ref([
43
43
 
44
44
  const subscribeTemplateId = ''
45
45
 
46
- function handleCapability(key: string, what: any) {
47
- console.log('handleCapability', key, what)
46
+ function handleCapability(key: string) {
48
47
  switch (key) {
49
48
  case 'scan':
50
49
  wx.scanCode({
@@ -130,7 +129,7 @@ function navigateTo(url: string) {
130
129
  v-for="item in capabilityCards"
131
130
  :key="item.key"
132
131
  class="rounded-[18rpx] bg-[#f0f9ff] p-[16rpx]"
133
- @tap="handleCapability(item.key, 'test')"
132
+ @tap="handleCapability(item.key)"
134
133
  >
135
134
  <text class="text-[24rpx] font-semibold text-[#1f1a3f]">
136
135
  {{ item.title }}
@@ -157,8 +156,5 @@ function navigateTo(url: string) {
157
156
  </t-cell-group>
158
157
  </view>
159
158
  </view>
160
-
161
- <t-toast id="t-toast" />
162
- <t-dialog id="t-dialog" />
163
159
  </view>
164
160
  </template>
@@ -241,7 +241,5 @@ function submit() {
241
241
  {{ currentStep === steps.length - 1 ? (submitted ? '已提交' : '提交') : '下一步' }}
242
242
  </t-button>
243
243
  </view>
244
-
245
- <t-toast id="t-toast" />
246
244
  </view>
247
245
  </template>
@@ -151,13 +151,13 @@ watch(refreshSeed, () => {
151
151
  lastUpdated.value = `更新于 ${new Date().toLocaleTimeString()}`
152
152
  })
153
153
 
154
- usePullDownRefresh(refreshDashboard)
155
-
156
154
  function refreshDashboard() {
157
155
  refreshSeed.value = Math.max(1, Math.floor(Math.random() * 9))
158
156
  showToast('指标已刷新')
159
157
  }
160
158
 
159
+ usePullDownRefresh(refreshDashboard)
160
+
161
161
  function onQuickAction(action: QuickActionItem) {
162
162
  if (!action.path) {
163
163
  showToast('该入口暂未配置')
@@ -313,7 +313,5 @@ function onQuickAction(action: QuickActionItem) {
313
313
  </t-cell-group>
314
314
  </view>
315
315
  </view>
316
-
317
- <t-toast id="t-toast" />
318
316
  </view>
319
317
  </template>
@@ -82,15 +82,13 @@ function clearLayout() {
82
82
  <t-button block theme="primary" @tap="applyDefaultLayout">
83
83
  使用 default 布局
84
84
  </t-button>
85
- <t-button block theme="success" variant="outline" @tap="applyAdminLayout">
85
+ <t-button block theme="primary" variant="outline" @tap="applyAdminLayout">
86
86
  切到 admin 布局
87
87
  </t-button>
88
- <t-button block theme="warning" variant="outline" @tap="clearLayout">
88
+ <t-button block theme="danger" variant="outline" @tap="clearLayout">
89
89
  关闭布局
90
90
  </t-button>
91
91
  </view>
92
92
  </view>
93
-
94
- <t-toast id="t-toast" />
95
93
  </view>
96
94
  </template>
@@ -142,7 +142,5 @@ reload()
142
142
  <view v-if="hasEmpty" class="mt-[20rpx]">
143
143
  <EmptyState title="暂无匹配任务" description="调整筛选条件或刷新数据" action-text="重新加载" @action="reload" />
144
144
  </view>
145
-
146
- <t-toast id="t-toast" />
147
145
  </view>
148
146
  </template>
@@ -1,3 +0,0 @@
1
- {
2
- "HelloWorld": "/components/HelloWorld/HelloWorld"
3
- }
@@ -1 +0,0 @@
1
- /// <reference types="weapp-vite/client" />
@@ -1,3 +0,0 @@
1
- {
2
- "HelloWorld": "/components/HelloWorld/HelloWorld"
3
- }
@@ -1 +0,0 @@
1
- /// <reference types="weapp-vite/client" />
@@ -1,3 +0,0 @@
1
- {
2
- "HelloWorld": "/components/HelloWorld/HelloWorld"
3
- }
@@ -1 +0,0 @@
1
- /// <reference types="weapp-vite/client" />