feat:环境变量优化

This commit is contained in:
hzm
2026-02-08 21:33:37 +08:00
parent 173330fa7f
commit 6d12e9485f
5 changed files with 30 additions and 4 deletions

View File

@@ -38,7 +38,16 @@
npm install npm install
``` ```
3. 运行开发服务器 3. 配置环境变量
```bash
cp env.example .env.local
```
按照 `env.example` 填入以下值:
- `NEXT_PUBLIC_SUPABASE_URL`Supabase 项目 URL
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`Supabase 匿名公钥
- `NEXT_PUBLIC_WEB3FORMS_ACCESS_KEY`Web3Forms Access Key
4. 运行开发服务器:
```bash ```bash
npm run dev npm run dev
``` ```
@@ -47,6 +56,7 @@
### 构建与部署 ### 构建与部署
本项目已配置 GitHub Actions。每次推送到 `main` 分支时,会自动执行构建并部署到 GitHub Pages。 本项目已配置 GitHub Actions。每次推送到 `main` 分支时,会自动执行构建并部署到 GitHub Pages。
如需使用 GitHub Actions 部署,请在 GitHub 项目 Settings → Secrets and variables → Actions 中创建对应的 Repository secrets字段名称与 `.env.local` 保持一致)。
若要手动构建: 若要手动构建:
```bash ```bash

4
app/icon.svg Normal file
View File

@@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="12" cy="12" r="10" stroke="#60A5FA" stroke-width="2" />
<path d="M5 14c2-4 7-6 14-5" stroke="#22D3EE" stroke-width="2" stroke-linecap="round" />
</svg>

After

Width:  |  Height:  |  Size: 264 B

View File

@@ -2,8 +2,8 @@ import { createClient } from '@supabase/supabase-js';
// Supabase 配置 // Supabase 配置
// 注意:此处使用 publishable key可安全在客户端使用 // 注意:此处使用 publishable key可安全在客户端使用
const supabaseUrl = 'https://mouvsqlmgymsaxikvqsh.supabase.co'; const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL || '';
const supabaseAnonKey = 'sb_publishable_c5f58knbVz8UgOh6L88MUQ_p9j8c1Q-'; const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || '';
export const supabase = createClient(supabaseUrl, supabaseAnonKey, { export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
auth: { auth: {

View File

@@ -570,7 +570,7 @@ function FeedbackModal({ onClose, user }) {
} }
// Web3Forms Access Key // Web3Forms Access Key
formData.append("access_key", "c390fbb1-77e0-4aab-a939-caa75edc7319"); formData.append("access_key", process.env.NEXT_PUBLIC_WEB3FORMS_ACCESS_KEY || '');
formData.append("subject", "基估宝 - 用户反馈"); formData.append("subject", "基估宝 - 用户反馈");
try { try {

12
env.example Normal file
View File

@@ -0,0 +1,12 @@
# Supabase 配置
# 从 Supabase 项目设置中获取这些值https://app.supabase.com/project/_/settings/api
# 复制此文件为 .env.local 并填入实际值
NEXT_PUBLIC_SUPABASE_URL=your_supabase_project_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
# web3forms 配置
# 从 web3forms 中获取这些值 https://app.web3forms.com/dashboard
NEXT_PUBLIC_WEB3FORMS_ACCESS_KEY=your_web3forms_access_key
# 如果要用 Github Actions 部署,需要在 Github 项目 Settings → secrets and actions → Actions → 创建 Repository secrets