From 45a3900cc2e9f0410205efab12dc77a4da206e56 Mon Sep 17 00:00:00 2001 From: steve02081504 Date: Fri, 14 Feb 2025 01:06:44 +0800 Subject: [PATCH] fix --- assists/main.ps1 | 4 +--- base.ps1 | 10 +++++----- fount-pwsh.psd1 | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/assists/main.ps1 b/assists/main.ps1 index 6223f2a..58d9437 100644 --- a/assists/main.ps1 +++ b/assists/main.ps1 @@ -17,9 +17,7 @@ function Set-FountAssist( ) { if ($AssistCharname) { $Global:FountAssist.AssistCharname = $AssistCharname } if ($FountUsername) { $Global:FountAssist.FountUsername = $FountUsername } - if (-not (Test-FountRunning)) { - Start-Fount background keepalive runshell $Global:FountAssist.FountUsername preload chars $Global:FountAssist.AssistCharname - } + Start-Fount background keepalive runshell $Global:FountAssist.FountUsername preload chars $Global:FountAssist.AssistCharname if ($script:FountAssistInstalled) { return } if ($EshellUI) { . $PSScriptRoot/esh-assist.ps1 } else { . $PSScriptRoot/pwsh-assist.ps1 } diff --git a/base.ps1 b/base.ps1 index fdfda9e..8254097 100644 --- a/base.ps1 +++ b/base.ps1 @@ -12,14 +12,14 @@ function Set-FountClient($ComputerName = "localhost", $Port = 16698) { } } - Write-Verbose "正在尝试连接到 Fount 服务器..." - # 创建新的 TCP 客户端 - $Client = New-Object System.Net.Sockets.TcpClient - if ($Client.ConnectAsync($ComputerName, $Port).Wait(100)) { + try{ + # 创建新的 TCP 客户端 + $Client = New-Object System.Net.Sockets.TcpClient + $Client.Connect($ComputerName, $Port) Write-Verbose "成功连接到 Fount 服务器。" $script:FountClient = $Client } - else { + catch { Write-Error "无法连接到 Fount 服务器" -ErrorAction Stop } } diff --git a/fount-pwsh.psd1 b/fount-pwsh.psd1 index 871981e..1fa4c6b 100644 --- a/fount-pwsh.psd1 +++ b/fount-pwsh.psd1 @@ -12,7 +12,7 @@ RootModule = 'fount-pwsh.psm1' # Version number of this module. - ModuleVersion = '0.0.2' + ModuleVersion = '0.0.3' # ID used to uniquely identify this module GUID = '2a16dae2-91d8-4743-952c-94acd1ed7e5a'