feat: initialize Tauri application with Preact framework
- Added main application logic in `src-tauri/src/lib.rs` and `src-tauri/src/main.rs`. - Configured Tauri settings in `tauri.conf.json`. - Created basic styling in `src/App.css`. - Implemented main application component in `src/App.tsx` with greeting functionality. - Included Preact logo in `src/assets/preact.svg`. - Set up rendering in `src/main.tsx`. - Defined TypeScript environment in `vite-env.d.ts` and configured TypeScript settings in `tsconfig.json` and `tsconfig.node.json`. - Configured Vite for Tauri development in `vite.config.ts`.
This commit is contained in:
1 parent
08e154894a
commit
a2a512d41d
9 files changed
+145
No files matched your search
+23
@@ -1,3 +1,4 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
# Dependências
|
# Dependências
|
||||||
node_modules/
|
node_modules/
|
||||||
.pnp
|
.pnp
|
||||||
@@ -51,6 +52,10 @@ models/
|
|||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs/
|
logs/
|
||||||
|
=======
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
*.log
|
*.log
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
@@ -58,6 +63,7 @@ yarn-error.log*
|
|||||||
pnpm-debug.log*
|
pnpm-debug.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
# IDEs e editores
|
# IDEs e editores
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
@@ -97,3 +103,20 @@ src-tauri/WixTools/
|
|||||||
*.temp
|
*.temp
|
||||||
*.bak
|
*.bak
|
||||||
*.backup
|
*.backup
|
||||||
|
=======
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
@@ -4,16 +4,20 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
<<<<<<< HEAD
|
||||||
"dev:ui": "vite",
|
"dev:ui": "vite",
|
||||||
"install:python-deps": "node scripts/install-python-deps.js",
|
"install:python-deps": "node scripts/install-python-deps.js",
|
||||||
"compile:sidecar": "python compile_sidecar.py",
|
"compile:sidecar": "python compile_sidecar.py",
|
||||||
"predev": "pnpm install:python-deps && pnpm compile:sidecar",
|
"predev": "pnpm install:python-deps && pnpm compile:sidecar",
|
||||||
|
=======
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
<<<<<<< HEAD
|
||||||
"@emotion/react": "^11.14.0",
|
"@emotion/react": "^11.14.0",
|
||||||
"@emotion/styled": "^11.14.1",
|
"@emotion/styled": "^11.14.1",
|
||||||
"@fontsource-variable/open-sans": "^5.2.7",
|
"@fontsource-variable/open-sans": "^5.2.7",
|
||||||
@@ -36,5 +40,16 @@
|
|||||||
"tailwindcss": "^4.1.18",
|
"tailwindcss": "^4.1.18",
|
||||||
"typescript": "~5.6.2",
|
"typescript": "~5.6.2",
|
||||||
"vite": "^6.0.3"
|
"vite": "^6.0.3"
|
||||||
|
=======
|
||||||
|
"preact": "^10.25.1",
|
||||||
|
"@tauri-apps/api": "^2",
|
||||||
|
"@tauri-apps/plugin-opener": "^2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@preact/preset-vite": "^2.9.3",
|
||||||
|
"typescript": "~5.6.2",
|
||||||
|
"vite": "^6.0.3",
|
||||||
|
"@tauri-apps/cli": "^2"
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,10 @@ tauri-build = { version = "2", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2", features = [] }
|
tauri = { version = "2", features = [] }
|
||||||
tauri-plugin-opener = "2"
|
tauri-plugin-opener = "2"
|
||||||
|
<<<<<<< HEAD
|
||||||
tauri-plugin-shell = "2"
|
tauri-plugin-shell = "2"
|
||||||
|
=======
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
{
|
{
|
||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
|
<<<<<<< HEAD
|
||||||
"identifier": "main-capability",
|
"identifier": "main-capability",
|
||||||
|
=======
|
||||||
|
"identifier": "default",
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
"description": "Capability for the main window",
|
"description": "Capability for the main window",
|
||||||
"windows": ["main"],
|
"windows": ["main"],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
|
<<<<<<< HEAD
|
||||||
"opener:default",
|
"opener:default",
|
||||||
{
|
{
|
||||||
"identifier": "shell:allow-execute",
|
"identifier": "shell:allow-execute",
|
||||||
@@ -15,5 +20,8 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
"opener:default"
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||||
|
<<<<<<< HEAD
|
||||||
use tauri_plugin_shell::ShellExt;
|
use tauri_plugin_shell::ShellExt;
|
||||||
use tauri_plugin_shell::process::CommandEvent;
|
use tauri_plugin_shell::process::CommandEvent;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -7,6 +8,8 @@ struct AppState {
|
|||||||
child_process: Arc<Mutex<Option<tauri_plugin_shell::process::CommandChild>>>,
|
child_process: Arc<Mutex<Option<tauri_plugin_shell::process::CommandChild>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn greet(name: &str) -> String {
|
fn greet(name: &str) -> String {
|
||||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||||
@@ -14,6 +17,7 @@ fn greet(name: &str) -> String {
|
|||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
|
<<<<<<< HEAD
|
||||||
let child_process = Arc::new(Mutex::new(Option::<tauri_plugin_shell::process::CommandChild>::None));
|
let child_process = Arc::new(Mutex::new(Option::<tauri_plugin_shell::process::CommandChild>::None));
|
||||||
let child_process_clone = Arc::clone(&child_process);
|
let child_process_clone = Arc::clone(&child_process);
|
||||||
|
|
||||||
@@ -66,6 +70,11 @@ pub fn run() {
|
|||||||
println!("[System]: Encerrando Backend...");
|
println!("[System]: Encerrando Backend...");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
=======
|
||||||
|
tauri::Builder::default()
|
||||||
|
.plugin(tauri_plugin_opener::init())
|
||||||
|
.invoke_handler(tauri::generate_handler![greet])
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
@@ -2,19 +2,43 @@
|
|||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "localaiapp",
|
"productName": "localaiapp",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
|
<<<<<<< HEAD
|
||||||
"identifier": "com.evandrodevbr.app",
|
"identifier": "com.evandrodevbr.app",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm predev && pnpm dev",
|
"beforeDevCommand": "pnpm predev && pnpm dev",
|
||||||
|
=======
|
||||||
|
"identifier": "evandrodevbr",
|
||||||
|
"build": {
|
||||||
|
"beforeDevCommand": "pnpm dev",
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
"devUrl": "http://localhost:1420",
|
"devUrl": "http://localhost:1420",
|
||||||
"beforeBuildCommand": "pnpm build",
|
"beforeBuildCommand": "pnpm build",
|
||||||
"frontendDist": "../dist"
|
"frontendDist": "../dist"
|
||||||
},
|
},
|
||||||
|
<<<<<<< HEAD
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"targets": "all",
|
"targets": "all",
|
||||||
"externalBin": [
|
"externalBin": [
|
||||||
"binaries/engine-backend"
|
"binaries/engine-backend"
|
||||||
],
|
],
|
||||||
|
=======
|
||||||
|
"app": {
|
||||||
|
"windows": [
|
||||||
|
{
|
||||||
|
"title": "localaiapp",
|
||||||
|
"width": 800,
|
||||||
|
"height": 600
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"security": {
|
||||||
|
"csp": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bundle": {
|
||||||
|
"active": true,
|
||||||
|
"targets": "all",
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/32x32.png",
|
"icons/32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/128x128.png",
|
||||||
@@ -22,6 +46,7 @@
|
|||||||
"icons/icon.icns",
|
"icons/icon.icns",
|
||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
]
|
]
|
||||||
|
<<<<<<< HEAD
|
||||||
},
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"windows": [
|
"windows": [
|
||||||
@@ -34,5 +59,7 @@
|
|||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
.logo.vite:hover {
|
.logo.vite:hover {
|
||||||
filter: drop-shadow(0 0 2em #747bff);
|
filter: drop-shadow(0 0 2em #747bff);
|
||||||
}
|
}
|
||||||
|
|||||||
+54
@@ -1,3 +1,4 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
import "@fontsource/inter";
|
import "@fontsource/inter";
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import {
|
||||||
@@ -294,3 +295,56 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
import { useState } from "preact/hooks";
|
||||||
|
import preactLogo from "./assets/preact.svg";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
import "./App.css";
|
||||||
|
|
||||||
|
function App() {
|
||||||
|
const [greetMsg, setGreetMsg] = useState("");
|
||||||
|
const [name, setName] = useState("");
|
||||||
|
|
||||||
|
async function greet() {
|
||||||
|
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||||
|
setGreetMsg(await invoke("greet", { name }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main class="container">
|
||||||
|
<h1>Welcome to Tauri + Preact</h1>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<a href="https://vite.dev" target="_blank">
|
||||||
|
<img src="/vite.svg" class="logo vite" alt="Vite logo" />
|
||||||
|
</a>
|
||||||
|
<a href="https://tauri.app" target="_blank">
|
||||||
|
<img src="/tauri.svg" class="logo tauri" alt="Tauri logo" />
|
||||||
|
</a>
|
||||||
|
<a href="https://preactjs.com" target="_blank">
|
||||||
|
<img src={preactLogo} class="logo preact" alt="Preact logo" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<p>Click on the Tauri, Vite, and Preact logos to learn more.</p>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="row"
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
greet();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
id="greet-input"
|
||||||
|
onInput={(e) => setName(e.currentTarget.value)}
|
||||||
|
placeholder="Enter a name..."
|
||||||
|
/>
|
||||||
|
<button type="submit">Greet</button>
|
||||||
|
</form>
|
||||||
|
<p>{greetMsg}</p>
|
||||||
|
</main>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
import { render } from "preact";
|
import { render } from "preact";
|
||||||
|
<<<<<<< HEAD
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
=======
|
||||||
|
>>>>>>> ce33464 (feat: initialize Tauri application with Preact framework)
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
|
|
||||||
render(<App />, document.getElementById("root")!);
|
render(<App />, document.getElementById("root")!);
|
||||||
Reference in new issue
Block a user