🚸 支持配置图像质量

This commit is contained in:
目棃
2025-01-10 17:41:08 +08:00
parent aba87dfac0
commit 63b7f685c1
9 changed files with 156 additions and 64 deletions

View File

@@ -1,7 +1,7 @@
/**
* @file store/modules/app.ts
* @description App store module
* @since Beta v0.6.4
* @since Beta v0.6.8
*/
import { path } from "@tauri-apps/api";
@@ -59,6 +59,8 @@ export const useAppStore = defineStore(
const needResize = ref<string>("true");
// 分享图生成默认设置为0表示默认保存到文件为数字表示当大小超过xMB时保存到文件否则保存到剪贴板
const shareDefaultFile = ref<number>(10);
// 图像压缩质量
const imageQualityPercent = ref<number>(80);
// 初始化
function init(): void {
@@ -72,6 +74,7 @@ export const useAppStore = defineStore(
needResize.value = "true";
gameDir.value = "未设置";
shareDefaultFile.value = 10;
imageQualityPercent.value = 10;
initDevice();
}
@@ -84,6 +87,11 @@ export const useAppStore = defineStore(
deviceInfo.value = getInitDeviceInfo();
}
function getImageUrl(url: string): string {
if (url.endsWith(".gif")) return url;
return `${url}?x-oss-process=image/format,jpg/quality,Q_${imageQualityPercent.value}`;
}
return {
theme,
buildTime,
@@ -100,8 +108,10 @@ export const useAppStore = defineStore(
needResize,
gameDir,
shareDefaultFile,
imageQualityPercent,
init,
changeTheme,
getImageUrl,
};
},
{
@@ -114,7 +124,15 @@ export const useAppStore = defineStore(
{
key: "app",
storage: window.localStorage,
pick: ["devMode", "loading", "buildTime", "isLogin", "needResize", "shareDefaultFile"],
pick: [
"devMode",
"loading",
"buildTime",
"isLogin",
"needResize",
"shareDefaultFile",
"imageQualityPercent",
],
},
{
key: "sidebar",