feat: iLife798接水功能#125
Merged
Merged
Conversation
- add `DormWaterCard` to homepage small-function grid - add `DormWaterWindow` as placeholder page - add i18n key for dorm water card title
Add complete water dispensing control flow with robust state synchronization: Features: - Start/end water dispensing via API with user feedback - Real-time device status polling (1-second interval, max 60 seconds) - Consecutive status detection (requires 3x status==99) to prevent network fluctuations from causing false "device ready" signals - Direct play/stop icon toggle on device card for better UX - Automatic state cleanup and counter reset on water operations UI/UX Improvements: - Remove modal dialog approach, now using inline card button control - Play icon → Stop icon during water dispensing - Real-time status feedback via toast notifications - Support for 3 languages with 9 new i18n strings Robustness: - Handles network interruptions gracefully (retries polling) - Mounted widget checks to prevent setState after unmount - Timeout protection (60 seconds max polling duration) - Proper state synchronization between UI and backend device status
Implement platform detection and custom User-Agent headers for all dorm water API requests to comply with backend requirements. Changes: - Add platform detection via dart:io Platform - Implement _getUserAgent() method with platform-specific UA strings: - iOS captcha: iLife798/3.1.1 (iPhone; iOS 26.2; Scale/3.00) - iOS others: iOS_ilife798_3.1.1 - Android all: Android_ilife798_2.0.11 - Other platforms: default to iOS UA - Add User-Agent header to all 6 API requests: - getCaptcha() - uses special captcha UA - sendSmsCode(), login(), getDeviceList() - startWater(), endWater(), checkDeviceStatus()
…agement - Integrate mobile_scanner for native QR code scanning - Implement toggleDeviceFavorite() API method in DormWaterSession - Create _QrCodeScannerPage with camera and torch toggle - Extract device ID from QR code URL format (https://i.hnkzy.com/q/1/{did}) - Add scan QR code button in AppBar (qrcode_line icon left of logout) - Auto-add scanned devices to favorites and refresh device list - Add i18n strings: scan_qr_code, device_id, add_device_failed - Support zh_CN, en_US, zh_TW languages - Lower mobile_scanner version to resolve MLKit pod conflicts
…vorites - Change _loadDevices() call to setState with removeWhere - Only remove the unfavorited device from list instead of full refresh - Keep user on the dorm water page after unfavoriting - Improve UX by avoiding unnecessary navigation
BenderBlog
reviewed
Mar 28, 2026
| super.initState(); | ||
| _session = DormWaterSession(); | ||
| _checkLoginStatus(); | ||
| _loadCaptcha(); |
Owner
There was a problem hiding this comment.
考虑把这个函数扔到 didChangeDependencies,initState 里面不要执行 setState()
BenderBlog
reviewed
Mar 28, 2026
| } | ||
|
|
||
| // Format: https://i.hnkzy.com/q/1/{did} | ||
| String deviceId = text; |
- Move `_loadCaptcha` from `initState` to `didChangeDependencies` to follow lifecycle best practices. - Add domain validation for `hnkzy.com` in QR code scanner to prevent processing invalid links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动预览
核心改动:
lib/page/dorm_water/dorm_water_window.dartlib/repository/dorm_water_session.dartlib/page/homepage/toolbox/dorm_water_card.dartlib/repository/preference.dartzh_CN.yamlzh_TW.yamlen_US.yamllib/repository/preference.dart页面设计
lib/page/dorm_water/dorm_water_window.dart1) 登录页(宿舍水机)
发送短信码+登录2) 设备列表页
mobile_scanner)3) 扫码页
mobile_scanner实时扫码API
lib/repository/dorm_water_session.dartBase URL:
https://i.ilife798.com接口划分:
GET /api/v1/captcha/->getCaptcha()POST /api/v1/acc/login/code->sendSmsCode()POST /api/v1/acc/login->login()GET /api/v1/ui/app/master->getDeviceList()GET /api/v1/dev/favo->toggleDeviceFavorite()GET /api/v1/dev/start->startWater()GET /api/v1/dev/end->endWater()GET /api/v1/ui/app/dev/status->checkDeviceStatus()鉴权与会话:
token/uid/eid->preference.dartAuthorization: tokensession(_currentSessionId)平台兼容:
User-Agent,适配 Android / iOS 请求特征。功能设计
主流程
状态轮询策略
位置:
lib/page/dorm_water/dorm_water_window.dart策略说明:
99才判定真正结束,降低瞬时抖动误判i18n
dorm_water.*全量文案键(中简/中繁/英文)homepage.toolbox.dorm_water