tauri.conf.json由tauri init (了解更多)生成并保存在你的Tauri应用源目录中(src-tauri)
你可以在生成后修改这个文件来自定义你的Tauri应用程序
它由以下属性组成:

build(构建)

目标目录 必须 包含一个 index.html 文件。
}, {property: “devPath”, type: “string”, description:指向一个目录或URL(例如一个实时热重载服务器)的路径(可以是相对或绝对路径)。}, {property: “beforeDevCommand”, optional: true, type: “string”, description:在开发模式中需要在启动Tauri之前执行的命令。}, {property: “beforeBuildCommand”, optional: true, type: “string”, description:在构建模式中需要在启动Tauri之前执行的命令。`}, {property: “withGlobalTauri”, optional: true, type: “boolean”, description: “启用“向window.TAURI对象注入API”。

如果你正在使用 Vanilla JS 而不是使用 Rollup 或 Webpack导入API,这个选项会非常有用。”}

]}/>
“build”: { “distDir”: “../dist”, “devPath”: “http://localhost:4000“, “beforeDevCommand”: “npm run dev”, “beforeBuildCommand”: “npm run build”, “withGlobalTauri”: false }

ctx

tauri build —debug.}, { property: “exitOnPanic”, optional: true, type: “boolean”, description:如果Rust代码运行时出现了错误是否要终止webview。

也可以使用 tauri dev —exit-on-panic 或 tauri dev -e。` ]} />
“ctx” { “debug”: false, “exitOnPanic”: false, }

tauri

