init2
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
],
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.24.4",
|
||||
"@babel/runtime": "^7.28.4",
|
||||
"@tarojs/components": "4.1.6",
|
||||
"@tarojs/helper": "4.1.6",
|
||||
"@tarojs/plugin-platform-weapp": "4.1.6",
|
||||
@@ -63,30 +63,30 @@
|
||||
"@tarojs/plugin-generator": "4.1.6",
|
||||
"@commitlint/cli": "^19.8.1",
|
||||
"@commitlint/config-conventional": "^19.8.1",
|
||||
"lint-staged": "^16.1.2",
|
||||
"lint-staged": "^16.1.6",
|
||||
"husky": "^9.1.7",
|
||||
"stylelint-config-standard": "^38.0.0",
|
||||
"@babel/core": "^7.24.4",
|
||||
"stylelint-config-standard": "^39.0.0",
|
||||
"@babel/core": "^7.28.4",
|
||||
"@tarojs/cli": "4.1.6",
|
||||
"@babel/plugin-transform-class-properties": "7.25.9",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@types/react": "^18.0.0",
|
||||
"webpack": "5.91.0",
|
||||
"@babel/plugin-transform-class-properties": "7.27.1",
|
||||
"@types/webpack-env": "^1.18.8",
|
||||
"@types/react": "^19.1.13",
|
||||
"webpack": "5.101.3",
|
||||
"@tarojs/taro-loader": "4.1.6",
|
||||
"@tarojs/webpack5-runner": "4.1.6",
|
||||
"babel-preset-taro": "4.1.6",
|
||||
"eslint-config-taro": "4.1.6",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint": "^9.35.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
||||
"react-refresh": "^0.14.0",
|
||||
"@babel/preset-react": "^7.24.1",
|
||||
"eslint-plugin-react": "^7.34.1",
|
||||
"eslint-plugin-react-hooks": "^4.4.0",
|
||||
"stylelint": "^16.4.0",
|
||||
"typescript": "^5.4.5",
|
||||
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
||||
"postcss": "^8.4.38",
|
||||
"@types/node": "^18",
|
||||
"@types/minimatch": "^5"
|
||||
"react-refresh": "^0.17.0",
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"stylelint": "^16.24.0",
|
||||
"typescript": "^5.9.2",
|
||||
"tsconfig-paths-webpack-plugin": "^4.2.0",
|
||||
"postcss": "^8.5.6",
|
||||
"@types/node": "^24",
|
||||
"@types/minimatch": "^6"
|
||||
}
|
||||
}
|
||||
739
2025-09-14-webpack-demo/pnpm-lock.yaml
generated
739
2025-09-14-webpack-demo/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,26 @@
|
||||
import { PropsWithChildren } from 'react'
|
||||
import { useLaunch } from '@tarojs/taro'
|
||||
import { PropsWithChildren } from "react";
|
||||
import { useLaunch } from "@tarojs/taro";
|
||||
|
||||
import './app.css'
|
||||
import "./app.css";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
function App({ children }: PropsWithChildren<any>) {
|
||||
useLaunch(() => {
|
||||
console.log('App launched.')
|
||||
})
|
||||
console.log("App launched.");
|
||||
console.log(Taro.getEnv(), Taro.ENV_TYPE);
|
||||
if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) {
|
||||
Taro.login({
|
||||
success: function (res) {
|
||||
console.log("login success", res);
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log("Not in a mini program environment, skipping login.");
|
||||
}
|
||||
});
|
||||
|
||||
// children 是将要会渲染的页面
|
||||
return children
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default App
|
||||
export default App;
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { useLoad } from '@tarojs/taro'
|
||||
import './index.css'
|
||||
import { View, Text, Button } from "@tarojs/components";
|
||||
import { useLoad } from "@tarojs/taro";
|
||||
import "./index.css";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
export default function Index() {
|
||||
useLoad(() => {
|
||||
console.log('Page loaded.')
|
||||
})
|
||||
console.log("Page loaded.");
|
||||
});
|
||||
|
||||
return (
|
||||
<View className='index'>
|
||||
<View className="index">
|
||||
<Text>Hello world!</Text>
|
||||
<Button
|
||||
openType="getUserInfo"
|
||||
onGetUserInfo={(e) => {
|
||||
console.log("onGetUserInfoEventDetail", e);
|
||||
}}
|
||||
>
|
||||
User Info
|
||||
</Button>
|
||||
</View>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
6
2025-09-14-webpack-demo/src/xhs/utils/is-xhs.ts
Normal file
6
2025-09-14-webpack-demo/src/xhs/utils/is-xhs.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
export const isXHS = () => {
|
||||
// @ts-ignore
|
||||
return Taro.getEnv() === "xhs";
|
||||
};
|
||||
2
2025-09-14-webpack-demo/types/global.d.ts
vendored
2
2025-09-14-webpack-demo/types/global.d.ts
vendored
@@ -16,7 +16,7 @@ declare namespace NodeJS {
|
||||
/** NODE 内置环境变量, 会影响到最终构建生成产物 */
|
||||
NODE_ENV: 'development' | 'production',
|
||||
/** 当前构建的平台 */
|
||||
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
|
||||
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn' | 'xhs'
|
||||
/**
|
||||
* 当前构建的小程序 appid
|
||||
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
|
||||
|
||||
Reference in New Issue
Block a user