valmisson / tauri-app-template

A template for building desktop applications with Tauri
MIT License
15 stars 0 forks source link

use only typescript, no rust? #1

Closed vanowm closed 2 years ago

vanowm commented 2 years ago

Total newbie here, trying convert from electron to tauri.

My understanding is that src-tauri is equal to main (background) and src-renderer to renderer processes in electron (that's only my deductive reasoning after attempting use examples from API in renderer:

import { appWindow } from '@tauri-apps/api/window';
console.log(appWindow);

which produces error

[plugin:vite:import-analysis] Failed to resolve import "@tauri-apps/api/window" from "src\main.ts". Does the file exist?

So if I want let's say dynamically change window title I'd need do it in the src-tauri code. I don't know rust, so I'd like to work solely with typescript, however neither the template nor any official documentation mention how to do so.

Any help on this front?

Thank you.

valmisson commented 2 years ago

You need install @tauri-apps/api

yarn add -D -W @tauri-apps/api
vanowm commented 2 years ago

Oh, thank you. Does it also mean my assumption on how this works also wrong? Like to manipulate window I can do everything from within src-renderer?

valmisson commented 2 years ago

Yes, that's correct, you can change in src-render using typescript.

Here are the functions available to handle windows