create-vite-taro 0.2.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-vite-taro",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Create Vite 8 + React 19 + Taro apps for H5 and WeChat Mini Program targets.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,8 @@
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.1"
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 (IS_WEAPP) {
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 = IS_WEAPP ? (windowInfo.statusBarHeight ?? 44) : 0
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
@@ -0,0 +1,3 @@
1
+ interface ImportMetaEnv {
2
+ readonly VITE_PLUGIN_TARO_TARGET: 'wx' | 'h5'
3
+ }
@@ -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 "../../components/navigation-bar/navigation-bar.tsx"
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={'Vite Taro App'}/>
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