create-weapp-vite 2.3.14 → 2.3.16
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-JolaD7Ia.js → src-C8kzMXK7.js} +11 -7
- package/package.json +1 -1
- package/templates/default/.vscode/extensions.json +2 -1
- package/templates/default/package.json +3 -0
- package/templates/lib/.vscode/extensions.json +2 -1
- package/templates/lib/package.json +4 -1
- package/templates/plugin/.vscode/extensions.json +7 -0
- package/templates/plugin/package.json +3 -0
- package/templates/tailwindcss/.vscode/extensions.json +2 -1
- package/templates/tailwindcss/package.json +3 -0
- package/templates/tdesign/.vscode/extensions.json +2 -1
- package/templates/tdesign/package.json +3 -0
- package/templates/vant/.vscode/extensions.json +2 -1
- package/templates/vant/package.json +3 -0
- package/templates/wevu/.vscode/extensions.json +2 -1
- package/templates/wevu/README.md +3 -3
- package/templates/wevu/package.json +4 -1
- package/templates/wevu/src/app.vue +1 -60
- package/templates/wevu/src/pages/index/index.vue +26 -194
- package/templates/wevu/src/pages/layouts/index.vue +0 -18
- package/templates/wevu/weapp-vite.config.ts +0 -7
- package/templates/wevu-tdesign/.vscode/extensions.json +2 -1
- package/templates/wevu-tdesign/README.md +3 -6
- package/templates/wevu-tdesign/package.json +4 -1
- package/templates/wevu-tdesign/project.private.config.json +0 -66
- package/templates/wevu-tdesign/src/app.vue +1 -73
- package/templates/wevu-tdesign/src/pages/index/index.vue +19 -362
- package/templates/wevu/src/components/InfoPanel/index.vue +0 -52
- package/templates/wevu/src/components/StatusPill/index.vue +0 -42
- package/templates/wevu/src/packageA/pages/workspace/index.vue +0 -137
- package/templates/wevu/src/packageB/pages/settings/index.vue +0 -131
- package/templates/wevu/src/pages/overview/index.vue +0 -149
- package/templates/wevu-tdesign/public/tabbar/ability-active.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/ability.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/data-active.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/data.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/form-active.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/form.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/home-active.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/home.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/list-active.png +0 -0
- package/templates/wevu-tdesign/public/tabbar/list.png +0 -0
- package/templates/wevu-tdesign/src/components/EmptyState/index.vue +0 -36
- package/templates/wevu-tdesign/src/components/FilterBar/index.vue +0 -64
- package/templates/wevu-tdesign/src/components/FormRow/index.vue +0 -43
- package/templates/wevu-tdesign/src/components/FormStep/index.vue +0 -48
- package/templates/wevu-tdesign/src/components/KpiBoard/index.vue +0 -145
- package/templates/wevu-tdesign/src/components/QuickActionGrid/index.vue +0 -79
- package/templates/wevu-tdesign/src/components/ResultCard/index.vue +0 -51
- package/templates/wevu-tdesign/src/components/SectionTitle/index.vue +0 -34
- package/templates/wevu-tdesign/src/components/TrendCard/index.vue +0 -101
- package/templates/wevu-tdesign/src/components/VirtualHostClassDemo/BrokenCard.vue +0 -46
- package/templates/wevu-tdesign/src/components/VirtualHostClassDemo/FixedExternalClassCard.vue +0 -50
- package/templates/wevu-tdesign/src/components/VirtualHostClassDemo/RecommendedCard.vue +0 -53
- package/templates/wevu-tdesign/src/hooks/useDialog.ts +0 -205
- package/templates/wevu-tdesign/src/hooks/useFormBinder.ts +0 -17
- package/templates/wevu-tdesign/src/hooks/useLayoutFeedbackBridge.ts +0 -17
- package/templates/wevu-tdesign/src/hooks/usePullDownRefresh.ts +0 -12
- package/templates/wevu-tdesign/src/hooks/useToast.ts +0 -100
- package/templates/wevu-tdesign/src/layouts/admin.vue +0 -41
- package/templates/wevu-tdesign/src/layouts/default.vue +0 -23
- package/templates/wevu-tdesign/src/pages/ability/index.vue +0 -164
- package/templates/wevu-tdesign/src/pages/data/index.vue +0 -189
- package/templates/wevu-tdesign/src/pages/form/index.vue +0 -271
- package/templates/wevu-tdesign/src/pages/layout-feedback/components/FeedbackCallerCard.vue +0 -79
- package/templates/wevu-tdesign/src/pages/layout-feedback/index.vue +0 -211
- package/templates/wevu-tdesign/src/pages/layout-store/index.vue +0 -127
- package/templates/wevu-tdesign/src/pages/layouts/index.vue +0 -120
- package/templates/wevu-tdesign/src/pages/list/index.vue +0 -146
- package/templates/wevu-tdesign/src/stores/layoutInteractionDemo.ts +0 -129
- package/templates/wevu-tdesign/src/subpackages/ability/index.vue +0 -103
- package/templates/wevu-tdesign/src/subpackages/lab/class-binding/index.vue +0 -440
- package/templates/wevu-tdesign/src/subpackages/lab/index.vue +0 -169
- package/templates/wevu-tdesign/src/subpackages/lab/virtual-host-class/index.vue +0 -94
- package/templates/wevu-tdesign/src/types/action.ts +0 -14
- package/templates/wevu-tdesign/src/types/list.ts +0 -17
- package/templates/wevu-tdesign/src/utils/changeEvent.ts +0 -53
- package/templates/wevu-tdesign/src/utils/listFilters.ts +0 -34
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import Dialog from 'tdesign-miniprogram/dialog/index'
|
|
2
|
-
import { getCurrentInstance, resolveLayoutBridge, resolveLayoutHost } from 'wevu'
|
|
3
|
-
import { LAYOUT_DIALOG_BRIDGE_KEY } from '@/hooks/useLayoutFeedbackBridge'
|
|
4
|
-
|
|
5
|
-
export interface DialogOptions {
|
|
6
|
-
bridgeKey?: string
|
|
7
|
-
context?: any
|
|
8
|
-
selector?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface BaseDialogPayload {
|
|
12
|
-
bridgeKey?: string
|
|
13
|
-
confirmBtn?: string
|
|
14
|
-
content: string
|
|
15
|
-
context?: any
|
|
16
|
-
selector?: string
|
|
17
|
-
title: string
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface AlertOptions extends BaseDialogPayload {}
|
|
21
|
-
|
|
22
|
-
export interface ConfirmOptions extends BaseDialogPayload {
|
|
23
|
-
cancelBtn?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface HostDialogInstance {
|
|
27
|
-
_onCancel?: (reason?: unknown) => void
|
|
28
|
-
_onConfirm?: (value?: unknown) => void
|
|
29
|
-
close?: () => void
|
|
30
|
-
setData?: (payload: Record<string, unknown>) => void
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type DialogMode = 'alert' | 'confirm'
|
|
34
|
-
|
|
35
|
-
type ResolvedDialogPayload<T extends BaseDialogPayload> = Omit<T, 'bridgeKey' | 'context' | 'selector'>
|
|
36
|
-
|
|
37
|
-
function resolveDialogContext(options: DialogOptions) {
|
|
38
|
-
return options.bridgeKey
|
|
39
|
-
? resolveLayoutBridge(options.bridgeKey, options.context ?? getCurrentInstance())
|
|
40
|
-
: options.context ?? getCurrentInstance()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function resolveDialogHost(options: DialogOptions) {
|
|
44
|
-
const bridgeKey = options.bridgeKey ?? LAYOUT_DIALOG_BRIDGE_KEY
|
|
45
|
-
const context = resolveDialogContext({
|
|
46
|
-
bridgeKey,
|
|
47
|
-
context: options.context,
|
|
48
|
-
})
|
|
49
|
-
const host = bridgeKey
|
|
50
|
-
? resolveLayoutHost<HostDialogInstance>(bridgeKey, { context })
|
|
51
|
-
: options.selector
|
|
52
|
-
? context?.selectComponent?.(options.selector) ?? null
|
|
53
|
-
: null
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
context,
|
|
57
|
-
host,
|
|
58
|
-
selector: options.selector,
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function closeDialogHost(host: HostDialogInstance) {
|
|
63
|
-
if (typeof host.close === 'function') {
|
|
64
|
-
host.close()
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
if (typeof host.setData === 'function') {
|
|
68
|
-
host.setData({ visible: false })
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function attachHostDialogHandlers(
|
|
73
|
-
host: HostDialogInstance,
|
|
74
|
-
handlers: {
|
|
75
|
-
onCancel?: (reason?: unknown) => void
|
|
76
|
-
onConfirm?: (value?: unknown) => void
|
|
77
|
-
},
|
|
78
|
-
) {
|
|
79
|
-
const originalConfirm = typeof host._onConfirm === 'function' ? host._onConfirm : undefined
|
|
80
|
-
const originalCancel = typeof host._onCancel === 'function' ? host._onCancel : undefined
|
|
81
|
-
|
|
82
|
-
host._onConfirm = (value?: unknown) => {
|
|
83
|
-
host._onConfirm = originalConfirm
|
|
84
|
-
host._onCancel = originalCancel
|
|
85
|
-
|
|
86
|
-
if (originalConfirm) {
|
|
87
|
-
originalConfirm.call(host, value)
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
closeDialogHost(host)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
handlers.onConfirm?.(value)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
host._onCancel = (reason?: unknown) => {
|
|
97
|
-
host._onConfirm = originalConfirm
|
|
98
|
-
host._onCancel = originalCancel
|
|
99
|
-
|
|
100
|
-
if (originalCancel) {
|
|
101
|
-
originalCancel.call(host, reason)
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
closeDialogHost(host)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
handlers.onCancel?.(reason)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function normalizeDialogPayload<T extends BaseDialogPayload>(
|
|
112
|
-
mode: DialogMode,
|
|
113
|
-
payload: T,
|
|
114
|
-
): ResolvedDialogPayload<T> {
|
|
115
|
-
const { bridgeKey: _bridgeKey, context: _context, selector: _selector, ...rest } = payload
|
|
116
|
-
|
|
117
|
-
if (mode === 'alert') {
|
|
118
|
-
return {
|
|
119
|
-
...rest,
|
|
120
|
-
cancelBtn: null,
|
|
121
|
-
} as ResolvedDialogPayload<T>
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return rest as ResolvedDialogPayload<T>
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function openDialogWithHost<T extends BaseDialogPayload>(
|
|
128
|
-
mode: DialogMode,
|
|
129
|
-
host: HostDialogInstance,
|
|
130
|
-
payload: ResolvedDialogPayload<T>,
|
|
131
|
-
) {
|
|
132
|
-
return new Promise((resolve, reject) => {
|
|
133
|
-
host.setData?.({
|
|
134
|
-
...payload,
|
|
135
|
-
visible: true,
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
attachHostDialogHandlers(host, {
|
|
139
|
-
onConfirm: resolve,
|
|
140
|
-
...(mode === 'confirm' ? { onCancel: reject } : {}),
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function openDialog<T extends BaseDialogPayload>(mode: DialogMode, payload: T) {
|
|
146
|
-
const bridgeKey = payload.bridgeKey ?? LAYOUT_DIALOG_BRIDGE_KEY
|
|
147
|
-
const { context, host, selector } = resolveDialogHost({
|
|
148
|
-
bridgeKey,
|
|
149
|
-
context: payload.context,
|
|
150
|
-
selector: payload.selector,
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
if (!context) {
|
|
154
|
-
return Promise.resolve()
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const normalizedPayload = normalizeDialogPayload(mode, payload)
|
|
158
|
-
|
|
159
|
-
if (host && typeof host.setData === 'function') {
|
|
160
|
-
return openDialogWithHost(mode, host, normalizedPayload)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (!selector) {
|
|
164
|
-
return Promise.resolve()
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const open = mode === 'alert' ? Dialog.alert : Dialog.confirm
|
|
168
|
-
|
|
169
|
-
return open({
|
|
170
|
-
selector,
|
|
171
|
-
context: context as any,
|
|
172
|
-
...normalizedPayload,
|
|
173
|
-
})
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export function alertDialog(payload: AlertOptions) {
|
|
177
|
-
return openDialog('alert', payload)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export function confirmDialog(payload: ConfirmOptions) {
|
|
181
|
-
return openDialog('confirm', payload)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export function useDialog(options: DialogOptions = {}) {
|
|
185
|
-
const bridgeKey = options.bridgeKey ?? LAYOUT_DIALOG_BRIDGE_KEY
|
|
186
|
-
const context = options.context ?? getCurrentInstance()
|
|
187
|
-
|
|
188
|
-
function withDefaults<T extends BaseDialogPayload>(payload: T): T {
|
|
189
|
-
return {
|
|
190
|
-
...payload,
|
|
191
|
-
bridgeKey,
|
|
192
|
-
context: payload.context ?? context,
|
|
193
|
-
selector: payload.selector ?? options.selector,
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
alert(payload: AlertOptions) {
|
|
199
|
-
return alertDialog(withDefaults(payload))
|
|
200
|
-
},
|
|
201
|
-
confirm(payload: ConfirmOptions) {
|
|
202
|
-
return confirmDialog(withDefaults(payload))
|
|
203
|
-
},
|
|
204
|
-
}
|
|
205
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ModelBindingOptions, ModelBindingPayload } from 'wevu'
|
|
2
|
-
import { useBindModel } from 'wevu'
|
|
3
|
-
|
|
4
|
-
export function useFormBinder() {
|
|
5
|
-
const bindModel = useBindModel()
|
|
6
|
-
|
|
7
|
-
function changeModel<T, ValueProp extends string = 'value', Formatted = T>(
|
|
8
|
-
path: string,
|
|
9
|
-
options?: ModelBindingOptions<T, 'change', ValueProp, Formatted>,
|
|
10
|
-
): ModelBindingPayload<T, 'change', ValueProp, Formatted> {
|
|
11
|
-
return bindModel(path).model({ event: 'change', ...options })
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
changeModel,
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const LAYOUT_TOAST_BRIDGE_KEY = 'layout-toast'
|
|
2
|
-
export const LAYOUT_DIALOG_BRIDGE_KEY = 'layout-dialog'
|
|
3
|
-
|
|
4
|
-
export interface ToastHostInstance {
|
|
5
|
-
hide?: () => void
|
|
6
|
-
show: (options: Record<string, unknown>) => void
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface DialogHostInstance {
|
|
10
|
-
_onCancel?: (reason?: unknown) => void
|
|
11
|
-
_onConfirm?: (value?: unknown) => void
|
|
12
|
-
close?: () => void
|
|
13
|
-
onCancel?: (reason?: unknown) => void
|
|
14
|
-
onConfirm?: (value?: unknown) => void
|
|
15
|
-
properties?: Record<string, unknown>
|
|
16
|
-
setData: (payload: Record<string, unknown>) => void
|
|
17
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { onPullDownRefresh } from 'wevu'
|
|
2
|
-
import { wpi } from 'wevu/api'
|
|
3
|
-
|
|
4
|
-
export function usePullDownRefresh(refresh: () => void | Promise<void>) {
|
|
5
|
-
onPullDownRefresh(async () => {
|
|
6
|
-
try {
|
|
7
|
-
await refresh()
|
|
8
|
-
}
|
|
9
|
-
catch {}
|
|
10
|
-
await wpi.stopPullDownRefresh()
|
|
11
|
-
})
|
|
12
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import Toast from 'tdesign-miniprogram/toast/index'
|
|
2
|
-
import { getCurrentInstance, resolveLayoutBridge, resolveLayoutHost } from 'wevu'
|
|
3
|
-
import { LAYOUT_TOAST_BRIDGE_KEY } from '@/hooks/useLayoutFeedbackBridge'
|
|
4
|
-
|
|
5
|
-
export type ToastTheme = 'success' | 'warning' | 'error' | 'default' | 'loading'
|
|
6
|
-
|
|
7
|
-
export interface ShowToastPayload {
|
|
8
|
-
bridgeKey?: string
|
|
9
|
-
context?: any
|
|
10
|
-
duration?: number
|
|
11
|
-
icon?: string
|
|
12
|
-
message?: string
|
|
13
|
-
placement?: string
|
|
14
|
-
selector?: string
|
|
15
|
-
theme?: ToastTheme
|
|
16
|
-
title?: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface ToastOptions {
|
|
20
|
-
bridgeKey?: string
|
|
21
|
-
selector?: string
|
|
22
|
-
duration?: number
|
|
23
|
-
theme?: ToastTheme
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function resolveToastContext(options: { bridgeKey?: string, context?: any }) {
|
|
27
|
-
return options.bridgeKey
|
|
28
|
-
? resolveLayoutBridge(options.bridgeKey, options.context ?? getCurrentInstance())
|
|
29
|
-
: options.context ?? getCurrentInstance()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function showToast(payload: string | ShowToastPayload, theme?: ToastTheme) {
|
|
33
|
-
const mpContext = getCurrentInstance()
|
|
34
|
-
const normalized = typeof payload === 'string'
|
|
35
|
-
? { message: payload, theme }
|
|
36
|
-
: payload
|
|
37
|
-
const bridgeKey = normalized.bridgeKey ?? LAYOUT_TOAST_BRIDGE_KEY
|
|
38
|
-
const selector = normalized.selector
|
|
39
|
-
const {
|
|
40
|
-
bridgeKey: _bridgeKey,
|
|
41
|
-
context: _context,
|
|
42
|
-
selector: _selector,
|
|
43
|
-
theme: nextTheme,
|
|
44
|
-
title,
|
|
45
|
-
message,
|
|
46
|
-
...rest
|
|
47
|
-
} = normalized
|
|
48
|
-
const options = {
|
|
49
|
-
message: message ?? title ?? '',
|
|
50
|
-
...rest,
|
|
51
|
-
...(nextTheme && nextTheme !== 'default' ? { theme: nextTheme } : {}),
|
|
52
|
-
}
|
|
53
|
-
const context = resolveToastContext({
|
|
54
|
-
bridgeKey,
|
|
55
|
-
context: normalized.context ?? mpContext,
|
|
56
|
-
})
|
|
57
|
-
const host = bridgeKey
|
|
58
|
-
? resolveLayoutHost<{
|
|
59
|
-
show?: (payload: typeof options) => void
|
|
60
|
-
}>(bridgeKey, { context })
|
|
61
|
-
: selector
|
|
62
|
-
? context?.selectComponent?.(selector) ?? null
|
|
63
|
-
: null
|
|
64
|
-
if (!context) {
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
if (host && typeof host.show === 'function') {
|
|
68
|
-
host.show(options)
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
if (!selector) {
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
Toast({
|
|
75
|
-
selector,
|
|
76
|
-
context: context as any,
|
|
77
|
-
...options,
|
|
78
|
-
} as any)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function useToast(options: ToastOptions = {}) {
|
|
82
|
-
const context = getCurrentInstance()
|
|
83
|
-
const bridgeKey = options.bridgeKey ?? LAYOUT_TOAST_BRIDGE_KEY
|
|
84
|
-
const selector = options.selector
|
|
85
|
-
const duration = options.duration ?? 1200
|
|
86
|
-
const defaultTheme = options.theme ?? 'success'
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
showToast(message: string, theme: ToastTheme = defaultTheme) {
|
|
90
|
-
return showToast({
|
|
91
|
-
bridgeKey,
|
|
92
|
-
context,
|
|
93
|
-
selector,
|
|
94
|
-
message,
|
|
95
|
-
duration,
|
|
96
|
-
...(theme === 'default' ? {} : { theme }),
|
|
97
|
-
})
|
|
98
|
-
},
|
|
99
|
-
}
|
|
100
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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 layout-host="layout-toast" />
|
|
33
|
-
<t-dialog layout-host="layout-dialog" />
|
|
34
|
-
</view>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<style>
|
|
38
|
-
.layout-admin {
|
|
39
|
-
min-height: 100%;
|
|
40
|
-
}
|
|
41
|
-
</style>
|
|
@@ -1,23 +0,0 @@
|
|
|
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 layout-host="layout-toast" />
|
|
15
|
-
<t-dialog layout-host="layout-dialog" />
|
|
16
|
-
</view>
|
|
17
|
-
</template>
|
|
18
|
-
|
|
19
|
-
<style>
|
|
20
|
-
.layout-default {
|
|
21
|
-
min-height: 100%;
|
|
22
|
-
}
|
|
23
|
-
</style>
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref } from 'wevu'
|
|
3
|
-
import { wpi } from 'wevu/api'
|
|
4
|
-
|
|
5
|
-
import SectionTitle from '@/components/SectionTitle/index.vue'
|
|
6
|
-
import { useDialog } from '@/hooks/useDialog'
|
|
7
|
-
import { useToast } from '@/hooks/useToast'
|
|
8
|
-
|
|
9
|
-
definePageJson({
|
|
10
|
-
navigationBarTitleText: '能力',
|
|
11
|
-
backgroundColor: '#f6f7fb',
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
const { alert } = useDialog()
|
|
15
|
-
const { showToast } = useToast()
|
|
16
|
-
|
|
17
|
-
const capabilityCards = ref([
|
|
18
|
-
{
|
|
19
|
-
key: 'scan',
|
|
20
|
-
title: '扫一扫',
|
|
21
|
-
desc: '识别条码或二维码',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
key: 'location',
|
|
25
|
-
title: '定位',
|
|
26
|
-
desc: '获取当前坐标',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
key: 'clipboard',
|
|
30
|
-
title: '剪贴板',
|
|
31
|
-
desc: '写入演示文本',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
key: 'share',
|
|
35
|
-
title: '分享',
|
|
36
|
-
desc: '唤起分享菜单',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
key: 'image',
|
|
40
|
-
title: '选择图片',
|
|
41
|
-
desc: '上传素材预览',
|
|
42
|
-
},
|
|
43
|
-
])
|
|
44
|
-
|
|
45
|
-
const subscribeTemplateId = ''
|
|
46
|
-
|
|
47
|
-
async function handleCapability(key: string) {
|
|
48
|
-
try {
|
|
49
|
-
switch (key) {
|
|
50
|
-
case 'scan': {
|
|
51
|
-
const result = await wpi.scanCode()
|
|
52
|
-
showToast(`识别结果:${result.result || '已完成'}`)
|
|
53
|
-
break
|
|
54
|
-
}
|
|
55
|
-
case 'location': {
|
|
56
|
-
const result = await wpi.getLocation({
|
|
57
|
-
type: 'wgs84',
|
|
58
|
-
})
|
|
59
|
-
showToast(`定位成功:${result.latitude.toFixed(2)}, ${result.longitude.toFixed(2)}`)
|
|
60
|
-
break
|
|
61
|
-
}
|
|
62
|
-
case 'clipboard':
|
|
63
|
-
await wpi.setClipboardData({
|
|
64
|
-
data: 'weapp-vite + wevu + TDesign',
|
|
65
|
-
})
|
|
66
|
-
showToast('已写入剪贴板')
|
|
67
|
-
break
|
|
68
|
-
case 'share':
|
|
69
|
-
await wpi.showShareMenu({
|
|
70
|
-
withShareTicket: true,
|
|
71
|
-
})
|
|
72
|
-
showToast('已开启分享菜单')
|
|
73
|
-
break
|
|
74
|
-
case 'image': {
|
|
75
|
-
const result = await wpi.chooseImage({
|
|
76
|
-
count: 3,
|
|
77
|
-
})
|
|
78
|
-
showToast(`已选择 ${result.tempFilePaths.length} 张图片`)
|
|
79
|
-
break
|
|
80
|
-
}
|
|
81
|
-
default:
|
|
82
|
-
break
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
const warningMap: Record<string, string> = {
|
|
87
|
-
scan: '扫码失败,请重试',
|
|
88
|
-
location: '未获取定位权限',
|
|
89
|
-
share: '分享菜单开启失败',
|
|
90
|
-
image: '未选择图片',
|
|
91
|
-
}
|
|
92
|
-
showToast(warningMap[key] || '操作失败,请重试', 'warning')
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function requestSubscribe() {
|
|
97
|
-
if (!subscribeTemplateId) {
|
|
98
|
-
alert({
|
|
99
|
-
title: '订阅消息',
|
|
100
|
-
content: '请在 ability 页面配置订阅模板 ID 后再试。',
|
|
101
|
-
confirmBtn: '知道了',
|
|
102
|
-
})
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
await wpi.requestSubscribeMessage({
|
|
107
|
-
tmplIds: [subscribeTemplateId],
|
|
108
|
-
})
|
|
109
|
-
showToast('订阅成功')
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
showToast('订阅失败', 'warning')
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function navigateTo(url: string) {
|
|
117
|
-
await wpi.navigateTo({
|
|
118
|
-
url,
|
|
119
|
-
})
|
|
120
|
-
}
|
|
121
|
-
</script>
|
|
122
|
-
|
|
123
|
-
<template>
|
|
124
|
-
<view class="min-h-screen bg-[#f6f7fb] px-[28rpx] pb-[88rpx] pt-[24rpx] text-[#1c1c3c]">
|
|
125
|
-
<view class="rounded-[28rpx] bg-linear-to-br from-[#ecfeff] via-[#ffffff] to-[#e0f2fe] p-[20rpx]">
|
|
126
|
-
<SectionTitle title="小程序能力" subtitle="本页展示原生 API 与分包导航" />
|
|
127
|
-
</view>
|
|
128
|
-
|
|
129
|
-
<view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
|
|
130
|
-
<SectionTitle title="常用能力" subtitle="点击体验微信原生 API" />
|
|
131
|
-
<view class="mt-[12rpx] grid grid-cols-2 gap-[12rpx]">
|
|
132
|
-
<view
|
|
133
|
-
v-for="item in capabilityCards"
|
|
134
|
-
:key="item.key"
|
|
135
|
-
class="rounded-[18rpx] bg-[#f0f9ff] p-[16rpx]"
|
|
136
|
-
@tap="handleCapability(item.key)"
|
|
137
|
-
>
|
|
138
|
-
<text class="text-[24rpx] font-semibold text-[#1f1a3f]">
|
|
139
|
-
{{ item.title }}
|
|
140
|
-
</text>
|
|
141
|
-
<text class="mt-[6rpx] block text-[20rpx] text-[#6f6b8a]">
|
|
142
|
-
{{ item.desc }}
|
|
143
|
-
</text>
|
|
144
|
-
</view>
|
|
145
|
-
</view>
|
|
146
|
-
<view class="mt-[16rpx]">
|
|
147
|
-
<t-button block theme="primary" variant="outline" @tap="requestSubscribe">
|
|
148
|
-
订阅消息提醒
|
|
149
|
-
</t-button>
|
|
150
|
-
</view>
|
|
151
|
-
</view>
|
|
152
|
-
|
|
153
|
-
<view class="mt-[18rpx] rounded-[24rpx] bg-white p-[20rpx] shadow-[0_18rpx_40rpx_rgba(17,24,39,0.08)]">
|
|
154
|
-
<SectionTitle title="分包演示" subtitle="weapp-vite 子包页面" />
|
|
155
|
-
<view class="mt-[12rpx]">
|
|
156
|
-
<t-cell-group>
|
|
157
|
-
<t-cell title="组件实验室" note="subpackages/lab" arrow @tap="navigateTo('/subpackages/lab/index')" />
|
|
158
|
-
<t-cell title="Class 绑定实验室" note="subpackages/lab/class-binding" arrow @tap="navigateTo('/subpackages/lab/class-binding/index')" />
|
|
159
|
-
<t-cell title="API 场景页" note="subpackages/ability" arrow @tap="navigateTo('/subpackages/ability/index')" />
|
|
160
|
-
</t-cell-group>
|
|
161
|
-
</view>
|
|
162
|
-
</view>
|
|
163
|
-
</view>
|
|
164
|
-
</template>
|