feat: 完善安装部署与数字溯源码
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import { Controller, Get, Param, Req, Res } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Request, Response } from 'express';
|
||||
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { Public } from '../common/decorators/public.decorator';
|
||||
import { extractIp } from '../common/utils/ua.util';
|
||||
import { PublicTraceService } from './public-trace.service';
|
||||
import { SettingsService } from '../settings/settings.service';
|
||||
|
||||
@ApiTags('公开溯源')
|
||||
@Controller()
|
||||
export class PublicTraceController {
|
||||
constructor(
|
||||
private readonly service: PublicTraceService,
|
||||
private readonly config: ConfigService,
|
||||
private readonly settings: SettingsService,
|
||||
) {}
|
||||
|
||||
@Public()
|
||||
@@ -26,10 +26,8 @@ export class PublicTraceController {
|
||||
// 短链跳转:扫码打开 /t/:shortCode -> 重定向到 C 端溯源页(不在 /api 前缀下)
|
||||
@Public()
|
||||
@Get('t/:shortCode')
|
||||
redirect(@Param('shortCode') shortCode: string, @Res() res: Response) {
|
||||
const template =
|
||||
this.config.get<string>('traceUrlTemplate') ||
|
||||
'http://localhost:5174/#/pages/trace/index?code={code}';
|
||||
res.redirect(302, template.replace('{code}', encodeURIComponent(shortCode)));
|
||||
async redirect(@Param('shortCode') shortCode: string, @Res() res: Response) {
|
||||
const clientBaseUrl = await this.settings.getClientBaseUrl();
|
||||
res.redirect(302, `${clientBaseUrl}/#/trace/${encodeURIComponent(shortCode)}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user