Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Launch on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Aug 25, 2022
1 parent 5503d69 commit 1fad121
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion interface/components/toggle.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<SwitchGroup as="div" class="flex items-center space-x-4">
<SwitchLabel class="text-xl">{checked ? "On" : "Off"}</SwitchLabel>

<Switch as="button" {checked} on:change={(event) => (checked = event.detail)} class={({ checked }) => classNames("focus:shadow-outline relative inline-flex h-7 w-12 flex-shrink-0 cursor-pointer rounded-full border-2 border-white transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-4 focus-visible:ring-popup-magenta", checked ? "bg-white" : "bg-transparent")} let:checked>
<Switch as="button" {checked} on:click on:change={(event) => (checked = event.detail)} class={({ checked }) => classNames("focus:shadow-outline relative inline-flex h-7 w-12 flex-shrink-0 cursor-pointer rounded-full border-2 border-white transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-4 focus-visible:ring-popup-magenta", checked ? "bg-white" : "bg-transparent")} let:checked>
<span class={classNames("relative top-[4px] left-1 inline-block h-4 w-4 transform rounded-full bg-white transition duration-200 ease-in-out ", checked ? "translate-x-[21px] !bg-black" : "translate-x-0")} />
</Switch>
</SwitchGroup>
Expand Down
7 changes: 7 additions & 0 deletions interface/stores/settings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { invoke } from "@tauri-apps/api"
import { writable, get, Writable } from "svelte/store"
import build from "../../build.json"

Expand Down Expand Up @@ -34,6 +35,12 @@ const defaultSettings: LibSettings = {
},
}

const dev = build.dev === "true"

if (dev === false && localStorage.settings === undefined) {
invoke("auto_launch")
}

export const settings: Writable<LibSettings> = writable(localStorage.settings ? JSON.parse(localStorage.settings) : defaultSettings)

settings.subscribe((data) => {
Expand Down
10 changes: 10 additions & 0 deletions interface/windows/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ export const clearData = async () => {
navigate("/")
location.reload()
}

export const showLogs = async () => {
const folderPath = await path.join(await path.configDir(), "Levminer", "Authme 4")

open(folderPath)
}

export const launchOnStartup = () => {
invoke("auto_launch")
}
2 changes: 1 addition & 1 deletion interface/windows/settings/settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h3>Start Authme after your computer started. Authme will start on the system tray.</h3>
</div>
<div class="ml-20 flex gap-3">
<Toggle bind:checked={$settings.settings.launchOnStartup} />
<Toggle bind:checked={$settings.settings.launchOnStartup} on:click={launchOnStartup} />
</div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"private": true,
"type": "module",
"scripts": {
"start": "node scripts/build.cjs alpha && tauri dev",
"start": "node scripts/build.cjs alpha true && tauri dev",
"dev": "parcel ./interface/layout/index.html --port 3000",
"build": "node scripts/build.cjs alpha && tauri build",
"build:alpha": "node scripts/build.cjs alpha && tauri build",
"build": "node scripts/build.cjs alpha false && tauri build",
"build:alpha": "node scripts/build.cjs alpha false && tauri build",
"build:bundle": "parcel build ./interface/layout/index.html --no-content-hash --no-source-maps"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions scripts/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const file = {
date: releaseDate,
version: package.version,
arch: process.arch,
dev: process.argv[3],
}

if (!existsSync("core/target/release")) {
Expand Down

0 comments on commit 1fad121

Please sign in to comment.