mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
🎨 完善 dialog.open/save 配置
This commit is contained in:
@@ -195,23 +195,28 @@ async function handleImportBtn(savePath?: string): Promise<void> {
|
|||||||
if (savePath) {
|
if (savePath) {
|
||||||
selectedFile = await dialog.open({
|
selectedFile = await dialog.open({
|
||||||
multiple: false,
|
multiple: false,
|
||||||
|
title: "选择要导入的祈愿数据文件",
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "UIGF",
|
name: "UIGF JSON",
|
||||||
extensions: ["json"],
|
extensions: ["json"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
defaultPath: savePath,
|
defaultPath: savePath,
|
||||||
|
directory: false,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
selectedFile = await dialog.open({
|
selectedFile = await dialog.open({
|
||||||
multiple: false,
|
multiple: false,
|
||||||
|
title: "选择要导入的祈愿数据文件",
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "UIGF",
|
name: "UIGF JSON",
|
||||||
extensions: ["json"],
|
extensions: ["json"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
defaultPath: `${await path.downloadDir()}`,
|
||||||
|
directory: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (selectedFile) {
|
if (selectedFile) {
|
||||||
@@ -283,13 +288,14 @@ async function handleExportBtn(): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const file = await dialog.save({
|
const file = await dialog.save({
|
||||||
defaultPath: `UIGF_${uidCur.value}.json`,
|
title: "选择导出祈愿数据的文件路径",
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "UIGF",
|
name: "UIGF JSON",
|
||||||
extensions: ["json"],
|
extensions: ["json"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
defaultPath: `${await path.downloadDir()}${path.sep}UIGF${uidCur.value}.json`,
|
||||||
});
|
});
|
||||||
if (!file) {
|
if (!file) {
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
|
|||||||
@@ -279,13 +279,16 @@ async function searchCard(): Promise<void> {
|
|||||||
// 导入 UIAF 数据,进行数据合并、刷新
|
// 导入 UIAF 数据,进行数据合并、刷新
|
||||||
async function importJson(): Promise<void> {
|
async function importJson(): Promise<void> {
|
||||||
const selectedFile = await dialog.open({
|
const selectedFile = await dialog.open({
|
||||||
|
title: "选择 UIAF 数据文件",
|
||||||
multiple: false,
|
multiple: false,
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "JSON",
|
name: "UIAF JSON",
|
||||||
extensions: ["json"],
|
extensions: ["json"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
defaultPath: await path.downloadDir(),
|
||||||
|
directory: false,
|
||||||
});
|
});
|
||||||
if (!selectedFile) {
|
if (!selectedFile) {
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file utils TGShare.ts
|
* @file utils TGShare.ts
|
||||||
* @description 生成分享截图并保存到本地
|
* @description 生成分享截图并保存到本地
|
||||||
* @since Beta v0.3.3
|
* @since Beta v0.3.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { dialog, fs, http, path } from "@tauri-apps/api";
|
import { dialog, fs, http, path } from "@tauri-apps/api";
|
||||||
@@ -11,7 +11,7 @@ import showSnackbar from "../components/func/snackbar";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 保存图片-canvas
|
* @description 保存图片-canvas
|
||||||
* @since Beta v0.3.0
|
* @since Beta v0.3.4
|
||||||
* @param {HTMLCanvasElement} canvas - canvas元素
|
* @param {HTMLCanvasElement} canvas - canvas元素
|
||||||
* @param {string} filename - 文件名
|
* @param {string} filename - 文件名
|
||||||
* @returns {Promise<void>} 无返回值
|
* @returns {Promise<void>} 无返回值
|
||||||
@@ -22,11 +22,11 @@ async function saveCanvasImg(canvas: HTMLCanvasElement, filename: string): Promi
|
|||||||
.split("")
|
.split("")
|
||||||
.map((item) => item.charCodeAt(0)),
|
.map((item) => item.charCodeAt(0)),
|
||||||
);
|
);
|
||||||
const saveDir = await path.downloadDir();
|
|
||||||
await dialog
|
await dialog
|
||||||
.save({
|
.save({
|
||||||
defaultPath: `${saveDir}${filename}.png`,
|
title: "保存图片",
|
||||||
filters: [{ name: "图片", extensions: ["png"] }],
|
filters: [{ name: "图片", extensions: ["png"] }],
|
||||||
|
defaultPath: `${await path.downloadDir()}${path.sep}${filename}.png`,
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res === null) return;
|
if (res === null) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user