mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🚸 处理图片以加快加载速度
This commit is contained in:
@@ -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