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
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
IMAGE_NAME: ${{ github.repository }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

concurrency:
group: go-tests-${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func run(ctx context.Context) error {
server.Engine().StaticFile("/favicon.ico", "public/favicon.ico")
server.Engine().StaticFile("/robots.txt", "public/robots.txt")
server.Engine().NoRoute(func(c *gin.Context) {
if strings.HasPrefix(c.Request.URL.Path, "/api/") {
if strings.HasPrefix(c.Request.URL.Path, "/api/") || c.Request.URL.Path == "/mcp" {
c.JSON(http.StatusNotFound, gin.H{"ret": 0, "msg": "接口不存在"})
return
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/components/ui/ActivityTimeline.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useNavigate} from 'react-router-dom';
import {Flex, Tag, Timeline, Typography} from 'antd';
import {formatMoney, parseAmount} from '@/lib/formatMoney';
import {formatPartyTime} from '@/lib/formatTime';
import {EmptyState} from './EmptyState';

export type ActivityItem = {
Expand All @@ -11,6 +12,7 @@ export type ActivityItem = {
created_at?: string;
party_id: number;
party_name: string;
timezone?: string;
currency_symbol: string;
type: 'initiated' | 'assigned';
counterparty_name: string;
Expand Down Expand Up @@ -75,7 +77,7 @@ export function ActivityTimeline({items}: ActivityTimelineProps) {
</Typography.Text>
<Typography.Text type="secondary" style={{fontSize: 13}}>
{title} · {it.party_name}
{it.created_at ? ` · ${it.created_at}` : ''}
{it.created_at ? ` · ${formatPartyTime(it.created_at, it.timezone)}` : ''}
</Typography.Text>
</div>
<Flex align="center" gap={8} wrap="wrap">
Expand Down
34 changes: 34 additions & 0 deletions frontend/src/lib/formatTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const DEFAULT_TZ = 'Asia/Shanghai';

function part(parts: Intl.DateTimeFormatPart[], type: Intl.DateTimeFormatPartTypes): string {
return parts.find((p) => p.type === type)?.value ?? '';
}

export function formatPartyTime(value?: string | null, timezone?: string | null): string {
if (!value) return '';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return value;

const zones = [timezone?.trim(), DEFAULT_TZ].filter((z): z is string => !!z);
for (const timeZone of zones) {
try {
const parts = new Intl.DateTimeFormat('en-CA', {
timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hourCycle: 'h23',
}).formatToParts(date);
return `${part(parts, 'year')}-${part(parts, 'month')}-${part(parts, 'day')} ${part(parts, 'hour')}:${part(parts, 'minute')}`;
} catch {
// invalid IANA timezone — try fallback
}
}
return value;
}

export function formatLocalTime(value?: string | null): string {
return formatPartyTime(value, Intl.DateTimeFormat().resolvedOptions().timeZone);
}
4 changes: 3 additions & 1 deletion frontend/src/pages/ItemPages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Alert, Badge, Button, message, Popconfirm, Space, Tabs} from 'antd';
import {AccountBookOutlined, DeleteOutlined, PlusOutlined} from '@ant-design/icons';
import {apiDelete, apiJson, apiPostForm} from '@/api/client';
import {formatMoney} from '@/lib/formatMoney';
import {formatPartyTime} from '@/lib/formatTime';
import {EmptyState, EntityCard, LedgerList, PageShell, SectionTitle, SummaryStrip, SurfaceCard,} from '@/components/ui';

type PartyRow = {
Expand Down Expand Up @@ -123,6 +124,7 @@ export function ItemPartyPage() {
const [err, setErr] = useState<string | null>(null);
const [party, setParty] = useState<{
name?: string;
timezone?: string;
currency_symbol?: string;
is_archived?: boolean;
} | null>(null);
Expand Down Expand Up @@ -296,7 +298,7 @@ export function ItemPartyPage() {
return {
id: it.id,
title: it.description || '(无描述)',
meta: `付款方:${it.payer_name} · 发起方:${it.initiator_name}${it.created_at ? ` · ${it.created_at}` : ''}`,
meta: `付款方:${it.payer_name} · 发起方:${it.initiator_name}${it.created_at ? ` · ${formatPartyTime(it.created_at, party?.timezone)}` : ''}`,
amount: formatMoney(sym, it.amount),
paid,
action:
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/PaymentPartyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useParams} from 'react-router-dom';
import {WalletOutlined} from '@ant-design/icons';
import {apiJson} from '@/api/client';
import {formatMoney} from '@/lib/formatMoney';
import {formatPartyTime} from '@/lib/formatTime';
import {EmptyState, LedgerList, PageShell, SectionTitle, SummaryStrip, SurfaceCard} from '@/components/ui';

type Item = { id: number; username: string; description: string; amount: string | number; created_at?: string };
Expand All @@ -12,7 +13,7 @@ export function PaymentPartyPage() {
const partyId = Number(partyIdParam);
const [loading, setLoading] = useState(true);
const [err, setErr] = useState<string | null>(null);
const [party, setParty] = useState<{ name?: string; description?: string; currency_symbol?: string } | null>(null);
const [party, setParty] = useState<{ name?: string; description?: string; timezone?: string; currency_symbol?: string } | null>(null);
const [items, setItems] = useState<Item[]>([]);
const [total, setTotal] = useState('');

Expand Down Expand Up @@ -60,7 +61,7 @@ export function PaymentPartyPage() {
rows={items.map((it) => ({
id: it.id,
title: it.description || '(无描述)',
meta: `发起方:${it.username}${it.created_at ? ` · ${it.created_at}` : ''}`,
meta: `发起方:${it.username}${it.created_at ? ` · ${formatPartyTime(it.created_at, party?.timezone)}` : ''}`,
amount: formatMoney(sym, it.amount),
}))}
empty={<EmptyState description="无待付条目"/>}
Expand Down
Loading
Loading