create-vite-taro 0.2.0 → 0.2.2
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/README.md +1 -1
- package/package.json +1 -1
- package/templates/default/README.md +1 -1
- package/templates/default/package.json +4 -3
- package/templates/default/src/components/navigation-bar/use-navigation-bar.ts +4 -2
- package/templates/default/src/global.d.ts +3 -0
- package/templates/default/src/pages/index/index.tsx +3 -3
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ bun create vite-taro my-app
|
|
|
45
45
|
| `npm run build:wx` | Build the WeChat Mini Program output into `dist/wx`. |
|
|
46
46
|
| `npm run build:h5` | Build the H5 output into `dist/h5`. |
|
|
47
47
|
| `npm run preview:h5` | Preview the built H5 output. |
|
|
48
|
-
| `npm run typecheck` | Typecheck with `
|
|
48
|
+
| `npm run typecheck` | Typecheck with `tsc`. |
|
|
49
49
|
|
|
50
50
|
## Troubleshooting
|
|
51
51
|
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ npm run dev:h5 # Start the H5 dev server
|
|
|
34
34
|
npm run build:wx # Build dist/wx
|
|
35
35
|
npm run build:h5 # Build dist/h5
|
|
36
36
|
npm run preview:h5 # Preview dist/h5
|
|
37
|
-
npm run typecheck # Typecheck with
|
|
37
|
+
npm run typecheck # Typecheck with tsc
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Troubleshooting
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"build:wx": "cross-env NODE_ENV=production VITE_PLUGIN_TARO_TARGET=wx vite build",
|
|
10
10
|
"build:h5": "cross-env NODE_ENV=production VITE_PLUGIN_TARO_TARGET=h5 vite build",
|
|
11
11
|
"preview:h5": "cross-env NODE_ENV=production VITE_PLUGIN_TARO_TARGET=h5 vite preview --outDir dist/h5",
|
|
12
|
-
"typecheck": "
|
|
12
|
+
"typecheck": "tsc -b"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"react": "^19.2.7",
|
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
"@types/node": "^26.0.0",
|
|
20
20
|
"@types/react": "^19.2.17",
|
|
21
21
|
"@types/react-dom": "^19.2.3",
|
|
22
|
-
"
|
|
22
|
+
"typescript": "^7.0.1-rc",
|
|
23
23
|
"cross-env": "^10.1.0",
|
|
24
|
+
"tailwindcss": "^4.3.1",
|
|
24
25
|
"vite": "^8.0.16",
|
|
25
|
-
"vite-plugin-taro": "^0.2.
|
|
26
|
+
"vite-plugin-taro": "^0.2.2"
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Taro from 'virtual:taro/api'
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
|
|
4
|
+
const isWechatTarget = import.meta.env.VITE_PLUGIN_TARO_TARGET === 'wx'
|
|
5
|
+
|
|
4
6
|
interface NavigationBarNavInfo {
|
|
5
7
|
height: number
|
|
6
8
|
top: number
|
|
@@ -44,7 +46,7 @@ function createFallbackMenuInfo(screenWidth: number): NavigationBarMenuInfo {
|
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
function getMenuInfo(screenWidth: number): NavigationBarMenuInfo {
|
|
47
|
-
if (
|
|
49
|
+
if (isWechatTarget) {
|
|
48
50
|
const menuButtonInfo = Taro.getMenuButtonBoundingClientRect()
|
|
49
51
|
if (menuButtonInfo.width > 0 && menuButtonInfo.height > 0) return menuButtonInfo
|
|
50
52
|
}
|
|
@@ -55,7 +57,7 @@ function getMenuInfo(screenWidth: number): NavigationBarMenuInfo {
|
|
|
55
57
|
export function initNavigationBar(): NavigationBarInfo {
|
|
56
58
|
const windowInfo = Taro.getWindowInfo()
|
|
57
59
|
const screenWidth = windowInfo.screenWidth || 375
|
|
58
|
-
const statusBarHeight =
|
|
60
|
+
const statusBarHeight = isWechatTarget ? (windowInfo.statusBarHeight ?? 44) : 0
|
|
59
61
|
const menuInfo = getMenuInfo(screenWidth)
|
|
60
62
|
const menuButtonStatusBarGap = Math.max(0, menuInfo.top - statusBarHeight)
|
|
61
63
|
const navBarHeight = menuButtonStatusBarGap * 2 + menuInfo.height + statusBarHeight
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import Taro from 'virtual:taro/api'
|
|
2
2
|
import { Button, Text, View } from 'virtual:taro/components'
|
|
3
|
-
import { NavigationBar } from
|
|
3
|
+
import { NavigationBar } from '../../components/navigation-bar/navigation-bar.tsx'
|
|
4
4
|
|
|
5
5
|
function IndexPage() {
|
|
6
6
|
return (
|
|
7
7
|
<View className="flex flex-col h-screen overflow-hidden">
|
|
8
|
-
<NavigationBar title=
|
|
8
|
+
<NavigationBar title="Vite Taro App" />
|
|
9
9
|
<View className="flex-1 flex items-center justify-center bg-slate-50 px-6 py-12">
|
|
10
10
|
<View className="rounded-3xl bg-white p-6 shadow-sm">
|
|
11
11
|
<Text className="block text-2xl font-semibold text-slate-950">Vite + Taro</Text>
|
|
@@ -15,7 +15,7 @@ function IndexPage() {
|
|
|
15
15
|
<Button
|
|
16
16
|
className="mt-6 rounded-xl bg-blue-600 px-4 py-2 text-white"
|
|
17
17
|
onClick={() => {
|
|
18
|
-
Taro.showToast({title: 'Hello Taro'})
|
|
18
|
+
Taro.showToast({ title: 'Hello Taro' })
|
|
19
19
|
}}
|
|
20
20
|
>
|
|
21
21
|
Show toast
|