mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🚸 处理图片以加快加载速度
This commit is contained in:
@@ -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`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<T>(
|
||||
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) {
|
||||
|
||||
@@ -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<void>} 无返回值
|
||||
*/
|
||||
async Debug(message: string, write: boolean = true): Promise<void> {
|
||||
if (write) await debug(message);
|
||||
console.debug(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 输出日志-信息
|
||||
* @since Beta v0.4.2
|
||||
|
||||
Reference in New Issue
Block a user