From 0d0df54e7f18633151789ad79d63ef9b47f68be9 Mon Sep 17 00:00:00 2001 From: zhiqizhou Date: Sun, 15 Jun 2025 16:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81LocalStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhiqizhou --- api/arkui/component/customComponent.d.ets | 9 ++++++--- api/arkui/stateManagement/decorator.d.ets | 10 +++++----- api/arkui/stateManagement/storage/localStorage.d.ets | 3 +-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/api/arkui/component/customComponent.d.ets b/api/arkui/component/customComponent.d.ets index 9df05c821c..c1e92bd751 100755 --- a/api/arkui/component/customComponent.d.ets +++ b/api/arkui/component/customComponent.d.ets @@ -20,11 +20,11 @@ -import { memo, ComponentBuilder, __memo_context_type, __memo_id_type } from "../stateManagement/runtime"; +import { memo, ComponentBuilder, __memo_context_type, __memo_id_type } from '../stateManagement/runtime'; -import { UIContext } from './../../../api/@ohos.arkui.UIContext' +import { UIContext } from './../../../api/@ohos.arkui.UIContext'; import { ExtendableComponent } from './extendableComponent'; - +import { LocalStorage } from '@ohos.arkui.stateManagement'; @Retention({policy: "SOURCE"}) export declare @interface Component { @@ -57,6 +57,7 @@ export interface CustomLayout { } export declare abstract class BaseCustomComponent extends ExtendableComponent { + public constructor(LocalStorage?: LocalStorage | undefined); } export declare abstract class CustomComponent, T_Options> extends BaseCustomComponent { @@ -69,6 +70,8 @@ export declare abstract class CustomComponent void ): S; + public constructor(LocalStorage?: LocalStorage | undefined); + // Life cycle for custom component aboutToAppear(): void aboutToDisappear(): void diff --git a/api/arkui/stateManagement/decorator.d.ets b/api/arkui/stateManagement/decorator.d.ets index fd7219e092..f30b099741 100644 --- a/api/arkui/stateManagement/decorator.d.ets +++ b/api/arkui/stateManagement/decorator.d.ets @@ -48,11 +48,6 @@ export declare @interface StorageLink { property: string; }; -@Retention({policy: "SOURCE"}) -export declare @interface LocalStorageProp { - property: string; -}; - @Retention({policy: "SOURCE"}) export declare @interface LocalStorageLink { property: string; @@ -123,6 +118,9 @@ export declare interface IObjectLinkDecoratedVariable extends IDecoratedImmut IDecoratedUpdatableVariable, IDecoratedV1Variable { } +export declare interface ILocalStorageLinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { +} + export declare interface IStorageLinkDecoratedVariable extends IDecoratedMutableVariable, IDecoratedV1Variable { } @@ -174,6 +172,8 @@ export declare interface IStateMgmtFactory { provideAlias: string, watchFunc?: WatchFuncType): IConsumeDecoratedVariable; makeObjectLink(owningView: ExtendableComponent, varName: string, initValue: T, wathcFunc?: WatchFuncType): IObjectLinkDecoratedVariable; + makeLocalStorageLink(owningView: ExtendableComponent, propName: string, + varName: string, initValue: T, watchFunc?: WatchFuncType): ILocalStorageLinkDecoratedVariable; makeStorageLink(owningView: ExtendableComponent, propName: string, varName: string, initValue: T, watchFunc?: WatchFuncType): IStorageLinkDecoratedVariable; makeStorageProp(owningView: ExtendableComponent, propName: string, diff --git a/api/arkui/stateManagement/storage/localStorage.d.ets b/api/arkui/stateManagement/storage/localStorage.d.ets index 4b9a33bab9..497aa22b8a 100644 --- a/api/arkui/stateManagement/storage/localStorage.d.ets +++ b/api/arkui/stateManagement/storage/localStorage.d.ets @@ -21,8 +21,7 @@ import { AbstractProperty, SubscribedAbstractProperty } from '../decorator'; export declare class LocalStorage { - public constructor(initializingProperties?: Object); - public static getShared(): LocalStorage | undefined; + public constructor(initializingProperties?: Record); public ref(propName: string): AbstractProperty | undefined; public setAndRef(propName: string, defaultValue: T): AbstractProperty; public link(propName: string): SubscribedAbstractProperty | undefined; -- Gitee