Forráskód Böngészése

fix: 保留资源目录 hint 并同步 Cargo.lock

get_resource_dir 仍给技能包查找用,不能随 PDFium 一起拆掉。
Cargo.lock 去掉 pdfium-render;清理 source-lifecycle 未使用导入。

Co-authored-by: darknessomi <darknessomi@users.noreply.github.com>
Cursor Agent 1 hónapja
szülő
commit
bfa077e39e

+ 1 - 97
src-tauri/Cargo.lock

@@ -1021,26 +1021,6 @@ dependencies = [
  "crossbeam-utils",
 ]
 
-[[package]]
-name = "console_error_panic_hook"
-version = "0.1.7"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
-dependencies = [
- "cfg-if",
- "wasm-bindgen",
-]
-
-[[package]]
-name = "console_log"
-version = "1.1.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "86919cef3e37b9356ccf54d4421208c17ecfda01beae61393e7ffd72916c0ef1"
-dependencies = [
- "log",
- "web-sys",
-]
-
 [[package]]
 name = "const-random"
 version = "0.1.18"
@@ -3575,15 +3555,6 @@ dependencies = [
  "either",
 ]
 
-[[package]]
-name = "itertools"
-version = "0.15.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"
-dependencies = [
- "either",
-]
-
 [[package]]
 name = "itoa"
 version = "1.0.18"
@@ -4494,7 +4465,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6e9ec52138abedcc58dc17a7c6c0c00a2bdb4f3427c7f63fa97fd0d859155caf"
 dependencies = [
  "gtk-sys",
- "libloading 0.7.4",
+ "libloading",
  "once_cell",
 ]
 
@@ -4523,16 +4494,6 @@ dependencies = [
  "winapi",
 ]
 
-[[package]]
-name = "libloading"
-version = "0.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60"
-dependencies = [
- "cfg-if",
- "windows-link 0.2.1",
-]
-
 [[package]]
 name = "libm"
 version = "0.2.16"
@@ -4703,12 +4664,6 @@ dependencies = [
  "thread-tree",
 ]
 
-[[package]]
-name = "maybe-owned"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4facc753ae494aeb6e3c22f839b158aebd4f9270f55cd3c79906c45476c47ab4"
-
 [[package]]
 name = "md-5"
 version = "0.10.6"
@@ -5454,32 +5409,6 @@ dependencies = [
  "hmac",
 ]
 
-[[package]]
-name = "pdfium-render"
-version = "0.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "826f8f64bc88cb15381cbb5aa245c1500632cd8a453b244bc2b0cbaff7098077"
-dependencies = [
- "bitflags 2.13.1",
- "bytemuck",
- "bytes",
- "chrono",
- "console_error_panic_hook",
- "console_log",
- "image",
- "itertools 0.15.0",
- "js-sys",
- "libloading 0.9.0",
- "log",
- "maybe-owned",
- "once_cell",
- "utf16string",
- "vecmath",
- "wasm-bindgen",
- "wasm-bindgen-futures",
- "web-sys",
-]
-
 [[package]]
 name = "percent-encoding"
 version = "2.3.2"
@@ -5612,12 +5541,6 @@ dependencies = [
  "futures-io",
 ]
 
-[[package]]
-name = "piston-float"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ad78bf43dcf80e8f950c92b84f938a0fc7590b7f6866fbcbeca781609c115590"
-
 [[package]]
 name = "pkg-config"
 version = "0.3.33"
@@ -5885,7 +5808,6 @@ dependencies = [
  "lancedb",
  "md-5",
  "notify",
- "pdfium-render",
  "serde",
  "serde_json",
  "sha2",
@@ -8443,15 +8365,6 @@ dependencies = [
  "url",
 ]
 
-[[package]]
-name = "utf16string"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b62a1e85e12d5d712bf47a85f426b73d303e2d00a90de5f3004df3596e9d216"
-dependencies = [
- "byteorder",
-]
-
 [[package]]
 name = "utf8-ranges"
 version = "1.0.5"
@@ -8482,15 +8395,6 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
 
-[[package]]
-name = "vecmath"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "956ae1e0d85bca567dee1dcf87fb1ca2e792792f66f87dced8381f99cd91156a"
-dependencies = [
- "piston-float",
-]
-
 [[package]]
 name = "version-compare"
 version = "0.2.1"

+ 13 - 0
src-tauri/src/commands/fs.rs

@@ -25,6 +25,19 @@ const LEGACY_KNOWLEDGE_DIR: &str = "wiki";
 const META_DIR: &str = ".qmai";
 const LEGACY_META_DIR: &str = ".llm-wiki";
 
+/// Bundled resource directory, set by the Tauri setup() callback once the
+/// AppHandle is available. Used by `get_resource_dir` so frontend skill
+/// lookup can find `../skills` without re-implementing Tauri's platform
+/// resource-dir logic.
+static RESOURCE_DIR_HINT: std::sync::OnceLock<std::path::PathBuf> =
+    std::sync::OnceLock::new();
+
+/// Called from Tauri's setup() with the resolved resource directory.
+/// No-op if already set.
+pub fn set_resource_dir_hint(dir: std::path::PathBuf) {
+    let _ = RESOURCE_DIR_HINT.set(dir);
+}
+
 #[allow(dead_code)]
 fn replace_last_path_segment(path: &str, from: &str, to: &str) -> Option<String> {
     let mut parts: Vec<&str> = path.split('/').collect();

+ 3 - 0
src-tauri/src/lib.rs

@@ -43,6 +43,9 @@ pub fn run() {
         .plugin(tauri_plugin_updater::Builder::new().build())
         .setup(|app| {
             use tauri::Manager;
+            if let Ok(dir) = app.path().resource_dir() {
+                commands::fs::set_resource_dir_hint(dir);
+            }
             if let Ok(dir) = app.path().app_data_dir() {
                 let store_path = dir.join("app-state.json");
                 eprintln!("[proxy] reading from {}", store_path.display());

+ 3 - 0
src-tauri/src/main.rs

@@ -45,6 +45,9 @@ fn main() {
         .plugin(tauri_plugin_updater::Builder::new().build())
         .setup(|app| {
             use tauri::Manager;
+            if let Ok(dir) = app.path().resource_dir() {
+                commands::fs::set_resource_dir_hint(dir);
+            }
             if let Ok(dir) = app.path().app_data_dir() {
                 let store_path = dir.join("app-state.json");
                 eprintln!("[proxy] reading from {}", store_path.display());

+ 1 - 1
src/lib/source-lifecycle.ts

@@ -10,7 +10,7 @@ import { useWikiStore } from "@/stores/wiki-store"
 import { enqueueBatch } from "@/lib/ingest-queue"
 import { hasUsableLlm } from "@/lib/has-usable-llm"
 import { resolveDefaultModel } from "@/lib/novel/model-resolver"
-import { getFileName, getFileStem, normalizePath } from "@/lib/path-utils"
+import { getFileStem, normalizePath } from "@/lib/path-utils"
 import {
   parseFrontmatterArray,
   parseSources,