Skip to content

Commit 894c013

Browse files
committed
upd
1 parent a425ed0 commit 894c013

7 files changed

Lines changed: 31 additions & 11 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ jobs:
7979
else
8080
sed -i '/^API_RATE_LIMIT_PER_MINUTE = /d' wrangler.toml
8181
fi
82+
if [ -n "${SHOW_AFF}" ]; then
83+
sed -i "s#\${SHOW_AFF}#${SHOW_AFF}#g" wrangler.toml
84+
else
85+
sed -i '/^SHOW_AFF = /d' wrangler.toml
86+
fi
8287
env:
8388
D1_DATABASE_ID: ${{ secrets.D1_DATABASE_ID }}
8489
D1_DATABASE_NAME: ${{ secrets.D1_DATABASE_NAME }}
@@ -88,6 +93,7 @@ jobs:
8893
TURNSTILE_SECRET: ${{ secrets.TURNSTILE_SECRET }}
8994
PASSWORD: ${{ secrets.PASSWORD }}
9095
API_RATE_LIMIT_PER_MINUTE: ${{ secrets.API_RATE_LIMIT_PER_MINUTE }}
96+
SHOW_AFF: ${{ secrets.SHOW_AFF }}
9197

9298
# 新增:在部署前应用 D1 数据库迁移
9399
# 这一步会明确地告诉 Wrangler 远程执行 D1 数据库的迁移脚本。

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<p><a href="/docs/github-action-tutorial.md">部署教程</a> · <a href="/docs/ai-deploy.md">AI帮你部署</a> ·
55
<a href="https://vmail.dev/api-docs" target="_blank">API 文档</a> · <a href="https://github.com/oiov/vmail/blob/main/README_en.md">English</a> | 简体中文</p>
66
<p>使用 Cloudflare Email Worker 实现的临时电子邮件服务</p>
7-
</div>
8-
7+
</div>
8+
99
> 🌟 本项目作者提供 **Claude Code** 稳定 API 渠道:[www.aicentos.com](https://www.aicentos.com/register?aff=Dptp) ,支持 claude-opus-4-6 等主流 AI Coding 大模型🥳
1010
1111
## 🌈 特点
@@ -79,6 +79,7 @@
7979
- `TURNSTILE_SECRET`: 您的 Turnstile 密钥,可选。
8080
- `PASSWORD`: 站点访问密码(可选)。
8181
- `API_RATE_LIMIT_PER_MINUTE`: API 每分钟请求限制(可选,默认 100)。
82+
- `SHOW_AFF`: 是否展示推广弹框和常驻推广链接(可选,`true` 开启,默认不展示)。
8283

8384
## 🔨 本地运行调试
8485

README_en.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ When deploying to Cloudflare Pages, you need to configure the following environm
126126

127127
- `DATABASE_NAME`: Your D1 database name.
128128
- `DATABASE_ID`: Your D1 database ID.
129-
- `TURNSTILE_KEY`: Your Turnstile site key.
130-
- `TURNSTILE_SECRET`: Your Turnstile secret key.
131129
- `COOKIES_SECRET`: A secret used to sign cookies.
130+
- `EMAIL_DOMAIN`: Your email domain, e.g. `example.com,example.net`.
131+
- `TURNSTILE_KEY`: Your Turnstile site key (optional).
132+
- `TURNSTILE_SECRET`: Your Turnstile secret key (optional).
133+
- `PASSWORD`: Site access password (optional).
134+
- `API_RATE_LIMIT_PER_MINUTE`: API rate limit per minute (optional, default 100).
135+
- `SHOW_AFF`: Show promotional popup and link (optional, `true` to enable, hidden by default).
132136

133137
## Community Group
134138

frontend/src/hooks/useConfig.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export interface AppConfig {
99
apiRateLimitPerMinute: number;
1010
// feat: 添加 cookiesSecret 到配置中,以便前端加密时使用
1111
cookiesSecret: string;
12+
// feat: 控制是否展示推广弹框和常驻链接
13+
showAff: boolean;
1214
}
1315

1416
// 创建 React Context

frontend/src/pages/Home.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export function Home() {
6565
); // feat: 新增状态,用于存储当前选中的域名
6666
const [showEmailModal, setShowEmailModal] = useState(false); // feat: 新增状态,用于控制邮件详情模态框的显示
6767
const [showPromoModal, setShowPromoModal] = useState(() => {
68+
// 如果未启用推广,不弹出
69+
if (!config.showAff) return false;
6870
// 检查是否已经显示过弹框(使用 localStorage)
6971
const hasShown = localStorage.getItem("aicentos_promo_shown");
7072
return !hasShown; // 如果没显示过,则自动弹出
@@ -361,7 +363,7 @@ export function Home() {
361363
/>
362364
</InfoModal>
363365
)}
364-
{showPromoModal && (
366+
{config.showAff && showPromoModal && (
365367
<InfoModal
366368
showModal={showPromoModal}
367369
setShowModal={setShowPromoModal}
@@ -458,12 +460,14 @@ export function Home() {
458460
<h1 className="text-gray-50 text-xl font-bold mb-3 group-hover:text-cyan-500 duration-500">
459461
{t("Virtual Temporary Email")}
460462
</h1>
461-
<button
462-
type="button"
463-
onClick={() => setShowPromoModal(true)}
464-
className="mb-6 text-left text-sm text-cyan-400 hover:text-cyan-300 transition-colors underline underline-offset-4 decoration-cyan-500/60">
465-
Vmail & AICentOS 联动注册送 Claude Code、Codex 免费额度
466-
</button>
463+
{config.showAff && (
464+
<button
465+
type="button"
466+
onClick={() => setShowPromoModal(true)}
467+
className="mb-6 text-left text-sm text-cyan-400 hover:text-cyan-300 transition-colors underline underline-offset-4 decoration-cyan-500/60">
468+
Vmail & AICentOS 联动注册送 Claude Code、Codex 免费额度
469+
</button>
470+
)}
467471
<div className="flex flex-col gap-4 text-sm text-gray-200">
468472
<a
469473
href="https://github.com/oiov/vmail"

worker/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface Env {
2525
TURNSTILE_SECRET: string;
2626
PASSWORD?: string;
2727
API_RATE_LIMIT_PER_MINUTE?: string;
28+
SHOW_AFF?: string;
2829
}
2930

3031
// 初始化 Hono 应用
@@ -343,6 +344,7 @@ app.get('/config', (c) => {
343344
cookiesSecret: c.env.COOKIES_SECRET,
344345
sitePasswordEnabled: Boolean(c.env.PASSWORD),
345346
apiRateLimitPerMinute: parseRateLimitPerMinute(c.env),
347+
showAff: c.env.SHOW_AFF === 'true',
346348
});
347349
});
348350

wrangler.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ COOKIES_SECRET = "${COOKIES_SECRET}"
2323
TURNSTILE_SECRET = "${TURNSTILE_SECRET}"
2424
PASSWORD = "${PASSWORD}"
2525
API_RATE_LIMIT_PER_MINUTE = "${API_RATE_LIMIT_PER_MINUTE}"
26+
SHOW_AFF = "${SHOW_AFF}"
2627

2728
# 配置邮件处理
2829
[triggers]

0 commit comments

Comments
 (0)