Skip to content

Commit 3c1b232

Browse files
committed
update
1 parent 959a890 commit 3c1b232

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

gui/src-tauri/capabilities/main.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
"identifier": "main-capability",
44
"description": "Capability for the main window",
55
"windows": [
6-
"main"
6+
"*"
77
],
8+
"remote": {
9+
"urls": ["http://*","https://*","ipc://*"]
10+
},
811
"permissions": [
912
"path:default",
1013
"event:default",
@@ -21,6 +24,16 @@
2124
"webview:allow-internal-toggle-devtools",
2225
"webview:allow-create-webview",
2326
"webview:allow-create-webview-window",
27+
"webview:allow-internal-toggle-devtools",
28+
"webview:allow-print",
29+
"webview:allow-reparent",
30+
"webview:allow-set-webview-focus",
31+
"webview:allow-set-webview-position",
32+
"webview:allow-set-webview-size",
33+
"webview:allow-set-webview-zoom",
34+
"webview:allow-webview-close",
35+
"webview:allow-webview-position",
36+
"webview:allow-webview-size",
2437
"process:allow-restart",
2538
{
2639
"identifier": "shell:allow-spawn",

gui/src-tauri/src/lib.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::any::Any;
1111
use tauri::AppHandle;
1212
use url::Url;
1313
use tauri::Manager;
14+
use tauri_plugin_shell::ShellExt;
1415

1516
#[command]
1617
fn pipylib(lib: String, argv: Vec<String>, argc: i32) -> Result<String, String> {
@@ -93,6 +94,17 @@ async fn create_proxy_webview(
9394
window_label: String,
9495
proxy_url: String,
9596
curl: String,
97+
) -> Result<(),()> {
98+
create_proxy_webview_core(app.clone(), label.to_string(), window_label.to_string(), proxy_url.to_string(), curl);
99+
Ok(())
100+
}
101+
102+
fn create_proxy_webview_core(
103+
app: tauri::AppHandle,
104+
label: String,
105+
window_label: String,
106+
proxy_url: String,
107+
curl: String,
96108
) -> Result<(),()> {
97109
unsafe {
98110

@@ -110,18 +122,27 @@ async fn create_proxy_webview(
110122
);
111123
options.proxy_url = proxy_url_ops
112124
}
113-
114-
let mut builder = tauri::WebviewBuilder::from_config(&options);
115-
125+
println!("builder!");
126+
127+
let builder = tauri::WebviewBuilder::from_config(&options).on_navigation(|url| {
128+
// allow the production URL or localhost on dev
129+
println!("on_navigation!");
130+
if url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "ipc" {
131+
println!("{}",url);
132+
// create_proxy_webview_core(app, url.to_string(), url.to_string(), proxy_url.to_string(), url.to_string());
133+
}
134+
true
135+
});
116136
let window = app
117137
.get_window(&window_label)
118138
.expect("Failed to find window by label");
119139

120-
window.add_child(
140+
let webview = window.add_child(
121141
builder,
122142
tauri::LogicalPosition::new(0, 0),
123-
tauri::LogicalSize::new(960, 800),
143+
window.inner_size().unwrap(),
124144
).unwrap();
145+
125146
}
126147
Ok(())
127148
}

gui/src-tauri/tauri.conf.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121
}
2222
],
2323
"security": {
24+
"csp": {
25+
"default-src": "'self' customprotocol: asset:",
26+
"connect-src": "ipc://localhost ipc://localhost/plugin:shell|open",
27+
"img-src": "'self' asset: http://asset.localhost blob: data:",
28+
"style-src": "'unsafe-inline' 'self' https://fonts.googleapis.com"
29+
},
30+
"assetProtocol": {
31+
"enable": false,
32+
"scope": []
33+
},
34+
"dangerousDisableAssetCspModification": false,
35+
"freezePrototype": false,
2436
"capabilities": ["main-capability"]
2537
},
2638
"withGlobalTauri": true

gui/src/layout/Apps.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const openWebview = (app)=>{
8080
getCurrentDL().then((urls)=>{
8181
console.log(urls)
8282
})
83-
} else if(platform.value=='windows'){
83+
} else if(platform.value=='windows' || true){
8484
// windows API not available on mobile
8585
options.parent = getCurrent();
8686

0 commit comments

Comments
 (0)