Skip to content

Commit 44b86a3

Browse files
author
linyuan.yang
committed
修改 bundle id
1 parent 59f1b1f commit 44b86a3

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎packages/app/src-tauri/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "sbox"
33
version = "0.0.1"
4+
authors = ["while"]
45
edition = "2021"
56

67
[lib]

‎packages/app/src-tauri/src/tools/autostart.rs‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/// 应用标识,与 tauri.conf.json 的 identifier 保持一致;各平台自启动实现共用。
2+
const APP_IDENTIFIER: &str = "com.while.sbox";
3+
14
#[cfg(target_os = "windows")]
25
mod imp {
36
use std::{env, mem, slice};
@@ -12,8 +15,9 @@ mod imp {
1215
},
1316
};
1417

18+
use super::APP_IDENTIFIER;
19+
1520
const RUN_KEY: &str = r"Software\Microsoft\Windows\CurrentVersion\Run";
16-
const VALUE_NAME: &str = "com.wandergame.sbox";
1721

1822
struct RegKey(HKEY);
1923

@@ -83,7 +87,7 @@ mod imp {
8387
let Some(key) = open_run_key_for_read()? else {
8488
return Ok(false);
8589
};
86-
let name = to_wide(VALUE_NAME);
90+
let name = to_wide(APP_IDENTIFIER);
8791
let mut size = 0u32;
8892
let status = unsafe {
8993
RegQueryValueExW(
@@ -106,7 +110,7 @@ mod imp {
106110

107111
pub fn set_enabled(enabled: bool) -> Result<(), String> {
108112
let key = open_or_create_run_key_for_write()?;
109-
let name = to_wide(VALUE_NAME);
113+
let name = to_wide(APP_IDENTIFIER);
110114
let status = if enabled {
111115
let command = to_wide(&run_command()?);
112116
unsafe {
@@ -139,7 +143,7 @@ mod imp {
139143
path::{Path, PathBuf},
140144
};
141145

142-
const LABEL: &str = "com.wandergame.sbox";
146+
use super::APP_IDENTIFIER;
143147

144148
fn home_dir() -> Result<PathBuf, String> {
145149
env::var_os("HOME")
@@ -151,7 +155,7 @@ mod imp {
151155
Ok(home_dir()?
152156
.join("Library")
153157
.join("LaunchAgents")
154-
.join(format!("{LABEL}.plist")))
158+
.join(format!("{APP_IDENTIFIER}.plist")))
155159
}
156160

157161
fn escape_xml(value: &str) -> String {
@@ -171,7 +175,7 @@ mod imp {
171175
<plist version="1.0">
172176
<dict>
173177
<key>Label</key>
174-
<string>{LABEL}</string>
178+
<string>{APP_IDENTIFIER}</string>
175179
<key>ProgramArguments</key>
176180
<array>
177181
<string>{exe}</string>
@@ -209,7 +213,7 @@ mod imp {
209213
mod imp {
210214
use std::{env, fs, path::PathBuf};
211215

212-
const APP_ID: &str = "com.wandergame.sbox";
216+
use super::APP_IDENTIFIER;
213217

214218
fn config_home() -> Result<PathBuf, String> {
215219
if let Some(path) = env::var_os("XDG_CONFIG_HOME").filter(|value| !value.is_empty()) {
@@ -223,7 +227,7 @@ mod imp {
223227
fn desktop_path() -> Result<PathBuf, String> {
224228
Ok(config_home()?
225229
.join("autostart")
226-
.join(format!("{APP_ID}.desktop")))
230+
.join(format!("{APP_IDENTIFIER}.desktop")))
227231
}
228232

229233
fn escape_desktop_value(value: &str) -> String {

‎packages/app/src-tauri/tauri.conf.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/dev/crates/tauri-config-schema/schema.json",
33
"productName": "sbox",
44
"version": "../../../package.json",
5-
"identifier": "com.wandergame.sbox",
5+
"identifier": "com.while.sbox",
66
"build": {
77
"frontendDist": "../dist",
88
"devUrl": "http://localhost:1400",
@@ -28,6 +28,7 @@
2828
},
2929
"bundle": {
3030
"active": true,
31+
"publisher": "while",
3132
"createUpdaterArtifacts": true,
3233
"targets": ["nsis", "app", "dmg", "deb", "appimage"],
3334
"icon": [

0 commit comments

Comments
 (0)