- 优化财务仪表板数据展示 - 增强账户管理功能 - 改进预算和分类管理 - 完善报表和统计分析 - 优化交易管理界面 - 更新Workspace工作区 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
945 B
TypeScript
33 lines
945 B
TypeScript
import { getQuery } from 'h3';
|
|
import { listExchangeRates } from '~/utils/finance-metadata';
|
|
import { useResponseSuccess } from '~/utils/response';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const query = getQuery(event);
|
|
const fromCurrency = query.from as string | undefined;
|
|
const toCurrency = query.to as string | undefined;
|
|
const date = query.date as string | undefined;
|
|
|
|
let rates = listExchangeRates();
|
|
|
|
if (fromCurrency) {
|
|
rates = rates.filter((rate) => rate.fromCurrency === fromCurrency);
|
|
}
|
|
|
|
if (toCurrency) {
|
|
rates = rates.filter((rate) => rate.toCurrency === toCurrency);
|
|
}
|
|
|
|
if (date) {
|
|
rates = rates.filter((rate) => rate.date === date);
|
|
} else if (rates.length > 0) {
|
|
const latestDate = rates.reduce(
|
|
(max, rate) => Math.max(rate.date, max),
|
|
rates[0].date,
|
|
);
|
|
rates = rates.filter((rate) => rate.date === latestDate);
|
|
}
|
|
|
|
return useResponseSuccess(rates);
|
|
});
|