create-weapp-vite 2.0.53 → 2.0.55

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 (137) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/dist/{src-j_bda7hF.js → src-nL81L3Ai.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/layouts/admin.vue +75 -0
  102. package/templates/wevu/src/layouts/default.vue +17 -0
  103. package/templates/wevu/src/pages/index/index.vue +7 -0
  104. package/templates/wevu/src/pages/layouts/index.vue +171 -0
  105. package/templates/wevu/tsconfig.json +8 -2
  106. package/templates/wevu-tdesign/package.json +4 -4
  107. package/templates/wevu-tdesign/project.private.config.json +1 -1
  108. package/templates/wevu-tdesign/src/app.vue +1 -0
  109. package/templates/wevu-tdesign/src/components/KpiBoard/index.vue +4 -6
  110. package/templates/wevu-tdesign/src/hooks/useToast.ts +1 -1
  111. package/templates/wevu-tdesign/src/layouts/admin.vue +37 -0
  112. package/templates/wevu-tdesign/src/layouts/default.vue +17 -0
  113. package/templates/wevu-tdesign/src/pages/index/index.vue +10 -0
  114. package/templates/wevu-tdesign/src/pages/layouts/index.vue +96 -0
  115. package/templates/wevu-tdesign/src/subpackages/lab/index.vue +22 -6
  116. package/templates/wevu-tdesign/tsconfig.json +8 -2
  117. package/templates/wevu-tdesign/vite.config.ts +9 -0
  118. package/templates/default/tsconfig.app.json +0 -49
  119. package/templates/default/tsconfig.node.json +0 -33
  120. package/templates/lib/tsconfig.app.json +0 -49
  121. package/templates/lib/tsconfig.node.json +0 -33
  122. package/templates/tailwindcss/tsconfig.app.json +0 -49
  123. package/templates/tailwindcss/tsconfig.node.json +0 -33
  124. package/templates/tdesign/tsconfig.app.json +0 -52
  125. package/templates/tdesign/tsconfig.node.json +0 -33
  126. package/templates/vant/tsconfig.app.json +0 -52
  127. package/templates/vant/tsconfig.node.json +0 -33
  128. package/templates/wevu/src/components.d.ts +0 -25
  129. package/templates/wevu/src/typed-components.d.ts +0 -22
  130. package/templates/wevu/src/typed-router.d.ts +0 -67
  131. package/templates/wevu/tsconfig.app.json +0 -51
  132. package/templates/wevu/tsconfig.node.json +0 -33
  133. package/templates/wevu-tdesign/src/components.d.ts +0 -267
  134. package/templates/wevu-tdesign/src/typed-components.d.ts +0 -955
  135. package/templates/wevu-tdesign/src/typed-router.d.ts +0 -75
  136. package/templates/wevu-tdesign/tsconfig.app.json +0 -54
  137. package/templates/wevu-tdesign/tsconfig.node.json +0 -33
@@ -0,0 +1,44 @@
1
+ import { setPageLayout } from 'weapp-vite/runtime'
2
+
3
+ Page({
4
+ data: {
5
+ currentLayout: 'default',
6
+ cards: [
7
+ {
8
+ title: 'default 布局',
9
+ desc: '当前页面首次进入时默认命中 src/layouts/default.vue。',
10
+ },
11
+ {
12
+ title: 'admin 布局',
13
+ desc: '点击按钮后会调用 setPageLayout("admin", props) 切到命名布局。',
14
+ },
15
+ {
16
+ title: '关闭布局',
17
+ desc: '也可以通过 setPageLayout(false) 临时关闭布局壳。',
18
+ },
19
+ ],
20
+ },
21
+ onLoad() {
22
+ setPageLayout('default')
23
+ },
24
+ applyDefaultLayout() {
25
+ this.setData({ currentLayout: 'default' })
26
+ setPageLayout('default')
27
+ },
28
+ applyAdminLayout() {
29
+ this.setData({ currentLayout: 'admin' })
30
+ setPageLayout('admin', {
31
+ title: 'Library Console',
32
+ subtitle: '这个标题来自原生 Page 中调用的 setPageLayout()。',
33
+ })
34
+ },
35
+ clearLayout() {
36
+ this.setData({ currentLayout: 'none' })
37
+ setPageLayout(false)
38
+ },
39
+ backHome() {
40
+ wx.navigateTo({
41
+ url: '/pages/index/index',
42
+ })
43
+ },
44
+ })
@@ -0,0 +1,19 @@
1
+ <view class="page">
2
+ <view class="hero">
3
+ <view class="hero__eyebrow">Native Layouts</view>
4
+ <view class="hero__title">原生 Page 已接入 layouts 与 setPageLayout()</view>
5
+ <view class="hero__desc">当前状态:{{currentLayout}}</view>
6
+ </view>
7
+
8
+ <view wx:for="{{cards}}" wx:key="title" class="section">
9
+ <view class="section-title">{{item.title}}</view>
10
+ <view class="section-desc">{{item.desc}}</view>
11
+ </view>
12
+
13
+ <view class="section">
14
+ <button class="action-btn" bindtap="applyDefaultLayout">使用 default 布局</button>
15
+ <button class="action-btn action-btn--primary" bindtap="applyAdminLayout">切到 admin 布局</button>
16
+ <button class="action-btn action-btn--ghost" bindtap="clearLayout">关闭布局</button>
17
+ <button class="action-btn action-btn--light" bindtap="backHome">返回首页</button>
18
+ </view>
19
+ </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": []
@@ -17,5 +17,10 @@ export default defineConfig({
17
17
  build: {
18
18
  outDir: 'dist-lib',
19
19
  minify: false,
20
+ rolldownOptions: {
21
+ external: [
22
+ /^wevu(?:\/.*)?$/,
23
+ ],
24
+ },
20
25
  },
21
26
  })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-tailwindcss-template",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite + tailwindcss 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -21,7 +21,7 @@
21
21
  "build": "weapp-vite build",
22
22
  "open": "weapp-vite open",
23
23
  "g": "weapp-vite generate",
24
- "postinstall": "weapp-tw patch"
24
+ "postinstall": "weapp-tw patch && weapp-vite prepare"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@egoist/tailwindcss-icons": "catalog:",
@@ -30,7 +30,7 @@
30
30
  "miniprogram-api-typings": "catalog:",
31
31
  "postcss": "catalog:",
32
32
  "sass": "catalog:",
33
- "tailwindcss": "catalog:",
33
+ "tailwindcss": "catalog:tailwind3",
34
34
  "typescript": "catalog:",
35
35
  "weapp-tailwindcss": "catalog:",
36
36
  "weapp-vite": "workspace:*"
@@ -2,7 +2,7 @@
2
2
  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3
3
  "projectname": "weapp-vite-tailwindcss-template",
4
4
  "setting": {
5
- "compileHotReLoad": false
5
+ "compileHotReLoad": true
6
6
  },
7
7
  "libVersion": "3.9.3"
8
8
  }
