Files
biz_firstpage/AGENTS.md
T
clz af0025ce38 Initial commit: @b2c/first_page HarmonyOS stage-mode HAR
## Repository
- HarmonyOS stage-mode HAR module, consumed by host app
- No standalone build — hvigorw, oh_modules, and ../biz_quote absent here

## Architecture
### Feed Cards
- FirstPage.createNodeView dispatches cards by FirstPageConstant.KEY_*
- Card config from first_page_cards_config.json loaded by FirstPageCardsConfigLoader
- Public entrypoint: Index.ets

### Market Ranking (src/main/ets/market-ranking/)
- HTTP: MarketRankingDataFetcher fetches recommend_futures contracts
- HQ: MarketRankingHqRequestClient subscribes via 4106/frame 2201/scenario qht_qihuo_sort
- TCP reconnect rebuilds subscription from original HTTP contract list
- Async callbacks guarded by request/subscription versions

### Other Cards
- HotList, CommodityOptions, AiDiagnosis, AiRiseFall, SelfSelectedStock, CustomEntryList, FourEntryList
- Each has DataFetcher + HQ request client + NodeComponent

## Key Changes (from CardHarmonyOS reference)
- Added MetricId, PeriodId, SortOrder enums (MarketRankingModels.ets)
- Replaced string comparisons with enum switches in thirdColumnTitle/Value/Color
- Removed redundant undefined guards in thirdColumnColor/priceColor, delegated to riseFallColor
- Inlined priceColor(), use riseFallColor directly
- Tab bar Stack.height(30), Alignment.End (reverted from 46/TopEnd)
- Name column fontWeight removed (default regular)
2026-07-26 01:13:28 +08:00

3.2 KiB

AGENTS.md

Repository

  • This is the HarmonyOS stage-mode HAR @b2c/first_page (biz_firstpage), not a host app. The host supplies several hoisted dependencies and runtime services.
  • There is no standalone build: hvigorw, oh_modules, and the sibling ../biz_quote dependency are absent here. Do not add undeclared host dependencies or claim build/test success; verify ArkTS changes by inspection and in the host project.
  • Load the arkts-grammar-standards skill before modifying .ets files.

Wiring

  • The public package entrypoint is root Index.ets; export new host-facing symbols there.
  • FirstPage.createNodeView dispatches feed cards by FirstPageConstant.KEY_*. A new feed card needs its key, component, and dispatch branch; card metadata is normally read from src/main/resources/rawfile/first_page_cards_config.json.
  • market-ranking is a special feed card under src/main/ets/market-ranking/, inserted with KEY_MARKET_RANKING and rendered directly by FirstPage. Its config key is marketRanking, loaded by FirstPageCardsConfigLoader.

Market Ranking

  • MarketRankingDataFetcher first fetches the recommended contract list over @kit.NetworkKit; MarketRankingHqRequestClient then subscribes those contracts through the host TableRequestClient/4106 infrastructure. Do not replace either path with mock data or a second quote client.
  • MarketRankingConstant.ets is currently shared by UI, HTTP, and HQ code: TAB_METRICS/PERIOD_RANGES contain labels, HTTP parameters, and 4106 field IDs. Changing order, IDs, or child-tab semantics affects both request paths; update them together and consult doc/market-ranking-known-issues.md before refactoring.
  • HQ requests use 4106, frame 2201, scenario qht_qihuo_sort, and pushtime=2.5; subscriptions must be released on page invisibility, Tab changes, refresh, and component destruction. TCP reconnect rebuilds the subscription from the original HTTP contract list.
  • The component guards asynchronous HTTP and quote callbacks with request/subscription versions; preserve those guards when changing refresh or Tab behavior. Row clicks use host jumpToQuote() and must preserve contract, market, and name list ordering.
  • Market-ranking host integration still requires validation of 4106 field IDs, standard-price fields, HTTP environment/auth, lifecycle/reconnect behavior, and quote-page routing; see doc/market-ranking-known-issues.md.

Conventions

  • Use $r('app.color.*') and the light/dark resource qualifiers for colors; do not hardcode theme colors. Put user-facing strings in src/main/resources/{base,zh_CN,en_US}/element/string.json.
  • FirstPageDebugUtil.isMarketRankingUseTestUrl and other test URL switches default to false; leave them disabled in commits.
  • Two files are named FirstPageConstant.ets: datacenter/FirstPageConstant.ets holds KEY_* card-dispatch constants, while util/FirstPageConstant.ets only exports TITLE_BAR_HEIGHT. Import the correct one.
  • biz_quote is imported both from its package root and deep paths; preserve the existing import style when touching quote code.
  • Release builds enable ArkGuard through build-profile.json5; keep obfuscation-rules.txt and consumer-rules.txt in mind when adding public or reflective symbols.