注意:所有的前置连字符都会被删除,只有第一个无连字符的字符会被作为短版本(short version)

}, { property: “name”, type: “string”, description:唯一的参数名称。}, { property: “description”, optional: true, type: “string”, description:会被显示在帮助中的参数描述信息。

通常来说,这是一个短的(一行)参数描述。}, { property: “longDescription”, optional: true, type: “string”, description:会被显示在帮助中的长的参数描述信息。

通常,这是一个更加详细描述(多行)参数的消息}, { property: “takesValue”, optional: true, type: “boolean”, description:指定参数在运行时需要一个值。
参数值可以以下列任一方式指定:

  • 使用一个空格间隔,例如-o value 或 —option value
  • 使用无空格的等号,例如 -o=value 或 —option=value
  • 使用无间断,例如-ovalue

}, { property: “index”, type: “number”, optional: true, description:参数位置索引,从1开始。
这个索引会根据其他的位置参数引用某个位置。
它不意味着在整个参数列表中的位置。
和 multiple=true 一起使用时,只有最后一个位置参数可以定义为多个(即指数最高的参数)。
}, { property: “multiple”, optional: true, type: “boolean”, description:声明参数可能会出现多次。
对于标记(flag),如果为true,则会记录一个参数出现的次数。
例如, -ddd 或 -d -d -d 将计为三次出现。

对于选项(option),多次出现 和 有多个值 之间是完全不同的。

例如, —opt val1 val2 被视为只出现一次,但有两个值,

而 —opt val1 —opt val2 会被视为出现两次。}, { property: “possibleValues”, optional: true, type: “string[]”, description:指定此参数可能的值列表。

在运行时,CLI会校验是否使用了其中某个值,否则会打印错误信息。}, { property: “minValues”, optional: true, type: “number”, description:指定此参数最小的值数量。

例如,如果你希望 -f 参数至少需要指定两个文件,你需要配置 minValues: 2,这样只有当此参数有了不少于两个值时才能通过校验。}, { property: “maxValues”, optional: true, type: “number”, description:指定此参数最大的值数量。

例如,如果你希望 -f 参数至多只能指定三个文件,你需要配置 max_values: 3,这样只有当此参数有了1~3个值时才能通过校验。}, { property: “required”, optional: true, type: “boolean”, description:配置此参数是否默认需要提供。

这意味着除非有冲突的规则,否则必须提供此参数。 冲突的规则优先级高于此参数。}, { property: “requiredUnless”, optional: true, type: “string”, description:指定一个会覆盖参数required配置的缺省值。
也就是说没有提供此缺省值的、required的参数必须指定值。}, { property: “requiredUnlessAll”, optional: true, type: “string[]”, description:指定一些会覆盖参数required配置的缺省值。
也就是说没有提供这些缺省值的、required的参数必须指定值。}, { property: “requiredUnlessOne”, optional: true, type: “string[]”, description:指定一些会覆盖参数required配置的缺省值。
也就是说没有提供其中一个缺省值的、required的参数必须指定值。}, { property: “conflictsWith”, optional: true, type: “string”, description:使用名称来设置一个冲突的参数。 即当使用此参数时,下列参数不能存在,反之亦然。}, { property: “conflictsWithAll”, optional: true, type: “string”, description:和conflicts_with作用相同,但是允许每个参数指定多个双向冲突。}, { property: “requires”, optional: true, type: “string”, description:当这个参数存在时会(按名称)检测另一个必要的参数是否存在。
即配置这个参数时同时必须指定某个参数。}, { property: “requiresAll”, optional: true, type: “string[]”, description:当这个参数存在时会(按名称)检测另一些必要的参数是否存在。
即配置这个参数时同时必须指定下列多个参数。}, { property: “requiresIf”, optional: true, type: “[string, string]”, description:允许通过标记[arg: string, value: string]来指定有条件的需要。
仅当arg的值等于 ${value}时有效。
}, { property: “requiredIf”, optional: true, type: “[string, string]”, description:允许通过标记[arg: string, value: string]来声明某个参数为有条件的需要。
仅当arg的值等于 ${value}时有效。
}, { property: “requireEquals”, optional: true, type: “boolean”, description:必须使用—option=val表达式描述参数
也就是说必须用等号分隔选项及其对应的参数值。}, ]} /> }, { property: “description”, optional: true, type: “string”, description:命令描述,将显示在帮助信息上。.}, { property: “longDescription”, optional: true, type: “string”, description:命令的长描述,将显示在帮助信息上。}, { property: “beforeHelp”, optional: true, type: “string”, description:在自动生成的帮助之外显示额外的帮助信息。
该信息显示在自动生成的帮助信息之前。
这通常用于头部信息。该信息显示在自动生成的帮助信息之后。}, { property: “afterHelp”, optional: true, type: “string”, description:在自动生成的帮助之外显示额外的帮助信息。
该信息显示在自动生成的帮助信息之后。
通常用于描述如何使用参数,或需要注意的事项。}, { property: “subcommands”, optional: true, type: “{ [name: string]: CliConfig }”, description:该命令的子命令列表。
子命令实际上都是“子程序”,因为它们可以拥有自己的参数、子命令、使用方式等等。
它们同时也会作为“应用命令”执行功能,因为它们会获得自动生成的帮助和使用方法信息。}, ]} /> }, { property: “embeddedServer”, type: “object”, child: }, { property: “bundle”, type: “object”, child:
默认会将所有目标平台支持的文件都打包在一起(mac 上的 osx/dmg, linux 上的 deb/appimage, windows 上的 msi).}, { property: “identifier”, type: “string”, description:使用反向域名形式(reverse-DNS)唯一标识你的应用程序的字符串 (例如 “com.example.appname” 或 “io.github.username.project”)。

在OS X 和 iOS上,这会被用作打包的 CFBundleIdentifier 值; 在 Windows 上,这个值会被哈希化后作为GUID使用。}, { property: “icon”, optional: true, type: “string[]”, description:用于应用程序包的图标路径(相对于src-tauri)列表。}, { property: “resources”, optional: true, type: “string[]”, description:需要复制到包的资源区的文件/目录列表。

支持Glob语法。}, { property: “externalBin”, optional: true, type: “string[]”, description:要嵌入你的应用程序的二进制文件列表(可以是相对或绝对路径)。
请注意,Tauri将使用模板”binary-name{-target-triple}{.system-extension}”查找不同操作系统的特定二进制文件。

例如,
你输入了“my-binary”:

  • Windows下使用”my-binary-x86_64-pc-windows-msvc.exe”
  • MacOS下使用”my-binary-x86_64-apple-darwin”
  • Linux下使用”my-binary-x86_64-unknown-linux-gnu”

因此请不要忘记为所有目标平台提供二进制文件。
}, { property: “copyright”, optional: true, type: “string”, description:与你应用程序关联的版权信息。}, { property: “category”, optional: true, type: “string”, description:应用程序分类。

应为下列一种:
Business, DeveloperTool, Education, Entertainment, Finance, Game, ActionGame, AdventureGame, ArcadeGame, BoardGame, CardGame, CasinoGame, DiceGame, EducationalGame, FamilyGame, KidsGame, MusicGame, PuzzleGame, RacingGame, RolePlayingGame, SimulationGame, SportsGame, StrategyGame, TriviaGame, WordGame, GraphicsAndDesign, HealthcareAndFitness, Lifestyle, Medical, Music, News, Photography, Productivity, Reference, SocialNetworking, Sports, Travel, Utility, Video, Weather。

}, { property: “shortDescription”, optional: true, type: “string”, description:应用程序简介。}, { property: “longDescription”, optional: true, type: “string”, description:应用程序详情(多行)。}, { property: “deb”, optional: true, type: “object”, child: }, { property: “osx”, optional: true, type: “object”, child:
如果使用此项, “.framework” 会被强制忽略且它会寻找标准安装位置。

你也可以使用某个特定框架的路径。}, { property: “minimumSystemVersion”, optional: true, type: “string”, description:被打包的应用程序所支持的最低MacOS版本。}, { property: “license”, optional: true, type: “string”, description:许可证文件路径,这个文件会被添加到DMG中。}, { property: “useBootstrapper”, optional: true, type: “boolean”, description:启用 boostrapper script.}]} /> }, { property: “exceptionDomain”, optional: true, type: “string”, description:允许你的应用程序与外部通讯。
它应该使用小写并且不包含端口和协议域名。
}, ]} /> }, { property: “allowlist”, type: “object”, child: }, { property: “window”, type: “object”, child: }, { property: “security”, type: “object”, child: 这是配置中一个非常重要的部分,因为它有助于确保您的网络视图安全。

Mozilla 上查看更多信息。
}, ]} /> }, { property: “edge”, type: “object”, child: }, { property: “inliner”, type: “object”, child:
我们的 GitHub 上查看更多信息` }, ]} /> }, ]} />
我们不直接启动应用,而是配置捆绑的应用来运行一个脚本来试图向应用暴露环境变量; 如果不这么做,您就会在使用系统命令行接口应用程序(例如Node.js)时遇到问题。
“tauri”: { “cli”: { “description”: “Tauri communication example”, “longDescription”: null, “beforeHelp”: null, “afterHelp”: null, “args”: [{ “short”: “c”, “name”: “config”, “takesValue”: true, “description”: “Config path” }, { “short”: “t”, “name”: “theme”, “takesValue”: true, “description”: “App theme”, “possibleValues”: [“light”, “dark”, “system”] }, { “short”: “v”, “name”: “verbose”, “multipleOccurrences”: true, “description”: “Verbosity level” }], “subcommands”: { “update”: { “description”: “Updates the app”, “longDescription”: null, “beforeHelp”: null, “afterHelp”: null, “args”: [{ “short”: “b”, “name”: “background”, “description”: “Update in background” }], “subcommands”: null } } }, “embeddedServer”: { “active”: true }, “bundle”: { “active”: true, “targets”: [“deb”], “identifier”: “com.tauri.dev”, “icon”: [“icons/32x32.png”, “icons/128x128.png”, “icons/128x128@2x.png”, “icons/icon.icns”, “icons/icon.ico”], “resources”: [], “externalBin”: [], “copyright”: “”, “category”: “DeveloperTool”, “shortDescription”: “”, “longDescription”: “”, “deb”: { “depends”: [] }, “osx”: { “frameworks”: [], “minimumSystemVersion”: “” }, “exceptionDomain”: “” }, “allowlist”: { “all”: true }, “window”: { “title”: “Tauri App”, “width”: 800, “height”: 600, “resizable”: true, “fullscreen”: false }, “security”: { “csp”: “default-src blob: data: filesystem: ws: http: https: ‘unsafe-eval’ ‘unsafe-inline’” }, “edge”: { “active”: true }, “inliner”: { “active”: true } }