mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 22:41:58 +03:00
settings: show the running app version
Updates tab, below the check-update button. Reads from tauri.conf.json via getVersion() in a real build (the source of truth for what's actually installed); falls back to package.json's version under vite dev, where there's no Tauri runtime to ask.
This commit is contained in:
parent
6f190c7245
commit
e5ef1164cc
4 changed files with 16 additions and 0 deletions
|
|
@ -132,6 +132,7 @@
|
||||||
<div class="settings-tabpanel-buttons">
|
<div class="settings-tabpanel-buttons">
|
||||||
<button id="check-update" data-i18n="checkUpdate">Check for updates</button>
|
<button id="check-update" data-i18n="checkUpdate">Check for updates</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="app-version" class="settings-version"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="settings-footer">
|
<div class="settings-footer">
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ const dict: Record<string, Record<string, string>> = {
|
||||||
tabFormat: "Format",
|
tabFormat: "Format",
|
||||||
tabData: "Data",
|
tabData: "Data",
|
||||||
tabUpdates: "Updates",
|
tabUpdates: "Updates",
|
||||||
|
version: "Version",
|
||||||
},
|
},
|
||||||
ru: {
|
ru: {
|
||||||
settings: "Настройки",
|
settings: "Настройки",
|
||||||
|
|
@ -152,6 +153,7 @@ const dict: Record<string, Record<string, string>> = {
|
||||||
tabFormat: "Формат",
|
tabFormat: "Формат",
|
||||||
tabData: "Данные",
|
tabData: "Данные",
|
||||||
tabUpdates: "Обновления",
|
tabUpdates: "Обновления",
|
||||||
|
version: "Версия",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
12
src/main.ts
12
src/main.ts
|
|
@ -18,6 +18,7 @@ import { Workspace } from "./workspace";
|
||||||
import { EN, RU } from "./engine/vocab-data";
|
import { EN, RU } from "./engine/vocab-data";
|
||||||
import { exportSheetImage } from "./ui/export";
|
import { exportSheetImage } from "./ui/export";
|
||||||
import { initSearch, SearchController } from "./ui/search";
|
import { initSearch, SearchController } from "./ui/search";
|
||||||
|
import pkg from "../package.json";
|
||||||
|
|
||||||
function welcomeText(lang: string): string {
|
function welcomeText(lang: string): string {
|
||||||
const sample = (lang === "ru" ? RU : EN).Samples?.["sample.welcome"];
|
const sample = (lang === "ru" ? RU : EN).Samples?.["sample.welcome"];
|
||||||
|
|
@ -356,6 +357,7 @@ function bindSettingsUI(): void {
|
||||||
settings.autoUpdateEnabled = autoUpdate.checked;
|
settings.autoUpdateEnabled = autoUpdate.checked;
|
||||||
void saveSettings(settings);
|
void saveSettings(settings);
|
||||||
});
|
});
|
||||||
|
void showAppVersion();
|
||||||
|
|
||||||
const tabs = document.querySelectorAll<HTMLButtonElement>("#settings-tabs .tab");
|
const tabs = document.querySelectorAll<HTMLButtonElement>("#settings-tabs .tab");
|
||||||
const tabPanels = document.querySelectorAll<HTMLElement>(".settings-tabpanel");
|
const tabPanels = document.querySelectorAll<HTMLElement>(".settings-tabpanel");
|
||||||
|
|
@ -381,6 +383,16 @@ function bindSettingsUI(): void {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** tauri.conf.json's version is the source of truth for an actual build; package.json is the vite-dev fallback */
|
||||||
|
async function showAppVersion(): Promise<void> {
|
||||||
|
let version = pkg.version;
|
||||||
|
if (isTauri()) {
|
||||||
|
const { getVersion } = await import("@tauri-apps/api/app");
|
||||||
|
version = await getVersion();
|
||||||
|
}
|
||||||
|
$("#app-version").textContent = `${t("version")} ${version}`;
|
||||||
|
}
|
||||||
|
|
||||||
/** Physical key (e.code) → Tauri accelerator name, layout-independent (works on ru). */
|
/** Physical key (e.code) → Tauri accelerator name, layout-independent (works on ru). */
|
||||||
function normalizeKeyName(e: KeyboardEvent): string | null {
|
function normalizeKeyName(e: KeyboardEvent): string | null {
|
||||||
const code = e.code;
|
const code = e.code;
|
||||||
|
|
|
||||||
|
|
@ -392,6 +392,7 @@ body {
|
||||||
font-size: 12.5px;
|
font-size: 12.5px;
|
||||||
}
|
}
|
||||||
.settings-tabpanel-buttons button:hover { background: var(--hover); }
|
.settings-tabpanel-buttons button:hover { background: var(--hover); }
|
||||||
|
.settings-version { color: var(--fg-muted); font-size: 11.5px; margin-top: 10px; }
|
||||||
#settings-panel label {
|
#settings-panel label {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue