tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
84.1k stars 2.53k forks source link

[feat] labeld uri scheme protocol #10691

Closed liesauer closed 4 weeks ago

liesauer commented 2 months ago

Describe the problem

when a custom uri scheme protocol is called, there is no way to know the request is send by which window and webview, so cannot do special logic between different windows and webviews.

微信图片_20240820100809

Describe the solution you'd like

makes the protocol handler(Fn(app, request) -> Response) become something like this:

Fn(app, window, webview, request) -> Response

or

Fn(app, window_label, webview_label, request) -> Response

for both register_uri_scheme_protocol and register_asynchronous_uri_scheme_protocol

Alternatives considered

No response

Additional context

No response

ConnorKrammer commented 2 months ago

I think it is possible that this information is not supplied by the APIs Tauri uses. You might need to register a scheme for each behaviour you want, or include a parameter in the URI (e.g. ?referrer=...) which allows you to differentiate the source in your handler. (And if that's possible, I suppose Tauri could build an abstraction around that, technically.)

liesauer commented 2 months ago

I think it is possible that this information is not supplied by the APIs Tauri uses. You might need to register a scheme for each behaviour you want, or include a parameter in the URI (e.g. ?referrer=...) which allows you to differentiate the source in your handler. (And if that's possible, I suppose Tauri could build an abstraction around that, technically.)

it's impossible to register 100 scheme protocols if i have 100 apps, all i need is one app:// scheme and loading different content from $DATA_DIR/$APP_ID, url query is kind of solution, but what if the user change app://main.html?app=a to app://main.html?app=b?

i am not expecting expose the APP_ID to the frontend, all the logic should be rust-side.

liesauer commented 2 months ago

when launching an "app", the window label is forced to be APP_ID and won't be changed, it's the most safe way to identify an "app", the user never and also no need to know there is a APP_ID thing exists.