# BuyOrNot **Repository Path**: dalovemoli/BuyOrNot ## Basic Information - **Project Name**: BuyOrNot - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-27 - **Last Updated**: 2026-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # BuyOrNot - 买不买老虎机 一个帮你做购买决定的趣味小工具。当你纠结要不要买某样东西时,让命运来决定! ## 功能特性 - 🎰 老虎机滚动动画,三个滚轮依次停下 - ✅ / ❌ 对号叉号图标,结果一目了然 - 🎊 买买买时触发彩纸特效 - 📱 响应式设计,支持移动端和桌面端 - 🌙 毛玻璃风格深色主题 ## 技术栈 - **前端框架**: React 19 + TypeScript - **构建工具**: Vite - **动画库**: Framer Motion - **样式**: 内联样式 + Tailwind CSS - **特效**: canvas-confetti ## 本地开发 ### 环境要求 - Node.js >= 18 - npm >= 9 ### 安装与运行 ```bash # 克隆项目 git clone https://gitee.com/dalovemoli/BuyOrNot.git cd BuyOrNot # 安装依赖 npm install # 启动开发服务器 npm run dev ``` 访问 http://localhost:5173/ 查看效果。 ### 构建生产版本 ```bash npm run build ``` 构建产物会生成在 `dist/` 目录。 ## 部署到服务器 ### 方式一:Nginx 部署(推荐) #### 1. 构建项目 ```bash npm run build ``` #### 2. 上传 dist 目录到服务器 ```bash # 使用 scp scp -r dist/* user@your-server:/var/www/buyornot/ # 或使用 rsync rsync -avz dist/ user@your-server:/var/www/buyornot/ ``` #### 3. 配置 Nginx ```nginx server { listen 80; server_name your-domain.com; # 替换为你的域名或 IP root /var/www/buyornot; index index.html; # SPA 路由支持 location / { try_files $uri $uri/ /index.html; } # 静态资源缓存 location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } # Gzip 压缩 gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; gzip_min_length 1000; } ``` #### 4. 重启 Nginx ```bash sudo nginx -t # 测试配置 sudo systemctl reload nginx # 重载配置 ``` --- ### 方式二:Docker 部署 #### 1. 创建 Dockerfile 在项目根目录创建 `Dockerfile`: ```dockerfile # 构建阶段 FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build # 运行阶段 FROM nginx:alpine COPY --from=builder /app/dist /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] ``` #### 2. 创建 nginx.conf ```nginx server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml; } ``` #### 3. 构建并运行 ```bash # 构建镜像 docker build -t buyornot . # 运行容器 docker run -d -p 8080:80 --name buyornot buyornot ``` 访问 http://your-server:8080 查看效果。 --- ### 方式三:Docker Compose 部署 创建 `docker-compose.yml`: ```yaml version: '3.8' services: buyornot: build: . ports: - "8080:80" restart: unless-stopped container_name: buyornot ``` 运行: ```bash docker-compose up -d ``` --- ### 方式四:Vercel / Netlify 一键部署 #### Vercel ```bash # 安装 Vercel CLI npm i -g vercel # 部署 vercel ``` #### Netlify ```bash # 安装 Netlify CLI npm i -g netlify-cli # 部署 netlify deploy --prod ``` 或直接在 [Vercel](https://vercel.com) / [Netlify](https://netlify.com) 网站导入 Git 仓库自动部署。 --- ### 方式五:宝塔面板部署 1. 在宝塔面板安装 **Nginx** 和 **Node.js** 2. 上传项目文件到服务器 3. 在项目目录执行: ```bash npm install npm run build ``` 4. 添加站点,网站目录指向 `dist/` 5. 配置伪静态(选择 Laravel 或自定义): ```nginx location / { try_files $uri $uri/ /index.html; } ``` ## 项目结构 ``` BuyOrNot/ ├── public/ # 静态资源 ├── src/ │ ├── components/ │ │ ├── Background.tsx # 渐变背景 │ │ ├── Icons.tsx # 对号/叉号图标 │ │ ├── QuestionInput.tsx # 问题输入框 │ │ ├── SlotMachine.tsx # 老虎机主组件 │ │ └── SlotReel.tsx # 单个滚轮组件 │ ├── data/ │ │ └── messages.ts # 趣味文案 │ ├── App.tsx # 主页面 │ ├── main.tsx # 入口文件 │ └── index.css # 全局样式 ├── index.html # HTML 模板 ├── package.json # 项目配置 ├── tsconfig.json # TypeScript 配置 └── vite.config.ts # Vite 配置 ``` ## 自定义修改 ### 修改滚轮内容 编辑 `src/components/SlotMachine.tsx`: ```tsx // 修改第 7 行的 ITEMS 数组 const ITEMS = [, ] ``` ### 修改趣味文案 编辑 `src/data/messages.ts`: ```tsx export const buyMessages = [ '你的自定义文案1', '你的自定义文案2', // ... ] export const notBuyMessages = [ '你的自定义文案1', '你的自定义文案2', // ... ] ``` ## License MIT