做婚恋网站赚钱吗网站版面设计流程包括哪些
2026/4/18 1:38:43 网站建设 项目流程
做婚恋网站赚钱吗,网站版面设计流程包括哪些,关于京东商城网站建设的实践报告,网站开发目的意义在基于 Tauri 开发桌面应用的过程中#xff0c;相信不少开发者都遇到过权限相关的报错#xff0c;其中Uncaught (in promise) shell.open not allowed URL就是高频问题之一。我近期在开发 Windows 端 Tauri 应用时就踩了这个坑#xff0c;尝试了网上大部分常规解法都无效相信不少开发者都遇到过权限相关的报错其中Uncaught (in promise) shell.open not allowed URL就是高频问题之一。我近期在开发 Windows 端 Tauri 应用时就踩了这个坑尝试了网上大部分常规解法都无效最终通过调整 capabilities 配置解决了问题本文就完整复盘整个解决过程希望能帮到遇到同样问题的开发者。一、问题背景与报错详情在 Tauri 应用中调用shell.open()方法打开外部 URL比如https://xxx.com时控制台直接抛出如下错误Uncaught (in promise) shell.open not allowed URL: allowed on: [windows: *, URL: local], [windows: *, URL: local] referenced by: capability: default-capability, permission: allow-open || capability: default-capability, permission: allow-open从报错信息能看出核心问题Tauri 的权限策略仅允许打开local本地URL而我要打开的是远程 HTTP/HTTPS 链接因此被权限拦截了。二、踩坑尝试常规解法均无效遇到问题后我首先查阅了 Tauri 官方文档和网上的常规解决方案逐一尝试但都没解决问题1. 调整 tauri.conf.json 中的 allowlist按照网上教程在tauri.conf.json的tauri allowlist shell中配置open: true并尝试增加 URL 白名单{ tauri: { allowlist: { shell: { open: true, allow: [https://*, http://*] // 尝试添加允许的URL } } } }重新构建应用后报错依然存在。2. 配置 permissions 数组有教程提到需要在 allowlist 同级增加permissions配置我也尝试了{ tauri: { allowlist: { shell: { open: true } }, permissions: [ { name: shell:open, allow: [https://*, http://*] } ] } }结果还是一样的报错问题没有任何改善。3. 检查 tauri 版本与 API 用法确认自己使用的 Tauri 版本v2.x中shell.open()的调用方式无误import { shell } from tauri-apps/plugin-shell; // 调用代码 async function openExternalUrl() { try { await shell.open(https://www.example.com); } catch (e) { console.error(打开URL失败, e); } }API 用法符合官方文档排除了调用方式错误的可能。三、解决调整 capabilities/default.json 配置在尝试了所有常规解法都无效后我注意到 Tauri v2.x 版本中权限管理的核心是capabilities能力配置而非旧版本的 allowlist。最终通过修改src-tauri/capabilities/default.json文件解决了问题1. 原始 default.json 配置默认配置中仅允许本地 URL没有开放远程 URL 权限{ $schema: ../gen/schemas/capability-schema.json, identifier: default-capability, description: Default capabilities for the app, permissions: [ { identifier: allow-open, description: Allow opening URLs, allow: [ { shell:open: { windows: *, url: local } } ] } ] }2. 修改后的配置核心在default.json中增加remote节点开放所有远程 URL 的访问权限也可根据需求限定具体域名{ $schema: ../gen/schemas/capability-schema.json, identifier: default-capability, description: Default capabilities for the app, permissions: [ { identifier: allow-open, description: Allow opening URLs, allow: [ { shell:open: { windows: *, url: local } }, { shell:open: { windows: *, url: remote } } ] } ], remote: { urls: [https://*, http://*, /**] } }3. 关键说明remote.urls指定允许访问的远程 URL 范围https://*和http://*表示允许所有 HTTPS/HTTP 链接/**兼容本地路径新增url: remote的shell:open权限明确允许打开远程 URL修改后需要重新构建应用pnpm tauri build或pnpm tauri dev配置才能生效。四、验证问题解决修改配置并重启应用后再次调用shell.open()打开远程 URL控制台无报错外部浏览器能正常打开目标链接问题彻底解决。总结Tauri v2.x 版本的权限管理核心是capabilities配置而非旧版本的 allowlist这是很多开发者踩坑的关键解决shell.open not allowed URL报错的核心是在capabilities/default.json中配置remote.urls并开放shell:open的remoteURL 权限网上部分教程基于 Tauri v1.x其中的 allowlist 配置在 v2.x 中已不再生效需注意版本适配。如果你的 Tauri 应用也遇到类似的 URL 权限报错不妨优先检查capabilities配置文件而非执着于旧版的 allowlist大概率能快速解决问题。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询