mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 03:27:43 +01:00
refactor: upgrade tauri-plugin-fs-pro version and optimize code (#383)
* refactor: upgrade `tauri-plugin-fs-pro` version and optimize code * style: delete useless tunes
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
"remark-breaks": "^4.0.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"remark-math": "^6.0.0",
|
||||
"tauri-plugin-fs-pro-api": "2.3.1",
|
||||
"tauri-plugin-fs-pro-api": "^2.4.0",
|
||||
"tauri-plugin-macos-permissions-api": "^2.2.0",
|
||||
"tauri-plugin-screenshots-api": "^2.1.0",
|
||||
"tauri-plugin-windows-version-api": "^2.0.0",
|
||||
|
||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -126,8 +126,8 @@ importers:
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0
|
||||
tauri-plugin-fs-pro-api:
|
||||
specifier: ^2.3.1
|
||||
version: 2.3.1
|
||||
specifier: ^2.4.0
|
||||
version: 2.4.0
|
||||
tauri-plugin-macos-permissions-api:
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
@@ -3308,8 +3308,8 @@ packages:
|
||||
engines: {node: '>=14.0.0'}
|
||||
hasBin: true
|
||||
|
||||
tauri-plugin-fs-pro-api@2.3.1:
|
||||
resolution: {integrity: sha512-fx/zITX9MWoDZ603FKWSybluZqJUEOvHU+H6kj3iRJNyoGFHoNkajpQbiK5cu81spQbGBlP9sV2HkaCI07gQ+Q==}
|
||||
tauri-plugin-fs-pro-api@2.4.0:
|
||||
resolution: {integrity: sha512-SfXMQC3SClaHCzEfrQOeSgQvx+YrlfQQpbbtj1U9LJhRjhwpIsC71UqtzcI2J7aJTt5njD+7Oe8daa3mH0Eybg==}
|
||||
|
||||
tauri-plugin-macos-permissions-api@2.2.0:
|
||||
resolution: {integrity: sha512-pgcBqtUMucSColUJ/HcLOBOr+Z+sma2o0nAuobG1uSGBwFJXwltGKE4XsYynktzfzyTpha/xwta2eLezH+EqLg==}
|
||||
@@ -7007,7 +7007,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- ts-node
|
||||
|
||||
tauri-plugin-fs-pro-api@2.3.1:
|
||||
tauri-plugin-fs-pro-api@2.4.0:
|
||||
dependencies:
|
||||
'@tauri-apps/api': 2.4.0
|
||||
|
||||
|
||||
76
src-tauri/Cargo.lock
generated
76
src-tauri/Cargo.lock
generated
@@ -1573,7 +1573,7 @@ version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
|
||||
dependencies = [
|
||||
"memoffset 0.9.1",
|
||||
"memoffset",
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
@@ -3217,15 +3217,6 @@ version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.1"
|
||||
@@ -3370,19 +3361,6 @@ version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.26.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"memoffset 0.7.1",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.29.0"
|
||||
@@ -3393,7 +3371,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
"memoffset 0.9.1",
|
||||
"memoffset",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4878,28 +4856,6 @@ dependencies = [
|
||||
"trim-in-place",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustbus"
|
||||
version = "0.19.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4054c51e241d0c6d57fab9fecda2223b7bdc7621be67f0d70568d94a6762f281"
|
||||
dependencies = [
|
||||
"nix 0.26.4",
|
||||
"rustbus_derive",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustbus_derive"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8dcb6a55a8a297bb62066b114624aac082ac1a330d90a0d5b336645208e29ae2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
@@ -5323,18 +5279,6 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "showfile"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "517f72ec91adba6aa0f0d680c0a685a171f30ae4a9a402e955f427ab6a29cdf4"
|
||||
dependencies = [
|
||||
"objc",
|
||||
"rustbus",
|
||||
"urlencoding",
|
||||
"windows 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.2"
|
||||
@@ -5919,17 +5863,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-fs-pro"
|
||||
version = "2.3.1"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88311267fcdd4221e1b86c8aedf4f8e33ea0ea33e28718624fe2bc7405935a84"
|
||||
checksum = "4be88c01baab2a859bae736f55ecd3f6a5aa548c8a1f15758644e31cd6a5eaf9"
|
||||
dependencies = [
|
||||
"file_icon_provider",
|
||||
"flate2",
|
||||
"fs_extra",
|
||||
"image",
|
||||
"open",
|
||||
"serde",
|
||||
"showfile",
|
||||
"tar",
|
||||
"tauri",
|
||||
"tauri-plugin",
|
||||
@@ -6715,7 +6657,7 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9"
|
||||
dependencies = [
|
||||
"memoffset 0.9.1",
|
||||
"memoffset",
|
||||
"tempfile",
|
||||
"winapi",
|
||||
]
|
||||
@@ -6797,12 +6739,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||
|
||||
[[package]]
|
||||
name = "urlpattern"
|
||||
version = "0.3.0"
|
||||
@@ -7984,7 +7920,7 @@ dependencies = [
|
||||
"futures-core",
|
||||
"futures-lite",
|
||||
"hex",
|
||||
"nix 0.29.0",
|
||||
"nix",
|
||||
"ordered-stream",
|
||||
"serde",
|
||||
"serde_repr",
|
||||
|
||||
@@ -41,7 +41,7 @@ tauri-plugin-updater = "2"
|
||||
tauri-plugin-process = "2"
|
||||
tauri-plugin-drag = "2"
|
||||
tauri-plugin-macos-permissions = "2"
|
||||
tauri-plugin-fs-pro = "=2.3.1"
|
||||
tauri-plugin-fs-pro = "2"
|
||||
tauri-plugin-screenshots = "2"
|
||||
applications = { git = "https://github.com/infinilabs/applications-rs", rev = "2345d3b86b711b03aa9aee6920e0108d81a8edb9" }
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use tauri::{AppHandle, Runtime};
|
||||
use tauri_plugin_fs_pro::{icon, name};
|
||||
use tauri_plugin_fs_pro::{icon, metadata, name, IconOptions};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_default_search_paths() -> Vec<String> {
|
||||
@@ -113,12 +113,17 @@ pub async fn list_app_with_metadata_in<R: Runtime>(
|
||||
let icon = if cfg!(target_os = "linux") {
|
||||
app.icon_path.clone().unwrap_or(PathBuf::from(""))
|
||||
} else {
|
||||
icon(app_handle.clone(), app_path.clone(), Some(256))
|
||||
let options = IconOptions {
|
||||
size: Some(256),
|
||||
save_path: None,
|
||||
};
|
||||
|
||||
icon(app_handle.clone(), app_path.clone(), Some(options))
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
};
|
||||
|
||||
let raw_app_metadata = tauri_plugin_fs_pro::metadata(app_path.clone(), None).await?;
|
||||
let raw_app_metadata = metadata(app_path.clone(), None).await?;
|
||||
|
||||
let app_metadata = AppMetadata {
|
||||
name: app_name,
|
||||
@@ -150,7 +155,10 @@ impl ApplicationSearchSource {
|
||||
let application_paths = Trie::new();
|
||||
let mut icons = HashMap::new();
|
||||
|
||||
let default_search_path = get_default_search_paths().into_iter().map(PathBuf::from).collect();
|
||||
let default_search_path = get_default_search_paths()
|
||||
.into_iter()
|
||||
.map(PathBuf::from)
|
||||
.collect();
|
||||
let mut ctx = AppInfoContext::new(default_search_path);
|
||||
ctx.refresh_apps().map_err(|err| err.to_string())?; // must refresh apps before getting them
|
||||
let apps = ctx.get_all_apps();
|
||||
@@ -171,7 +179,12 @@ impl ApplicationSearchSource {
|
||||
let icon = if cfg!(target_os = "linux") {
|
||||
app.icon_path.clone().unwrap_or(PathBuf::from(""))
|
||||
} else {
|
||||
icon(app_handle.clone(), path.clone(), Some(256))
|
||||
let options = IconOptions {
|
||||
size: Some(256),
|
||||
save_path: None,
|
||||
};
|
||||
|
||||
icon(app_handle.clone(), path.clone(), Some(options))
|
||||
.await
|
||||
.map_err(|err| err.to_string())?
|
||||
};
|
||||
@@ -289,4 +302,4 @@ fn read_icon_and_encode(icon_path: &Path) -> Result<String, std::io::Error> {
|
||||
|
||||
// Encode the data to base64
|
||||
Ok(encode(&icon_data))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,6 @@ const Extensions = () => {
|
||||
});
|
||||
}, [activeId, allApps]);
|
||||
|
||||
console.log("currentPlugin", currentPlugin);
|
||||
|
||||
return (
|
||||
<ExtensionsContext.Provider
|
||||
value={{
|
||||
|
||||
@@ -209,7 +209,7 @@ export default function Chat({}: ChatProps) {
|
||||
}, []);
|
||||
|
||||
const getFileIcon = useCallback(async (path: string, size: number) => {
|
||||
return icon(path, size);
|
||||
return icon(path, { size });
|
||||
}, []);
|
||||
|
||||
const handleSearch = (keyword: string) => {
|
||||
|
||||
@@ -48,8 +48,7 @@ export const useChatStore = create<IChatStore>()(
|
||||
{
|
||||
name: "chat-state",
|
||||
// storage: createJSONStorage(() => sessionStorage),
|
||||
partialize: (_state) => ({
|
||||
}),
|
||||
partialize: (_state) => ({}),
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -104,7 +104,7 @@ export const createTauriAdapter = (): TauriPlatformAdapter => {
|
||||
|
||||
async getFileIcon(path, size) {
|
||||
const { icon } = await import("tauri-plugin-fs-pro-api");
|
||||
return icon(path, size);
|
||||
return icon(path, { size });
|
||||
},
|
||||
|
||||
async checkUpdate() {
|
||||
|
||||
Reference in New Issue
Block a user