fix(market-ranking): 持久化展开状态
This commit is contained in:
@@ -15,14 +15,13 @@ import { formatGreatNumber, formatPercent, riseFallColor } from '../common/Numbe
|
|||||||
import { AllCardsCard } from '../node/model/AiDiagnosisNodeModel';
|
import { AllCardsCard } from '../node/model/AiDiagnosisNodeModel';
|
||||||
import { PERIOD_RANGES, TAB_METRICS } from './MarketRankingConstant';
|
import { PERIOD_RANGES, TAB_METRICS } from './MarketRankingConstant';
|
||||||
import { enableDarkMode } from '@kernel/theme_manager';
|
import { enableDarkMode } from '@kernel/theme_manager';
|
||||||
import { EmitterConstants, GlobalContext, jumpToQuote } from 'biz_common';
|
import { EmitterConstants, GlobalContext, jumpToQuote, PreferenceService } from 'biz_common';
|
||||||
import { RouterUtil } from '../util/RouterUtil';
|
import { RouterUtil } from '../util/RouterUtil';
|
||||||
|
|
||||||
const NORMAL_SIZE = 3;
|
const NORMAL_SIZE = 3;
|
||||||
const MAX_SIZE = 5;
|
const MAX_SIZE = 5;
|
||||||
const UNFOLDED_STORAGE_KEY = 'firstPageMarketRankingUnfolded';
|
const SP_FILE_NAME_FIRST_PAGE_MARKET_RANKING = 'sp_file_name_first_page_market_ranking';
|
||||||
|
const SP_KEY_FIRST_PAGE_MARKET_RANKING_EXPAND = 'sp_key_first_page_market_ranking_expand';
|
||||||
PersistentStorage.persistProp<boolean>(UNFOLDED_STORAGE_KEY, false);
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
export struct MarketRankingNodeComponent {
|
export struct MarketRankingNodeComponent {
|
||||||
@@ -42,7 +41,7 @@ export struct MarketRankingNodeComponent {
|
|||||||
// Tab 与展开状态
|
// Tab 与展开状态
|
||||||
@State primaryIdx: number = 0;
|
@State primaryIdx: number = 0;
|
||||||
@State secondaryIdx: number = 0;
|
@State secondaryIdx: number = 0;
|
||||||
@StorageLink(UNFOLDED_STORAGE_KEY) unfolded: boolean = false;
|
@State unfolded: boolean = false;
|
||||||
|
|
||||||
// Tab 滚动区域状态
|
// Tab 滚动区域状态
|
||||||
@State tabViewportWidth: number = 0;
|
@State tabViewportWidth: number = 0;
|
||||||
@@ -75,6 +74,11 @@ export struct MarketRankingNodeComponent {
|
|||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
this.isComponentActive = true;
|
this.isComponentActive = true;
|
||||||
|
this.unfolded = PreferenceService.getBooleanValueSync(
|
||||||
|
SP_FILE_NAME_FIRST_PAGE_MARKET_RANKING,
|
||||||
|
SP_KEY_FIRST_PAGE_MARKET_RANKING_EXPAND,
|
||||||
|
false,
|
||||||
|
);
|
||||||
this.updateCardConfig();
|
this.updateCardConfig();
|
||||||
if (this.firstPageVisible) {
|
if (this.firstPageVisible) {
|
||||||
this.subscribeTcpNetStatus();
|
this.subscribeTcpNetStatus();
|
||||||
@@ -642,6 +646,12 @@ export struct MarketRankingNodeComponent {
|
|||||||
|
|
||||||
private toggleUnfolded(): void {
|
private toggleUnfolded(): void {
|
||||||
this.unfolded = !this.unfolded;
|
this.unfolded = !this.unfolded;
|
||||||
|
PreferenceService.putVal(
|
||||||
|
SP_FILE_NAME_FIRST_PAGE_MARKET_RANKING,
|
||||||
|
SP_KEY_FIRST_PAGE_MARKET_RANKING_EXPAND,
|
||||||
|
this.unfolded,
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private showTabGradient(): boolean {
|
private showTabGradient(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user