♻️ 姑且没登录的功能都给试了下

This commit is contained in:
目棃
2024-07-03 17:49:15 +08:00
parent 367307029b
commit 8a2c7d13c6
47 changed files with 1135 additions and 315 deletions

View File

@@ -1,28 +1,35 @@
/**
* @file utils/TGShell.ts
* @description Shell工具
* @since Beta v0.4.4
* @since Beta v0.5.0
*/
import { os, shell } from "@tauri-apps/api";
import { platform } from "@tauri-apps/plugin-os";
import { Command } from "@tauri-apps/plugin-shell";
import showSnackbar from "../components/func/snackbar.js";
/**
* @description Shell工具
* @since Beta v0.4.4
* @since Beta v0.5.0
*/
class TGShell {
/**
* @description 打开文件
* @since Beta v0.4.4
* @since Beta v0.5.0
* @param {string} path - 文件路径
* @returns {Promise<void>} 无返回值
*/
async openPath(path: string): Promise<void> {
const platform = await os.platform();
const plat = platform();
let command: string;
if (platform === "win32") command = "win_open";
else command = "mac_open";
await new shell.Command(command, [path]).execute();
if (plat === "windows") command = "win_open";
else if (plat === "macos") command = "mac_open";
else {
showSnackbar({ text: "暂不支持该平台", color: "warn" });
return;
}
await Command.create(command, [path]).execute();
}
}