@@ -2,7 +2,8 @@
2
2
  "$schema": "https://vite.icebreaker.top/app.json",
3
3
  "pages": [
4
4
  "pages/index/index",
5
- "pages/profile/index"
5
+ "pages/profile/index",
6
+ "pages/layouts/index"
6
7
  ],
7
8
  "window": {},
8
9
  "style": "v2",
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,40 @@
1
+ .layout-admin {
2
+ min-height: 100%;
3
+ background:
4
+ radial-gradient(circle at top right, rgb(34 197 94 / 18%), transparent 28%),
5
+ linear-gradient(180deg, #f7fff8 0%, #effcf2 100%);
6
+ }
7
+
8
+ .layout-admin__hero {
9
+ padding: 36rpx 32rpx 32rpx;
10
+ color: #fff;
11
+ background: linear-gradient(145deg, #14532d 0%, #16a34a 64%, #4ade80 100%);
12
+ border-radius: 0 0 28rpx 28rpx;
13
+ }
14
+
15
+ .layout-admin__eyebrow {
16
+ display: inline-flex;
17
+ padding: 8rpx 16rpx;
18
+ font-size: 22rpx;
19
+ background: rgb(255 255 255 / 14%);
20
+ border-radius: 999rpx;
21
+ }
22
+
23
+ .layout-admin__title {
24
+ display: block;
25
+ margin-top: 18rpx;
26
+ font-size: 42rpx;
27
+ font-weight: 700;
28
+ }
29
+
30
+ .layout-admin__subtitle {
31
+ display: block;
32
+ margin-top: 12rpx;
33
+ font-size: 24rpx;
34
+ line-height: 1.7;
35
+ opacity: 0.92;
36
+ }
37
+
38
+ .layout-admin__body {
39
+ padding-bottom: 32rpx;
40
+ }
@@ -0,0 +1 @@
1
+ Component({})
@@ -0,0 +1,10 @@
1
+ <view class="layout-admin">
2
+ <view class="layout-admin__hero">
3
+ <text class="layout-admin__eyebrow">layouts/admin/index.wxml</text>
4
+ <text class="layout-admin__title">{{title || 'Tailwind Admin Layout'}}</text>
5
+ <text class="layout-admin__subtitle">{{subtitle || 'Tailwind 原生模板也支持 setPageLayout()。'}}</text>
6
+ </view>
7
+ <view class="layout-admin__body">
8
+ <slot />
9
+ </view>
10
+ </view>
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,3 @@
1
+ .layout-default {
2
+ min-height: 100%;
3
+ }
@@ -0,0 +1 @@
1
+ Component({})
@@ -0,0 +1,3 @@
1
+ <view class="layout-default">
2
+ <slot />
3
+ </view>
@@ -45,4 +45,9 @@ Page({
45
45
  // eslint-disable-next-line no-console
46
46
  console.log(hello())
47
47
  },
48
+ goToLayouts() {
49
+ wx.navigateTo({
50
+ url: '/pages/layouts/index',
51
+ })
52
+ },
48
53
  })
@@ -20,5 +20,8 @@
20
20
  <view class="underline" mark:url="https://tw.icebreaker.top/" bind:tap="copy">
21
21
  https://tw.icebreaker.top/
22
22
  </view>
23
+ <button class="rounded-full bg-sky-600 px-6 py-2 text-white" bindtap="goToLayouts">
24
+ 打开布局演示页
25
+ </button>
23
26
  </view>
24
27
  </view>
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "navigationBarTitleText": "布局能力"
4
+ }
@@ -0,0 +1 @@
1
+ /* 由 Tailwind utility class 驱动,保留空文件用于页面 sidecar 结构 */
@@ -0,0 +1,33 @@
1
+ import { setPageLayout } from 'weapp-vite/runtime'
2
+
3
+ Page({
4
+ data: {
5
+ currentLayout: 'default',
6
+ cards: [
7
+ { title: 'default 布局', desc: '当前页面默认命中 src/layouts/default。' },
8
+ { title: 'admin 布局', desc: '通过 setPageLayout("admin", props) 切换到命名布局。' },
9
+ { title: '关闭布局', desc: '通过 setPageLayout(false) 移除当前页面壳。' },
10
+ ],
11
+ },
12
+ onLoad() {
13
+ setPageLayout('default')
14
+ },
15
+ applyDefaultLayout() {
16
+ this.setData({ currentLayout: 'default' })
17
+ setPageLayout('default')
18
+ },
19
+ applyAdminLayout() {
20
+ this.setData({ currentLayout: 'admin' })
21
+ setPageLayout('admin', {
22
+ title: 'Tailwind Console',
23
+ subtitle: '这个标题来自原生 Page 调用 setPageLayout()。',
24
+ })
25
+ },
26
+ clearLayout() {
27
+ this.setData({ currentLayout: 'none' })
28
+ setPageLayout(false)
29
+ },
30
+ backHome() {
31
+ wx.switchTab({ url: '/pages/index/index' })
32
+ },
33
+ })
@@ -0,0 +1,19 @@
1
+ <view class="min-h-screen bg-slate-100 px-4 py-5">
2
+ <view class="rounded-2xl border border-sky-200 bg-gradient-to-br from-sky-50 to-white p-5 shadow-sm">
3
+ <view class="text-xs font-semibold uppercase tracking-[0.2em] text-sky-700">Native Layouts</view>
4
+ <view class="mt-3 text-2xl font-bold text-slate-900">Tailwind 原生模板已接入 layouts</view>
5
+ <view class="mt-3 text-sm leading-7 text-slate-600">当前状态:{{currentLayout}}</view>
6
+ </view>
7
+
8
+ <view wx:for="{{cards}}" wx:key="title" class="mt-4 rounded-2xl border border-slate-200 bg-white p-5 shadow-sm">
9
+ <view class="text-lg font-bold text-slate-900">{{item.title}}</view>
10
+ <view class="mt-3 text-sm leading-7 text-slate-600">{{item.desc}}</view>
11
+ </view>
12
+
13
+ <view class="mt-4 rounded-2xl border border-slate-200 bg-white p-5 shadow-sm">
14
+ <button class="!mt-0 rounded-full bg-slate-900 text-white" bindtap="applyDefaultLayout">使用 default 布局</button>
15
+ <button class="mt-3 rounded-full bg-emerald-600 text-white" bindtap="applyAdminLayout">切到 admin 布局</button>
16
+ <button class="mt-3 rounded-full bg-slate-200 text-slate-900" bindtap="clearLayout">关闭布局</button>
17
+ <button class="mt-3 rounded-full bg-sky-100 text-sky-700" bindtap="backHome">返回首页</button>
18
+ </view>
19
+ </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": []
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-tailwindcss-tdesign-template",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite + tailwindcss + tdesign 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -21,7 +21,7 @@
21
21
  "build": "weapp-vite build",
