CLAUDE.md 5.1 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

椤圭洰姒傝堪

YZWater3 鏄壃宸炴棴杞╃鎶鏈夐檺鍏徃寮鍙戠殑璺ㄥ钩鍙版薄姘村鐞嗗巶鐩戞帶绯荤粺锛屽熀浜 Avalonia UI 12 + .NET 8锛屾敮鎸 Windows/Linux/macOS銆

甯哥敤鍛戒护

# 杩樺師渚濊禆
dotnet restore

# 鏋勫缓
dotnet build

# 杩愯锛堥粯璁や粠 src/YZWater.Avalonia 鍚姩锛
dotnet run --project src/YZWater.Avalonia

# 鍙戝竷鍗曟枃浠讹紙Windows锛
dotnet publish src/YZWater.Avalonia -c Release -r win-x64 --self-contained -p:PublishSingleFile=true

椤圭洰缁撴瀯

涓や釜椤圭洰锛孉valonia 渚濊禆 Core锛

YZWater3.sln
src/
鈹溾攢鈹 YZWater.Core/           # 鏍稿績涓氬姟閫昏緫锛圲I 鏃犲叧锛
鈹   鈹溾攢鈹 Models/             # 鏁版嵁妯″瀷锛圫qlSugar ORM锛
鈹   鈹溾攢鈹 Services/           # 鎵鏈変笟鍔℃湇鍔★紙鍗曚緥妯″紡涓轰富锛
鈹   鈹溾攢鈹 ViewModels/         # CommunityToolkit.Mvvm ViewModel
鈹   鈹斺攢鈹 Utils/              # WinSize銆丷esolutionManager
鈹
鈹斺攢鈹 YZWater.Avalonia/       # UI 灞
    鈹溾攢鈹 Views/              # AXAML 瑙嗗浘锛圴iewA~ViewF + Login + Main锛
    鈹溾攢鈹 Controls/           # 鑷畾涔夊伐涓氭帶浠 + ThemeHelper
    鈹溾攢鈹 Themes/             # IndustrialTheme / IndustrialThemeLight / IndustrialStyles
    鈹溾攢鈹 Converters/
    鈹斺攢鈹 Services/

鍏抽敭鏋舵瀯

杩愯妯″紡锛堥氳繃 yzwater-config.jsonRunMode 閰嶇疆锛

妯″紡 琛屼负
Direct 鐩磋繛 PLC锛堥粯璁わ級
Server 杩 PLC + 鍚姩 WebSocket 鏈嶅姟绔紙HubServer锛岀鍙 8765锛
Client 杩炴帴 WebSocket 鏈嶅姟绔帴鏀舵暟鎹紝涓嶇洿杩 PLC
Mock 鏃 PLC 鏃朵娇鐢 MockPlcService 鐢熸垚妯℃嫙鏁版嵁

鏈嶅姟灞傦紙YZWater.Core/Services锛

  • 鍗曚緥鏈嶅姟锛堥渶 ResetInstance() 鍚庨噸寤猴紝鐢ㄤ簬鐧诲嚭/閲嶇櫥褰曪級锛PlcPollingServiceAlarmService
  • 闈欐佹湇鍔PlcService锛圚slCommunication 瑗块棬瀛 S7锛夈ConfigService锛圝SON 閰嶇疆锛夈DatabaseService锛圫qlSugar + SQLite锛夈AuthServiceMockPlcService
  • HubServer / HubClient锛歐ebSocket 涓帶閫氫俊锛屾敮鎸佹搷浣滈攣銆佽繙绋嬪懡浠わ紙start_pump/stop_pump
  • PlcConfig锛氭墍鏈 PLC 鍦板潃鏄犲皠闆嗕腑绠$悊锛屾敮鎸侀厤缃枃浠惰鐩

鍚姩娴佺▼锛圓pp.axaml.cs锛

LogService.Initialize() 鈫 DatabaseService.Initialize() 鈫 鍔犺浇涓婚/璇█/PLC閰嶇疆
  鈫 ShowLoginWindow 鈫 [鐧诲綍鎴愬姛] 鈫 StartServices() 鈫 ShowMainWindow()

StartServices() 鏍规嵁 RunMode 閫夋嫨 Direct/Server/Client锛屽潎浼氳皟鐢 StartPlcServices() 鍚姩 PlcPolling + Alarm + DataLogging銆

涓婚绯荤粺

