import { WallpaperService } from '../services/WallpaperService';
export class WallpaperController {
private wallpaperService: WallpaperService;
constructor(wallpaperService: WallpaperService) {
this.wallpaperService = wallpaperService;
}
async getRandomWallpaper(resolution: string = '1920x1080', market: string = 'zh-CN'): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
try {
const wallpaperInfo = await this.wallpaperService.getRandomWallpaper(resolution, market);
return {
content: [
{
type: 'text' as const,
text: JSON.stringify(wallpaperInfo, null, 2),
},
],
};
} catch (error) {
return {
content: [
{
type: 'text',
text: `获取壁纸时出错: ${error instanceof Error ? error.message : '未知错误'}`,
},
],
};
}
}
}