22
22
  "open": "weapp-vite open",
23
23
  "g": "weapp-vite generate",
24
- "postinstall": "weapp-tw patch"
24
+ "postinstall": "weapp-tw patch && weapp-vite prepare"
25
25
  },
26
26
  "dependencies": {
27
27
  "tdesign-miniprogram": "catalog:"
@@ -33,7 +33,7 @@
33
33
  "miniprogram-api-typings": "catalog:",
34
34
  "postcss": "catalog:",
35
35
  "sass": "catalog:",
36
- "tailwindcss": "catalog:",
36
+ "tailwindcss": "catalog:tailwind3",
37
37
  "typescript": "catalog:",
38
38
  "weapp-tailwindcss": "catalog:",
39
39
  "weapp-vite": "workspace:*"
@@ -2,7 +2,7 @@
2
2
  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3
3
  "projectname": "weapp-vite-tailwindcss-tdesign-template",
4
4
  "setting": {
5
- "compileHotReLoad": false
5
+ "compileHotReLoad": true
6
6
  },
7
7
  "libVersion": "3.14.2"
8
- }
8
+ }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "$schema": "https://vite.icebreaker.top/app.json",
3
3
  "pages": [
4
- "pages/index/index"
4
+ "pages/index/index",
5
+ "pages/layouts/index"
5
6
  ],
