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
18 changes: 18 additions & 0 deletions plugins/todos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 1.4.0 - 2026-11-26

### Added

- 支持两层嵌套任务:主任务下可添加若干子任务,子任务就是普通任务——可单独排期(拖到日历某天)、拖拽完成 / 删除、双击编辑、点击跳转;池里嵌套展示,主任务行右侧按情况显示「添加子任务」或「展开 / 收起」,展开后列表底部为「+ 子任务」,主任务行同时显示进度(如 `2/3`)
- 设置中新增「任务颜色」选项:按完成状态取色(青绿未完成 / 红逾期 / 灰已完成,一眼看出进度)或按任务配色(每条任务一个颜色,便于在多任务间总览),选择随快照保存、重启后保留

### Changed

- 任务左侧色条默认改为按任务配色(上一版固定为中优先级橙色,而优先级没有编辑入口,新建任务全是同色);可在设置里切回按完成状态取色,优先级信息仍保留在悬停提示中
- 日历排期里不再隐藏已完成任务:留在当天、置灰并排在未完成任务之后,方便回看当天完成了什么
- 已完成任务统一归入「已完成」分组,不再重复出现在今天 / 本周 / 未安排列表
- 删除语义按拖拽来源区分:从待办池拖到右下删除整条任务;从日历某一天拖出时只移除当天安排,不再跨天删除整条任务
- 拖拽操作区的图标按语义区分:已完成任务右上为蓝色「取消完成」,日历来源右下为琥珀色「移除当天」,底部图例同步提示
- 拖拽操作区整体缩小到原来的 60%,图标、阴影与命中区域同步缩放
- 仅待办池布局下隐藏头部无意义的周 / 月视图切换
- `Ctrl/Cmd+Enter` 改为两步:任务输入框未聚焦时先聚焦并把光标放到末尾,已聚焦时提交任务;设置 / 操作指引弹层打开时不抢焦点

## 1.3.0 - 2026-11-24

### Added
Expand Down
2 changes: 1 addition & 1 deletion plugins/todos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

### 周视图
![img.png](docs/img.png)
### 日历视图
### 仅待办视图
![img_1.png](docs/img_1.png)

## 快速开始
Expand Down
Binary file modified plugins/todos/docs/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plugins/todos/docs/img_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions plugins/todos/docs/superpowers/specs/2026-11-24-ui-polish.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
- 低优先级:绿色
- 色条增加 `role="img"` 和“优先级:高/中/低”标签

> 2026-11-26 回退:优先级目前没有编辑入口,新建任务固定为「中」,色条于是全部变成橙色,丢掉了「一条任务一个颜色」的辨识度。现在改为设置项:「按完成状态」用青绿 / 红 / 灰区分钟未完成、逾期、已完成;「按任务配色」按任务 ID 稳定取色。两种模式都能跨重启保留,优先级信息仍保留在色条的 `title` / `aria-label` 中。

### 4. 月视图任务不可读

月视图单元格宽度有限,任务徽章保留完整 border/padding,标题只剩一两个字;超过 3 个任务时也没有稳定的溢出提示。
Expand Down
2 changes: 1 addition & 1 deletion plugins/todos/public/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "高颜值、快捷高效的待办事项管理工具,支持日历视图与拖拽操作",
"homepage": "https://github.com/Code-Agitator/ztools-todos",
"author": "Agitator",
"version": "1.3.0",
"version": "1.4.0",
"main": "index.html",
"preload": "preload/services.js",
"logo": "logo.svg",
Expand Down
9 changes: 9 additions & 0 deletions plugins/todos/src/components/BottomLegend.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,19 @@
color: var(--color-success);
}

/* 拖拽已完成任务 / 从日历拖出时的语义变体,与操作区配色保持一致 */
.legend-icon.complete.undo {
color: var(--color-info);
}

.legend-icon.delete {
color: var(--color-danger);
}

.legend-icon.delete.unschedule {
color: var(--color-warning);
}

.legend-icon.edit {
color: var(--teal);
}
Expand Down
13 changes: 13 additions & 0 deletions plugins/todos/src/components/BottomLegend.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ describe('BottomLegend', () => {
expect(screen.getByText('快捷键')).toBeInTheDocument();
});

it('shows the drag variants while dragging a completed or calendar task', () => {
render(
<BottomLegend
onShowShortcuts={() => {}}
dragHint={{ complete: 'undo', remove: 'unschedule' }}
/>
);
expect(screen.getByText('右上 取消完成')).toBeInTheDocument();
expect(screen.getByText('右下 移除当天')).toBeInTheDocument();
expect(screen.queryByText('右上 完成')).not.toBeInTheDocument();
expect(screen.queryByText('右下 删除')).not.toBeInTheDocument();
});

