mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-11 10:43:31 +02:00
Revert "chore(deps) Update dependency @types/imagemin to v8 (#2635)"
This reverts commit c0285e873d.
This commit is contained in:
committed by
Lucas Nogueira
parent
c0285e873d
commit
ca30dbe2cc
@@ -17,7 +17,7 @@
|
||||
"svelte": "3.35.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "../../tooling/api/dist",
|
||||
"@tauri-apps/api": "link:../../tooling/api/dist",
|
||||
"hotkeys-js": "^3.8.5",
|
||||
"sirv-cli": "1.0.11"
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
445
examples/api/src-tauri/Cargo.lock
generated
445
examples/api/src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,9 @@ use std::path::PathBuf;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::{
|
||||
api::dialog::ask, http::ResponseBuilder, CustomMenuItem, Event, GlobalShortcutManager, Manager,
|
||||
SystemTray, SystemTrayEvent, SystemTrayMenu, WindowBuilder, WindowUrl,
|
||||
api::dialog::ask, async_runtime, http::ResponseBuilder, CustomMenuItem, Event,
|
||||
GlobalShortcutManager, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu, WindowBuilder,
|
||||
WindowUrl,
|
||||
};
|
||||
|
||||
#[derive(Serialize)]
|
||||
@@ -196,14 +197,18 @@ fn main() {
|
||||
// Application is ready (triggered only once)
|
||||
Event::Ready => {
|
||||
let app_handle = app_handle.clone();
|
||||
app_handle
|
||||
.global_shortcut_manager()
|
||||
.register("CmdOrCtrl+1", move || {
|
||||
let app_handle = app_handle.clone();
|
||||
let window = app_handle.get_window("main").unwrap();
|
||||
window.set_title("New title!").unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
// launch a new thread so it doesnt block any channel
|
||||
async_runtime::spawn(async move {
|
||||
let app_handle = app_handle.clone();
|
||||
app_handle
|
||||
.global_shortcut_manager()
|
||||
.register("CmdOrCtrl+1", move || {
|
||||
let app_handle = app_handle.clone();
|
||||
let window = app_handle.get_window("main").unwrap();
|
||||
window.set_title("New title!").unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
// Triggered when a window is trying to close
|
||||
@@ -213,19 +218,20 @@ fn main() {
|
||||
// use the exposed close api, and prevent the event loop to close
|
||||
api.prevent_close();
|
||||
// ask the user if he wants to quit
|
||||
ask(
|
||||
Some(&window),
|
||||
"Tauri API",
|
||||
"Are you sure that you want to close this window?",
|
||||
move |answer| {
|
||||
if answer {
|
||||
// .close() cannot be called on the main thread
|
||||
std::thread::spawn(move || {
|
||||
// we need to run this on another thread because this is the event loop callback handler
|
||||
// and the dialog API needs to communicate with the event loop.
|
||||
std::thread::spawn(move || {
|
||||
ask(
|
||||
Some(&window),
|
||||
"Tauri API",
|
||||
"Are you sure that you want to close this window?",
|
||||
move |answer| {
|
||||
if answer {
|
||||
app_handle.get_window(&label).unwrap().close().unwrap();
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Keep the event loop running even if all windows are closed
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"build": {
|
||||
"distDir": "../public",
|
||||
"devPath": "http://localhost:5000",
|
||||
"devPath": "../public",
|
||||
"beforeDevCommand": "yarn dev",
|
||||
"beforeBuildCommand": "yarn build"
|
||||
},
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script>
|
||||
import { appWindow, WebviewWindow, LogicalSize, LogicalPosition, UserAttentionType, PhysicalSize, PhysicalPosition } from "@tauri-apps/api/window";
|
||||
import { appWindow, WebviewWindow, LogicalSize, LogicalPosition, UserAttentionType, getCurrent } from "@tauri-apps/api/window";
|
||||
import { open as openDialog } from "@tauri-apps/api/dialog";
|
||||
import { open } from "@tauri-apps/api/shell";
|
||||
|
||||
window.UserAttentionType = UserAttentionType;
|
||||
let selectedWindow = appWindow.label;
|
||||
let selectedWindow = getCurrent().label;
|
||||
const windowMap = {
|
||||
[selectedWindow]: appWindow
|
||||
}
|
||||
@@ -26,13 +26,6 @@
|
||||
let maxHeight = null;
|
||||
let x = 100;
|
||||
let y = 100;
|
||||
let scaleFactor = 1;
|
||||
let innerPosition = new PhysicalPosition(x, y);
|
||||
let outerPosition = new PhysicalPosition(x, y);
|
||||
let innerSize = new PhysicalSize(width, height);
|
||||
let outerSize = new PhysicalSize(width, height);
|
||||
let resizeEventUnlisten;
|
||||
let moveEventUnlisten;
|
||||
|
||||
let windowTitle = "Awesome Tauri Example!";
|
||||
|
||||
@@ -69,39 +62,6 @@
|
||||
})
|
||||
}
|
||||
|
||||
function handleWindowResize() {
|
||||
windowMap[selectedWindow].innerSize().then(response => {
|
||||
innerSize = response
|
||||
width = innerSize.width
|
||||
height = innerSize.height
|
||||
});
|
||||
windowMap[selectedWindow].outerSize().then(response => {
|
||||
outerSize = response
|
||||
});
|
||||
}
|
||||
|
||||
function handleWindowMove() {
|
||||
windowMap[selectedWindow].innerPosition().then(response => {
|
||||
innerPosition = response
|
||||
});
|
||||
windowMap[selectedWindow].outerPosition().then(response => {
|
||||
outerPosition = response
|
||||
x = outerPosition.x
|
||||
y = outerPosition.y
|
||||
});
|
||||
}
|
||||
|
||||
function addWindowEventListeners(window) {
|
||||
if (resizeEventUnlisten) {
|
||||
resizeEventUnlisten();
|
||||
}
|
||||
if(moveEventUnlisten) {
|
||||
moveEventUnlisten();
|
||||
}
|
||||
moveEventUnlisten = window.listen('tauri://move', handleWindowMove);
|
||||
resizeEventUnlisten = window.listen('tauri://resize', handleWindowResize);
|
||||
}
|
||||
|
||||
async function requestUserAttention_() {
|
||||
await windowMap[selectedWindow].minimize();
|
||||
await windowMap[selectedWindow].requestUserAttention(UserAttentionType.Critical);
|
||||
@@ -119,8 +79,6 @@
|
||||
$: minWidth && minHeight ? windowMap[selectedWindow].setMinSize(new LogicalSize(minWidth, minHeight)) : windowMap[selectedWindow].setMinSize(null);
|
||||
$: maxWidth && maxHeight ? windowMap[selectedWindow].setMaxSize(new LogicalSize(maxWidth, maxHeight)) : windowMap[selectedWindow].setMaxSize(null);
|
||||
$: windowMap[selectedWindow].setPosition(new LogicalPosition(x, y));
|
||||
$: windowMap[selectedWindow].scaleFactor().then(factor => scaleFactor = factor);
|
||||
$: addWindowEventListeners(windowMap[selectedWindow]);
|
||||
</script>
|
||||
|
||||
<div class="flex col">
|
||||
@@ -213,56 +171,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="flex">
|
||||
<div class="grow window-property">
|
||||
<div>Inner Size</div>
|
||||
<span>Width: {innerSize.width}</span>
|
||||
<span>Height: {innerSize.height}</span>
|
||||
</div>
|
||||
<div class="grow window-property">
|
||||
<div>Outer Size</div>
|
||||
<span>Width: {outerSize.width}</span>
|
||||
<span>Height: {outerSize.height}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="grow window-property">
|
||||
<div>Inner Logical Size</div>
|
||||
<span>Width: {innerSize.toLogical(scaleFactor).width}</span>
|
||||
<span>Height: {innerSize.toLogical(scaleFactor).height}</span>
|
||||
</div>
|
||||
<div class="grow window-property">
|
||||
<div>Outer Logical Size</div>
|
||||
<span>Width: {outerSize.toLogical(scaleFactor).width}</span>
|
||||
<span>Height: {outerSize.toLogical(scaleFactor).height}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="grow window-property">
|
||||
<div>Inner Position</div>
|
||||
<span>x: {innerPosition.x}</span>
|
||||
<span>y: {innerPosition.y}</span>
|
||||
</div>
|
||||
<div class="grow window-property">
|
||||
<div>Outer Position</div>
|
||||
<span>x: {outerPosition.x}</span>
|
||||
<span>y: {outerPosition.y}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="grow window-property">
|
||||
<div>Inner Logical Position</div>
|
||||
<span>x: {innerPosition.toLogical(scaleFactor).x}</span>
|
||||
<span>y: {innerPosition.toLogical(scaleFactor).y}</span>
|
||||
</div>
|
||||
<div class="grow window-property">
|
||||
<div>Outer Logical Position</div>
|
||||
<span>x: {outerPosition.toLogical(scaleFactor).x}</span>
|
||||
<span>y: {outerPosition.toLogical(scaleFactor).y}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form style="margin-top: 24px" on:submit|preventDefault={setTitle_}>
|
||||
<input id="title" bind:value={windowTitle} />
|
||||
<button class="button" type="submit">Set title</button>
|
||||
@@ -286,11 +194,4 @@
|
||||
.window-controls input {
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.window-property {
|
||||
margin-top: 12px;
|
||||
}
|
||||
.window-property span {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
estree-walker "^1.0.1"
|
||||
picomatch "^2.2.2"
|
||||
|
||||
"@tauri-apps/api@../../tooling/api/dist":
|
||||
version "1.0.0-beta.7"
|
||||
"@tauri-apps/api@link:../../tooling/api/dist":
|
||||
version "0.0.0"
|
||||
|
||||
"@types/estree@*":
|
||||
version "0.0.46"
|
||||
|
||||
Reference in New Issue
Block a user