feat: initialize taro react typescript miniapp

This commit is contained in:
czz
2026-05-07 14:41:39 +08:00
commit 5a98d4afe7
18 changed files with 17606 additions and 0 deletions

10
src/app.config.ts Normal file
View File

@@ -0,0 +1,10 @@
export default defineAppConfig({
pages: ["pages/index/index"],
window: {
navigationBarTitleText: "新手小程序",
navigationBarBackgroundColor: "#1AAD19",
navigationBarTextStyle: "white",
backgroundTextStyle: "light",
backgroundColor: "#f6f7fb"
}
});

21
src/app.scss Normal file
View File

@@ -0,0 +1,21 @@
page {
background: #f6f7fb;
color: #1f2937;
font-size: 32rpx;
}
.page {
min-height: 100vh;
padding: 40rpx 32rpx 60rpx;
box-sizing: border-box;
background:
radial-gradient(circle at top right, rgba(26, 173, 25, 0.15), transparent 26%),
linear-gradient(180deg, #f7fbf5 0%, #f6f7fb 100%);
}
.card {
background: rgba(255, 255, 255, 0.96);
border-radius: 28rpx;
padding: 36rpx 32rpx;
box-shadow: 0 18rpx 48rpx rgba(15, 23, 42, 0.08);
}

8
src/app.tsx Normal file
View File

@@ -0,0 +1,8 @@
import "./app.scss";
function App(props) {
const { children } = props;
return children ?? null;
}
export default App;

View File

@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: "首页"
});

View File

@@ -0,0 +1,48 @@
.title {
display: block;
font-size: 46rpx;
font-weight: 700;
line-height: 1.4;
margin-bottom: 16rpx;
color: #0f172a;
}
.subtitle {
display: block;
font-size: 28rpx;
line-height: 1.8;
color: #475569;
}
.section {
margin-top: 28rpx;
}
.section-title {
display: block;
font-size: 32rpx;
font-weight: 600;
margin-bottom: 14rpx;
color: #111827;
}
.list-item {
margin-bottom: 12rpx;
line-height: 1.8;
color: #334155;
}
.primary-btn {
margin-top: 28rpx;
border-radius: 999rpx;
background: linear-gradient(135deg, #1aad19 0%, #138a15 100%);
color: #ffffff;
border: none;
}
.tip {
display: block;
margin-top: 20rpx;
font-size: 24rpx;
color: #64748b;
}

49
src/pages/index/index.tsx Normal file
View File

@@ -0,0 +1,49 @@
import { useState } from "react";
import { Button, Text, View } from "@tarojs/components";
import Taro from "@tarojs/taro";
import "./index.scss";
const steps = [
"先执行 npm install 安装依赖",
"再执行 npm run dev:weapp 启动编译",
"用微信开发者工具打开当前项目",
"继续在 React 页面里开发你的业务"
];
export default function Index() {
const [clicked, setClicked] = useState(false);
const handleStart = () => {
setClicked(true);
Taro.showToast({
title: "开始开发吧",
icon: "success"
});
};
return (
<View className="page">
<View className="card">
<Text className="title"> React </Text>
<Text className="subtitle">
TaroReact TypeScript React
</Text>
<View className="section">
<Text className="section-title"></Text>
{steps.map((item, index) => (
<View className="list-item" key={item}>
{index + 1}. {item}
</View>
))}
</View>
<Button className="primary-btn" onClick={handleStart}>
</Button>
{clicked ? <Text className="tip"> React </Text> : null}
</View>
</View>
);
}