tauri icon indicating copy to clipboard operation
tauri copied to clipboard

[feat] labeld uri scheme protocol

Open liesauer opened this issue 1 year ago • 3 comments

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

liesauer avatar Aug 20 '24 02:08 liesauer

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.)

ConnorKrammer avatar Aug 20 '24 08:08 ConnorKrammer

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 avatar Aug 20 '24 08:08 liesauer

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.

liesauer avatar Aug 20 '24 09:08 liesauer