create-weapp-vite 2.0.53 → 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 (157) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/{src-j_bda7hF.js → src-hBW5b5RM.js} +11 -9
  4. package/package.json +1 -1
  5. package/templates/default/package.json +3 -2
  6. package/templates/default/project.private.config.json +1 -1
  7. package/templates/default/src/app.json +2 -1
  8. package/templates/default/src/layouts/admin/index.json +3 -0
  9. package/templates/default/src/layouts/admin/index.scss +40 -0
  10. package/templates/default/src/layouts/admin/index.ts +1 -0
  11. package/templates/default/src/layouts/admin/index.wxml +10 -0
  12. package/templates/default/src/layouts/default/index.json +3 -0
  13. package/templates/default/src/layouts/default/index.scss +3 -0
  14. package/templates/default/src/layouts/default/index.ts +1 -0
  15. package/templates/default/src/layouts/default/index.wxml +3 -0
  16. package/templates/default/src/pages/index/index.ts +5 -0
  17. package/templates/default/src/pages/index/index.wxml +3 -0
  18. package/templates/default/src/pages/layouts/index.json +4 -0
  19. package/templates/default/src/pages/layouts/index.scss +68 -0
  20. package/templates/default/src/pages/layouts/index.ts +42 -0
  21. package/templates/default/src/pages/layouts/index.wxml +19 -0
  22. package/templates/default/tsconfig.json +8 -2
  23. package/templates/lib/package.json +6 -2
  24. package/templates/lib/project.private.config.json +1 -1
  25. package/templates/lib/src/app.json +2 -1
  26. package/templates/lib/src/layouts/admin/index.json +3 -0
  27. package/templates/lib/src/layouts/admin/index.scss +41 -0
  28. package/templates/lib/src/layouts/admin/index.ts +1 -0
  29. package/templates/lib/src/layouts/admin/index.wxml +10 -0
  30. package/templates/lib/src/layouts/default/index.json +3 -0
  31. package/templates/lib/src/layouts/default/index.scss +3 -0
  32. package/templates/lib/src/layouts/default/index.ts +1 -0
  33. package/templates/lib/src/layouts/default/index.wxml +3 -0
  34. package/templates/lib/src/pages/index/index.scss +14 -3
  35. package/templates/lib/src/pages/index/index.ts +5 -0
  36. package/templates/lib/src/pages/index/index.wxml +6 -0
  37. package/templates/lib/src/pages/layouts/index.json +4 -0
  38. package/templates/lib/src/pages/layouts/index.scss +70 -0
  39. package/templates/lib/src/pages/layouts/index.ts +44 -0
  40. package/templates/lib/src/pages/layouts/index.wxml +19 -0
  41. package/templates/lib/tsconfig.json +8 -2
  42. package/templates/lib/weapp-vite.lib.config.ts +5 -0
  43. package/templates/tailwindcss/package.json +3 -3
  44. package/templates/tailwindcss/project.private.config.json +1 -1
  45. package/templates/tailwindcss/src/app.json +2 -1
  46. package/templates/tailwindcss/src/layouts/admin/index.json +3 -0
  47. package/templates/tailwindcss/src/layouts/admin/index.scss +40 -0
  48. package/templates/tailwindcss/src/layouts/admin/index.ts +1 -0
  49. package/templates/tailwindcss/src/layouts/admin/index.wxml +10 -0
  50. package/templates/tailwindcss/src/layouts/default/index.json +3 -0
  51. package/templates/tailwindcss/src/layouts/default/index.scss +3 -0
  52. package/templates/tailwindcss/src/layouts/default/index.ts +1 -0
  53. package/templates/tailwindcss/src/layouts/default/index.wxml +3 -0
  54. package/templates/tailwindcss/src/pages/index/index.ts +5 -0
  55. package/templates/tailwindcss/src/pages/index/index.wxml +3 -0
  56. package/templates/tailwindcss/src/pages/layouts/index.json +4 -0
  57. package/templates/tailwindcss/src/pages/layouts/index.scss +1 -0
  58. package/templates/tailwindcss/src/pages/layouts/index.ts +33 -0
  59. package/templates/tailwindcss/src/pages/layouts/index.wxml +19 -0
  60. package/templates/tailwindcss/tsconfig.json +8 -2
  61. package/templates/tdesign/package.json +3 -3
  62. package/templates/tdesign/project.private.config.json +2 -2
  63. package/templates/tdesign/src/app.json +2 -1
  64. package/templates/tdesign/src/layouts/admin/index.json +3 -0
  65. package/templates/tdesign/src/layouts/admin/index.scss +40 -0
  66. package/templates/tdesign/src/layouts/admin/index.ts +1 -0
  67. package/templates/tdesign/src/layouts/admin/index.wxml +10 -0
  68. package/templates/tdesign/src/layouts/default/index.json +3 -0
  69. package/templates/tdesign/src/layouts/default/index.scss +3 -0
  70. package/templates/tdesign/src/layouts/default/index.ts +1 -0
  71. package/templates/tdesign/src/layouts/default/index.wxml +3 -0
  72. package/templates/tdesign/src/pages/index/index.ts +5 -0
  73. package/templates/tdesign/src/pages/index/index.wxml +3 -0
  74. package/templates/tdesign/src/pages/layouts/index.json +4 -0
  75. package/templates/tdesign/src/pages/layouts/index.scss +1 -0
  76. package/templates/tdesign/src/pages/layouts/index.ts +32 -0
  77. package/templates/tdesign/src/pages/layouts/index.wxml +16 -0
  78. package/templates/tdesign/tsconfig.json +8 -2
  79. package/templates/tdesign/vite.config.ts +9 -0
  80. package/templates/vant/package.json +3 -3
  81. package/templates/vant/project.private.config.json +1 -1
  82. package/templates/vant/src/app.json +2 -1
  83. package/templates/vant/src/layouts/admin/index.json +3 -0
  84. package/templates/vant/src/layouts/admin/index.scss +40 -0
  85. package/templates/vant/src/layouts/admin/index.ts +1 -0
  86. package/templates/vant/src/layouts/admin/index.wxml +10 -0
  87. package/templates/vant/src/layouts/default/index.json +3 -0
  88. package/templates/vant/src/layouts/default/index.scss +3 -0
  89. package/templates/vant/src/layouts/default/index.ts +1 -0
  90. package/templates/vant/src/layouts/default/index.wxml +3 -0
  91. package/templates/vant/src/pages/index/index.ts +5 -0
  92. package/templates/vant/src/pages/index/index.wxml +3 -0
  93. package/templates/vant/src/pages/layouts/index.json +4 -0
  94. package/templates/vant/src/pages/layouts/index.scss +3 -0
  95. package/templates/vant/src/pages/layouts/index.ts +35 -0
  96. package/templates/vant/src/pages/layouts/index.wxml +17 -0
  97. package/templates/vant/tsconfig.json +8 -2
  98. package/templates/vant/vite.config.ts +9 -0
  99. package/templates/wevu/package.json +4 -3
  100. package/templates/wevu/project.private.config.json +2 -2
  101. package/templates/wevu/src/app.vue +7 -7
  102. package/templates/wevu/src/layouts/admin.vue +73 -0
  103. package/templates/wevu/src/layouts/default.vue +17 -0
  104. package/templates/wevu/src/pages/index/index.vue +7 -0
  105. package/templates/wevu/src/pages/layouts/index.vue +169 -0
  106. package/templates/wevu/tsconfig.json +8 -2
  107. package/templates/wevu-tdesign/package.json +4 -4
  108. package/templates/wevu-tdesign/project.private.config.json +1 -1
  109. package/templates/wevu-tdesign/src/app.vue +4 -3
  110. package/templates/wevu-tdesign/src/components/KpiBoard/index.vue +4 -6
  111. package/templates/wevu-tdesign/src/hooks/useDialog.ts +56 -14
  112. package/templates/wevu-tdesign/src/hooks/useToast.ts +42 -15
  113. package/templates/wevu-tdesign/src/layouts/admin.vue +41 -0
  114. package/templates/wevu-tdesign/src/layouts/default.vue +23 -0
  115. package/templates/wevu-tdesign/src/pages/ability/index.vue +2 -6
  116. package/templates/wevu-tdesign/src/pages/form/index.vue +0 -2
  117. package/templates/wevu-tdesign/src/pages/index/index.vue +12 -4
  118. package/templates/wevu-tdesign/src/pages/layouts/index.vue +94 -0
  119. package/templates/wevu-tdesign/src/pages/list/index.vue +0 -2
  120. package/templates/wevu-tdesign/src/subpackages/lab/index.vue +22 -6
  121. package/templates/wevu-tdesign/tsconfig.json +8 -2
  122. package/templates/wevu-tdesign/vite.config.ts +9 -0
  123. package/templates/default/auto-import-components.json +0 -3
  124. package/templates/default/src/vite-env.d.ts +0 -1
  125. package/templates/default/tsconfig.app.json +0 -49
  126. package/templates/default/tsconfig.node.json +0 -33
  127. package/templates/lib/auto-import-components.json +0 -3
  128. package/templates/lib/src/vite-env.d.ts +0 -1
  129. package/templates/lib/tsconfig.app.json +0 -49
  130. package/templates/lib/tsconfig.node.json +0 -33
  131. package/templates/tailwindcss/auto-import-components.json +0 -3
  132. package/templates/tailwindcss/src/vite-env.d.ts +0 -1
  133. package/templates/tailwindcss/tsconfig.app.json +0 -49
  134. package/templates/tailwindcss/tsconfig.node.json +0 -33
  135. package/templates/tdesign/auto-import-components.json +0 -84
  136. package/templates/tdesign/src/vite-env.d.ts +0 -1
  137. package/templates/tdesign/tsconfig.app.json +0 -52
  138. package/templates/tdesign/tsconfig.node.json +0 -33
  139. package/templates/vant/auto-import-components.json +0 -71
  140. package/templates/vant/src/vite-env.d.ts +0 -1
  141. package/templates/vant/tsconfig.app.json +0 -52
  142. package/templates/vant/tsconfig.node.json +0 -33
  143. package/templates/wevu/auto-import-components.json +0 -4
  144. package/templates/wevu/src/components.d.ts +0 -25
  145. package/templates/wevu/src/typed-components.d.ts +0 -22
  146. package/templates/wevu/src/typed-router.d.ts +0 -67
  147. package/templates/wevu/src/vite-env.d.ts +0 -1
  148. package/templates/wevu/tsconfig.app.json +0 -51
  149. package/templates/wevu/tsconfig.node.json +0 -33
  150. package/templates/wevu-tdesign/auto-import-components.json +0 -84
  151. package/templates/wevu-tdesign/mini-program.html-data.json +0 -6784
  152. package/templates/wevu-tdesign/src/components.d.ts +0 -267
  153. package/templates/wevu-tdesign/src/typed-components.d.ts +0 -955
  154. package/templates/wevu-tdesign/src/typed-router.d.ts +0 -75
  155. package/templates/wevu-tdesign/src/vite-env.d.ts +0 -1
  156. package/templates/wevu-tdesign/tsconfig.app.json +0 -54
  157. package/templates/wevu-tdesign/tsconfig.node.json +0 -33
