Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function App() {
const m = await GetMonitors();
setMonitors(m || []);
} catch (err) {
console.error('Failed to load monitors:', err);
// 静默失败,避免托盘/多显示器不可用时刷屏
}
}, []);

Expand Down Expand Up @@ -305,21 +305,16 @@ function App() {
};

const onResetConfirm = async (onlySettings: boolean) => {
console.log("Reset confirmed, onlySettings:", onlySettings);
setIsResetDialogOpen(false);
const tid = toast.loading(onlySettings ? '正在重置应用配置...' : '正在重置应用并清理数据...');
try {
if (onlySettings) {
console.log("Calling ResetSettings...");
await ResetSettings();
} else {
console.log("Calling ResetApplication...");
await ResetApplication();
}
console.log("Reset success");
toast.success(onlySettings ? '应用配置已恢复默认' : '应用数据已清空,配置已恢复默认', { id: tid });
setIsSettingsOpen(false);
// Refresh local state
await loadConfig();
if (!onlySettings) {
await loadHistory();
Expand All @@ -328,7 +323,6 @@ function App() {
fetchToday(true);
}
} catch (err) {
console.error("Reset error:", err);
toast.error('重置失败: ' + err, { id: tid });
}
};
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/HistoryDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function HistoryDrawer({
onDeleteHistory,
onClearHistory
}: HistoryDrawerProps) {
// Sort history by date descending to ensure newest is always first
const sortedHistory = [...history].sort((a, b) => b.date.localeCompare(a.date));
// 后端 ListHistory 已按 CreatedAt 降序返回,直接使用;若需严格按日期展示可在此再排序
const displayHistory = history;

return (
<Drawer shouldScaleBackground={false}>
Expand All @@ -47,7 +47,7 @@ export function HistoryDrawer({
</DrawerHeader>
<div className="flex-1 min-h-0 overflow-y-auto">
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 p-4 pb-12">
{sortedHistory.map((item) => (
{displayHistory.map((item) => (
<HistoryItemCard
key={item.key}
item={item}
Expand All @@ -56,7 +56,7 @@ export function HistoryDrawer({
onDelete={() => onDeleteHistory(item.key)}
/>
))}
{sortedHistory.length === 0 && (
{displayHistory.length === 0 && (
<div className="col-span-full py-20 text-center text-muted-foreground font-light">
暂无历史记录
</div>
Expand Down
8 changes: 2 additions & 6 deletions frontend/src/lib/watermark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Solar, Lunar, HolidayUtil } from 'lunar-javascript';

export async function renderWatermark(data: any): Promise<string> {
console.log("renderWatermark called with:", { ...data, image_path: data.image_path ? "data:..." : undefined });
const {
image_path, title, date, copyright, variant,
enable_watermark, enable_calendar, holiday_data,
Expand Down Expand Up @@ -50,7 +49,6 @@ export async function renderWatermark(data: any): Promise<string> {

// 2. Draw Calendar if enabled
if (enable_calendar) {
console.log("Drawing calendar...");
drawCalendar(ctx, canvas, date, holiday_data, data.target_ratio);
}

Expand All @@ -77,8 +75,8 @@ function calculateSafeArea(width: number, height: number, targetRatio: number) {
const topY = (height - visibleHeight) / 2;
const bottomY = (height + visibleHeight) / 2;

// 基础边距:可见高度的 5%
const paddingX = visibleWidth * 0.04;
// 基础边距:可见区域的 4%
const paddingX = visibleWidth * 0.04;
const paddingY = visibleHeight * 0.04;

return {
Expand Down Expand Up @@ -204,8 +202,6 @@ function drawCalendar(ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement,
throw new Error(`Invalid date: ${dateStr}`);
}

console.log(`Calendar for: ${year}-${month}-${today}`);

// 日历配置
const safeArea = calculateSafeArea(canvas.width, canvas.height, targetRatio);
const scale = safeArea.visibleHeight / 1080;
Expand Down
Loading