diff --git a/src/index.html b/src/index.html
index 75b5771..4668864 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,82 +1,73 @@
-
+
-
- {{TABLE_HEADERS}}
- {{DATA}}
-
-
+
+
Auth Inbox
+
+
+ {{TABLE_HEADERS}}
+ {{DATA}}
+
+
+
diff --git a/src/index.ts b/src/index.ts
index 8c217d9..12ef87b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -70,34 +70,43 @@ export default {
}
try {
- // 查询 code_emails 数据库,选择指定的字段
const { results } = await env.DB.prepare(
'SELECT from_org, to_addr, topic, code, created_at FROM code_mails ORDER BY created_at DESC'
).all();
- // 构建 HTML 表格行
let dataHtml = '';
for (const row of results) {
+ const codeLinkParts = row.code.split(',');
+ let codeLinkContent;
+
+ if (codeLinkParts.length > 1) {
+ const [code, link] = codeLinkParts;
+ codeLinkContent = `${code}
${row.topic}`;
+ } else if (row.code.startsWith('http')) {
+ codeLinkContent = `
${row.topic}`;
+ } else {
+ codeLinkContent = row.code;
+ }
+
dataHtml += `
- | ${row.from_org} |
- ${row.to_addr} |
- ${row.topic} |
- ${row.code} |
- ${row.created_at} |
-
`;
+
${row.from_org} |
+
${row.to_addr} |
+
${row.topic} |
+
${codeLinkContent} |
+
${row.created_at} |
+ `;
}
- // 替换 indexHtml 中的 {{DATA}} 占位符和表头
let responseHtml = indexHtml
.replace('{{TABLE_HEADERS}}', `
-
- | From |
- To |
- Topic |
- Code/Link |
- Receive Time |
-
- `)
+
+ | From |
+ To |
+ Topic |
+ Code/Link |
+ Receive Time |
+
+ `)
.replace('{{DATA}}', dataHtml);
return new Response(responseHtml, {
@@ -113,10 +122,9 @@ export default {
// 主要功能
async email(message, env, ctx) {
- const barkUrl = env.barkUrl; // "https://api.day.app"
- const barkTokens = JSON.parse(env.barkTokens) as string[]; // ["token1", "token2"]
- const GoogleAPIKey = env.GoogleAPIKey; // "xxxxxxxxxxxxxxxxxxxxxxxx"
const useBark = env.UseBark.toLowerCase() === 'true'; // true or false
+ const GoogleAPIKey = env.GoogleAPIKey; // "xxxxxxxxxxxxxxxxxxxxxxxx"
+
const rawEmail = await new Response(message.raw).text();
const message_id = message.headers.get("Message-ID");
@@ -244,6 +252,13 @@ export default {
// Send title and code to Bark using GET request for each token
if (useBark) {
+ const barkUrl = env.barkUrl; // "https://api.day.app"
+ // ["token1", "token2"]
+ const barkTokens = env.barkTokens
+ .replace(/^\[|\]$/g, '')
+ .split(',')
+ .map(token => token.trim());
+
const barkUrlEncodedTitle = encodeURIComponent(title);
const barkUrlEncodedCode = encodeURIComponent(code);
diff --git a/wrangler.toml b/wrangler.toml
index ca4fc70..5a4d7e1 100644
--- a/wrangler.toml
+++ b/wrangler.toml
@@ -25,10 +25,13 @@ enabled = true
[vars]
UseBark = "true"
barkUrl = "https://api.day.app"
-barkTokens = "["token1", "token2"]" # set to your bark tokens on your iOS device, download it from https://bark.day.app/, you can use multiple tokens, if you only use one, then set it to '['token1']'
-FrontEndAdminID = "admin" # your login
-FrontEndAdminPassword = "password" # your password
-GoogleAPIKey = "xxxxxxxxxxx" # your google api
+#barkTokens = "[token1, token2]" # set to your bark tokens on your iOS device, download it from https://bark.day.app/, you can use multiple tokens, if you only use one, then set it to '[token1]'
+#FrontEndAdminID = "admin" # your login
+#FrontEndAdminPassword = "password" # your password
+#GoogleAPIKey = "xxxxxxxxxxx" # your google api
+
+
+
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
# [ai]
@@ -49,7 +52,8 @@ GoogleAPIKey = "xxxxxxxxxxx" # your google api
[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "inbox-d1"
-database_id = "
"
+database_id = "20e35790-1762-45f3-9158-e9e0ad9411cd"
+
# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.