Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wx.getSystemInfo is deprecated. #16855

Closed
kirklin opened this issue Nov 12, 2024 · 1 comment
Closed

wx.getSystemInfo is deprecated. #16855

kirklin opened this issue Nov 12, 2024 · 1 comment

Comments

@kirklin
Copy link

kirklin commented Nov 12, 2024

相关平台

微信小程序

小程序基础库: 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

实际结果

控制台警告wx.getSystemInfo API废弃
QQ_1731427371214

环境信息

  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 

@TheKonka
Copy link
Member

这个是 微信官方把 getSystemInfo 这个api 拆分成了多个吧,你自己不用旧的,用新的就行,应该跟taro关系不大

@kirklin kirklin closed this as completed Nov 13, 2024
This was referenced Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants