🚸 处理图片以加快加载速度

This commit is contained in:
目棃
2025-01-09 09:41:11 +08:00
parent 6744c875b6
commit b7f9d083e7
3 changed files with 25 additions and 6 deletions

View File

@@ -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]; else if (item.post.images.length > 0) cover = item.post.images[0];
if (cover === undefined) return ""; if (cover === undefined) return "";
if (cover.endsWith(".gif")) return cover; 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`;
} }
/** /**

View File

@@ -1,11 +1,13 @@
/** /**
* @file utils/TGHttp.ts * @file utils/TGHttp.ts
* @description 封装HTTP请求 * @description 封装HTTP请求
* @since Beta v0.5.1 * @since Beta v0.6.8
*/ */
import { fetch } from "@tauri-apps/plugin-http"; import { fetch } from "@tauri-apps/plugin-http";
import TGLogger from "@/utils/TGLogger.js";
/** /**
* @description 请求参数 * @description 请求参数
* @since Beta v0.5.1 * @since Beta v0.5.1
@@ -53,8 +55,12 @@ async function TGHttp<T>(
const query = new URLSearchParams(options.query).toString(); const query = new URLSearchParams(options.query).toString();
url += `?${query}`; url += `?${query}`;
} }
console.log("fetch url: ", url); if (options.isBlob) {
console.log("fetch options: ", options); 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) return await fetch(url, fetchOptions)
.then((res) => { .then((res) => {
if (res.ok) { if (res.ok) {

View File

@@ -1,10 +1,10 @@
/** /**
* @file utils/TGLogger.ts * @file utils/TGLogger.ts
* @description 日志工具 * @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 日志工具 * @description 日志工具
@@ -24,6 +24,18 @@ class Logger {
return this.instance; return this.instance;
} }
/**
* @description 输出日志-调试
* @since Beta v0.6.8
* @param {string} message 日志信息
* @param {boolean} [write] 是否写入日志文件,默认为 true
* @returns {Promise<void>} 无返回值
*/
async Debug(message: string, write: boolean = true): Promise<void> {
if (write) await debug(message);
console.debug(message);
}
/** /**
* @description 输出日志-信息 * @description 输出日志-信息
* @since Beta v0.4.2 * @since Beta v0.4.2