系统信息只是待定,在 vue 中不显示任何结果

问题描述

作为我的个人项目,我想使用 Electron 和 Vue 制作一个桌面应用程序。我已经完成了所有设置并使用已经完成的 gui 完美运行,但是有一个小问题。要获取系统信息,我使用 systeminformation 并在 General.vue 文件的脚本标记调用它不起作用。

General.js

<script>
import { defineComponent } from 'vue'
import systeminformation from 'systeminformation'

export default defineComponent({
  name: 'General',mounted () {
    this.getData() // Call the function once started
  },methods: {
    getData: function () {
      console.log('test 1') // Gets printed out
      systeminformation.cpu()
        .then(data => console.log(data)) // All of these do nothing
        .catch(reason => console.log(reason))
        .finally(() => console.log('test 1.5'))
      console.log('test 2') // Gets printed out
    }
  }
})
</script>

代码应该获取有关我设备的 cpu 的所有信息,但除了测试之外,控制台中没有显示任何内容。我已经尝试在一个只使用基本 Node 的简单测试项目中运行它,并且它按预期运行。

关于为什么它在这里不起作用,我唯一的理论可能是它在 .vue 中并且离应用程序的后端部分太远了?我将非常感谢任何帮助。如果您想进行实验,这里有一个 link 项目供您克隆它。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)