20 Persisted Scope

原文链接: https://tauri.app/plugin/persisted-scope/

保存文件系统与资源作用域,并在应用重新打开时恢复它们。

支持的平台

平台支持程度说明
Windows完整支持
Linux完整支持
macOS完整支持
Android完整支持
iOS完整支持

设置

安装 persisted-scope 插件即可开始。

安装方式

自动

使用你的项目包管理器添加依赖:

1
npm run tauri add persisted-scope
1
yarn run tauri add persisted-scope
1
pnpm tauri add persisted-scope
1
deno task tauri add persisted-scope
1
bun tauri add persisted-scope
1
cargo tauri add persisted-scope

手动

  1. 在 src-tauri 文件夹中运行以下命令,把插件加入 Cargo.toml 里的项目依赖:

    1
    
    cargo add tauri-plugin-persisted-scope
    
  2. 修改 lib.rs 初始化插件:

    1
    2
    3
    4
    5
    6
    7
    
    #[cfg_attr(mobile, tauri::mobile_entry_point)]
    pub fn run() {
        tauri::Builder::default()
            .plugin(tauri_plugin_persisted_scope::init())
            .run(tauri::generate_context!())
            .expect("error while running tauri application");
    }
    

用法

设置完成后,该插件会自动保存并恢复文件系统与资源作用域。

最后修改 September 26, 2026: 更新 (630b11f59)