From e923600f88e282ca1d539051c1871c20bcea2bed Mon Sep 17 00:00:00 2001 From: parksb Date: Sun, 27 Aug 2023 21:11:50 +0900 Subject: [PATCH] Show application meta information at settings page --- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 3 +++ src/routes/Settings.tsx | 30 +++++++++++++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 8358736..20d361e 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" tauri-build = { version = "1.4", features = [] } [dependencies] -tauri = { version = "1.4", features = [ "dialog-confirm", "dialog-ask", "notification-all", "shell-open"] } +tauri = { version = "1.4", features = [ "path-all", "dialog-confirm", "dialog-ask", "notification-all", "shell-open"] } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" chrono = { version = "0.4", default-features = false, features = ["clock", "serde"] } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 191c410..78ee3e4 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -23,6 +23,9 @@ "dialog": { "ask": true, "confirm": true + }, + "path": { + "all": true } }, "bundle": { diff --git a/src/routes/Settings.tsx b/src/routes/Settings.tsx index f1562bc..e2fd757 100644 --- a/src/routes/Settings.tsx +++ b/src/routes/Settings.tsx @@ -1,15 +1,23 @@ +import { getVersion } from '@tauri-apps/api/app'; +import { appDataDir } from '@tauri-apps/api/path'; + import { createSignal, For, Match, onMount, Show, Switch } from "solid-js"; import "../styles/Settings.css"; import * as api from "../api/settings"; function Settings() { + const [version, setVersion] = createSignal(""); + const [latestVersion, setLatestVersion] = createSignal(""); + const [dataDir, setDataDir] = createSignal(""); + const [settings, setSettings] = createSignal([]); const [newSettings, setNewSettings] = createSignal<{ [key in api.SettingKey]: string }>({ [api.SettingKey.POLLING_FREQUENCY]: "", [api.SettingKey.NOTIFICATION]: "", [api.SettingKey.DB_SCHEME_VERSION]: "", [api.SettingKey.THEME]: "", + [api.SettingKey.ITEMS_ORDER]: "", }); const keyToText = (key: api.SettingKey) => { @@ -63,7 +71,21 @@ function Settings() { ; onMount(async () => { - await load(); + const fetchLatestVersion = async (): Promise => { + const res = await fetch("https://api.github.com/repos/parksb/collie/releases/latest"); + return (await res.json())['tag_name']; + }; + + const [fetchedVersion, fetchedLatestVersion, fetchedDataDir] = await Promise.all([ + getVersion(), + fetchLatestVersion(), + appDataDir(), + load(), + ]); + + setVersion(fetchedVersion); + setLatestVersion(fetchedLatestVersion); + setDataDir(fetchedDataDir); let newSettingsPlaceholder = newSettings(); settings().forEach((setting: api.Setting) => { @@ -109,6 +131,12 @@ function Settings() { } +
  • + Current version: v{version()} + Latest version: {latestVersion()} +
  • +
  • Data directory: {dataDir()}
  • );