@@ -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,
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
  }
@@ -0,0 +1,41 @@
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ subtitle?: string
4
+ title?: string
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
+ })
14
+ </script>
15
+
16
+ <template>
17
+ <view class="layout-admin min-h-full bg-[linear-gradient(180deg,#f8f7ff_0%,#f1efff_100%)]">
18
+ <view class="rounded-b-[32rpx] bg-[linear-gradient(145deg,#2f2b5f_0%,#4b3fb8_64%,#8b7bff_100%)] px-[32rpx] pb-[32rpx] pt-[36rpx] text-white shadow-[0_18rpx_42rpx_rgba(75,63,184,0.18)]">
19
+ <text class="inline-flex rounded-full bg-white/15 px-[16rpx] py-[8rpx] text-[22rpx]">
20
+ layouts/admin.vue
21
+ </text>
22
+ <text class="mt-[18rpx] block text-[46rpx] font-semibold">
23
+ {{ props.title || 'Admin Layout' }}
24
+ </text>
25
+ <text class="mt-[12rpx] block text-[24rpx] leading-[1.7] text-white/90">
26
+ {{ props.subtitle || '页面内容通过默认 slot 注入到布局中。' }}
27
+ </text>
28
+ </view>
29
+ <view class="pb-[32rpx]">
30
+ <slot />
31
+ </view>
32
+ <t-toast id="t-toast" />
33
+ <t-dialog id="t-dialog" />
34
+ </view>
35
+ </template>
36
+
37
+ <style>
38
+ .layout-admin {
39
+ min-height: 100%;
40
+ }
41
+ </style>
@@ -0,0 +1,23 @@
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
+
11
+ <template>
12
+ <view class="layout-default">
13
+ <slot />
14
+ <t-toast id="t-toast" />
15
+ <t-dialog id="t-dialog" />
16
+ </view>
17
+ </template>
18
+
19
+ <style>
20
+ .layout-default {
21
+ min-height: 100%;
22
+ }
23
+ </style>
@@ -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>
@@ -98,6 +98,16 @@ const quickActions = ref<QuickActionItem[]>([
98
98
  path: '/pages/ability/index',
99
99
  type: 'tab',
100
100
  },
101
+ {
102
+ key: 'layouts',
103
+ title: '布局能力',
104
+ description: 'default / admin / false',
105
+ icon: 'layers',
106
+ tag: 'Layout',
107
+ tone: 'brand',
108
+ path: '/pages/layouts/index',
109
+ type: 'sub',
110
+ },
101
111
  {
102
112
  key: 'lab',
103
113
  title: '组件实验室',
@@ -141,13 +151,13 @@ watch(refreshSeed, () => {
141
151
  lastUpdated.value = `更新于 ${new Date().toLocaleTimeString()}`
142
152
  })
143
153
 
144
- usePullDownRefresh(refreshDashboard)
145
-
146
154
  function refreshDashboard() {
147
155
  refreshSeed.value = Math.max(1, Math.floor(Math.random() * 9))
148
156
  showToast('指标已刷新')
149
157
  }
150
158
 
159
+ usePullDownRefresh(refreshDashboard)
160
+
151
161
  function onQuickAction(action: QuickActionItem) {
152
162
  if (!action.path) {
153
163
  showToast('该入口暂未配置')
@@ -303,7 +313,5 @@ function onQuickAction(action: QuickActionItem) {
303
313
  </t-cell-group>
304
314
  </view>
305
315
  </view>
306
-
307
- <t-toast id="t-toast" />
308
316
  </view>
309
317
  </template>
@@ -0,0 +1,94 @@
1
+ <script setup lang="ts">
2
+ import { ref, setPageLayout } from 'wevu'
3
+
4
+ import SectionTitle from '@/components/SectionTitle/index.vue'
5
+ import { useToast } from '@/hooks/useToast'
6
+
7
+ definePageJson({
8
+ navigationBarTitleText: '布局',
9
+ backgroundColor: '#f6f7fb',
10
+ })
11
+
12
+ const { showToast } = useToast()
13
+ const currentLayout = ref<'default' | 'admin' | 'none'>('default')
14
+
15
+ const cards = [
16
+ {
17
+ key: 'default',
18
+ title: 'default 布局',
19
+ desc: '页面未声明 layout 时,会自动命中 src/layouts/default.vue。',
20
+ },
21
+ {
22
+ key: 'admin',
23
+ title: 'admin 布局',
24
+ desc: '通过 setPageLayout(\'admin\') 切换到命名布局,并把 title/subtitle 作为 props 传给布局组件。',
25
+ },
26
+ {
27
+ key: 'none',
28
+ title: '关闭布局',
29
+ desc: '通过 setPageLayout(false) 临时移除页面壳,用于沉浸式页或特殊根结构。',
30
+ },
31
+ ]
32
+
33
+ function applyDefaultLayout() {
34
+ currentLayout.value = 'default'
35
+ setPageLayout('default')
36
+ showToast('已切回 default 布局')
37
+ }
38
+
39
+ function applyAdminLayout() {
40
+ currentLayout.value = 'admin'
41
+ setPageLayout('admin', {
42
+ title: 'Studio Admin',
43
+ subtitle: '这个标题来自 setPageLayout() 运行时传入的 props。',
44
+ })
45
+ showToast('已切换到 admin 布局')
46
+ }
47
+
48
+ function clearLayout() {
49
+ currentLayout.value = 'none'
50
+ setPageLayout(false)
51
+ showToast('已关闭布局')
52
+ }
53
+ </script>
54
+
55
+ <template>
56
+ <view class="min-h-screen bg-[#f6f7fb] px-[28rpx] pb-[88rpx] pt-[24rpx] text-[#1c1c3c]">
57
+ <view class="rounded-[28rpx] bg-gradient-to-br from-[#eef2ff] via-[#ffffff] to-[#ede9fe] p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.06)]">
58
+ <SectionTitle title="页面布局能力" subtitle="基础模板已接入 src/layouts 目录约定" />
59
+ <text class="mt-[12rpx] block text-[22rpx] leading-[1.7] text-[#5b5b7b]">
60
+ 当前状态:{{ currentLayout }}。可在 default、admin 与 false 三种模式之间切换,用来承接后台页、运营页或沉浸式页面。
61
+ </text>
62
+ </view>
63
+
64
+ <view class="mt-[18rpx] flex flex-col gap-[14rpx]">
65
+ <view
66
+ v-for="item in cards"
67
+ :key="item.key"
68
+ class="rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]"
69
+ >
70
+ <text class="text-[28rpx] font-semibold text-[#1f1a3f]">
71
+ {{ item.title }}
72
+ </text>
73
+ <text class="mt-[10rpx] block text-[22rpx] leading-[1.7] text-[#6f6b8a]">
74
+ {{ item.desc }}
75
+ </text>
76
+ </view>
77
+ </view>
78
+
79
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
80
+ <SectionTitle title="切换布局" subtitle="运行时调用 setPageLayout()" />
81
+ <view class="mt-[14rpx] flex flex-col gap-[12rpx]">
82
+ <t-button block theme="primary" @tap="applyDefaultLayout">
83
+ 使用 default 布局
84
+ </t-button>
85
+ <t-button block theme="primary" variant="outline" @tap="applyAdminLayout">
86
+ 切到 admin 布局
87
+ </t-button>
88
+ <t-button block theme="danger" variant="outline" @tap="clearLayout">
89
+ 关闭布局
90
+ </t-button>
91
+ </view>
92
+ </view>
93
+ </view>
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>
@@ -22,6 +22,22 @@ const tabs = [
22
22
  { value: 'display', label: '展示' },
23
23
  ]
24
24
 
25
+ function handleTabChange(e: any) {
26
+ activeTab.value = String(e.detail.value)
27
+ }
28
+
29
+ function handleRateChange(e: any) {
30
+ rating.value = Number(e.detail.value)
31
+ }
32
+
33
+ function handleSliderChange(e: any) {
34
+ slider.value = Number(e.detail.value)
35
+ }
36
+
37
+ function handleToggleChange(e: any) {
38
+ toggle.value = Boolean(e.detail.value)
39
+ }
40
+
25
41
  function navigateTo(url: string) {
26
42
  wx.navigateTo({
27
43
  url,
@@ -34,7 +50,7 @@ function navigateTo(url: string) {
34
50
  <view class="rounded-[28rpx] bg-gradient-to-br from-[#f5f3ff] via-[#ffffff] to-[#eef2ff] p-[20rpx]">
35
51
  <SectionTitle title="TDesign 组件实验室" subtitle="常用组件的组合应用" />
36
52
  <view class="mt-[12rpx]">
37
- <t-tabs :value="activeTab" @change="(e) => (activeTab = e.detail.value)">
53
+ <t-tabs :value="activeTab" @change="handleTabChange">
38
54
  <t-tab-panel v-for="tab in tabs" :key="tab.value" :value="tab.value" :label="tab.label" />
39
55
  </t-tabs>
40
56
  </view>
@@ -68,7 +84,7 @@ function navigateTo(url: string) {
68
84
  B
69
85
  </t-avatar>
70
86
  </t-badge>
71
- <t-avatar-group max="3" size="small">
87
+ <t-avatar-group :max="3" size="small">
72
88
  <t-avatar>U1</t-avatar>
73
89
  <t-avatar>U2</t-avatar>
74
90
  <t-avatar>U3</t-avatar>
@@ -92,14 +108,14 @@ function navigateTo(url: string) {
92
108
  <text class="text-[22rpx] text-[#6f6b8a]">
93
109
  满意度评分
94
110
  </text>
95
- <t-rate :value="rating" @change="(e) => (rating = e.detail.value)" />
111
+ <t-rate :value="rating" @change="handleRateChange" />
96
112
  </view>
97
113
  <view class="flex items-center justify-between">
98
114
  <text class="text-[22rpx] text-[#6f6b8a]">
99
115
  阈值调整
100
116
  </text>
101
117
  <view class="flex items-center gap-[12rpx]">
102
- <t-slider :value="slider" @change="(e) => (slider = e.detail.value)" />
118
+ <t-slider :value="slider" @change="handleSliderChange" />
103
119
  <text class="text-[22rpx] text-[#6f6b8a]">
104
120
  {{ slider }}%
105
121
  </text>
@@ -109,7 +125,7 @@ function navigateTo(url: string) {
109
125
  <text class="text-[22rpx] text-[#6f6b8a]">
110
126
  自动提醒
111
127
  </text>
112
- <t-switch :value="toggle" @change="(e) => (toggle = e.detail.value)" />
128
+ <t-switch :value="toggle" @change="handleToggleChange" />
113
129
  </view>
114
130
  </view>
115
131
 
@@ -142,7 +158,7 @@ function navigateTo(url: string) {
142
158
  <text class="text-[22rpx] text-[#6f6b8a]">
143
159
  扫码体验
144
160
  </text>
145
- <t-qrcode value="https://vite.icebreaker.top" size="90" />
161
+ <t-qrcode value="https://vite.icebreaker.top" :size="90" />
146
162
  </view>
147
163
  </view>
148
164
  </view>
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "references": [
3
3
  {
4
- "path": "./tsconfig.app.json"
4
+ "path": "./.weapp-vite/tsconfig.app.json"
5
5
  },
6
6
  {
7
- "path": "./tsconfig.node.json"
7
+ "path": "./.weapp-vite/tsconfig.server.json"
8
+ },
9
+ {
10
+ "path": "./.weapp-vite/tsconfig.node.json"
11
+ },
12
+ {
13
+ "path": "./.weapp-vite/tsconfig.shared.json"
8
14
  }
9
15
  ],
10
16
  "files": []
@@ -11,6 +11,15 @@ export default defineConfig({
11
11
  },
12
12
  weapp: {
13
13
  srcRoot: 'src',
14
+ typescript: {
15
+ app: {
16
+ compilerOptions: {
17
+ paths: {
18
+ 'tdesign-miniprogram/*': ['./node_modules/tdesign-miniprogram/miniprogram_dist/*'],
19
+ },
20
+ },
21
+ },
22
+ },
14
23
  autoRoutes: true,
15
24
  autoImportComponents: {
16
25
  resolvers: [TDesignResolver()],
@@ -1,3 +0,0 @@
1
- {
2
- "HelloWorld": "/components/HelloWorld/HelloWorld"
3
- }
@@ -1 +0,0 @@
1
- /// <reference types="weapp-vite/client" />
@@ -1,49 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2023",
5
- "jsx": "preserve",
6
- "lib": [
7
- "ES2023",
8
- "DOM",
9
- "DOM.Iterable"
10
- ],
11
- "moduleDetection": "force",
12
- "baseUrl": ".",
13
- "module": "ESNext",
14
- "moduleResolution": "bundler",
15
- "paths": {
16
- "@/*": [
17
- "./src/*"
18
- ]
19
- },
20
- "resolveJsonModule": true,
21
- "types": [
22
- "miniprogram-api-typings"
23
- ],
24
- "allowImportingTsExtensions": true,
25
- "allowJs": true,
26
- "strict": true,
27
- "noFallthroughCasesInSwitch": true,
28
- "noUnusedLocals": true,
29
- "noUnusedParameters": true,
30
- "noEmit": true,
31
- "allowSyntheticDefaultImports": true,
32
- "esModuleInterop": true,
33
- "isolatedModules": true,
34
- "verbatimModuleSyntax": true,
35
- "noUncheckedSideEffectImports": true,
36
- "erasableSyntaxOnly": true,
37
- "skipLibCheck": true
38
- },
39
- "vueCompilerOptions": {
40
- "plugins": [
41
- "weapp-vite/volar"
42
- ]
43
- },
44
- "include": [
45
- "src/**/*",
46
- "types/**/*.d.ts",
47
- "env.d.ts"
48
- ]
49
- }
@@ -1,33 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2023",
5
- "lib": [
6
- "ES2023"
7
- ],
8
- "moduleDetection": "force",
9
- "module": "ESNext",
10
- "moduleResolution": "bundler",
11
- "resolveJsonModule": true,
12
- "types": [
13
- "node"
14
- ],
15
- "allowImportingTsExtensions": true,
16
- "strict": true,
17
- "noFallthroughCasesInSwitch": true,
18
- "noUnusedLocals": true,
19
- "noUnusedParameters": true,
20
- "noEmit": true,
21
- "verbatimModuleSyntax": true,
22
- "noUncheckedSideEffectImports": true,
23
- "erasableSyntaxOnly": true,
24
- "skipLibCheck": true
25
- },
26
- "include": [
27
- "vite.config.ts",
28
- "vite.config.*.ts",
29
- "*.config.ts",
30
- "config/**/*.ts",
31
- "scripts/**/*.ts"
32
- ]
33
- }
@@ -1,3 +0,0 @@
1
- {
2
- "HelloWorld": "/components/HelloWorld/HelloWorld"
3
- }
@@ -1 +0,0 @@
1
- /// <reference types="weapp-vite/client" />
@@ -1,49 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2023",
5
- "jsx": "preserve",
6
- "lib": [
7
- "ES2023",
8
- "DOM",
9
- "DOM.Iterable"
10
- ],
11
- "moduleDetection": "force",
12
- "baseUrl": ".",
13
- "module": "ESNext",
14
- "moduleResolution": "bundler",
15
- "paths": {
16
- "@/*": [
17
- "./src/*"
18
- ]
19
- },
20
- "resolveJsonModule": true,
21
- "types": [
22
- "miniprogram-api-typings"
23
- ],
24
- "allowImportingTsExtensions": true,
25
- "allowJs": true,
26
- "strict": true,
27
- "noFallthroughCasesInSwitch": true,
28
- "noUnusedLocals": true,
29
- "noUnusedParameters": true,
30
- "noEmit": true,
31
- "allowSyntheticDefaultImports": true,
32
- "esModuleInterop": true,
33
- "isolatedModules": true,
34
- "verbatimModuleSyntax": true,
35
- "noUncheckedSideEffectImports": true,
36
- "erasableSyntaxOnly": true,
37
- "skipLibCheck": true
38
- },
39
- "vueCompilerOptions": {
40
- "plugins": [
41
- "weapp-vite/volar"
42
- ]
43
- },
44
- "include": [
45
- "src/**/*",
46
- "types/**/*.d.ts",
47
- "env.d.ts"
48
- ]
49
- }