Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.2k stars 1.89k forks source link

鸿蒙Next纯血版本如何接入mmkv? #1261

Closed ChawLoo closed 3 months ago

ChawLoo commented 4 months ago

原先想通过编译成CPP引入,但是那一块不太熟悉,原先打算用CMake编译后去接入,但是搞不明白

lingol commented 4 months ago

The official support of MMKV for OpenHarmonyOS is under construction. You can wait for it.

ChawLoo commented 4 months ago

预估多久面市?

lingol commented 4 months ago

I can't say for sure. Eventually, it should be released before the next big event of the OHOS Next.

alhah commented 4 months ago

Does the big event mean WeChat porting to OHOS?

lingol commented 4 months ago

The undergoing work can be found in the branch dev_openharmony. It's still in an early stage.

wangyatong commented 4 months ago

24年年底之前绝对上线🤪

lingol commented 4 months ago

For those who would try, it's live on OHPM. https://ohpm.openharmony.cn/#/cn/detail/@tencent%2Fmmkv wiki https://github.com/Tencent/MMKV/wiki/ohos_setup

ChawLoo commented 4 months ago

牛啊牛啊

ChawLoo commented 4 months ago

我mini m2芯片,跑的模拟器、真机跑了也有问题 image

ChawLoo commented 4 months ago

最新测试结果,真机一样有问题

pioneerz commented 4 months ago

最新测试结果,真机一样有问题

我mini m2芯片,跑的模拟器 image

image 这个限制还挺多的

ChawLoo commented 4 months ago

最新测试结果,真机一样有问题

我mini m2芯片,跑的模拟器 image

image 这个限制还挺多的

但是我满足呀,手机目前Mate 60 Pro Preview 2版本 ,模拟器也是Beta1版本 image

lingol commented 4 months ago

What's the log from hilog?

ChawLoo commented 4 months ago

What's the log from hilog?

04-19 09:06:29.479 43415-43415 A03D00/JSAPP pid-43415 I Callee constructor is OK string 04-19 09:06:29.479 43415-43415 A03D00/JSAPP pid-43415 I Ability::constructor callee is object [object Object] 04-19 09:06:29.487 43415-43415 A00000/MMKV pid-43415 I NAPI Error: code 6, msg Need number 04-19 09:06:29.499 43415-43415 A00000/testTag pid-43415 I Ability onWindowStageCreate 04-19 09:06:29.499 43415-43415 A03D00/JSAPP pid-43415 I 初始化配置缓存框架 04-19 09:06:29.501 43415-43415 A00000/testTag pid-43415 I Ability onForeground

image

lingol commented 4 months ago

I see. There's a bug in MMKV.initialize() on handling optional parameters. Will fix in the next version. For the time being, you can bypass this by passing the logLevel param:

import { MMKV, MMKVLogLevel } from '@tencent/mmkv';

let appCtx = this.context.getApplicationContext();
MMKV.initialize(appCtx, MMKVLogLevel.LevelInfo);
lingol commented 4 months ago

It's fixed in "@tencent/mmkv": "1.3.5-alpha".

lebusishu commented 4 months ago

我mini m2芯片,跑的模拟器、真机跑了也有问题 image

也遇到了,需要指定MMKVLogLevel才可以,我这样就可以了:MMKV.initializeWithPath(filePath, context.cacheDir, MMKVLogLevel.LevelInfo)

lingol commented 4 months ago

我mini m2芯片,跑的模拟器、真机跑了也有问题 image

也遇到了,需要指定MMKVLogLevel才可以,我这样就可以了:MMKV.initializeWithPath(filePath, context.cacheDir, MMKVLogLevel.LevelInfo)

Try it. It's fixed in "@tencent/mmkv": "1.3.5-alpha".

lingol commented 3 months ago

It's released in v1.3.5.