create-weapp-vite 2.0.58 → 2.0.60

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 (28) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/{src-hBW5b5RM.js → src-CXCuh90o.js} +69 -11
  4. package/package.json +1 -1
  5. package/templates/default/project.private.config.json +1 -1
  6. package/templates/lib/package.json +1 -1
  7. package/templates/lib/project.private.config.json +1 -1
  8. package/templates/tailwindcss/project.private.config.json +1 -1
  9. package/templates/tdesign/project.private.config.json +1 -1
  10. package/templates/vant/project.private.config.json +1 -1
  11. package/templates/wevu/project.private.config.json +1 -1
  12. package/templates/wevu-tdesign/package.json +1 -1
  13. package/templates/wevu-tdesign/project.private.config.json +19 -1
  14. package/templates/wevu-tdesign/src/app.vue +2 -0
  15. package/templates/wevu-tdesign/src/hooks/useDialog.ts +165 -34
  16. package/templates/wevu-tdesign/src/hooks/useLayoutFeedbackBridge.ts +17 -0
  17. package/templates/wevu-tdesign/src/hooks/useToast.ts +48 -9
  18. package/templates/wevu-tdesign/src/layouts/admin.vue +6 -0
  19. package/templates/wevu-tdesign/src/layouts/default.vue +6 -0
  20. package/templates/wevu-tdesign/src/pages/ability/index.vue +0 -2
  21. package/templates/wevu-tdesign/src/pages/form/index.vue +0 -1
  22. package/templates/wevu-tdesign/src/pages/index/index.vue +67 -6
  23. package/templates/wevu-tdesign/src/pages/layout-feedback/components/FeedbackCallerCard.vue +79 -0
  24. package/templates/wevu-tdesign/src/pages/layout-feedback/index.vue +211 -0
  25. package/templates/wevu-tdesign/src/pages/layout-store/index.vue +127 -0
  26. package/templates/wevu-tdesign/src/pages/layouts/index.vue +25 -1
  27. package/templates/wevu-tdesign/src/pages/list/index.vue +0 -1
  28. package/templates/wevu-tdesign/src/stores/layoutInteractionDemo.ts +129 -0
@@ -1,9 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import type { QuickActionItem } from '@/types/action'
3
3
 
4
- import { computed, ref, watch } from 'wevu'
4
+ import { computed, getCurrentInstance, ref, resolveLayoutBridge, resolveLayoutHost, watch } from 'wevu'
5
5
  import KpiBoard from '@/components/KpiBoard/index.vue'
6
6
  import QuickActionGrid from '@/components/QuickActionGrid/index.vue'
7
+ import { LAYOUT_TOAST_BRIDGE_KEY } from '@/hooks/useLayoutFeedbackBridge'
7
8
  import { usePullDownRefresh } from '@/hooks/usePullDownRefresh'
8
9
  import { useToast } from '@/hooks/useToast'
9
10
 
@@ -14,6 +15,7 @@ definePageJson({
14
15
  })
15
16
 
16
17
  const { showToast } = useToast()
18
+ const pageInstance = getCurrentInstance<any>()
17
19
 
18
20
  const noticeText = ref('欢迎体验 wevu + weapp-vite + TDesign 模板,已启用分包与多页面导航。')
19
21
  const lastUpdated = ref('刚刚')
