changed the 'barkToken' variable

This commit is contained in:
TooonyChen committed 2024-10-08 14:01:59 +13:00
1 parent 38fc8d96e4
commit 2a97457391
3 files changed
+83 -71

No files matched your search

+39 -46
View File
@@ -1,82 +1,73 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Auth Inbox</title>
<!-- 引入 Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- 选择您喜欢的字体,这里以 Roboto 为例 -->
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap" rel="stylesheet">
<style>
/* 全局样式 */
body {
font-family: 'Roboto', sans-serif;
background-color: #f9f9f9;
font-family: 'Open Sans', sans-serif;
background-color: #1a1a1a;
color: #ffffff;
margin: 0;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
}
.container {
flex-grow: 1;
}
/* 标题样式 */
h1 {
text-align: center;
color: #333;
color: #61dafb;
margin-bottom: 30px;
font-size: 2.5em;
}
/* 表格容器 */
.table-container {
overflow-x: auto;
margin: 0 auto;
background-color: #2a2a2a;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
/* 表格样式 */
table {
width: 100%;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
/* 表头样式 */
th {
background-color: #4CAF50;
color: white;
background-color: #333;
color: #61dafb;
padding: 15px;
text-align: left;
font-weight: bold;
border-bottom: 2px solid #ddd;
border-bottom: 2px solid #444;
}
/* 单元格样式 */
td {
padding: 12px 15px;
border-bottom: 1px solid #ddd;
color: #555;
border-bottom: 1px solid #444;
color: #ffffff;
}
/* 表格行悬停效果 */
tr:hover {
background-color: #f1f1f1;
background-color: #3a3a3a;
}
a {
color: #61dafb;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
#footer {
text-align: center;
position: absolute;
bottom: 0;
width: 100%;
height: 2.5rem;
padding: 20px 0;
color: #888;
}
/* 响应式调整 */
@media (max-width: 600px) {
th, td {
padding: 10px;
}
h1 {
font-size: 2em;
}
@@ -84,13 +75,15 @@
</style>
</head>
<body>
<h1>Auth Inbox</h1>
<div class="table-container">
<table>
{{TABLE_HEADERS}}
{{DATA}}
</table>
<footer id="footer">Coded By <a href="https://github.com/TooonyChen">github@TooonyChen</a></footer>
<div class="container">
<h1>Auth Inbox</h1>
<div class="table-container">
<table>
{{TABLE_HEADERS}}
{{DATA}}
</table>
</div>
</div>
<footer id="footer">Coded By <a href="https://github.com/TooonyChen">github@TooonyChen</a></footer>
</body>
</html>
+35 -20
View File
@@ -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}<br><a href="${link}" target="_blank">${row.topic}</a>`;
} else if (row.code.startsWith('http')) {
codeLinkContent = `<a href="${row.code}" target="_blank">${row.topic}</a>`;
} else {
codeLinkContent = row.code;
}
dataHtml += `<tr>
<td>${row.from_org}</td>
<td>${row.to_addr}</td>
<td>${row.topic}</td>
<td>${row.code}</td>
<td>${row.created_at}</td>
</tr>`;
<td>${row.from_org}</td>
<td>${row.to_addr}</td>
<td>${row.topic}</td>
<td>${codeLinkContent}</td>
<td>${row.created_at}</td>
</tr>`;
}
// 替换 indexHtml 中的 {{DATA}} 占位符和表头
let responseHtml = indexHtml
.replace('{{TABLE_HEADERS}}', `
<tr>
<th>From</th>
<th>To</th>
<th>Topic</th>
<th>Code/Link</th>
<th>Receive Time</th>
</tr>
`)
<tr>
<th>From</th>
<th>To</th>
<th>Topic</th>
<th>Code/Link</th>
<th>Receive Time</th>
</tr>
`)
.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);
+9 -5
View File
@@ -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 = "<unique-ID-for-your-database>"
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.