Make file opening work properly
This commit is contained in:
parent
6e4f3d670f
commit
f642fa8e4d
|
|
@ -4,7 +4,7 @@ use tauri_plugin_log::{Target, TargetKind};
|
||||||
use log::{trace, info, debug, warn, error};
|
use log::{trace, info, debug, warn, error};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
use chrono::Local;
|
use chrono::Local;
|
||||||
use tauri::{webview, AppHandle, Manager, Url, WebviewUrl, WebviewWindowBuilder};
|
use tauri::{AppHandle, Manager, Url, WebviewUrl, WebviewWindowBuilder};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -96,14 +96,14 @@ fn handle_file_associations(app: AppHandle, files: Vec<PathBuf>) {
|
||||||
let fs_scope = app.fs_scope();
|
let fs_scope = app.fs_scope();
|
||||||
|
|
||||||
// This is for the `asset:` protocol to work:
|
// This is for the `asset:` protocol to work:
|
||||||
// let asset_protocol_scope = app.asset_protocol_scope();
|
let asset_protocol_scope = app.asset_protocol_scope();
|
||||||
|
|
||||||
for file in &files {
|
for file in &files {
|
||||||
// This requires the `fs` plugin:
|
// This requires the `fs` plugin:
|
||||||
let _ = fs_scope.allow_file(file);
|
let _ = fs_scope.allow_file(file);
|
||||||
|
|
||||||
// This is for the `asset:` protocol:
|
// This is for the `asset:` protocol:
|
||||||
// let _ = asset_protocol_scope.allow_file(file);
|
let _ = asset_protocol_scope.allow_file(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Scope handling end --
|
// -- Scope handling end --
|
||||||
|
|
@ -118,13 +118,8 @@ fn handle_file_associations(app: AppHandle, files: Vec<PathBuf>) {
|
||||||
.join(",");
|
.join(",");
|
||||||
warn!("{}",files);
|
warn!("{}",files);
|
||||||
|
|
||||||
// tauri::WebviewWindowBuilder::new(&app, "main", Default::default())
|
|
||||||
// .initialization_script(&format!("window.openedFiles = [{files}]"))
|
|
||||||
// .build()
|
|
||||||
// .unwrap();
|
|
||||||
let window = app.get_webview_window("main").unwrap();
|
let window = app.get_webview_window("main").unwrap();
|
||||||
window.eval(&format!("window.openedFiles = [{files}]")).unwrap();
|
window.eval(&format!("window.openedFiles = [{files}]")).unwrap();
|
||||||
// window.emit("openedFiles", &format!("[{files}]")).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null,
|
||||||
|
"assetProtocol": {
|
||||||
|
"enable": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bundle": {
|
"bundle": {
|
||||||
|
|
|
||||||
|
|
@ -6705,7 +6705,9 @@ function outliner(object = undefined) {
|
||||||
async function startup() {
|
async function startup() {
|
||||||
await loadConfig();
|
await loadConfig();
|
||||||
createNewFileDialog(_newFile, _open, config);
|
createNewFileDialog(_newFile, _open, config);
|
||||||
showNewFileDialog(config);
|
if (!window.openedFiles) {
|
||||||
|
showNewFileDialog(config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
|
|
|
||||||
|
|
@ -145,12 +145,14 @@ function createNewFileDialog(newFileCallback, openFileCallback, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showNewFileDialog(config) {
|
function showNewFileDialog(config) {
|
||||||
|
if (!overlay) return;
|
||||||
overlay.style.display = 'block';
|
overlay.style.display = 'block';
|
||||||
newFileDialog.style.display = 'block';
|
newFileDialog.style.display = 'block';
|
||||||
displayFiles(config.recentFiles); // Reload the recent files
|
displayFiles(config.recentFiles); // Reload the recent files
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
|
if (!overlay) return;
|
||||||
overlay.style.display = 'none';
|
overlay.style.display = 'none';
|
||||||
newFileDialog.style.display = 'none';
|
newFileDialog.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue