修复错误,优化性能,实现类型系统,优化安装卸载过程

This commit is contained in:
LIm1tZz7 committed 2026-10-05 00:15:01 +08:00
1 parent fd5f320360
commit 48eec484b7
104 files changed
+4127 -845

No files matched your search

+10 -8
View File
@@ -1,6 +1,6 @@
$ErrorActionPreference = 'Stop'
# csql-web:先起独占数据目录的 server,再起 Web 服务,配置读 chusql.toml。
# csql-web:先起独占数据目录的 server,再起 Web 服务,配置读 settings.toml。
# 打印错误并退出 1。
function Fail([string]$msg) { Write-Host "!! $msg" -ForegroundColor Red; exit 1 }
@@ -11,16 +11,16 @@ $home_dir = Split-Path -Parent $MyInvocation.MyCommand.Path
$bin = Join-Path $home_dir 'bin'
$config_dir = if ($env:APPDATA) { Join-Path $env:APPDATA 'ChuSQL' } else { Join-Path $home_dir 'config' }
$config = Join-Path $config_dir 'chusql.toml'
$config = Join-Path $config_dir 'settings.toml'
if (-not (Test-Path $config)) { Fail "config not found: $config" }
# 从配置里取一个 [web] 段的值。
function Get-WebSetting([string]$Key, [string]$Default) {
# 从配置里取某个分区的一个值。
function Get-SectionSetting([string]$Section, [string]$Key, [string]$Default) {
$section = ''
$pattern = '^\s*' + [regex]::Escape($Key) + '\s*='
foreach ($raw in (Get-Content -Path $config -Encoding UTF8)) {
if ($raw -match '^\s*\[') { $section = ($raw -replace '[\[\]\s]', ''); continue }
if ($section -ne 'web') { continue }
if ($section -ne $Section) { continue }
$line = $raw -replace '#.*$', ''
if ($line -match $pattern) {
return (($line -replace '^[^=]*=\s*', '').Trim().Trim('"'))
@@ -34,9 +34,11 @@ $web_exe = Join-Path $bin 'chusql-web.exe'
if (-not (Test-Path $server_exe)) { Fail "server binary not found in $bin" }
if (-not (Test-Path $web_exe)) { Fail "web binary not found in $bin" }
$host_addr = Get-WebSetting 'host' '127.0.0.1'
$port = Get-WebSetting 'port' '7778'
$log_dir = Join-Path $home_dir 'logs'
# 监听地址与端口取 [web] 段,日志目录取 [storage] log_files(相对路径以安装目录为基准)。
$host_addr = Get-SectionSetting 'web' 'listen_host' '127.0.0.1'
$port = Get-SectionSetting 'web' 'port' '7778'
$log_setting = Get-SectionSetting 'storage' 'log_files' './logs'
$log_dir = if ([System.IO.Path]::IsPathRooted($log_setting)) { $log_setting } else { Join-Path $home_dir $log_setting }
New-Item -ItemType Directory -Force -Path $log_dir | Out-Null
$server = $null