Skip to content

Commit

Permalink
🌐 chore(locale): 优化周报生成完成的提示语
Browse files Browse the repository at this point in the history
- 重构周报生成成功提示的国际化文案格式
- 【优化】调整日期处理逻辑,使用传入的时间范围替代计算方式
- 【重构】简化commands.ts中的导入路径
- 【样式】调整日期显示格式为更友好的形式
  • Loading branch information
littleCareless committed Feb 6, 2025
1 parent 0acce20 commit efebbe3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"ai.model.loading": "Loading AI model list...",
"weeklyReport.generating": "Generating weekly report...",
"weeklyReport.empty.response": "AI generated content is empty",
"weeklyReport.generation.success": "Weekly report generated successfully: : {0} {1}",
"weeklyReport.generation.success": "Weekly report for {1} ({0}) has been generated successfully",
"weeklyReport.generation.failed": "Failed to generate weekly report: {0}",
"weeklyReport.copy.success": "Content copied to clipboard",
"weeklyReport.copy.failed": "Copy failed: {0}",
Expand Down
2 changes: 1 addition & 1 deletion i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"ai.model.loading": "正在加载 AI 模型列表...",
"weeklyReport.generating": "正在生成周报...",
"weeklyReport.empty.response": "AI 生成内容为空",
"weeklyReport.generation.success": "周报生成成功: {0} {1}",
"weeklyReport.generation.success": "{1}的{0}工作周报已生成完成",
"weeklyReport.generation.failed": "生成周报失败: {0}",
"weeklyReport.copy.success": "内容已复制到剪贴板",
"weeklyReport.copy.failed": "复制失败: {0}",
Expand Down
2 changes: 1 addition & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GenerateCommitCommand } from "./commands/GenerateCommitCommand";
import { SelectModelCommand } from "./commands/SelectModelCommand";
import { GenerateWeeklyReportCommand } from "./commands/GenerateWeeklyReportCommand";
import { ReviewCodeCommand } from "./commands/ReviewCodeCommand";
import { notify } from "./utils/notification/NotificationManager";
import { notify } from "./utils";

/**
* 管理VS Code命令的注册和销毁
Expand Down
15 changes: 6 additions & 9 deletions src/webview/handlers/WeeklyReportMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class WeeklyReportMessageHandler {
command: "report",
data: report,
});

console.log("message.data.period", message.data.period);
const formattedPeriod = this.formatPeriod(message.data.period);
console.log("formattedPeriod", formattedPeriod);
notify.info("weeklyReport.generation.success", [formattedPeriod, author]);
Expand All @@ -46,20 +46,17 @@ export class WeeklyReportMessageHandler {
}
}

private formatPeriod(period: string): string {
const now = new Date();
const weeks = parseInt(period);
const pastDate = new Date(now.setDate(now.getDate() - weeks * 7));

const formatDate = (date: Date) => {
private formatPeriod(period: { startDate: string; endDate: string }): string {
const formatDate = (dateStr: string) => {
const date = new Date(dateStr);
const yyyy = date.getFullYear();
const mm = String(date.getMonth() + 1).padStart(2, "0");
const dd = String(date.getDate()).padStart(2, "0");
return `${yyyy} ${mm} ${dd}`;
};

const endDate = formatDate(new Date());
const startDate = formatDate(pastDate);
const startDate = formatDate(period.startDate);
const endDate = formatDate(period.endDate);
return `${startDate} - ${endDate}`;
}
}

0 comments on commit efebbe3

Please sign in to comment.