Skip to content

Commit

Permalink
Merge pull request #27 from station0x/dev
Browse files Browse the repository at this point in the history
Auto Updater
  • Loading branch information
ElRakabawi authored Dec 22, 2022
2 parents 4d42c2a + 2c97a17 commit d94b16b
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 91 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "final_cypher",
"private": true,
"version": "0.1.7",
"version": "0.1.8",
"type": "module",
"bin": "dist/server.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "final_cypher"
version = "0.1.0"
version = "0.1.8"
description = "FinalCypher Launcher"
authors = ["you"]
license = ""
Expand Down
12 changes: 11 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
windows_subsystem = "windows"
)]
use tauri::Manager;
use tauri::Size;
use tauri::SystemTray;
use tauri::{CustomMenuItem, SystemTrayMenu, SystemTrayMenuItem, SystemTrayEvent};
use std::process::Command;
// use tauri::Size::Physical;
// use std::collections::BTreeSet;
// use merkle_hash::MerkleTree;
// use merkle_hash::MerkleItem;
Expand All @@ -16,6 +18,14 @@ use std::process::Command;
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!!!!", name)
}
#[tauri::command]
fn resize(w: u32, h: u32, window: tauri::Window) -> Result<(), String> {
window.set_size(Size::Physical(tauri::PhysicalSize { width: w, height: h }))
// window.set_size(tauri:Size::Physical(()))
// window.set_size(tauri::Size::Physical(Size::Physical(()) ))
.map_err(|e| e.to_string())?;
Ok(())
}

#[tauri::command]
fn open_exe(exe_path: String, auth_token: String) -> Result<(), String> {
Expand Down Expand Up @@ -93,7 +103,7 @@ fn main() {
}
_ => {}
})
.invoke_handler(tauri::generate_handler![greet, close_splashscreen, open_exe])
.invoke_handler(tauri::generate_handler![greet, close_splashscreen, open_exe, resize])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Binary file added src/assets/img/updater.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions src/components/Titlebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div @click="minimizeWindow" class="titlebar-button" id="titlebar-minimize">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path></svg>
</div>
<div @click="closeWindow" class="titlebar-button-red" id="titlebar-close">
<div v-if="!isUpdater" @click="closeWindow" class="titlebar-button-red" id="titlebar-close">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
</div>
</div>
Expand All @@ -13,14 +13,22 @@
import { appWindow } from '@tauri-apps/api/window'
export default {
methods: {
minimizeWindow() {
appWindow.minimize()
},
closeWindow() {
appWindow.close()
}
data() {
return {
isUpdater: false
}
},
methods: {
minimizeWindow() {
appWindow.minimize()
},
closeWindow() {
appWindow.close()
}
},
created() {
if(this.$route.fullPath === '/updater') this.isUpdater = true
}
}
</script>

Expand Down
6 changes: 3 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ if(isProd) {
// }
// });
}
document.addEventListener('DOMContentLoaded', async () => {
await invoke("close_splashscreen");
})
// document.addEventListener('DOMContentLoaded', async () => {
// await invoke("close_splashscreen");
// })

// auth.onAuthStateChanged

Expand Down
2 changes: 2 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Auth = () => import('../views/Auth.vue')
const Register = () => import('../views/Register.vue')
const FinalCypher = () => import('../views/games/FinalCypher.vue')
const Logo = () => import('../views/Logo.vue')
const Updater = () => import('../views/Updater.vue')

// Vue.use(VueRouter)
const routes = [
Expand All @@ -17,6 +18,7 @@ const routes = [
{ path: '/auth', component: Auth, name: 'Auth' },
{ path: '/register', component: Register, name: 'Register' },
{ path: '/logo', component: Logo, name: 'Logo' },
{ path: '/updater', component: Updater, name: 'Updater' }
]

const router = createRouter({
Expand Down
90 changes: 90 additions & 0 deletions src/views/Updater.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<template>
<section class="grid h-screen place-items-center bg-[#121212]">
<div class="w-full h-full uploader-bg">
<div class="absolute bottom-[18px] flex-1 w-[465px] h-[50px]">
<div class="flex justify-between col-span-2 flex-row px-[20px] py-[20px]">
<div class="font-bold font-Konnect text-xl text-white drop-shadow-xl">
<svg class="inline mr-2 w-5 h-5 -mt-1 text-gray-200 animate-spin dark:text-neutral-600 fill-brand-cold-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
Updating..
</div>
</div>
</div>
<!-- <div data-tauri-drag-region class="titlebar">
<div @click="minimizeWindow" class="titlebar-button" id="titlebar-minimize">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path></svg>
</div>
</div> -->
<!-- <img class="relative z-0 left-0" src="../assets/img/updater.png" />
<div class="absolute bottom-[28px] flex-1 w-[465px] h-[50px]">
<div class="flex justify-between col-span-2 flex-row px-[20px] py-[20px]">
<div class="font-bold font-Konnect text-xl text-white">
<svg class="inline mr-2 w-5 h-5 -mt-1 text-gray-200 animate-spin dark:text-neutral-600 fill-brand-cold-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
</svg>
Updating
</div>
</div>
</div> -->
</div>
</section>
</template>

<script>
import { appWindow } from '@tauri-apps/api/window'
import { emit } from '@tauri-apps/api/event'
import { listen } from '@tauri-apps/api/event'
export default {
methods: {
minimizeWindow() {
appWindow.minimize()
}
},
created() {
listen('tauri://update-status', function (res) {
console.log('New status: ', res)
})
emit('tauri://update-install')
}
}
</script>

<style scoped>
.titlebar {
height: 30px;
/* background: #329ea3; */
user-select: none;
display: flex;
justify-content: flex-end;
/* position: fixed; */
top: 0;
left: 0;
right: 0;
z-index: 10;
background-color: #121212;
}
.titlebar-button, .titlebar-button-red {
display: inline-flex;
justify-content: center;
align-items: center;
width: 36px;
height: 30px;
cursor: pointer;
color: rgba(255,255,255,.85);
}
.titlebar-button:hover {
background: rgba(255,255,255,.1);
}
.titlebar-button-red:hover {
background: rgb(212, 77, 77);
}
.uploader-bg {
background-image: url('../assets/img/updater.png');
background-position: center;
background-repeat: no-repeat;
}
</style>
Loading

0 comments on commit d94b16b

Please sign in to comment.