Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(config): fix conflicts between development mode and installed desktop ports

hairyf33c6aa874efb
diff --git a/src-tauri/resources/dsh-win-terminal-inspector/LICENSE b/src-tauri/resources/dsh-win-terminal-inspector/LICENSE
new file mode 100644
index 00000000..e52bd125
--- /dev/null
+++ b/src-tauri/resources/dsh-win-terminal-inspector/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 clearkurt
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/src-tauri/src/config/constants.rs b/src-tauri/src/config/constants.rs
index 20521429..e7e1efdc 100644
--- a/src-tauri/src/config/constants.rs
+++ b/src-tauri/src/config/constants.rs
@@ -18,7 +18,11 @@ pub const PNPM_BASE_URL: &str = "https://registry.npmjs.org/pnpm/-/";
/// Harness 服务地址与默认端口
pub const DSH_HOST: &str = "http://127.0.0.1";
+/// 生产(release)默认端口
pub const DSH_PORT: u16 = 3080;
+/// 开发(debug)默认端口:与生产隔离,避免 `pnpm tauri dev` 与已安装桌面端
+/// 争用同一个 3080 端口冲突。
+pub const DSH_DEV_PORT: u16 = 3081;
/// 安装目录与 CLI 入口(相对安装目录)
pub const DSH_CORE_DIR: &str = "dsh";
diff --git a/src-tauri/src/config/format.rs b/src-tauri/src/config/format.rs
index c44c5a92..ab20c207 100644
--- a/src-tauri/src/config/format.rs
+++ b/src-tauri/src/config/format.rs
@@ -1,9 +1,4 @@
-use crate::config::{DSH_HOST, DSH_PORT};
-
-/// 获取 Harness 服务基础地址
-pub fn get_dsh_base_url() -> String {
- format!("{}:{}", DSH_HOST, DSH_PORT)
-}
+use crate::config::DSH_HOST;
/// 获取指定端口的 Harness 服务地址
pub fn get_dsh_service_url(port: u16) -> String {
diff --git a/src-tauri/src/config/setting.rs b/src-tauri/src/config/setting.rs
index a9cbfecc..cbb404ed 100644
--- a/src-tauri/src/config/setting.rs
+++ b/src-tauri/src/config/setting.rs
@@ -25,11 +25,20 @@ fn default_cli_link_enabled() -> bool {
true
}
+/// 默认服务端口:debug 构建与生产隔离,避免开发时与已运行的桌面端争用 3080。
+fn default_port() -> u16 {
+ if cfg!(debug_assertions) {
+ DSH_DEV_PORT
+ } else {
+ DSH_PORT
+ }
+}
+
impl Default for Setting {
fn default() -> Self {
Self {
installed: false,
- port: DSH_PORT,
+ port: default_port(),
auto_start: true,
language: "zh-CN".to_string(),
dsh_pkg_commit: None,
diff --git a/src-tauri/src/service/plugin/mod.rs b/src-tauri/src/service/plugin/mod.rs
index dc286a32..697e1875 100644
--- a/src-tauri/src/service/plugin/mod.rs
+++ b/src-tauri/src/service/plugin/mod.rs
@@ -165,7 +165,7 @@ pub async fn install(app_handle: &AppHandle, ids: &[String]) -> Result<(), Strin
// 新增/变更 bundle 需要服务重启才会加载:安装前先停掉正在运行的服务,
// 后续 launch 会以全新进程加载新插件(首次安装场景服务尚未启动,跳过)。
- if workflow::utils::is_dsh_running().await {
+ if workflow::utils::is_dsh_running(config::get_store_dat_setting(app_handle).port).await {
log::info!("Stopping running harness service before installing preinstall plugins");
if let Err(e) = workflow::stop(app_handle.clone()).await {
log::warn!("failed to stop harness before preinstall: {e}");
diff --git a/src-tauri/src/service/workflow/utils.rs b/src-tauri/src/service/workflow/utils.rs
index 56b04271..60466ad7 100644
--- a/src-tauri/src/service/workflow/utils.rs
+++ b/src-tauri/src/service/workflow/utils.rs
@@ -4,8 +4,8 @@ use std::path::PathBuf;
use std::thread;
use std::time::Duration;
-/// 检查 Harness 是否真正在运行
-pub async fn is_dsh_running() -> bool {
+/// 检查 Harness 是否真正在运行(探测指定端口,随配置端口联动)
+pub async fn is_dsh_running(port: u16) -> bool {
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(2))
.build()
@@ -17,8 +17,7 @@ pub async fn is_dsh_running() -> bool {
None => return false,
};
- use crate::config::get_dsh_base_url;
- let url = format!("{}/", get_dsh_base_url());
+ let url = format!("{}/", crate::config::get_dsh_service_url(port));
// 发送请求并判断是否就绪
let check_status = async {
diff --git a/src-tauri/src/task/tick_check_dsh_process/mod.rs b/src-tauri/src/task/tick_check_dsh_process/mod.rs
index 4577a872..811d74e0 100644
--- a/src-tauri/src/task/tick_check_dsh_process/mod.rs
+++ b/src-tauri/src/task/tick_check_dsh_process/mod.rs
@@ -10,7 +10,8 @@ use tauri::AppHandle;
pub async fn trigger(app_handle: AppHandle) -> Result<(), Box<dyn std::error::Error>> {
let current_status = status::get_status();
- let is_dsh_running = utils::is_dsh_running().await;
+ let port = crate::config::get_store_dat_setting(&app_handle).port;
+ let is_dsh_running = utils::is_dsh_running(port).await;
log::trace!("DSH status check: dsh_running={}", is_dsh_running);
// 只有当当前状态为运行中时,才更新状态