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.
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-hBW5b5RM.js → src-CXCuh90o.js} +69 -11
- package/package.json +1 -1
- package/templates/default/project.private.config.json +1 -1
- package/templates/lib/package.json +1 -1
- package/templates/lib/project.private.config.json +1 -1
- package/templates/tailwindcss/project.private.config.json +1 -1
- package/templates/tdesign/project.private.config.json +1 -1
- package/templates/vant/project.private.config.json +1 -1
- package/templates/wevu/project.private.config.json +1 -1
- package/templates/wevu-tdesign/package.json +1 -1
- package/templates/wevu-tdesign/project.private.config.json +19 -1
- package/templates/wevu-tdesign/src/app.vue +2 -0
- package/templates/wevu-tdesign/src/hooks/useDialog.ts +165 -34
- package/templates/wevu-tdesign/src/hooks/useLayoutFeedbackBridge.ts +17 -0
- package/templates/wevu-tdesign/src/hooks/useToast.ts +48 -9
- package/templates/wevu-tdesign/src/layouts/admin.vue +6 -0
- package/templates/wevu-tdesign/src/layouts/default.vue +6 -0
- package/templates/wevu-tdesign/src/pages/ability/index.vue +0 -2
- package/templates/wevu-tdesign/src/pages/form/index.vue +0 -1
- package/templates/wevu-tdesign/src/pages/index/index.vue +67 -6
- package/templates/wevu-tdesign/src/pages/layout-feedback/components/FeedbackCallerCard.vue +79 -0
- package/templates/wevu-tdesign/src/pages/layout-feedback/index.vue +211 -0
- package/templates/wevu-tdesign/src/pages/layout-store/index.vue +127 -0
- package/templates/wevu-tdesign/src/pages/layouts/index.vue +25 -1
- package/templates/wevu-tdesign/src/pages/list/index.vue +0 -1
- package/templates/wevu-tdesign/src/stores/layoutInteractionDemo.ts +129 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { computed, defineStore, ref } from 'wevu'
|
|
2
|
+
import { alertDialog, confirmDialog } from '@/hooks/useDialog'
|
|
3
|
+
import { showToast } from '@/hooks/useToast'
|
|
4
|
+
|
|
5
|
+
export type LayoutKind = 'default' | 'admin'
|
|
6
|
+
export type LayoutCommandType = 'toast' | 'alert' | 'confirm'
|
|
7
|
+
export type LayoutCommandStatus = 'idle' | 'running'
|
|
8
|
+
|
|
9
|
+
export interface LayoutCommand {
|
|
10
|
+
id: number
|
|
11
|
+
title: string
|
|
12
|
+
content: string
|
|
13
|
+
type: LayoutCommandType
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createLog(message: string) {
|
|
17
|
+
return `${new Date().toLocaleTimeString()} ${message}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const useLayoutInteractionDemoStore = defineStore('layout-interaction-demo', () => {
|
|
21
|
+
const activeLayout = ref<LayoutKind>('default')
|
|
22
|
+
const commandSeed = ref(0)
|
|
23
|
+
const commandStatus = ref<LayoutCommandStatus>('idle')
|
|
24
|
+
const lastResult = ref('尚未触发交互')
|
|
25
|
+
const logs = ref<string[]>([
|
|
26
|
+
createLog('Store 已就绪,当前由 store 直接调用 layout 宿主。'),
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
const adminLayoutProps = computed(() => ({
|
|
30
|
+
title: 'Store Admin Layout',
|
|
31
|
+
subtitle: `当前通过 wevu/store 驱动,最近动作:${lastResult.value}`,
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
function appendLog(message: string) {
|
|
35
|
+
logs.value = [createLog(message), ...logs.value].slice(0, 8)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function setLayout(layout: LayoutKind) {
|
|
39
|
+
activeLayout.value = layout
|
|
40
|
+
appendLog(`切换到 ${layout} 布局`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function createCommand(type: LayoutCommandType, title: string, content: string): LayoutCommand {
|
|
44
|
+
commandSeed.value += 1
|
|
45
|
+
return {
|
|
46
|
+
id: commandSeed.value,
|
|
47
|
+
type,
|
|
48
|
+
title,
|
|
49
|
+
content,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function runCommand(command: LayoutCommand) {
|
|
54
|
+
commandStatus.value = 'running'
|
|
55
|
+
appendLog(`Store 请求 ${command.title}`)
|
|
56
|
+
|
|
57
|
+
if (command.type === 'toast') {
|
|
58
|
+
showToast(command.content)
|
|
59
|
+
finishCommand(`${command.title} 已由 ${activeLayout.value} layout 宿主展示`)
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (command.type === 'alert') {
|
|
64
|
+
await alertDialog({
|
|
65
|
+
title: command.title,
|
|
66
|
+
content: command.content,
|
|
67
|
+
confirmBtn: '知道了',
|
|
68
|
+
})
|
|
69
|
+
finishCommand(`${command.title} 已确认`)
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
await confirmDialog({
|
|
75
|
+
title: command.title,
|
|
76
|
+
content: command.content,
|
|
77
|
+
confirmBtn: '确认',
|
|
78
|
+
cancelBtn: '取消',
|
|
79
|
+
})
|
|
80
|
+
finishCommand(`${command.title} 点击确认`)
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
finishCommand(`${command.title} 点击取消`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function triggerToast() {
|
|
88
|
+
return runCommand(
|
|
89
|
+
createCommand('toast', `Store Toast #${commandSeed.value + 1}`, `当前由 ${activeLayout.value} layout 宿主展示 toast。`),
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function triggerAlert() {
|
|
94
|
+
return runCommand(
|
|
95
|
+
createCommand('alert', `Store Alert #${commandSeed.value + 1}`, `当前由 ${activeLayout.value} layout 宿主展示 alert。`),
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function triggerConfirm() {
|
|
100
|
+
return runCommand(
|
|
101
|
+
createCommand('confirm', `Store Confirm #${commandSeed.value + 1}`, `请确认由 ${activeLayout.value} layout 宿主承载的确认弹窗。`),
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function finishCommand(message: string) {
|
|
106
|
+
lastResult.value = message
|
|
107
|
+
commandStatus.value = 'idle'
|
|
108
|
+
appendLog(message)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function resetLogs() {
|
|
112
|
+
logs.value = [createLog('已清空日志,继续观察 store 与 layout 的通信。')]
|
|
113
|
+
lastResult.value = '日志已清空'
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
activeLayout,
|
|
118
|
+
adminLayoutProps,
|
|
119
|
+
commandStatus,
|
|
120
|
+
lastResult,
|
|
121
|
+
logs,
|
|
122
|
+
finishCommand,
|
|
123
|
+
resetLogs,
|
|
124
|
+
setLayout,
|
|
125
|
+
triggerAlert,
|
|
126
|
+
triggerConfirm,
|
|
127
|
+
triggerToast,
|
|
128
|
+
}
|
|
129
|
+
})
|