From 7751c25e15f01db302b089372821e46487591564 Mon Sep 17 00:00:00 2001 From: heixiansen Date: Mon, 17 Feb 2025 15:10:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E6=A0=87=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +++- composables/icon.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 composables/icon.ts diff --git a/.gitignore b/.gitignore index 0533ab4..f101bc2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ dist .vscode release -src-tauri/easytier/logs \ No newline at end of file +src-tauri/easytier/logs +src-tauri/easytier/tool/ResourcesExtract.exe +src-tauri/easytier/tool/ResourcesExtract.cfg diff --git a/composables/icon.ts b/composables/icon.ts new file mode 100644 index 0000000..8f6442a --- /dev/null +++ b/composables/icon.ts @@ -0,0 +1,34 @@ +import { basename, extname } from "@tauri-apps/api/path"; +import { exists } from "@tauri-apps/plugin-fs"; +import { Command } from "@tauri-apps/plugin-shell"; + +export const getIcon = async function (sourcePath: string, icoDirPath: string) { + if(sourcePath.endsWith(".url")) return false; + let res = await Command.create("ResourcesExtract", [ + "/Source", + sourcePath, + "/DestFolder", + icoDirPath, + "/ExtractIcons", + "1", + "/ExtractCursors", + "0", + "/OpenDestFolder", + "0", + "/MultiFilesMode", + "1" + ]).execute(); + if (res.code == 0) { + let icoPath = icoDirPath + "\\" + (await basename(sourcePath)); + icoPath = icoPath.replace(`.${await extname(sourcePath)}`, "_1.ico"); + console.log(icoPath) + if (await exists(icoPath)) { + return icoPath; + } else { + return false; + } + return; + } else { + return false; + } +};