From b5081afb2cadca6101dd6093ae5d854a20ce6a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Wed, 22 Apr 2026 10:19:01 +0800 Subject: [PATCH] 1 --- project.config.json | 2 +- src/services/userService.ts | 2 +- src/utils/genPoster.ts | 7 ++++--- src/utils/share.ts | 7 +++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/project.config.json b/project.config.json index dbb6d57..acbf751 100644 --- a/project.config.json +++ b/project.config.json @@ -57,4 +57,4 @@ "include": [] }, "editorSetting": {} -} \ No newline at end of file +} diff --git a/src/services/userService.ts b/src/services/userService.ts index 6761e8e..37151a9 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -217,7 +217,7 @@ export class UserService { // 处理人数统计 - 兼容不同的字段名 const registered_count = - game.current_players || game.participant_count || 0; + game.participant_count ?? game.current_players ?? 0; const max_count = game.max_players || game.max_participants || 0; // 转换为 ListCard 期望的格式 diff --git a/src/utils/genPoster.ts b/src/utils/genPoster.ts index 1f2339f..7c0b597 100644 --- a/src/utils/genPoster.ts +++ b/src/utils/genPoster.ts @@ -319,8 +319,9 @@ export async function generatePosterImage(data: any): Promise { console.log("start !!!!"); - // const dpr = Taro.getWindowInfo().pixelRatio; - const dpr = 1; + const systemDpr = + Taro.getWindowInfo?.().pixelRatio || Taro.getSystemInfoSync().pixelRatio || 1; + const dpr = Math.min(Math.max(systemDpr, 1), 2); // console.log(dpr, 'dpr') const width = 600; const height = 1000; @@ -487,7 +488,7 @@ export async function generatePosterImage(data: any): Promise { const { tempFilePath } = await Taro.canvasToTempFilePath({ canvas, fileType: 'png', - quality: 0.7, + quality: 1, }); console.log('tempFilePath', tempFilePath) return tempFilePath; diff --git a/src/utils/share.ts b/src/utils/share.ts index 0f6f4f8..1066873 100644 --- a/src/utils/share.ts +++ b/src/utils/share.ts @@ -26,10 +26,9 @@ const designHeight = 400 // 获取屏幕宽度,如果没有传入width则使用屏幕宽度 const windowWidth = Taro.getSystemInfoSync().windowWidth -// 获取 DPR - 使用系统像素比确保高清显示 -// const systemDpr = Taro.getSystemInfoSync().pixelRatio -const dpr = 1 -// Math.min(systemDpr, 3) // 限制最大dpr为3,避免过度放大 +// 获取 DPR - 使用系统像素比确保高清显示,限制上限避免内存占用过高 +const systemDpr = Taro.getSystemInfoSync().pixelRatio || 1 +const dpr = Math.min(Math.max(systemDpr, 1), 2) // 2. 计算缩放比例(设备宽度 / 设计稿宽度) const scale = windowWidth / designWidth