it('calls onShowShortcuts when shortcut button is clicked', () => {
const onShowShortcuts = jest.fn();
render(<BottomLegend onShowShortcuts={onShowShortcuts} />);
Expand Down
28 changes: 20 additions & 8 deletions plugins/todos/src/components/BottomLegend.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
import React from 'react';
import { ArrowRight, Check, Pencil, Trash2 } from 'lucide-react';
import { ArrowRight, CalendarMinus, Check, Pencil, Trash2, Undo2 } from 'lucide-react';
import './BottomLegend.css';

interface BottomLegendProps {
onShowShortcuts: () => void;
/** 拖拽中时扇形的实际语义,用来提示「取消完成 / 移除当天」这类变体 */
dragHint?: {
complete: 'complete' | 'undo';
remove: 'delete' | 'unschedule';
};
}

export function BottomLegend({ onShowShortcuts }: BottomLegendProps) {
export function BottomLegend({ onShowShortcuts, dragHint }: BottomLegendProps) {
const completeIsUndo = dragHint?.complete === 'undo';
const removeIsUnschedule = dragHint?.remove === 'unschedule';

return (
<div className="bottom-legend">
<div className="legend-item">
<span className="legend-icon complete">
<Check size={10} strokeWidth={2.5} />
<span className={`legend-icon complete ${completeIsUndo ? 'undo' : ''}`}>
{completeIsUndo
? <Undo2 size={10} strokeWidth={2.5} />
: <Check size={10} strokeWidth={2.5} />}
</span>
<span>右上 完成</span>
<span>{completeIsUndo ? '右上 取消完成' : '右上 完成'}</span>
</div>
<div className="legend-item">
<span className="legend-icon delete">
<Trash2 size={10} strokeWidth={2.5} />
<span className={`legend-icon delete ${removeIsUnschedule ? 'unschedule' : ''}`}>
{removeIsUnschedule
? <CalendarMinus size={10} strokeWidth={2.5} />
: <Trash2 size={10} strokeWidth={2.5} />}
</span>
<span>右下 删除</span>
<span>{removeIsUnschedule ? '右下 移除当天' : '右下 删除'}</span>
</div>
<div className="legend-item">
<span className="legend-icon edit">
Expand Down
2 changes: 2 additions & 0 deletions plugins/todos/src/components/Calendar/Calendar.css
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@
opacity: 0.5;
text-decoration: line-through;
color: var(--graphite);
/* 已完成任务留在排期里,但整体去色,避免和未完成任务抢注意力 */
filter: grayscale(1);
}

.task-chip.ghost {
Expand Down
5 changes: 3 additions & 2 deletions plugins/todos/src/components/Calendar/DayCell.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { DayCell } from './DayCell';
import { Task } from '../../types';
import { getTaskColor } from '../../utils/colorUtils';

const createMockTask = (overrides: Partial<Task> = {}): Task => ({
id: '1',
Expand Down Expand Up @@ -134,7 +135,7 @@ describe('DayCell', () => {
expect(container.querySelector('.cell-more')).toBeNull();
});

it('uses the task priority color for the chip indicator', () => {
it('uses the auto-assigned task color for the chip indicator', () => {
const tasks = [
createMockTask({ id: '1', title: 'Task 1', priority: 'high' }),
];
Expand All @@ -149,7 +150,7 @@ describe('DayCell', () => {
/>
);
const chip = container.querySelector('.task-chip') as HTMLElement;
expect(chip.style.getPropertyValue('--task-color')).toBe('#DC2626');
expect(chip.style.getPropertyValue('--task-color')).toBe(getTaskColor(tasks[0]));
expect(container.querySelector('.priority-bar')).toHaveAttribute('aria-label', '优先级:高');
});

Expand Down
31 changes: 31 additions & 0 deletions plugins/todos/src/components/Calendar/MonthView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { MonthView } from './MonthView';
import { AppProvider } from '../../context/AppContext';
import { useAppContext } from '../../context/AppContext';
import { loadData } from '../../utils/storageUtils';
import { formatDate } from '../../utils/dateUtils';
import { DEFAULT_WORKSPACE_CONFIGS } from '../../constants/colorSchemes';

jest.mock('../../utils/storageUtils', () => ({
loadData: jest.fn(),
Expand Down Expand Up @@ -38,6 +40,35 @@ describe('MonthView', () => {
mockedLoadData.mockReturnValue(null);
});

it('keeps completed tasks in the day cell and puts them last', () => {
const today = formatDate(new Date());
mockedLoadData.mockReturnValue({
version: '1.0.0',
workspaces: {
work: [
{ id: 'done-1', title: '做完的', priority: 'medium', dates: [today], status: 'done', createdAt: today, updatedAt: today },
{ id: 'todo-1', title: '没做完的', priority: 'medium', dates: [today], status: 'todo', createdAt: today, updatedAt: today },
],
life: [],
study: [],
},
currentWorkspace: 'work',
workspaceConfigs: DEFAULT_WORKSPACE_CONFIGS,
viewMode: 'month',
layoutMode: 'split',
taskViewMode: 'tag',
taskColorMode: 'random',
currentDate: today,
});

const { container } = render(<MonthView />, { wrapper });
const cell = container.querySelector(`.day-cell[data-date="${today}"]`)!;
const titles = Array.from(cell.querySelectorAll('.chip-title')).map(el => el.textContent);

expect(titles).toEqual(['没做完的', '做完的']);
expect(cell.querySelector('.task-chip.done')).toBeInTheDocument();
});

it('renders month header with week days', () => {
render(<MonthView />, { wrapper });
expect(screen.getByText('周一')).toBeInTheDocument();
Expand Down
5 changes: 4 additions & 1 deletion plugins/todos/src/components/Calendar/MonthView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTasks } from '../../hooks/useTasks';
import { useAppContext } from '../../context/AppContext';
import { DayCell } from './DayCell';
import { isToday, getWeekStart, formatDate } from '../../utils/dateUtils';
import { sortTasksByCompletion } from '../../utils/taskUtils';
import { COLOR_SCHEMES } from '../../constants/colorSchemes';

interface MonthViewProps {
Expand Down Expand Up @@ -35,6 +36,7 @@ export function MonthView({ hoveredTaskId, onHoverTask, onSelectTask, onDateClic
const [hoveredDate, setHoveredDate] = useState<string | null>(null);

const monthDays = getCurrentMonth();
// 子任务也是可排期的完整任务,和主任务一样按自己的日期出现在排期里
const tasks = getCurrentTasks();

const handleDrop = (date: string, e: React.DragEvent) => {
Expand Down Expand Up @@ -96,7 +98,8 @@ export function MonthView({ hoveredTaskId, onHoverTask, onSelectTask, onDateClic
</div>
<div className="month-grid">
{monthDays.map(({ date, isCurrentMonth }) => {
const dayTasks = tasks.filter(t => t.dates.includes(date) && t.status !== 'done');
// 已完成的任务保留在当天,但置灰并排到最后
const dayTasks = sortTasksByCompletion(tasks.filter(t => t.dates.includes(date)));
const isHoveredWeek = hoveredDate ? isSameWeek(date, hoveredDate) : false;
return (
<DayCell
Expand Down
59 changes: 59 additions & 0 deletions plugins/todos/src/components/Calendar/WeekView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { WeekView } from './WeekView';
import { AppProvider } from '../../context/AppContext';
import { useAppContext } from '../../context/AppContext';
import { loadData } from '../../utils/storageUtils';
import { formatDate, getWeekStart } from '../../utils/dateUtils';
import { DEFAULT_WORKSPACE_CONFIGS } from '../../constants/colorSchemes';

jest.mock('../../utils/storageUtils', () => ({
loadData: jest.fn(),
Expand Down Expand Up @@ -61,6 +63,63 @@ describe('WeekView', () => {
mockedLoadData.mockReturnValue(null);
});

it('schedules subtasks on their own dates like normal tasks', () => {
const today = formatDate(getWeekStart(new Date()));
mockedLoadData.mockReturnValue({
version: '1.0.0',
workspaces: {
work: [
{ id: 'parent-1', title: '主任务', priority: 'medium', dates: [today], status: 'todo', createdAt: today, updatedAt: today },
{ id: 'sub-1', title: '子任务', priority: 'medium', dates: [today], status: 'todo', createdAt: today, updatedAt: today, parentId: 'parent-1' },
],
life: [],
study: [],
},
currentWorkspace: 'work',
workspaceConfigs: DEFAULT_WORKSPACE_CONFIGS,
viewMode: 'week',
layoutMode: 'split',
taskViewMode: 'tag',
taskColorMode: 'random',
currentDate: today,
});

const { container } = render(<WeekView />, { wrapper });
const row = container.querySelector(`.day-row[data-date="${today}"]`)!;
const titles = Array.from(row.querySelectorAll('.chip-title')).map(el => el.textContent);

expect(titles).toEqual(['主任务', '子任务']);
});

it('keeps completed tasks in the day row and puts them last', () => {
const today = formatDate(getWeekStart(new Date()));
mockedLoadData.mockReturnValue({
version: '1.0.0',
workspaces: {
work: [
{ id: 'done-1', title: '做完的', priority: 'medium', dates: [today], status: 'done', createdAt: today, updatedAt: today },
{ id: 'todo-1', title: '没做完的', priority: 'medium', dates: [today], status: 'todo', createdAt: today, updatedAt: today },
],
life: [],
study: [],
},
currentWorkspace: 'work',
workspaceConfigs: DEFAULT_WORKSPACE_CONFIGS,
viewMode: 'week',
layoutMode: 'split',
taskViewMode: 'tag',
taskColorMode: 'random',
currentDate: today,
});

const { container } = render(<WeekView />, { wrapper });
const row = container.querySelector(`.day-row[data-date="${today}"]`)!;
const titles = Array.from(row.querySelectorAll('.chip-title')).map(el => el.textContent);

expect(titles).toEqual(['没做完的', '做完的']);
expect(row.querySelector('.task-chip.done')).toBeInTheDocument();
});

it('renders 7 day rows', () => {
const { container } = render(<WeekView />, { wrapper });
const dayRows = container.querySelectorAll('.day-row');
Expand Down
5 changes: 4 additions & 1 deletion plugins/todos/src/components/Calendar/WeekView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useTasks } from '../../hooks/useTasks';
import { useAppContext } from '../../context/AppContext';
import { DayRow } from './DayRow';
import { isToday } from '../../utils/dateUtils';
import { sortTasksByCompletion } from '../../utils/taskUtils';
import { COLOR_SCHEMES } from '../../constants/colorSchemes';

interface WeekViewProps {
Expand All @@ -25,6 +26,7 @@ export function WeekView({ hoveredTaskId, onHoverTask, onSelectTask }: WeekViewP
const { getCurrentTasks, addDateToTask, removeDateFromTask, completeTask } = useTasks();

const weekDays = getCurrentWeek();
// 子任务也是可排期的完整任务,和主任务一样按自己的日期出现在排期里
const tasks = getCurrentTasks();

const accentColor = useMemo(() => {
Expand Down Expand Up @@ -73,7 +75,8 @@ export function WeekView({ hoveredTaskId, onHoverTask, onSelectTask }: WeekViewP
return (
<div className="week-view">
{weekDays.map(dayDate => {
const dayTasks = tasks.filter(t => t.dates.includes(dayDate) && t.status !== 'done');
// 已完成的任务保留在当天,但置灰并排到最后
const dayTasks = sortTasksByCompletion(tasks.filter(t => t.dates.includes(dayDate)));
return (
<DayRow
key={dayDate}
Expand Down
26 changes: 25 additions & 1 deletion plugins/todos/src/components/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { useEffect } from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import { Header } from './Header';
import { AppProvider } from '../context/AppContext';
import { AppProvider, useAppContext } from '../context/AppContext';

const renderWithProvider = (ui: React.ReactElement) => {
return render(<AppProvider>{ui}</AppProvider>);
};

function LayoutModeSetter({ mode }: { mode: 'split' | 'pool-only' }) {
const { dispatch } = useAppContext();

useEffect(() => {
dispatch({ type: 'SET_LAYOUT_MODE', payload: { layoutMode: mode } });
}, [dispatch, mode]);

return null;
}

describe('Header', () => {
it('renders logo', () => {
renderWithProvider(<Header />);
Expand All @@ -25,6 +36,19 @@ describe('Header', () => {
expect(container.querySelector('.view-btn')).toBeInTheDocument();
});

it('hides the week / month toggle in pool-only layout', () => {
const { container } = render(
<AppProvider>
<LayoutModeSetter mode="pool-only" />
<Header />
</AppProvider>
);

expect(container.querySelector('.view-toggle')).toBeNull();
expect(screen.queryByRole('button', { name: '周' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '月' })).not.toBeInTheDocument();
});

it('renders with correct container class', () => {
const { container } = renderWithProvider(<Header />);
expect(container.querySelector('.header')).toBeInTheDocument();
Expand Down
Loading
Loading