字玩FontPlayer开发笔记10 Tauri2多窗口通信
字玩FontPlayer是笔者开源的一款字体设计工具,使用Vue3 + ElementUI开发,源代码:github | gitee
笔记
最近在使用Tauri进行打包应用,这两天在测试可编程脚本模块时,发现原有代码使用了window.open方法,在Tauri应用中一直触发不了新窗口弹出,查了一下说Tauri并不推荐使用window.open操作,比较好的做法是使用Tauri自带的Webview窗口功能,于是笔者就用Tauri自带的api将脚本模块重置。
设置权限
窗口功能默认是禁用的,需要开启权限才能支持。每个细分功能都用对应的权限字段,在permissions里进行设置。笔者为方便测试暂时把所有关于窗口的权限都启用了:
src-tauri/capabilities/defualt.json
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "enables the default permissions",
"windows": [
"main",
"glyph-script"
],
"remote": {
"urls": ["https://*.tauri.app/"]
},
"permissions": [
{
"identifier": "fs:scope",
"allow": [
{
"path": "$APPDATA"
},
{
"path": "$APPDATA/**"
}
]
},
"core:default",
"fs:read-files",
"fs:write-files",
"fs:allow-appdata-read-recursive",
"fs:allow-appdata-write-recursive",
"fs:default",
"dialog:default",
"core:event:allow-emit",
"core:event:allow-listen",
"core:webview:allow-clear-all-browsing-data",
"core:webview:allow-create-webview",
"core:webview:allow-create-webview-window",
"core:webview:allow-get-all-webviews",
"core:webview:allow-internal-toggle-devtools",
"core:webview:allow-print",
"core:webview:allow-reparent",
"core:webview:allow-set-webview-focus"

1658

被折叠的 条评论
为什么被折叠?



