mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-04 15:47:50 +02:00
fix: use webview's resources table (#1191)
* fix: use webview's resources table * fix clipboard into_img usage * fix mobile
This commit is contained in:
@@ -8,7 +8,7 @@ use serde::Deserialize;
|
||||
use tauri::{
|
||||
ipc::{Channel, CommandScope, GlobalScope},
|
||||
path::{BaseDirectory, SafePathBuf},
|
||||
AppHandle, Manager, Resource, ResourceId, Runtime,
|
||||
Manager, Resource, ResourceId, Runtime, Webview,
|
||||
};
|
||||
|
||||
use std::{
|
||||
@@ -82,7 +82,7 @@ pub struct WatchOptions {
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn watch<R: Runtime>(
|
||||
app: AppHandle<R>,
|
||||
webview: Webview<R>,
|
||||
paths: Vec<SafePathBuf>,
|
||||
options: WatchOptions,
|
||||
on_event: Channel,
|
||||
@@ -92,7 +92,7 @@ pub async fn watch<R: Runtime>(
|
||||
let mut resolved_paths = Vec::with_capacity(paths.capacity());
|
||||
for path in paths {
|
||||
resolved_paths.push(resolve_path(
|
||||
&app,
|
||||
&webview,
|
||||
&global_scope,
|
||||
&command_scope,
|
||||
path,
|
||||
@@ -124,7 +124,7 @@ pub async fn watch<R: Runtime>(
|
||||
WatcherKind::Watcher(watcher)
|
||||
};
|
||||
|
||||
let rid = app
|
||||
let rid = webview
|
||||
.resources_table()
|
||||
.add(WatcherResource::new(kind, resolved_paths));
|
||||
|
||||
@@ -132,8 +132,8 @@ pub async fn watch<R: Runtime>(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn unwatch<R: Runtime>(app: AppHandle<R>, rid: ResourceId) -> CommandResult<()> {
|
||||
let watcher = app.resources_table().take::<WatcherResource>(rid)?;
|
||||
pub async fn unwatch<R: Runtime>(webview: Webview<R>, rid: ResourceId) -> CommandResult<()> {
|
||||
let watcher = webview.resources_table().take::<WatcherResource>(rid)?;
|
||||
WatcherResource::with_lock(&watcher, |watcher| {
|
||||
match &mut watcher.kind {
|
||||
WatcherKind::Debouncer(ref mut debouncer) => {
|
||||
|
||||
Reference in New Issue
Block a user