当前位置: 首页 > wzjs >正文

北京网站制作公司哪家好中国网新重庆

北京网站制作公司哪家好,中国网新重庆,工业设计代做网站,西部数码网站建设本文档对比 Tauri v1 和 v2 版本的配置结构和内容差异,帮助开发者了解版本变更并进行迁移。 配置结构变化 v1 配置结构 {"package": { ... },"tauri": { "allowlist": { ... },"bundle": { ... },"security":…

本文档对比 Tauri v1 和 v2 版本的配置结构和内容差异,帮助开发者了解版本变更并进行迁移。

配置结构变化

v1 配置结构

{"package": { ... },"tauri": { "allowlist": { ... },"bundle": { ... },"security": { ... },"updater": { ... },"windows": [ ... ]},"build": { ... },"plugins": { ... }
}

v2 配置结构

{"identifier": "...","productName": "...", "version": "...","app": {"security": { ... },"windows": [ ... ]},"build": { ... },"bundle": { ... }, "plugins": { ... }
}

主要变化

根级配置

v1v2说明
package.productNameproductName移至根级
package.versionversion移至根级
-identifier新增,必填项,应用唯一标识符
-mainBinaryName新增,可选,主二进制文件名

根级配置示例

v1 配置:

{"package": {"productName": "我的Tauri应用","version": "0.1.0"},"tauri": { ... }
}

v2 配置:

{"identifier": "com.example.myapp","productName": "我的Tauri应用","version": "0.1.0","app": { ... }
}

核心配置项

v1v2说明
tauriapp重命名
tauri.allowlistapp.security.capabilities权限系统重构
tauri.bundlebundle移至根级
tauri.securityapp.security移动位置
tauri.updaterbundle.createUpdaterArtifacts简化为布尔值
tauri.windowsapp.windows移动位置

开发构建配置

v1v2说明
build.devPathbuild.devUrl重命名
build.distDirbuild.frontendDist重命名
build.withGlobalTauriapp.withGlobalTauri移至app配置
-build.removeUnusedCommands新增

构建配置示例

v1 配置:

{"build": {"devPath": "http://localhost:3000","distDir": "../dist","withGlobalTauri": true}
}

v2 配置:

{"build": {"devUrl": "http://localhost:3000","frontendDist": "../dist","removeUnusedCommands": true},"app": {"withGlobalTauri": true}
}

安全配置

v1v2说明
tauri.security.cspapp.security.csp位置变更
tauri.security.freezePrototypeapp.security.freezePrototype位置变更
tauri.security.dangerousDisableAssetCspModificationapp.security.dangerousDisableAssetCspModification位置变更
tauri.security.dangerousRemoteDomainIpcAccess-已移除
tauri.security.dangerousUseHttpScheme-已移除
-app.security.pattern新增安全模式配置
-app.security.assetProtocol新增资源协议安全配置

安全配置示例

v1 配置:

{"tauri": {"security": {"csp": "default-src 'self'","freezePrototype": true,"dangerousDisableAssetCspModification": false}}
}

v2 配置:

{"app": {"security": {"csp": "default-src 'self'","freezePrototype": true,"dangerousDisableAssetCspModification": false,"pattern": {"use": "brownfield"},"assetProtocol": {"enable": true,"scope": ["**/*.html", "**/*.js", "**/*.css", "**/*.png"]}}}
}

权限系统(Capabilities)

v2 引入了全新的权限系统,替代了 v1 的 allowlist。新系统更灵活、更安全,使用 capabilities 配置。

v1 权限配置 (allowlist):

{"tauri": {"allowlist": {"fs": {"all": true,"readFile": true,"writeFile": true,"scope": ["$APPDATA/**", "$APPCONFIG/**"]},"dialog": {"all": true},"shell": {"execute": true,"scope": [{ "name": "node", "cmd": "node", "args": true }]}}}
}

v2 权限配置 (capabilities):

{"app": {"security": {"capabilities": [{"identifier": "fs:default","allow": [{ "path": "$APPDATA/**" },{ "path": "$APPCONFIG/**" }]},{"identifier": "dialog:default"},{"identifier": "shell:allow-execute","permissions": ["allow-execute-command"],"commands": [{ "name": "node", "args": true }]}]}}
}

打包配置

v1v2说明
tauri.bundle.activebundle.active位置变更
tauri.bundle.targetsbundle.targets位置变更
tauri.bundle.iconbundle.icon位置变更
-bundle.createUpdaterArtifacts新增,替代v1的updater配置
-bundle.useLocalToolsDir新增

平台特定配置

v1v2说明
tauri.bundle.windowsbundle.windows位置变更
tauri.bundle.macOSbundle.macOS位置变更
tauri.bundle.linuxbundle.linux位置变更
-bundle.android新增,支持Android平台
-bundle.iOS新增,支持iOS平台

移动平台配置

v2新增了对移动平台的支持,下面是移动平台特有的配置示例:

Android 配置:

{"bundle": {"android": {"versionCode": 1,"minSdkVersion": 24,"targetSdkVersion": 33,"icon": "icons/android-icon.png","packageName": "com.example.myapp","useCustomStatusBarColor": true,"statusBarColor": "#FFFFFF","keystore": {"path": "keystore.jks","keyAlias": "key0","password": "${ENV_PASSWORD}"}}}
}

iOS 配置:

{"bundle": {"iOS": {"developmentTeam": "ABCDE12345","minimumOsVersion": "13.0","deviceFamily": ["iphone", "ipad"],"infoPlist": {"NSCameraUsageDescription": "此应用需要访问您的相机","NSPhotoLibraryUsageDescription": "此应用需要访问您的照片库","CFBundleURLTypes": [{"CFBundleURLName": "com.example.myapp","CFBundleURLSchemes": ["myapp"]}]}}}
}

窗口配置

v1和v2的窗口配置选项基本相同,但在v2中有以下新增属性:

新增属性说明
shadow窗口是否有阴影
theme窗口主题(light/dark)
incognito是否使用隐身模式
fileDropEnabled是否允许文件拖放
label窗口标签,用于API引用

窗口配置示例

v1 配置:

{"tauri": {"windows": [{"title": "我的应用","width": 800,"height": 600,"resizable": true,"fullscreen": false}]}
}

v2 配置:

{"app": {"windows": [{"title": "我的应用","width": 800,"height": 600,"resizable": true,"fullscreen": false,"shadow": true,"theme": "light","incognito": false,"fileDropEnabled": true,"label": "main"}]}
}

插件系统变更

Tauri v2 的插件系统相比 v1 有重大更新,支持更灵活的插件配置:

v1 插件配置:

{"plugins": {"fs": {"scope": ["$APPDATA/**"]},"sql": {}}
}

v2 插件配置:

{"plugins": {"local-fs": {"scope": ["$APPDATA/**"]},"sql": {"allowedPaths": ["$APPDATA/database.sqlite"]}}
}

文件格式与平台特定配置

文件格式

两个版本都支持:

  • JSON: tauri.conf.json(默认)
  • JSON5: tauri.conf.jsontauri.conf.json5
  • TOML: Tauri.toml

平台特定配置

v1v2说明
tauri.linux.conf.jsontauri.linux.conf.json无变化
tauri.windows.conf.jsontauri.windows.conf.json无变化
tauri.macos.conf.jsontauri.macos.conf.json无变化
-tauri.android.conf.json新增,Android平台配置
-tauri.ios.conf.json新增,iOS平台配置

迁移指南

从 Tauri v1 迁移到 v2 时,建议按照以下步骤操作:

  1. 必填字段添加

    • 添加必需的identifier字段,使用反向域名表示法(如com.company.app
  2. 基本结构调整

    • package配置移至根级
    • tauri更改为app
    • bundle移至根级
  3. 构建配置更新

    • devPath更新为devUrl
    • distDir更新为frontendDist
    • withGlobalTauri移至app配置
  4. 权限系统迁移

    • allowlist迁移到新的capabilities权限系统
    • 对每个权限定义identifier和具体的权限范围
  5. 安全配置更新

    • 将所有安全相关配置移至app.security
    • 添加新的patternassetProtocol配置
  6. 窗口配置更新

    • 调整窗口配置路径为app.windows
    • 考虑使用新增的窗口属性增强功能
  7. 更新器配置

    • 将复杂的updater配置替换为简单的bundle.createUpdaterArtifacts布尔值
  8. 移动平台支持(如需):

    • 添加bundle.androidbundle.iOS配置

迁移示例

以下是一个完整的迁移示例,展示从 v1 到 v2 的具体配置变化:

v1 配置文件:

{"package": {"productName": "我的Tauri应用","version": "0.1.0"},"tauri": {"allowlist": {"fs": {"all": true,"scope": ["$APPDATA/**"]},"dialog": {"all": true}},"bundle": {"active": true,"icon": "icons/icon.png","targets": ["deb", "msi", "dmg"]},"security": {"csp": "default-src 'self'"},"updater": {"active": true,"endpoints": ["https://example.com/update-feed.json"]},"windows": [{"title": "我的应用","width": 800,"height": 600}]},"build": {"devPath": "http://localhost:3000","distDir": "../dist"}
}

v2 配置文件:

{"identifier": "com.example.myapp","productName": "我的Tauri应用","version": "0.1.0","app": {"security": {"csp": "default-src 'self'","capabilities": [{"identifier": "fs:default","allow": [{ "path": "$APPDATA/**" }]},{"identifier": "dialog:default"}]},"windows": [{"title": "我的应用","width": 800,"height": 600,"label": "main"}]},"build": {"devUrl": "http://localhost:3000","frontendDist": "../dist"},"bundle": {"active": true,"icon": "icons/icon.png","targets": ["deb", "msi", "dmg"],"createUpdaterArtifacts": true}
}

参考资料

  • Tauri v1配置文档
  • Tauri v2配置文档
  • Tauri v1配置Schema
  • Tauri v2配置Schema

文章转载自:

http://X5IwfRO2.dfckx.cn
http://iH5aW8CB.dfckx.cn
http://Vm8F5Ozw.dfckx.cn
http://c2KanTnY.dfckx.cn
http://OyL5Rh6T.dfckx.cn
http://3ftaKQnB.dfckx.cn
http://LRtfZGl4.dfckx.cn
http://ZIqXUJw8.dfckx.cn
http://PJYbTMmx.dfckx.cn
http://4XZ5igvB.dfckx.cn
http://lFO3oNfN.dfckx.cn
http://KBw7rTet.dfckx.cn
http://OprC5FQr.dfckx.cn
http://4TEHGmGR.dfckx.cn
http://OcRBvyGF.dfckx.cn
http://B4nhSg4l.dfckx.cn
http://0Rak8UQG.dfckx.cn
http://xXQVTx0s.dfckx.cn
http://nLplYGJq.dfckx.cn
http://CpnLrFkC.dfckx.cn
http://ciXW6wXq.dfckx.cn
http://lgSqBUFi.dfckx.cn
http://xw0lgrAQ.dfckx.cn
http://LXqVmDgI.dfckx.cn
http://v89rq5H4.dfckx.cn
http://DReqLdGt.dfckx.cn
http://VmWay1MP.dfckx.cn
http://o8PUN5KS.dfckx.cn
http://Xxttlu8L.dfckx.cn
http://6mD8bUWZ.dfckx.cn
http://www.dtcms.com/wzjs/742403.html

相关文章:

  • 网站诚信备案网站建设 漳州
  • 网站源码怎么使用宁波建设集团几个分公司
  • 整个网站开发框架流程咸阳网站设计建设公司
  • 试玩网站建设微信朋友圈推广
  • 高端集团官方网站建设公司更改wordpress登陆界面
  • 什么网站是solr做的久久建筑网怎么不好用
  • 网站做好了怎么做后台管理新会住房和城乡建设部网站
  • 网站标准尺寸怎么自己做一个小程序
  • 网站建设的步骤教程视频教程企业服务类型有哪些
  • 网站前台模板 html引流用什么话术更吸引人
  • 广西新农村建设工作专题网站网站数据库地址是什么
  • 福建省住房和城乡建设厅的网站哪些大公司用wordpress
  • 常州市建设局网站6网站首页倒计时功能怎么做
  • 企业网站对网络营销的意义百度搜索收录提交入口
  • 珠海专业医疗网站建设外国设计师素材网站
  • 一诺互联网站建设公司建设招聘网站
  • 宣传册制作网站百度一下电脑版
  • 千图网素材解析网站开发那些做黑网站的都是团体还是个人
  • 自己做的网站服务器开了进不去网站开发框架技术
  • 深圳专业网站设计专业定制乐装网
  • 企业网站设计意义快速开发平台开发
  • 北京驾校网站建设如何提交网站给百度
  • 申请网站长沙seo培训
  • 北京网站备案查询优秀企业网站建设
  • 重庆城乡建设网站首页wordpress安全漏洞
  • 建设银行官网站下载地址山东济宁刚刚出大事
  • 免费建站的平台免费咨询律师的电话
  • 国内免费自建网站东莞寮步
  • 宁波怎么建网站模板wordpress百度云链接地址
  • 皇家梅陇公馆网站建设品牌型网站的设计