@@ -108,6 +110,26 @@ const quickActions = ref<QuickActionItem[]>([
108
110
  path: '/pages/layouts/index',
109
111
  type: 'sub',
110
112
  },
113
+ {
114
+ key: 'layout-feedback',
115
+ title: 'Layout 通信',
116
+ description: '页面/组件调用 layout',
117
+ icon: 'chat-bubble',
118
+ tag: 'Bridge',
119
+ tone: 'brand',
120
+ path: '/pages/layout-feedback/index',
121
+ type: 'sub',
122
+ },
123
+ {
124
+ key: 'layout-store',
125
+ title: 'Store 调用 Layout',
126
+ description: 'store 驱动 layout 宿主',
127
+ icon: 'layers',
128
+ tag: 'Store',
129
+ tone: 'brand',
130
+ path: '/pages/layout-store/index',
131
+ type: 'sub',
132
+ },
111
133
  {
112
134
  key: 'lab',
113
135
  title: '组件实验室',
@@ -151,11 +173,49 @@ watch(refreshSeed, () => {
151
173
  lastUpdated.value = `更新于 ${new Date().toLocaleTimeString()}`
152
174
  })
153
175
 
176
+ function nextRefreshSeedValue() {
177
+ return refreshSeed.value >= 9 ? 1 : refreshSeed.value + 1
178
+ }
179
+
154
180
  function refreshDashboard() {
155
- refreshSeed.value = Math.max(1, Math.floor(Math.random() * 9))
181
+ refreshSeed.value = nextRefreshSeedValue()
156
182
  showToast('指标已刷新')
157
183
  }
158
184
 
185
+ function inspectLayoutToastBridge() {
186
+ const bridge = resolveLayoutBridge(LAYOUT_TOAST_BRIDGE_KEY, pageInstance)
187
+ const layoutByPage = pageInstance?.selectComponent?.('weapp-layout-default')
188
+ ?? pageInstance?.selectComponent?.('.weapp-layout-default')
189
+ ?? null
190
+ const toastFromBridge = resolveLayoutHost(LAYOUT_TOAST_BRIDGE_KEY, { context: pageInstance })
191
+
192
+ return {
193
+ bridgeResolved: Boolean(bridge),
194
+ bridgeIsPage: bridge === pageInstance,
195
+ bridgeHasSelectComponent: typeof bridge?.selectComponent === 'function',
196
+ layoutFoundByPage: Boolean(layoutByPage),
197
+ toastFoundByBridge: Boolean(toastFromBridge),
198
+ bridgeKeys: bridge ? Object.keys(bridge).slice(0, 20) : [],
199
+ layoutKeys: layoutByPage ? Object.keys(layoutByPage).slice(0, 20) : [],
200
+ }
201
+ }
202
+
203
+ void inspectLayoutToastBridge
204
+
205
+ function runLayoutToastE2E() {
206
+ refreshSeed.value = nextRefreshSeedValue()
207
+ const bridgeState = inspectLayoutToastBridge()
208
+ setTimeout(() => {
209
+ showToast('指标已刷新')
210
+ }, 0)
211
+ return {
212
+ ...bridgeState,
213
+ refreshSeed: refreshSeed.value,
214
+ }
215
+ }
216
+
217
+ void runLayoutToastE2E
218
+
159
219
  usePullDownRefresh(refreshDashboard)
160
220
 
161
221
  function onQuickAction(action: QuickActionItem) {
@@ -193,9 +253,11 @@ function onQuickAction(action: QuickActionItem) {
193
253
  <text class="text-[20rpx] text-white/70">
194
254
  {{ lastUpdated }}
195
255
  </text>
196
- <t-button size="small" theme="default" variant="outline" @tap="refreshDashboard">
197
- 刷新指标
198
- </t-button>
256
+ <view id="refresh-dashboard-trigger" @tap="refreshDashboard">
257
+ <t-button size="small" theme="default" variant="outline">
258
+ 刷新指标
259
+ </t-button>
260
+ </view>
199
261
  </view>
200
262
  </view>
201
263
 
@@ -313,6 +375,5 @@ function onQuickAction(action: QuickActionItem) {
313
375
  </t-cell-group>
314
376
  </view>
315
377
  </view>
316
- <t-toast id="t-toast" />
317
378
  </view>
318
379
  </template>
@@ -0,0 +1,79 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'wevu'
3
+ import { useDialog } from '@/hooks/useDialog'
4
+ import { useToast } from '@/hooks/useToast'
5
+
6
+ const props = defineProps<{
7
+ onReport?: (payload: string) => void
8
+ }>()
9
+
10
+ const actionSeed = ref(0)
11
+ const { showToast } = useToast({ duration: 1400 })
12
+ const { alert, confirm } = useDialog()
13
+
14
+ function nextLabel(prefix: string) {
15
+ actionSeed.value += 1
16
+ return `${prefix} #${actionSeed.value}`
17
+ }
18
+
19
+ function triggerChildToast() {
20
+ const label = nextLabel('子组件 Toast')
21
+ showToast(`${label} 已通过 layout 宿主触发`)
22
+ props.onReport?.(`${label} 已触发`)
23
+ }
24
+
25
+ function triggerChildAlert() {
26
+ const label = nextLabel('子组件 Alert')
27
+ void alert({
28
+ title: label,
29
+ content: '当前弹窗由子组件直接调用 useDialog(),但实际宿主仍在 layout 内。',
30
+ confirmBtn: '知道了',
31
+ }).then(() => {
32
+ props.onReport?.(`${label} 已确认`)
33
+ })
34
+ }
35
+
36
+ function triggerChildConfirm() {
37
+ const label = nextLabel('子组件 Confirm')
38
+ void confirm({
39
+ title: label,
40
+ content: '点击确认后会回传一条日志,证明子组件与页面都能经由同一 layout 宿主通信。',
41
+ confirmBtn: '确认',
42
+ cancelBtn: '取消',
43
+ }).then(() => {
44
+ props.onReport?.(`${label} 点击确认`)
45
+ }).catch(() => {
46
+ props.onReport?.(`${label} 点击取消`)
47
+ })
48
+ }
49
+ </script>
50
+
51
+ <template>
52
+ <view class="rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
53
+ <view class="flex items-center justify-between">
54
+ <view>
55
+ <text class="text-[28rpx] font-semibold text-[#1f1a3f]">
56
+ 子组件直连 layout 宿主
57
+ </text>
58
+ <text class="mt-[6rpx] block text-[22rpx] leading-[1.7] text-[#6f6b8a]">
59
+ 这个组件不接收 toast/dialog 实例,也不手动 selectComponent,只直接调用 useToast() / useDialog()。
60
+ </text>
61
+ </view>
62
+ <t-tag size="small" theme="primary" variant="light">
63
+ Child
64
+ </t-tag>
65
+ </view>
66
+
67
+ <view class="mt-[18rpx] flex flex-col gap-[12rpx]">
68
+ <t-button block theme="primary" variant="outline" @tap="triggerChildToast">
69
+ 子组件触发 Toast
70
+ </t-button>
71
+ <t-button block theme="primary" variant="outline" @tap="triggerChildAlert">
72
+ 子组件触发 Alert
73
+ </t-button>
74
+ <t-button block theme="danger" variant="outline" @tap="triggerChildConfirm">
75
+ 子组件触发 Confirm
76
+ </t-button>
77
+ </view>
78
+ </view>
79
+ </template>
@@ -0,0 +1,211 @@
1
+ <script setup lang="ts">
2
+ import { computed, getCurrentInstance, ref, resolveLayoutHost } from 'wevu'
3
+ import SectionTitle from '@/components/SectionTitle/index.vue'
4
+ import { useDialog } from '@/hooks/useDialog'
5
+ import { LAYOUT_DIALOG_BRIDGE_KEY, LAYOUT_TOAST_BRIDGE_KEY } from '@/hooks/useLayoutFeedbackBridge'
6
+ import { useToast } from '@/hooks/useToast'
7
+ import FeedbackCallerCard from './components/FeedbackCallerCard.vue'
8
+
9
+ definePageJson({
10
+ navigationBarTitleText: 'Layout 通信演示',
11
+ backgroundColor: '#f6f7fb',
12
+ })
13
+
14
+ const pageInstance = getCurrentInstance<any>()
15
+ const { showToast } = useToast({ duration: 1400 })
16
+ const { alert, confirm } = useDialog()
17
+ const actionSeed = ref(0)
18
+ const actionLogs = ref<string[]>([
19
+ '页面与子组件都会直接调用 useToast() / useDialog(),由 layout 统一承载宿主。',
20
+ ])
21
+
22
+ const bridgeStatus = computed(() => {
23
+ const toastHost = resolveLayoutHost(LAYOUT_TOAST_BRIDGE_KEY, { context: pageInstance })
24
+ const dialogHost = resolveLayoutHost(LAYOUT_DIALOG_BRIDGE_KEY, { context: pageInstance })
25
+
26
+ return [
27
+ {
28
+ key: 'toast',
29
+ title: 'Toast Host',
30
+ description: toastHost ? '已解析到 layout 内的 t-toast 实例。' : '尚未解析到 toast 宿主。',
31
+ ready: Boolean(toastHost),
32
+ },
33
+ {
34
+ key: 'dialog',
35
+ title: 'Dialog Host',
36
+ description: dialogHost ? '已解析到 layout 内的 t-dialog 实例。' : '尚未解析到 dialog 宿主。',
37
+ ready: Boolean(dialogHost),
38
+ },
39
+ ]
40
+ })
41
+
42
+ function pushLog(message: string) {
43
+ actionLogs.value = [`${new Date().toLocaleTimeString()} ${message}`, ...actionLogs.value].slice(0, 8)
44
+ }
45
+
46
+ function onChildReport(message: string) {
47
+ pushLog(message)
48
+ }
49
+
50
+ function nextLabel(prefix: string) {
51
+ actionSeed.value += 1
52
+ return `${prefix} #${actionSeed.value}`
53
+ }
54
+
55
+ function triggerPageToast() {
56
+ const label = nextLabel('页面 Toast')
57
+ showToast(`${label} 已通过 layout 宿主触发`)
58
+ pushLog(`${label} 已触发`)
59
+ }
60
+
61
+ function triggerPageAlert() {
62
+ const label = nextLabel('页面 Alert')
63
+ void alert({
64
+ title: label,
65
+ content: '这是页面直接调用 useDialog() 后,由 layout 内 t-dialog 承载的弹窗。',
66
+ confirmBtn: '知道了',
67
+ }).then(() => {
68
+ pushLog(`${label} 已确认`)
69
+ })
70
+ }
71
+
72
+ function triggerPageConfirm() {
73
+ const label = nextLabel('页面 Confirm')
74
+ void confirm({
75
+ title: label,
76
+ content: '确认后会写入日志,方便观察页面与 layout 宿主之间的通信。',
77
+ confirmBtn: '确认',
78
+ cancelBtn: '取消',
79
+ }).then(() => {
80
+ pushLog(`${label} 点击确认`)
81
+ }).catch(() => {
82
+ pushLog(`${label} 点击取消`)
83
+ })
84
+ }
85
+
86
+ function inspectDialogHostE2E() {
87
+ const dialogHost = resolveLayoutHost<any>(LAYOUT_DIALOG_BRIDGE_KEY, { context: pageInstance })
88
+ return {
89
+ hasHost: Boolean(dialogHost),
90
+ visible: dialogHost?.data?.visible ?? dialogHost?.properties?.visible ?? null,
91
+ hasOnConfirm: typeof dialogHost?._onConfirm === 'function',
92
+ hasOnCancel: typeof dialogHost?._onCancel === 'function',
93
+ hasNativeConfirm: typeof dialogHost?.onConfirm === 'function',
94
+ hasNativeCancel: typeof dialogHost?.onCancel === 'function',
95
+ title: dialogHost?.data?.title ?? dialogHost?.properties?.title ?? '',
96
+ confirmBtn: dialogHost?.data?._confirm?.content ?? dialogHost?.properties?.confirmBtn ?? '',
97
+ cancelBtn: dialogHost?.data?._cancel?.content ?? dialogHost?.properties?.cancelBtn ?? '',
98
+ }
99
+ }
100
+
101
+ async function runPageAlertCloseE2E() {
102
+ triggerPageAlert()
103
+ await new Promise(resolve => setTimeout(resolve, 120))
104
+ return inspectDialogHostE2E()
105
+ }
106
+
107
+ async function runPageConfirmOpenE2E() {
108
+ triggerPageConfirm()
109
+ await new Promise(resolve => setTimeout(resolve, 120))
110
+ return inspectDialogHostE2E()
111
+ }
112
+
113
+ function getLayoutFeedbackLogsE2E() {
114
+ return actionLogs.value.slice()
115
+ }
116
+
117
+ async function runDialogHostConfirmE2E() {
118
+ const dialogHost = resolveLayoutHost<any>(LAYOUT_DIALOG_BRIDGE_KEY, { context: pageInstance })
119
+ dialogHost?.onConfirm?.()
120
+ await new Promise(resolve => setTimeout(resolve, 60))
121
+ return inspectDialogHostE2E()
122
+ }
123
+
124
+ async function runDialogHostCancelE2E() {
125
+ const dialogHost = resolveLayoutHost<any>(LAYOUT_DIALOG_BRIDGE_KEY, { context: pageInstance })
126
+ dialogHost?.onCancel?.()
127
+ await new Promise(resolve => setTimeout(resolve, 60))
128
+ return inspectDialogHostE2E()
129
+ }
130
+
131
+ void inspectDialogHostE2E
132
+ void runPageAlertCloseE2E
133
+ void runPageConfirmOpenE2E
134
+ void getLayoutFeedbackLogsE2E
135
+ void runDialogHostConfirmE2E
136
+ void runDialogHostCancelE2E
137
+ </script>
138
+
139
+ <template>
140
+ <view class="min-h-screen bg-[#f6f7fb] px-[28rpx] pb-[88rpx] pt-[24rpx] text-[#1c1c3c]">
141
+ <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)]">
142
+ <SectionTitle title="Layout 反馈宿主通信" subtitle="页面与子组件都直接调用 hooks,由 layout 持有 toast / dialog 组件实例" />
143
+ <text class="mt-[12rpx] block text-[22rpx] leading-[1.7] text-[#5b5b7b]">
144
+ 推荐用法是业务侧只关心 useToast() / useDialog(),layout 负责注册宿主;页面和组件都不需要关心 id、selector,也不需要直接拿 layout 实例。
145
+ </text>
146
+ </view>
147
+
148
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
149
+ <SectionTitle title="Bridge 状态" subtitle="当前页面是否成功解析到 layout 宿主" />
150
+ <view class="mt-[16rpx] flex flex-col gap-[12rpx]">
151
+ <view
152
+ v-for="item in bridgeStatus"
153
+ :key="item.key"
154
+ class="rounded-[18rpx] bg-[#f7f7fb] p-[16rpx]"
155
+ >
156
+ <view class="flex items-center justify-between">
157
+ <text class="text-[24rpx] font-semibold text-[#1f1a3f]">
158
+ {{ item.title }}
159
+ </text>
160
+ <t-tag :theme="item.ready ? 'success' : 'warning'" size="small" variant="light">
161
+ {{ item.ready ? 'Ready' : 'Pending' }}
162
+ </t-tag>
163
+ </view>
164
+ <text class="mt-[8rpx] block text-[20rpx] leading-[1.7] text-[#6f6b8a]">
165
+ {{ item.description }}
166
+ </text>
167
+ </view>
168
+ </view>
169
+ </view>
170
+
171
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
172
+ <SectionTitle title="页面直接调用" subtitle="页面本身直接触发 layout 内的 toast / dialog 方法" />
173
+ <view class="mt-[16rpx] flex flex-col gap-[12rpx]">
174
+ <view id="layout-feedback-page-toast-trigger">
175
+ <t-button block theme="primary" @tap="triggerPageToast">
176
+ 页面触发 Toast
177
+ </t-button>
178
+ </view>
179
+ <view id="layout-feedback-page-alert-trigger">
180
+ <t-button block theme="primary" variant="outline" @tap="triggerPageAlert">
181
+ 页面触发 Alert
182
+ </t-button>
183
+ </view>
184
+ <view id="layout-feedback-page-confirm-trigger">
185
+ <t-button block theme="danger" variant="outline" @tap="triggerPageConfirm">
186
+ 页面触发 Confirm
187
+ </t-button>
188
+ </view>
189
+ </view>
190
+ </view>
191
+
192
+ <view class="mt-[18rpx]">
193
+ <FeedbackCallerCard :on-report="onChildReport" />
194
+ </view>
195
+
196
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
197
+ <SectionTitle title="通信日志" subtitle="观察页面与子组件调用 layout 宿主后的反馈结果" />
198
+ <view class="mt-[16rpx] flex flex-col gap-[10rpx]">
199
+ <view
200
+ v-for="(item, index) in actionLogs"
201
+ :key="`${item}-${index}`"
202
+ class="rounded-[16rpx] bg-[#f7f7fb] px-[16rpx] py-[14rpx]"
203
+ >
204
+ <text class="block text-[20rpx] leading-[1.7] text-[#4c4b6c]">
205
+ {{ item }}
206
+ </text>
207
+ </view>
208
+ </view>
209
+ </view>
210
+ </view>
211
+ </template>
@@ -0,0 +1,127 @@
1
+ <script setup lang="ts">
2
+ import { onUnload, setPageLayout, storeToRefs, watch } from 'wevu'
3
+ import SectionTitle from '@/components/SectionTitle/index.vue'
4
+ import { useLayoutInteractionDemoStore } from '@/stores/layoutInteractionDemo'
5
+
6
+ definePageJson({
7
+ navigationBarTitleText: 'Store 调用 Layout',
8
+ backgroundColor: '#f6f7fb',
9
+ })
10
+
11
+ const store = useLayoutInteractionDemoStore()
12
+ const { activeLayout, adminLayoutProps, commandStatus, lastResult, logs } = storeToRefs(store)
13
+
14
+ watch([activeLayout, adminLayoutProps], ([layout, props]) => {
15
+ if (layout === 'admin') {
16
+ setPageLayout('admin', props)
17
+ return
18
+ }
19
+ setPageLayout('default')
20
+ }, { immediate: true })
21
+
22
+ function useDefaultLayout() {
23
+ store.setLayout('default')
24
+ }
25
+
26
+ function useAdminLayout() {
27
+ store.setLayout('admin')
28
+ }
29
+
30
+ function openToastByStore() {
31
+ store.triggerToast()
32
+ }
33
+
34
+ function openAlertByStore() {
35
+ store.triggerAlert()
36
+ }
37
+
38
+ function openConfirmByStore() {
39
+ store.triggerConfirm()
40
+ }
41
+
42
+ function clearLogs() {
43
+ store.resetLogs()
44
+ }
45
+
46
+ onUnload(() => {
47
+ setPageLayout('default')
48
+ })
49
+ </script>
50
+
51
+ <template>
52
+ <view class="min-h-screen bg-[#f6f7fb] px-[28rpx] pb-[88rpx] pt-[24rpx] text-[#1c1c3c]">
53
+ <view class="rounded-[28rpx] bg-gradient-to-br from-[#e8f1ff] via-[#ffffff] to-[#eef2ff] p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.06)]">
54
+ <SectionTitle title="Store 驱动 Layout 交互" subtitle="wevu/store 发起意图,页面上下文消费后命中 layout 内的 toast / dialog 宿主" />
55
+ <text class="mt-[12rpx] block text-[22rpx] leading-[1.7] text-[#5b5b7b]">
56
+ 推荐边界是 store 只保存布局状态和交互意图,真正调用 useToast() / useDialog() / setPageLayout() 仍由页面执行,这样不会把 page runtime hook 直接塞进 store。
57
+ </text>
58
+ </view>
59
+
60
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
61
+ <SectionTitle title="当前状态" subtitle="观察 store 对布局和宿主交互的描述" />
62
+ <view class="mt-[16rpx] flex flex-col gap-[12rpx]">
63
+ <view class="rounded-[18rpx] bg-[#f7f7fb] p-[16rpx]">
64
+ <text class="text-[24rpx] font-semibold text-[#1f1a3f]">
65
+ 当前布局:{{ activeLayout }}
66
+ </text>
67
+ <text class="mt-[8rpx] block text-[20rpx] leading-[1.7] text-[#6f6b8a]">
68
+ command 状态:{{ commandStatus }}
69
+ </text>
70
+ </view>
71
+ <view class="rounded-[18rpx] bg-[#f7f7fb] p-[16rpx]">
72
+ <text class="text-[24rpx] font-semibold text-[#1f1a3f]">
73
+ 最近结果
74
+ </text>
75
+ <text class="mt-[8rpx] block text-[20rpx] leading-[1.7] text-[#6f6b8a]">
76
+ {{ lastResult }}
77
+ </text>
78
+ </view>
79
+ </view>
80
+ </view>
81
+
82
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
83
+ <SectionTitle title="切换 Layout" subtitle="store 修改布局状态,页面 watch 后调用 setPageLayout()" />
84
+ <view class="mt-[16rpx] flex flex-col gap-[12rpx]">
85
+ <t-button block theme="primary" @tap="useDefaultLayout">
86
+ Store 切到 default 布局
87
+ </t-button>
88
+ <t-button block theme="primary" variant="outline" @tap="useAdminLayout">
89
+ Store 切到 admin 布局
90
+ </t-button>
91
+ </view>
92
+ </view>
93
+
94
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
95
+ <SectionTitle title="触发 Layout 宿主" subtitle="store 直接调用 toast / dialog,命中当前 layout 内的反馈宿主" />
96
+ <view class="mt-[16rpx] flex flex-col gap-[12rpx]">
97
+ <t-button block theme="primary" @tap="openToastByStore">
98
+ Store 触发 Toast
99
+ </t-button>
100
+ <t-button block theme="primary" variant="outline" @tap="openAlertByStore">
101
+ Store 触发 Alert
102
+ </t-button>
103
+ <t-button block theme="danger" variant="outline" @tap="openConfirmByStore">
104
+ Store 触发 Confirm
105
+ </t-button>
106
+ </view>
107
+ </view>
108
+
109
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
110
+ <SectionTitle title="通信日志" subtitle="记录 store 发出的布局切换与交互命令" />
111
+ <t-button class="mt-[16rpx]" size="small" theme="default" variant="outline" @tap="clearLogs">
112
+ 清空日志
113
+ </t-button>
114
+ <view class="mt-[16rpx] flex flex-col gap-[10rpx]">
115
+ <view
116
+ v-for="(item, index) in logs"
117
+ :key="`${item}-${index}`"
118
+ class="rounded-[16rpx] bg-[#f7f7fb] px-[16rpx] py-[14rpx]"
119
+ >
120
+ <text class="block text-[20rpx] leading-[1.7] text-[#4c4b6c]">
121
+ {{ item }}
122
+ </text>
123
+ </view>
124
+ </view>
125
+ </view>
126
+ </view>
127
+ </template>
@@ -50,6 +50,18 @@ function clearLayout() {
50
50
  setPageLayout(false)
51
51
  showToast('已关闭布局')
52
52
  }
53
+
54
+ function openLayoutFeedbackDemo() {
55
+ wx.navigateTo({
56
+ url: '/pages/layout-feedback/index',
57
+ })
58
+ }
59
+
60
+ function openLayoutStoreDemo() {
61
+ wx.navigateTo({
62
+ url: '/pages/layout-store/index',
63
+ })
64
+ }
53
65
  </script>
54
66
 
55
67
  <template>
@@ -90,6 +102,18 @@ function clearLayout() {
90
102
  </t-button>
91
103
  </view>
92
104
  </view>
93
- <t-toast id="t-toast" />
105
+
106
+ <view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
107
+ <SectionTitle title="通信演示" subtitle="查看页面/组件如何直接使用 layout 里的反馈宿主" />
108
+ <text class="mt-[12rpx] block text-[22rpx] leading-[1.7] text-[#6f6b8a]">
109
+ 演示页会同时展示页面调用和子组件调用,它们都只依赖 useToast() / useDialog(),不会直接操作 layout 实例。
110
+ </text>
111
+ <t-button class="mt-[16rpx]" block theme="primary" variant="outline" @tap="openLayoutFeedbackDemo">
112
+ 打开 Layout 通信演示
113
+ </t-button>
114
+ <t-button class="mt-[12rpx]" block theme="primary" variant="outline" @tap="openLayoutStoreDemo">
115
+ 打开 Store 驱动 Layout 演示
116
+ </t-button>
117
+ </view>
94
118
  </view>
95
119
  </template>
@@ -142,6 +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
- <t-toast id="t-toast" />
146
145
  </view>
147
146
  </template>