From b7f9d083e70e5bacdcb085544c6e5105e94ed63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Thu, 9 Jan 2025 09:41:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20=E5=A4=84=E7=90=86=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=BB=A5=E5=8A=A0=E5=BF=AB=E5=8A=A0=E8=BD=BD=E9=80=9F?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/app/t-postcard.vue | 3 ++- src/utils/TGHttp.ts | 12 +++++++++--- src/utils/TGLogger.ts | 16 ++++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/components/app/t-postcard.vue b/src/components/app/t-postcard.vue index 14fde786..1dd3be8e 100644 --- a/src/components/app/t-postcard.vue +++ b/src/components/app/t-postcard.vue @@ -142,7 +142,8 @@ function getPostCover(item: TGApp.Plugins.Mys.Post.FullData): string { else if (item.post.images.length > 0) cover = item.post.images[0]; if (cover === undefined) return ""; if (cover.endsWith(".gif")) return cover; - return `${cover}?x-oss-process=image/format,png`; + // 裁剪图片格式为 png,比例为 36:13,进行缩放但是不拉伸 + return `${cover}?x-oss-process=image/resize,m_fill,w_360,h_130,limit_0/format,png`; } /** diff --git a/src/utils/TGHttp.ts b/src/utils/TGHttp.ts index 8cb52f20..f63d8cc9 100644 --- a/src/utils/TGHttp.ts +++ b/src/utils/TGHttp.ts @@ -1,11 +1,13 @@ /** * @file utils/TGHttp.ts * @description 封装HTTP请求 - * @since Beta v0.5.1 + * @since Beta v0.6.8 */ import { fetch } from "@tauri-apps/plugin-http"; +import TGLogger from "@/utils/TGLogger.js"; + /** * @description 请求参数 * @since Beta v0.5.1 @@ -53,8 +55,12 @@ async function TGHttp( const query = new URLSearchParams(options.query).toString(); url += `?${query}`; } - console.log("fetch url: ", url); - console.log("fetch options: ", options); + if (options.isBlob) { + await TGLogger.Debug(`Fetch Image: ${url}`); + } else { + await TGLogger.Debug(`Fetch URL: ${url}`); + await TGLogger.Debug(`Fetch Options: ${JSON.stringify(options)}`); + } return await fetch(url, fetchOptions) .then((res) => { if (res.ok) { diff --git a/src/utils/TGLogger.ts b/src/utils/TGLogger.ts index a592653b..5962efeb 100644 --- a/src/utils/TGLogger.ts +++ b/src/utils/TGLogger.ts @@ -1,10 +1,10 @@ /** * @file utils/TGLogger.ts * @description 日志工具 - * @since Beta v0.5.0 + * @since Beta v0.6.8 */ -import { attachConsole, error, info, warn } from "@tauri-apps/plugin-log"; +import { attachConsole, error, info, warn, debug } from "@tauri-apps/plugin-log"; /** * @description 日志工具 @@ -24,6 +24,18 @@ class Logger { return this.instance; } + /** + * @description 输出日志-调试 + * @since Beta v0.6.8 + * @param {string} message 日志信息 + * @param {boolean} [write] 是否写入日志文件,默认为 true + * @returns {Promise} 无返回值 + */ + async Debug(message: string, write: boolean = true): Promise { + if (write) await debug(message); + console.debug(message); + } + /** * @description 输出日志-信息 * @since Beta v0.4.2