鍙屼富棰橀氳繃 ResourceInclude 鍒囨崲 Application.Resources.MergedDictionaries

  • Themes/IndustrialTheme.axaml锛堟繁鑹诧級
  • Themes/IndustrialThemeLight.axaml锛堟祬鑹诧級

鑷畾涔夋帶浠DynamicResource锛岃屾槸璁㈤槄 ThemeHelper.ThemeChanged 浜嬩欢鍚庤皟鐢 InvalidateVisual() 閲嶇粯銆ThemeHelper 鍐呴儴鐢ㄩ潤鎬 IBrush 灞炴х紦瀛樺綋鍓嶄富棰橀鑹诧紝渚 Render() 鏂规硶鐩存帴璇诲彇銆

鑷畾涔夊伐涓氭帶浠讹紙YZWater.Avalonia/Controls锛

鍏ㄩ儴缁ф壙 Control 骞堕噸鍐 Render(DrawingContext)锛屼娇鐢 AffectsRender<> 澹版槑瑙﹀彂閲嶇粯鐨勫睘鎬э細

  • WaterTankControl - 姘寸娑蹭綅
  • PumpControl - 娉碉紙甯︽棆杞姩鐢伙紝OnAttachedToVisualTree 鍚姩 DispatcherTimer锛
  • FanControl - 椋庢墖锛堝悓涓婏級
  • PipeLineControl - 绠¢亾锛堣櫄绾挎祦鍔ㄥ姩鐢伙級
  • ValveControl - 闃闂紙涓夋侊級
  • GaugeControl - 浠〃
  • StatusCard - 鐘舵佸崱鐗

MVVM 绾﹀畾

  • ViewModel 缁ф壙 ObservableObject锛屼娇鐢 [ObservableProperty][RelayCommand]锛圕ommunityToolkit.Mvvm 婧愮敓鎴愬櫒锛
  • View 鍜 ViewModel 鍦 App.axaml.csMainViewModel 涓氳繃 DataContext 缁戝畾
  • MainViewModel 鎸佹湁鎵鏈夊瓙 ViewModel 瀹炰緥锛岄氳繃 CurrentView 灞炴у垏鎹 Tab

鏁版嵁搴

  • ORM锛歋qlSugar锛堜笉鏄 README 涓彁鍒扮殑 FreeSql锛屽凡杩佺Щ锛
  • 鏂囦欢锛yzwater.db锛圫QLite锛
  • 鍒濆鍖栵細DatabaseService.Initialize() 涓愪釜寤鸿〃锛屽崟琛ㄥけ璐ヤ笉褰卞搷鍏朵粬琛
  • 琛細users, alarm_records, flow_records, analog_records, audit_logs, persons, equipment_statuses

璁よ瘉

AuthService 绠$悊鐧诲綍鐘舵侊紝鏀寔 4 绉嶈鑹诧紙Viewer / Operator / Engineer / Admin锛夈傞娆″惎鍔ㄨ嚜鍔ㄥ垱寤洪粯璁 admin 璐︽埛锛坅dmin/admin123锛夈傜櫥鍑烘椂閫氳繃 UserLoggedOut 浜嬩欢瑙﹀彂 StopServices() 骞堕噸鏂版樉绀虹櫥褰曠獥鍙c

鑷傚簲甯冨眬

AdaptiveContainer 鎺т欢瀹炵幇绛夋瘮缂╂斁锛岃璁″熀鍑 1280脳800锛岀缉鏀捐寖鍥 0.6x鈥1.5x銆

閰嶇疆鏂囦欢

yzwater-config.json锛堟牴鐩綍锛岃 .gitignore 鎺掗櫎锛夛細

  • PLC 杩炴帴锛PlcIp, PlcPort, AutoConnect
  • 鎶ヨ闃堝硷細LevelHighAlarm, LevelLowAlarm, FlowHighAlarm, FlowLowAlarm
  • 涓帶锛RunMode, HubPort, HubServerUrl, HubToken
  • 涓婚/璇█锛IsDarkTheme, IsChinese
  • PLC 鍦板潃瑕嗙洊锛PlcAddresses锛圖ictionary锛宬ey 涓 PlcConfig 涓殑鏍囩鍚嶏級
  • 鏃ュ織

    Serilog 杈撳嚭鍒 Logs/log-{date}.txt锛堟寜澶╂粴鍔級鍜屾帶鍒跺彴銆傚穿婧冩棩蹇楀啓鍏ユ牴鐩綍 crash.log