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

Javascript API monitor functions don't work #2294

Closed
woubuc opened this issue Jul 24, 2021 · 0 comments
Closed

Javascript API monitor functions don't work #2294

woubuc opened this issue Jul 24, 2021 · 0 comments

Comments

@woubuc
Copy link
Contributor

woubuc commented Jul 24, 2021

Describe the bug

In the window API, the currentMonitor(), primaryMonitor() and availableMonitors() functions don't work. They call an incorrect command from the JS side which causes an error.

To Reproduce

Steps to reproduce the behavior:

  1. In a project with the JS API enabled, use any of the above functions.
  2. See an error in the Javascript console:

unknown variant primaryMonitor, expected createWebview or manage

Additional context

These three functions are standalone functions and call a top-level Tauri command, which is expected to be a variant of the Cmd enum. But these commands are actually in the WindowManagerCmd enum and should be invoked with a window label.

So I think a fix would be to move all three of these functions into the WebviewWindow class and call them with the current window label as a window command. Unless the availableMonitors() and primaryMonitor() functions should be standalone commands, in which case the Rust side will need to be updated to accept these as a top-level command.

Platform and Versions (required):

Operating System - Windows, version 10.0.19042 X64
Webview2 - 92.0.902.55

Node.js environment
  Node.js - 14.16.0
  @tauri-apps/cli - 1.0.0-beta.6
  @tauri-apps/api - 1.0.0-beta.5

Global packages
  npm - 6.14.11
  yarn - 1.22.4

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/.idea
/.nuxt
/assets
/components
/i18n
/layouts
/mixins
/node_modules
/pages
/plugins
/src-tauri
/static
/types
/utils

App
  tauri.rs - 1.0.0-beta.5
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri:
'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:3000
  framework - Vue.js (Nuxt)
  bundler - Webpack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant