-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
166 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Tauri + Vue + Typescript App</title> | ||
</head> | ||
|
||
<body> | ||
<div id="file"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use tauri::Manager; | ||
use window_shadows::set_shadow; | ||
|
||
use crate::{error::BackendError, Response}; | ||
|
||
#[tauri::command] | ||
pub async fn open_file_dialog(handle: tauri::AppHandle) -> Result<Response, BackendError> { | ||
let dialog = tauri::WindowBuilder::new(&handle, "file", tauri::WindowUrl::App("file.html".into())) | ||
.decorations(false) | ||
.build()?; | ||
|
||
set_shadow(dialog, true)?; | ||
|
||
Ok(Response { | ||
kind: "success".to_owned(), | ||
message: "Window::OpenFileDialog successful".to_owned(), | ||
}) | ||
} | ||
|
||
#[tauri::command] | ||
pub async fn close_file_dialog(handle: tauri::AppHandle) -> Result<Response, BackendError> { | ||
handle | ||
.get_window("file") | ||
.ok_or(BackendError { | ||
kind: "tauri::Error".to_owned(), | ||
message: "the window with the label `file` not found".to_owned(), | ||
})? | ||
.close()?; | ||
|
||
Ok(Response { | ||
kind: "success".to_owned(), | ||
message: "Window::CloseFileDialog successful".to_owned(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
<template> | ||
<main :data-theme="theme ? 'dark' : 'light'" class="w-screen h-screen"> | ||
<Titlebar :theme="theme" @set-theme="setTheme"></Titlebar> | ||
<button class="btn btn-primary" @click="openDialog">Open Window</button> | ||
<button class="btn btn-primary" @click="closeDialog">Close Window</button> | ||
</main> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import Titlebar from './components/Titlebar.vue'; | ||
import { onMounted, ref } from 'vue'; | ||
import { invoke } from "@tauri-apps/api/tauri"; | ||
import Titlebar from "./components/Titlebar.vue"; | ||
import { onMounted, ref } from "vue"; | ||
const theme = ref(false) | ||
const theme = ref(false); | ||
function setTheme(value: boolean) { | ||
theme.value = value | ||
if (theme.value) localStorage.setItem("theme", "dark") | ||
else localStorage.setItem("theme", "light") | ||
theme.value = value; | ||
if (theme.value) localStorage.setItem("theme", "dark"); | ||
else localStorage.setItem("theme", "light"); | ||
} | ||
function openDialog() { | ||
invoke("open_file_dialog") | ||
.then((res) => console.log(res)) | ||
.catch((err) => console.error(err)); | ||
} | ||
function closeDialog() { | ||
invoke("close_file_dialog") | ||
.then((res) => console.log(res)) | ||
.catch((err) => console.error(err)); | ||
} | ||
onMounted(() => { | ||
theme.value = localStorage.getItem("theme") === "dark" | ||
}) | ||
theme.value = localStorage.getItem("theme") === "dark"; | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<template> | ||
<main :data-theme="theme ? 'dark' : 'light'" class="w-screen h-screen"> | ||
Hello world! | ||
</main> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue'; | ||
const theme = ref(false); | ||
onMounted(() => { | ||
theme.value = localStorage.getItem("theme") === "dark"; | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { createApp } from "vue"; | ||
import App from "./App.vue"; | ||
import "./style.css" | ||
import File from "./File.vue"; | ||
import "./style.css"; | ||
|
||
createApp(App).mount("#app"); | ||
if (document.querySelector("#app")) createApp(App).mount("#app"); | ||
if (document.querySelector("#file")) createApp(File).mount("#file"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters