What are the uses of Permission? #11706
-
Hello, I would like to make some suggestions. Error: Unhandled Promise Rejection: window.get_all_windows not allowed on window "chat", webview "chat", URL: local Use & Config: import { getAllWindows, getCurrentWindow } from "@tauri-apps/api/window";
import { WebviewWindow } from "@tauri-apps/api/webviewWindow";
const closeWin = useCallback(async (label: string) => {
const targetWindow = await getWin(label);
if (!targetWindow) {
return;
}
try {
await targetWindow.close();
} catch (error) {
}
}, []);
const getWin = useCallback(async (label: string) => {
return WebviewWindow.getByLabel(label);
}, []); src-tauri/capabilities/default.json "permissions": [
"core:default",
"core:event:allow-emit",
"core:event:allow-listen",
"core:webview:allow-create-webview",
"core:webview:allow-create-webview-window",
"core:webview:allow-get-all-webviews",
"core:webview:allow-webview-close",
"core:webview:allow-webview-hide",
"core:webview:allow-webview-show",
"core:webview:allow-webview-size",
"core:webview:allow-set-webview-size",
"core:webview:allow-set-webview-zoom",
"core:window:default",
"core:window:allow-center",
"core:window:allow-close",
"core:window:allow-hide",
"core:window:allow-show",
"core:window:allow-create",
"core:window:allow-destroy",
"core:window:allow-start-dragging",
"core:window:allow-set-size",
"core:window:allow-get-all-windows",
"shell:allow-open",
"http:default",
"http:allow-fetch",
"http:allow-fetch-cancel",
"http:allow-fetch-read-body",
"http:allow-fetch-send",
"websocket:default",
"websocket:allow-connect",
"websocket:allow-send",
{
"identifier": "http:default",
"allow": [
{
"url": "http://localhost:2900"
}
],
"deny": []
}
] |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Your |
Beta Was this translation helpful? Give feedback.
Your
src-tauri/capabilities/default.json
file should also have awindows
property by default, doesn't it? I assume it looks like this"windows": ["main"]
(main
is the label of your first window unless you specify a custom label). The error is asking you to add the label of your second window to that array because capabilities are opt-in."windows": ["main", "chat"]