feat(helpers): 添加东12时区日期格式化函数并更新相关调用
refactor(handlers): 修改文章链接格式为年/月/日结构并统一使用东12时区时间 docs: 更新Markdown标题级别和收听语音版标题
This commit is contained in:
@@ -3,7 +3,7 @@ export function insertFoot() {
|
||||
|
||||
---
|
||||
|
||||
#### **收听语音版**
|
||||
## **收听语音版AI日报**
|
||||
|
||||
| 🎙️ **小宇宙** | 📹 **抖音** |
|
||||
| --- | --- |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// src/handlers/commitToGitHub.js
|
||||
import { getISODate, formatMarkdownText, replaceImageProxy,formatDateToGMT0WithTime, sleep } from '../helpers.js';
|
||||
import { getISODate, formatMarkdownText, replaceImageProxy,formatDateToGMT12WithTime } from '../helpers.js';
|
||||
import { getGitHubFileSha, createOrUpdateGitHubFile } from '../github.js';
|
||||
import { storeInKV } from '../kv.js';
|
||||
import { marked } from '../marked.esm.js';
|
||||
@@ -13,13 +13,15 @@ export async function handleCommitToGitHub(request, env) {
|
||||
const dateStr = formData.get('date') || getISODate();
|
||||
const dailyMd = formData.get('daily_summary_markdown');
|
||||
const podcastMd = formData.get('podcast_script_markdown');
|
||||
// 从 "YYYY-MM-DD" 格式的 dateStr 中提取 "YYYY-MM"
|
||||
const yearMonth = dateStr.substring(0, 7);
|
||||
const report = {
|
||||
report_date: dateStr,
|
||||
title: dateStr+'日刊',
|
||||
link: '/daily/'+dateStr+'.html',
|
||||
link: '/'+yearMonth+'/'+dateStr+'/',
|
||||
content_html: null,
|
||||
// 可以添加其他相關欄位,例如作者、來源等
|
||||
published_date: formatDateToGMT0WithTime(new Date()) // 記錄保存時間
|
||||
published_date: formatDateToGMT12WithTime(new Date()) // 記錄保存時間
|
||||
}
|
||||
|
||||
const filesToCommit = [];
|
||||
|
||||
@@ -253,7 +253,7 @@ export async function handleGenAIContent(request, env) {
|
||||
if (fullPromptForCall2_System) promptsMarkdownContent += `### System Instruction\n\`\`\`\n${fullPromptForCall2_System}\n\`\`\`\n\n`;
|
||||
if (fullPromptForCall2_User) promptsMarkdownContent += `### User Input (Output of Call 1)\n\`\`\`\n${fullPromptForCall2_User}\n\`\`\`\n\n`;
|
||||
|
||||
let dailySummaryMarkdownContent = `# ${env.DAILY_TITLE} ${formatDateToChinese(dateStr)}` + '\n\n';
|
||||
let dailySummaryMarkdownContent = `## ${env.DAILY_TITLE} ${formatDateToChinese(dateStr)}` + '\n\n';
|
||||
dailySummaryMarkdownContent += '> '+ env.DAILY_TITLE_MIN + '\n\n';
|
||||
let outputOfCall3 = null;
|
||||
console.log("Call 3 to Chat (Processing Call 2 Output): User prompt length:", outputOfCall2.length);
|
||||
@@ -271,7 +271,7 @@ export async function handleGenAIContent(request, env) {
|
||||
const errorHtml = generateGenAiPageHtml(env, '生成AI日报出错(摘要)', `<p><strong>Failed during processing of summarized content:</strong> ${escapeHtml(error.message)}</p>${error.stack ? `<pre>${escapeHtml(error.stack)}</pre>` : ''}`, dateStr, true, selectedItemsParams, fullPromptForCall1_System, fullPromptForCall1_User, fullPromptForCall2_System, fullPromptForCall2_User);
|
||||
return new Response(errorHtml, { status: 500, headers: { 'Content-Type': 'text/html; charset=utf-8' } });
|
||||
}
|
||||
dailySummaryMarkdownContent += '\n\n#### **AI内容摘要**\n\n```\n' + outputOfCall3 + '\n```\n\n';
|
||||
dailySummaryMarkdownContent += '\n\n### **AI内容摘要**\n\n```\n' + outputOfCall3 + '\n```\n\n';
|
||||
|
||||
dailySummaryMarkdownContent += `\n\n${removeMarkdownCodeBlock(outputOfCall2)}`;
|
||||
if (env.INSERT_FOOT=='true') dailySummaryMarkdownContent += insertFoot() +`\n\n`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { replaceImageProxy, formatDateToGMT0WithTime } from '../helpers.js';
|
||||
import { replaceImageProxy, formatMarkdownText, formatDateToGMT12WithTime } from '../helpers.js';
|
||||
import { getDailyReportContent } from '../github.js';
|
||||
import { storeInKV } from '../kv.js';
|
||||
import { marked } from '../marked.esm.js';
|
||||
@@ -18,15 +18,17 @@ export async function handleWriteRssData(request, env) {
|
||||
return new Response(`No content found for ${path}`, { status: 404 });
|
||||
}
|
||||
|
||||
// 从 "YYYY-MM-DD" 格式的 dateStr 中提取 "YYYY-MM"
|
||||
const yearMonth = dateStr.substring(0, 7);
|
||||
const report = {
|
||||
report_date: dateStr,
|
||||
title: dateStr+'日刊',
|
||||
link: '/daily/'+dateStr+'.html',
|
||||
link: '/'+yearMonth+'/'+dateStr+'/',
|
||||
content_html: null,
|
||||
// 可以添加其他相關欄位,例如作者、來源等
|
||||
published_date: formatDateToGMT0WithTime(new Date()) // 記錄保存時間
|
||||
published_date: formatDateToGMT12WithTime(new Date()) // 記錄保存時間
|
||||
}
|
||||
report.content_html = marked.parse(replaceImageProxy(env.IMG_PROXY, content));
|
||||
report.content_html = marked.parse(formatMarkdownText(replaceImageProxy(env.IMG_PROXY, content)));
|
||||
storeInKV(env.DATA_KV, `${dateStr}-report`, report);
|
||||
|
||||
return new Response(JSON.stringify(report), {
|
||||
|
||||
@@ -257,6 +257,23 @@ export function formatRssDate(date) {
|
||||
return new Intl.DateTimeFormat('zh-CN', options).format(date);
|
||||
}
|
||||
|
||||
export function formatDateToGMT12WithTime(isoDateString) {
|
||||
if (!isoDateString) return '';
|
||||
const date = new Date(isoDateString);
|
||||
const options = {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false, // 使用24小时制
|
||||
timeZone: 'Asia/Kamchatka'// 指定东12时区
|
||||
};
|
||||
// 使用 'zh-CN' 语言环境以确保中文格式
|
||||
return new Intl.DateTimeFormat('zh-CN', options).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts English double quotes (") to Chinese double quotes (“”).
|
||||
* @param {string} text - The input string.
|
||||
|
||||
Reference in New Issue
Block a user