Skip to content

Commit

Permalink
Tauri API implemented in Svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealIndianBoi committed Dec 27, 2024
1 parent 3dc7a1b commit 33f50f5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 35 deletions.
9 changes: 8 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
"mainBinaryName": "OpenGOAL-Launcher",
"version": "2.5.4",
"identifier": "OpenGOAL-Launcher",
"plugins": {},
"plugins": {
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDM5Q0RCMDMyRkYwQTQxOTIKUldTU1FRci9NckROT1FERSs0UjhTNzRsTHU0cjZGdTZzN1FTWGF4aldYdGFlTG56eWc5Uko4YzkK",
"endpoints": [
"https://raw.githubusercontent.com/open-goal/launcher/main/.tauri/latest-release-v2.json"
]
}
},
"app": {
"security": {
"assetProtocol": {
Expand Down
15 changes: 9 additions & 6 deletions src/components/header/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import IconWindowMinimize from "~icons/mdi/window-minimize";
import IconWindowClose from "~icons/mdi/window-close";
import { UpdateStore } from "$lib/stores/AppStore";
import { checkUpdate } from "@tauri-apps/plugin-updater";
import { check } from "@tauri-apps/plugin-updater";
import { isInDebugMode } from "$lib/utils/common";
import {
getActiveVersion,
Expand All @@ -19,7 +19,7 @@
import { exceptionLog, infoLog } from "$lib/rpc/logging";
import { _ } from "svelte-i18n";
import { toastStore } from "$lib/stores/ToastStore";
const appWindow = getCurrentWebviewWindow()
const appWindow = getCurrentWebviewWindow();
let launcherVerison = null;
Expand All @@ -31,12 +31,12 @@ const appWindow = getCurrentWebviewWindow()
$VersionStore.activeVersionName = await getActiveVersion();
// Check for a launcher update
// NOTE - the following code (checkUpdate) won't work unless you have `update` configuration
// NOTE - the following code (check for Update) won't work unless you have `update` configuration
// added to the tauri.conf.json
if (!isInDebugMode()) {
const updateResult = await checkUpdate();
const updateResult = await check();
if (updateResult.shouldUpdate) {
// TODO - store methods to clean this up
let changeLog = [];
try {
changeLog = JSON.parse(updateResult.manifest.body);
Expand Down Expand Up @@ -80,7 +80,7 @@ const appWindow = getCurrentWebviewWindow()
latestToolingVersion !== undefined &&
$VersionStore.activeVersionName !== latestToolingVersion.version
) {
// Check that we havn't already downloaded it
// Check that we haven't already downloaded it
let alreadyHaveRelease = false;
const downloadedOfficialVersions =
await listDownloadedVersions("official");
Expand Down Expand Up @@ -166,3 +166,6 @@ const appWindow = getCurrentWebviewWindow()
</button>
</div>
</header>

<style>
</style>
8 changes: 6 additions & 2 deletions src/routes/Update.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
import { installUpdate } from "@tauri-apps/plugin-updater";
import { check } from "@tauri-apps/plugin-updater";
import { relaunch } from "@tauri-apps/plugin-process";
import {
Button,
Expand All @@ -26,7 +26,8 @@
async function updateHandler() {
updating = true;
await installUpdate();
let update = await check();
await update?.downloadAndInstall();
await relaunch();
}
</script>
Expand Down Expand Up @@ -121,3 +122,6 @@
</h1>
{/if}
</div>
<style>
</style>
58 changes: 32 additions & 26 deletions src/splash/components/LocaleQuickChanger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,40 @@
});
</script>

<select
data-testId="locale-select"
name="locales"
id="locales"
title={$_("splash_selectLocale")}
class="emoji-font pointer-events-auto !p-0 !pl-1 !pr-1 !pt-1 text-sm bg-gray-700 mb-1 absolute top-0 border-transparent focus:border-transparent focus:ring-0"
on:change={(evt) => {
let newLocale = evt.target.value;
dispatch("change", {
newLocale: newLocale,
});
}}
>
{#each AVAILABLE_LOCALES as locale}
{#if locale.id === currentLocale}
<option value={locale.id} selected
><span class="emoji-font">{locale.flag}</span></option
>
{:else}
<option value={locale.id}
><span class="emoji-font">{locale.flag}</span></option
>
{/if}
{/each}
</select>
<div>
<select
data-testId="locale-select"
name="locales"
id="locales"
title={$_("splash_selectLocale")}
class="emoji-font pointer-events-auto !p-0 !pl-1 !pr-1 !pt-1 text-sm bg-gray-700 mb-1 absolute top-0 border-transparent focus:border-transparent focus:ring-0"
bind:value={currentLocale}
on:change={() => {
dispatch("change", {
newLocale: currentLocale,
});
}}
>
{#each AVAILABLE_LOCALES as locale}
{#if locale.id === currentLocale}
<option value={locale.id} selected>
<!-- TODO: Fix FLags
<span class="emoji-font">{locale.flag}</span>
-->
</option>
{:else}
<option value={locale.id}>
<!-- TODO: Fix Flags
<span class="emoji-font">{locale.flag}</span>
-->
</option>
{/if}
{/each}
</select>
</div>

<style>
.emoji-font {
font-family: "Twemoji Country Flags", "Roboto Mono";
font-family: "Twemoji Country Flags", "Roboto Mono", serif;
}
</style>
4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from "vite";
import { svelte } from "@sveltejs/vite-plugin-svelte";
import Icons from "unplugin-icons/vite";
import { fileURLToPath, URL } from "url";
import { sveltePreprocess } from "svelte-preprocess";

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -11,6 +12,9 @@ export default defineConfig({
plugins: [
svelte({
hot: !process.env.VITEST,
preprocess: sveltePreprocess({
postcss: true, // Enable PostCSS for styles
}),
}),
Icons({
compiler: "svelte",
Expand Down

0 comments on commit 33f50f5

Please sign in to comment.