build & pm2 start
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getLinkDetailsById } from '@/app/api/links/service';
|
||||
|
||||
// 正确的Next.js 15 API路由处理函数参数类型定义
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
context: { params: { linkId: string } }
|
||||
context: { params: Promise<any> }
|
||||
) {
|
||||
try {
|
||||
// 获取参数,支持异步格式
|
||||
const params = await context.params;
|
||||
const linkId = params.linkId;
|
||||
const link = await getLinkDetailsById(linkId);
|
||||
|
||||
@@ -3,10 +3,12 @@ import { getLinkById } from '../service';
|
||||
|
||||
export async function GET(
|
||||
request: NextRequest,
|
||||
{ params }: { params: { linkId: string } }
|
||||
context: { params: Promise<any> }
|
||||
) {
|
||||
try {
|
||||
const { linkId } = params;
|
||||
// 获取参数,支持异步格式
|
||||
const params = await context.params;
|
||||
const linkId = params.linkId;
|
||||
const link = await getLinkById(linkId);
|
||||
|
||||
if (!link) {
|
||||
@@ -18,9 +20,9 @@ export async function GET(
|
||||
|
||||
return NextResponse.json(link);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch link details:', error);
|
||||
console.error('Failed to fetch link:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to fetch link details', message: (error as Error).message },
|
||||
{ error: 'Failed to fetch link', message: (error as Error).message },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,9 @@ export default function LinkDetailsCard({ linkId, onClose }: LinkDetailsCardProp
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<p className="text-2xl font-bold text-foreground">{linkDetails.visits.toLocaleString()}</p>
|
||||
<p className="text-2xl font-bold text-foreground">
|
||||
{linkDetails?.visits !== undefined ? linkDetails.visits.toLocaleString() : '0'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -254,7 +256,9 @@ export default function LinkDetailsCard({ linkId, onClose }: LinkDetailsCardProp
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<p className="text-2xl font-bold text-foreground">{linkDetails.uniqueVisitors.toLocaleString()}</p>
|
||||
<p className="text-2xl font-bold text-foreground">
|
||||
{linkDetails?.uniqueVisitors !== undefined ? linkDetails.uniqueVisitors.toLocaleString() : '0'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -281,7 +285,9 @@ export default function LinkDetailsCard({ linkId, onClose }: LinkDetailsCardProp
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<p className="text-2xl font-bold text-foreground">{linkDetails.avgTime}</p>
|
||||
<p className="text-2xl font-bold text-foreground">
|
||||
{linkDetails?.avgTime || '0s'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -308,7 +314,9 @@ export default function LinkDetailsCard({ linkId, onClose }: LinkDetailsCardProp
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<p className="text-2xl font-bold text-foreground">{linkDetails.conversionRate}%</p>
|
||||
<p className="text-2xl font-bold text-foreground">
|
||||
{linkDetails?.conversionRate !== undefined ? `${linkDetails.conversionRate}%` : '0%'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user