6
7
  "window": {},
7
8
  "componentFramework": "glass-easel",
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,40 @@
1
+ .layout-admin {
2
+ min-height: 100%;
3
+ background:
4
+ radial-gradient(circle at top right, rgb(99 102 241 / 18%), transparent 28%),
5
+ linear-gradient(180deg, #f7f7ff 0%, #f0f2ff 100%);
6
+ }
7
+
8
+ .layout-admin__hero {
9
+ padding: 36rpx 32rpx 32rpx;
10
+ color: #fff;
11
+ background: linear-gradient(145deg, #2f2b5f 0%, #4b3fb8 64%, #8b7bff 100%);
12
+ border-radius: 0 0 28rpx 28rpx;
13
+ }
14
+
15
+ .layout-admin__eyebrow {
16
+ display: inline-flex;
17
+ padding: 8rpx 16rpx;
18
+ font-size: 22rpx;
19
+ background: rgb(255 255 255 / 14%);
20
+ border-radius: 999rpx;
21
+ }
22
+
23
+ .layout-admin__title {
24
+ display: block;
25
+ margin-top: 18rpx;
26
+ font-size: 42rpx;
27
+ font-weight: 700;
28
+ }
29
+
30
+ .layout-admin__subtitle {
31
+ display: block;
32
+ margin-top: 12rpx;
33
+ font-size: 24rpx;
34
+ line-height: 1.7;
35
+ opacity: 0.92;
36
+ }
37
+
38
+ .layout-admin__body {
39
+ padding-bottom: 32rpx;
40
+ }
@@ -0,0 +1 @@
1
+ Component({})
@@ -0,0 +1,10 @@
1
+ <view class="layout-admin">
2
+ <view class="layout-admin__hero">
3
+ <text class="layout-admin__eyebrow">layouts/admin/index.wxml</text>
4
+ <text class="layout-admin__title">{{title || 'TDesign Admin Layout'}}</text>
5
+ <text class="layout-admin__subtitle">{{subtitle || 'TDesign 原生模板也支持 setPageLayout()。'}}</text>
6
+ </view>
7
+ <view class="layout-admin__body">
8
+ <slot />
9
+ </view>
10
+ </view>
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,3 @@
1
+ .layout-default {
2
+ min-height: 100%;
3
+ }
@@ -0,0 +1 @@
1
+ Component({})
@@ -0,0 +1,3 @@
1
+ <view class="layout-default">
2
+ <slot />
3
+ </view>
@@ -84,6 +84,11 @@ Page({
84
84
  // eslint-disable-next-line no-console
85
85
  console.log(hello())
86
86
  },
87
+ goToLayouts() {
88
+ wx.navigateTo({
89
+ url: '/pages/layouts/index',
90
+ })
91
+ },
87
92
  handleAction() {
88
93
  ActionSheet.show({
89
94
  theme: ActionSheetTheme.Grid,
@@ -19,6 +19,9 @@
19
19
  <view>
20
20
  <t-button theme="primary" ghost bind:tap="handleAction">TDesign Button</t-button>
21
21
  </view>
22
+ <view>
23
+ <t-button theme="success" variant="outline" bind:tap="goToLayouts">打开布局演示页</t-button>
24
+ </view>
22
25
  </view>
23
26
  <t-action-sheet id="t-action-sheet" bind:selected="handleSelected" />
24
27
  </view>
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://vite.icebreaker.top/page.json",
3
+ "navigationBarTitleText": "布局能力"
4
+ }
@@ -0,0 +1 @@
1
+ /* 由 Tailwind utility class 驱动,保留空文件用于页面 sidecar 结构 */
@@ -0,0 +1,32 @@
1
+ import Toast from 'tdesign-miniprogram/toast/index'
2
+ import { setPageLayout } from 'weapp-vite/runtime'
3
+
4
+ Page({
5
+ data: {
6
+ currentLayout: 'default',
7
+ },
8
+ onLoad() {
9
+ setPageLayout('default')
10
+ },
11
+ applyDefaultLayout() {
12
+ this.setData({ currentLayout: 'default' })
13
+ setPageLayout('default')
14
+ Toast({ context: this, selector: '#t-toast', message: '已切回 default 布局' })
15
+ },
16
+ applyAdminLayout() {
17
+ this.setData({ currentLayout: 'admin' })
18
+ setPageLayout('admin', {
19
+ title: 'TDesign Console',
20
+ subtitle: '这个标题来自原生 Page 调用 setPageLayout()。',
21
+ })
22
+ Toast({ context: this, selector: '#t-toast', message: '已切换到 admin 布局' })
23
+ },
24
+ clearLayout() {
25
+ this.setData({ currentLayout: 'none' })
26
+ setPageLayout(false)
27
+ Toast({ context: this, selector: '#t-toast', message: '已关闭布局' })
28
+ },
29
+ backHome() {
30
+ wx.navigateTo({ url: '/pages/index/index' })
31
+ },
32
+ })
@@ -0,0 +1,16 @@
1
+ <view class="min-h-screen bg-slate-100 px-4 py-5">
2
+ <view class="rounded-2xl bg-white p-5 shadow-sm">
3
+ <view class="text-xs font-semibold uppercase tracking-[0.2em] text-violet-700">Native Layouts</view>
4
+ <view class="mt-3 text-2xl font-bold text-slate-900">TDesign 原生模板已接入 layouts</view>
5
+ <view class="mt-3 text-sm leading-7 text-slate-600">当前状态:{{currentLayout}}</view>
6
+ </view>
7
+
8
+ <view class="mt-4 rounded-2xl bg-white p-5 shadow-sm">
9
+ <t-button block theme="primary" bind:tap="applyDefaultLayout">使用 default 布局</t-button>
10
+ <t-button class="mt-3" block theme="success" variant="outline" bind:tap="applyAdminLayout">切到 admin 布局</t-button>
11
+ <t-button class="mt-3" block theme="warning" variant="outline" bind:tap="clearLayout">关闭布局</t-button>
12
+ <t-button class="mt-3" block theme="default" variant="outline" bind:tap="backHome">返回首页</t-button>
13
+ </view>
14
+
15
+ <t-toast id="t-toast" />
16
+ </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": []
@@ -5,6 +5,15 @@ import { defineConfig } from 'weapp-vite/config'
5
5
  export default defineConfig({
6
6
  weapp: {
7
7
  srcRoot: 'src',
8
+ typescript: {
9
+ app: {
10
+ compilerOptions: {
11
+ paths: {
12
+ 'tdesign-miniprogram/*': ['./node_modules/tdesign-miniprogram/miniprogram_dist/*'],
13
+ },
14
+ },
15
+ },
16
+ },
8
17
  autoImportComponents: {
9
18
  resolvers: [TDesignResolver()],
10
19
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite-tailwindcss-vant-template",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "private": true,
6
6
  "description": "原生微信小程序 weapp-vite + tailwindcss 模板",
7
7
  "author": "ice breaker <1324318532@qq.com>",
@@ -21,7 +21,7 @@
21
21
  "build": "weapp-vite build",
22
22
  "open": "weapp-vite open",
23
23
  "g": "weapp-vite generate",
24
- "postinstall": "weapp-tw patch"
24
+ "postinstall": "weapp-tw patch && weapp-vite prepare"
25
25
  },
26
26
  "dependencies": {
27
27
  "@vant/weapp": "catalog:"
@@ -33,7 +33,7 @@
33
33
  "miniprogram-api-typings": "catalog:",
34
34
  "postcss": "catalog:",
35
35
  "sass": "catalog:",
36
- "tailwindcss": "catalog:",
36
+ "tailwindcss": "catalog:tailwind3",
37
37
  "typescript": "catalog:",
38
38
  "weapp-tailwindcss": "catalog:",
39
39
  "weapp-vite": "workspace:*"
@@ -2,7 +2,7 @@
2
2
  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
3
3
  "projectname": "weapp-vite-tailwindcss-vant-template",
4
4
  "setting": {
5
- "compileHotReLoad": false
5
+ "compileHotReLoad": true
6
6
  },
7
7
  "libVersion": "3.14.0"
8
8
  }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "$schema": "https://vite.icebreaker.top/app.json",
3
3
  "pages": [
4
- "pages/index/index"
4
+ "pages/index/index",
5
+ "pages/layouts/index"
5
6
  ],
6
7
  "window": {},
7
8
  "componentFramework": "glass-easel",
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }