-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Description
相关平台
微信小程序
小程序基础库: 3.6.4
使用框架: React
复现步骤
import { getSystemInfo } from "@tarojs/taro";
import { cache } from "~/cache";
/**
* 异步设置系统信息
* @param force - 是否强制获取系统信息
*/
export async function setSystemInfoAsync(force = false) {
if (force) {
// 强制获取系统信息
getSystemInfo({
success(systemInfo) {
// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
cache.set("sysInfo", systemInfo);
},
});
} else {
// 尝试从缓存中获取系统信息
const cachedSystemInfo = await cache.get("sysInfo");
if (!cachedSystemInfo) {
// 如果缓存中没有系统信息,则获取系统信息并缓存
getSystemInfo({
success(systemInfo) {
// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
cache.set("sysInfo", systemInfo);
},
});
}
}
}
期望结果
更新wx.getSystemInfo 到最新版的API
实际结果
环境信息
Taro CLI 4.0.5 environment info:
System:
OS: macOS 15.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.1.0 - /opt/homebrew/bin/node
npm: 10.9.0 - /opt/homebrew/bin/npm
npmPackages:
@tarojs/cli: 4.0.5 => 4.0.5
@tarojs/components: 4.0.5 => 4.0.5
@tarojs/helper: 4.0.5 => 4.0.5
@tarojs/plugin-framework-react: 4.0.5 => 4.0.5
@tarojs/plugin-html: ^4.0.5 => 4.0.5
@tarojs/plugin-platform-alipay: 4.0.5 => 4.0.5
@tarojs/plugin-platform-h5: 4.0.5 => 4.0.5
@tarojs/plugin-platform-harmony-hybrid: 4.0.5 => 4.0.5
@tarojs/plugin-platform-jd: 4.0.5 => 4.0.5
@tarojs/plugin-platform-qq: 4.0.5 => 4.0.5
@tarojs/plugin-platform-swan: 4.0.5 => 4.0.5
@tarojs/plugin-platform-tt: 4.0.5 => 4.0.5
@tarojs/plugin-platform-weapp: 4.0.5 => 4.0.5
@tarojs/react: 4.0.5 => 4.0.5
@tarojs/runtime: 4.0.5 => 4.0.5
@tarojs/shared: 4.0.5 => 4.0.5
@tarojs/taro: 4.0.5 => 4.0.5
@tarojs/taro-loader: 4.0.5 => 4.0.5
@tarojs/webpack5-runner: 4.0.5 => 4.0.5
babel-preset-taro: 4.0.5 => 4.0.5
eslint-config-taro: 4.0.5 => 4.0.5
react: ^18.3.1 => 18.3.1
Metadata
Metadata
Assignees
Labels
No labels
