mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-11 01:02:01 +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">
|
||||
<button id="check-update" data-i18n="checkUpdate">Check for updates</button>
|
||||
</div>
|
||||
<div id="app-version" class="settings-version"></div>
|
||||
</div>
|
||||
|
||||
<div class="settings-footer">
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ const dict: Record<string, Record<string, string>> = {
|
|||
tabFormat: "Format",
|
||||
tabData: "Data",
|
||||
tabUpdates: "Updates",
|
||||
version: "Version",
|
||||
},
|
||||
ru: {
|
||||
settings: "Настройки",
|
||||
|
|
@ -152,6 +153,7 @@ const dict: Record<string, Record<string, string>> = {
|
|||
tabFormat: "Формат",
|
||||
tabData: "Данные",
|
||||
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 { exportSheetImage } from "./ui/export";
|
||||
import { initSearch, SearchController } from "./ui/search";
|
||||
import pkg from "../package.json";
|
||||
|
||||
function welcomeText(lang: string): string {
|
||||
const sample = (lang === "ru" ? RU : EN).Samples?.["sample.welcome"];
|
||||
|
|
@ -356,6 +357,7 @@ function bindSettingsUI(): void {
|
|||
settings.autoUpdateEnabled = autoUpdate.checked;
|
||||
void saveSettings(settings);
|
||||
});
|
||||
void showAppVersion();
|
||||
|
||||
const tabs = document.querySelectorAll<HTMLButtonElement>("#settings-tabs .tab");
|
||||
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). */
|
||||
function normalizeKeyName(e: KeyboardEvent): string | null {
|
||||
const code = e.code;
|
||||
|
|
|
|||
|
|
@ -392,6 +392,7 @@ body {
|
|||
font-size: 12.5px;
|
||||
}
|
||||
.settings-tabpanel-buttons button:hover { background: var(--hover); }
|
||||
.settings-version { color: var(--fg-muted); font-size: 11.5px; margin-top: 10px; }
|
||||
#settings-panel label {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue