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.
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-j_bda7hF.js → src-hBW5b5RM.js} +11 -9
- package/package.json +1 -1
- package/templates/default/package.json +3 -2
- package/templates/default/project.private.config.json +1 -1
- package/templates/default/src/app.json +2 -1
- package/templates/default/src/layouts/admin/index.json +3 -0
- package/templates/default/src/layouts/admin/index.scss +40 -0
- package/templates/default/src/layouts/admin/index.ts +1 -0
- package/templates/default/src/layouts/admin/index.wxml +10 -0
- package/templates/default/src/layouts/default/index.json +3 -0
- package/templates/default/src/layouts/default/index.scss +3 -0
- package/templates/default/src/layouts/default/index.ts +1 -0
- package/templates/default/src/layouts/default/index.wxml +3 -0
- package/templates/default/src/pages/index/index.ts +5 -0
- package/templates/default/src/pages/index/index.wxml +3 -0
- package/templates/default/src/pages/layouts/index.json +4 -0
- package/templates/default/src/pages/layouts/index.scss +68 -0
- package/templates/default/src/pages/layouts/index.ts +42 -0
- package/templates/default/src/pages/layouts/index.wxml +19 -0
- package/templates/default/tsconfig.json +8 -2
- package/templates/lib/package.json +6 -2
- package/templates/lib/project.private.config.json +1 -1
- package/templates/lib/src/app.json +2 -1
- package/templates/lib/src/layouts/admin/index.json +3 -0
- package/templates/lib/src/layouts/admin/index.scss +41 -0
- package/templates/lib/src/layouts/admin/index.ts +1 -0
- package/templates/lib/src/layouts/admin/index.wxml +10 -0
- package/templates/lib/src/layouts/default/index.json +3 -0
- package/templates/lib/src/layouts/default/index.scss +3 -0
- package/templates/lib/src/layouts/default/index.ts +1 -0
- package/templates/lib/src/layouts/default/index.wxml +3 -0
- package/templates/lib/src/pages/index/index.scss +14 -3
- package/templates/lib/src/pages/index/index.ts +5 -0
- package/templates/lib/src/pages/index/index.wxml +6 -0
- package/templates/lib/src/pages/layouts/index.json +4 -0
- package/templates/lib/src/pages/layouts/index.scss +70 -0
- package/templates/lib/src/pages/layouts/index.ts +44 -0
- package/templates/lib/src/pages/layouts/index.wxml +19 -0
- package/templates/lib/tsconfig.json +8 -2
- package/templates/lib/weapp-vite.lib.config.ts +5 -0
- package/templates/tailwindcss/package.json +3 -3
- package/templates/tailwindcss/project.private.config.json +1 -1
- package/templates/tailwindcss/src/app.json +2 -1
- package/templates/tailwindcss/src/layouts/admin/index.json +3 -0
- package/templates/tailwindcss/src/layouts/admin/index.scss +40 -0
- package/templates/tailwindcss/src/layouts/admin/index.ts +1 -0
- package/templates/tailwindcss/src/layouts/admin/index.wxml +10 -0
- package/templates/tailwindcss/src/layouts/default/index.json +3 -0
- package/templates/tailwindcss/src/layouts/default/index.scss +3 -0
- package/templates/tailwindcss/src/layouts/default/index.ts +1 -0
- package/templates/tailwindcss/src/layouts/default/index.wxml +3 -0
- package/templates/tailwindcss/src/pages/index/index.ts +5 -0
- package/templates/tailwindcss/src/pages/index/index.wxml +3 -0
- package/templates/tailwindcss/src/pages/layouts/index.json +4 -0
- package/templates/tailwindcss/src/pages/layouts/index.scss +1 -0
- package/templates/tailwindcss/src/pages/layouts/index.ts +33 -0
- package/templates/tailwindcss/src/pages/layouts/index.wxml +19 -0
- package/templates/tailwindcss/tsconfig.json +8 -2
- package/templates/tdesign/package.json +3 -3
- package/templates/tdesign/project.private.config.json +2 -2
- package/templates/tdesign/src/app.json +2 -1
- package/templates/tdesign/src/layouts/admin/index.json +3 -0
- package/templates/tdesign/src/layouts/admin/index.scss +40 -0
- package/templates/tdesign/src/layouts/admin/index.ts +1 -0
- package/templates/tdesign/src/layouts/admin/index.wxml +10 -0
- package/templates/tdesign/src/layouts/default/index.json +3 -0
- package/templates/tdesign/src/layouts/default/index.scss +3 -0
- package/templates/tdesign/src/layouts/default/index.ts +1 -0
- package/templates/tdesign/src/layouts/default/index.wxml +3 -0
- package/templates/tdesign/src/pages/index/index.ts +5 -0
- package/templates/tdesign/src/pages/index/index.wxml +3 -0
- package/templates/tdesign/src/pages/layouts/index.json +4 -0
- package/templates/tdesign/src/pages/layouts/index.scss +1 -0
- package/templates/tdesign/src/pages/layouts/index.ts +32 -0
- package/templates/tdesign/src/pages/layouts/index.wxml +16 -0
- package/templates/tdesign/tsconfig.json +8 -2
- package/templates/tdesign/vite.config.ts +9 -0
- package/templates/vant/package.json +3 -3
- package/templates/vant/project.private.config.json +1 -1
- package/templates/vant/src/app.json +2 -1
- package/templates/vant/src/layouts/admin/index.json +3 -0
- package/templates/vant/src/layouts/admin/index.scss +40 -0
- package/templates/vant/src/layouts/admin/index.ts +1 -0
- package/templates/vant/src/layouts/admin/index.wxml +10 -0
- package/templates/vant/src/layouts/default/index.json +3 -0
- package/templates/vant/src/layouts/default/index.scss +3 -0
- package/templates/vant/src/layouts/default/index.ts +1 -0
- package/templates/vant/src/layouts/default/index.wxml +3 -0
- package/templates/vant/src/pages/index/index.ts +5 -0
- package/templates/vant/src/pages/index/index.wxml +3 -0
- package/templates/vant/src/pages/layouts/index.json +4 -0
- package/templates/vant/src/pages/layouts/index.scss +3 -0
- package/templates/vant/src/pages/layouts/index.ts +35 -0
- package/templates/vant/src/pages/layouts/index.wxml +17 -0
- package/templates/vant/tsconfig.json +8 -2
- package/templates/vant/vite.config.ts +9 -0
- package/templates/wevu/package.json +4 -3
- package/templates/wevu/project.private.config.json +2 -2
- package/templates/wevu/src/app.vue +7 -7
- package/templates/wevu/src/layouts/admin.vue +73 -0
- package/templates/wevu/src/layouts/default.vue +17 -0
- package/templates/wevu/src/pages/index/index.vue +7 -0
- package/templates/wevu/src/pages/layouts/index.vue +169 -0
- package/templates/wevu/tsconfig.json +8 -2
- package/templates/wevu-tdesign/package.json +4 -4
- package/templates/wevu-tdesign/project.private.config.json +1 -1
- package/templates/wevu-tdesign/src/app.vue +4 -3
- package/templates/wevu-tdesign/src/components/KpiBoard/index.vue +4 -6
- package/templates/wevu-tdesign/src/hooks/useDialog.ts +56 -14
- package/templates/wevu-tdesign/src/hooks/useToast.ts +42 -15
- package/templates/wevu-tdesign/src/layouts/admin.vue +41 -0
- package/templates/wevu-tdesign/src/layouts/default.vue +23 -0
- package/templates/wevu-tdesign/src/pages/ability/index.vue +2 -6
- package/templates/wevu-tdesign/src/pages/form/index.vue +0 -2
- package/templates/wevu-tdesign/src/pages/index/index.vue +12 -4
- package/templates/wevu-tdesign/src/pages/layouts/index.vue +94 -0
- package/templates/wevu-tdesign/src/pages/list/index.vue +0 -2
- package/templates/wevu-tdesign/src/subpackages/lab/index.vue +22 -6
- package/templates/wevu-tdesign/tsconfig.json +8 -2
- package/templates/wevu-tdesign/vite.config.ts +9 -0
- package/templates/default/auto-import-components.json +0 -3
- package/templates/default/src/vite-env.d.ts +0 -1
- package/templates/default/tsconfig.app.json +0 -49
- package/templates/default/tsconfig.node.json +0 -33
- package/templates/lib/auto-import-components.json +0 -3
- package/templates/lib/src/vite-env.d.ts +0 -1
- package/templates/lib/tsconfig.app.json +0 -49
- package/templates/lib/tsconfig.node.json +0 -33
- package/templates/tailwindcss/auto-import-components.json +0 -3
- package/templates/tailwindcss/src/vite-env.d.ts +0 -1
- package/templates/tailwindcss/tsconfig.app.json +0 -49
- package/templates/tailwindcss/tsconfig.node.json +0 -33
- package/templates/tdesign/auto-import-components.json +0 -84
- package/templates/tdesign/src/vite-env.d.ts +0 -1
- package/templates/tdesign/tsconfig.app.json +0 -52
- package/templates/tdesign/tsconfig.node.json +0 -33
- package/templates/vant/auto-import-components.json +0 -71
- package/templates/vant/src/vite-env.d.ts +0 -1
- package/templates/vant/tsconfig.app.json +0 -52
- package/templates/vant/tsconfig.node.json +0 -33
- package/templates/wevu/auto-import-components.json +0 -4
- package/templates/wevu/src/components.d.ts +0 -25
- package/templates/wevu/src/typed-components.d.ts +0 -22
- package/templates/wevu/src/typed-router.d.ts +0 -67
- package/templates/wevu/src/vite-env.d.ts +0 -1
- package/templates/wevu/tsconfig.app.json +0 -51
- package/templates/wevu/tsconfig.node.json +0 -33
- package/templates/wevu-tdesign/auto-import-components.json +0 -84
- package/templates/wevu-tdesign/mini-program.html-data.json +0 -6784
- package/templates/wevu-tdesign/src/components.d.ts +0 -267
- package/templates/wevu-tdesign/src/typed-components.d.ts +0 -955
- package/templates/wevu-tdesign/src/typed-router.d.ts +0 -75
- package/templates/wevu-tdesign/src/vite-env.d.ts +0 -1
- package/templates/wevu-tdesign/tsconfig.app.json +0 -54
- 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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
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
|
|
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
|
|
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>
|
|
@@ -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>
|
|
@@ -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="
|
|
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="
|
|
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="
|
|
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="
|
|
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": "
|
|
4
|
+
"path": "./.weapp-vite/tsconfig.app.json"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
|
-
"path": "
|
|
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 +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 +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
|
-
}
|