Bump app version to 0.5.1 and add auto-update support

- Implemented auto-update logic in `ScribeTopBar` with update notification and user interaction.
- Integrated `@tauri-apps/plugin-updater` and `@tauri-apps/plugin-process` for updater functionality.
- Added automatic migration feature with `autoMigrateElectron` support and UI feedback.
- Refactored app architecture with new routing, components, and layout for better modularity.
- Enhanced JSON response handling in API client for robust data parsing.
- Updated locales to include new translations for update and migration-related UI.
This commit is contained in:
natreex
2026-04-07 16:09:35 -04:00
parent 687c1d582c
commit 5c7e71ce9e
19 changed files with 461 additions and 46 deletions

View File

@@ -38,7 +38,6 @@ import OfflineProvider from '@/context/OfflineProvider';
import OfflineContext, {OfflineContextType} from '@/context/OfflineContext';
import OfflinePinSetup from '@/components/offline/OfflinePinSetup';
import OfflinePinVerify from '@/components/offline/OfflinePinVerify';
import MigrationModal from '@/components/migration/MigrationModal';
import {isDesktop} from '@/lib/configs';
import * as tauri from '@/lib/tauri';
import useSyncBooks from '@/hooks/useSyncBooks';
@@ -137,16 +136,6 @@ function ScribeContent({children}: { children: ReactNode }) {
const [currentChapter, setCurrentChapter] = useState<ChapterProps | undefined>(undefined);
const [currentBook, setCurrentBook] = useState<BookProps | null>(null);
const [bookSettingId, setBookSettingId] = useState<string>('');
const [showMigrationPopup, setShowMigrationPopup] = useState<boolean>(false);
useEffect(function (): void {
if (!isDesktop) return;
const done: boolean = localStorage.getItem('electron_migration_done') === 'true';
const dismissed: boolean = localStorage.getItem('electron_migration_dismissed') === 'true';
if (!done && !dismissed) {
setShowMigrationPopup(true);
}
}, []);
const [serverSyncedBooks, setServerSyncedBooks] = useState<SyncedBook[]>([]);
const [localSyncedBooks, setLocalSyncedBooks] = useState<SyncedBook[]>([]);
@@ -437,12 +426,6 @@ function ScribeContent({children}: { children: ReactNode }) {
onCancel={(): void => {}}
/>
)}
{showMigrationPopup && (
<MigrationModal
onClose={function (): void { setShowMigrationPopup(false); }}
onSuccess={function (): void { setShowMigrationPopup(false); window.location.reload(); }}
/>
)}
</SettingBookContext.Provider>
</AIUsageContext.Provider>
</ChapterContext.Provider>

View File

@@ -1,11 +1,14 @@
const logo = "/eritors-favicon-white.png";
import React, {useContext} from "react";
import {Download, X} from "lucide-react";
import {BookContext, BookContextProps} from "@/context/BookContext";
import {useTranslations} from '@/lib/i18n';
import {useAutoUpdate} from "@/hooks/useAutoUpdate";
export default function ScribeTopBar() {
const {book}: BookContextProps = useContext<BookContextProps>(BookContext);
const t = useTranslations();
const update = useAutoUpdate();
return (
<div className="flex items-center justify-between px-6 py-3 bg-tertiary border-b border-secondary">
<div className="flex items-center space-x-4 group">
@@ -33,6 +36,21 @@ export default function ScribeTopBar() {
</div>
)}
<div className="flex items-center space-x-2 min-w-[120px] justify-end">
{update.available && (
<div className="flex items-center gap-2 bg-primary/15 border border-primary/30 rounded-lg px-3 py-1.5">
<span className="text-xs text-text-secondary">v{update.version}</span>
<button onClick={update.install} disabled={update.downloading}
className="flex items-center gap-1 text-xs font-medium text-primary hover:text-primary-light transition-colors">
<Download className="w-3.5 h-3.5" strokeWidth={2}/>
{update.downloading ? t("scribeTopBar.updating") : t("scribeTopBar.update")}
</button>
{!update.downloading && (
<button onClick={update.dismiss} className="text-text-secondary hover:text-text-primary transition-colors">
<X className="w-3.5 h-3.5" strokeWidth={2}/>
</button>
)}
</div>
)}
</div>
</div>
)

View File

@@ -1,5 +1,5 @@
'use client'
import {ArrowRightLeft, ExternalLink, Feather, Globe, Info, MapPin, MessageCircle, Users, Wand2, X} from 'lucide-react';
import {ExternalLink, Feather, Globe, Info, MapPin, MessageCircle, Users, Wand2, X} from 'lucide-react';
import React, {lazy, Suspense, useContext, useEffect, useState} from "react";
import {BookContext, BookContextProps} from "@/context/BookContext";
import {PanelComponent} from "@/lib/types/editor";
@@ -12,8 +12,6 @@ import InsetPanel from "@/components/ui/InsetPanel";
import IconButton from "@/components/ui/IconButton";
import OfflineContext, {OfflineContextType} from "@/context/OfflineContext";
import {isDesktop} from '@/lib/configs';
import MigrationModal from '@/components/migration/MigrationModal';
// Lazy loaded Editor components
const WorldEditor = lazy(function () {
return import('@/components/book/settings/world/editor/WorldEditor');
@@ -54,11 +52,6 @@ export default function ComposerRightBar(): React.JSX.Element {
const [panelHidden, setPanelHidden] = useState<boolean>(false);
const [currentPanel, setCurrentPanel] = useState<PanelComponent | undefined>();
const [showAbout, setShowAbout] = useState<boolean>(false);
const [showMigration, setShowMigration] = useState<boolean>(false);
const migrationDone: boolean = localStorage.getItem('electron_migration_done') === 'true';
const migrationDismissed: boolean = localStorage.getItem('electron_migration_dismissed') === 'true';
const showMigrationButton: boolean = isDesktop && !migrationDone;
function togglePanel(component: PanelComponent): void {
if (panelHidden) {
@@ -110,16 +103,6 @@ export default function ComposerRightBar(): React.JSX.Element {
];
const homeComponents: PanelComponent[] = [
...(showMigrationButton ? [{
id: 0,
title: t("composerRightBar.homeComponents.migration.title"),
description: t("composerRightBar.homeComponents.migration.description"),
badge: 'IMPORT',
icon: ArrowRightLeft,
action: function (): void {
setShowMigration(true);
}
}] : []),
{
id: 1,
title: t("composerRightBar.homeComponents.about.title"),
@@ -241,10 +224,6 @@ export default function ComposerRightBar(): React.JSX.Element {
{showAbout && <AboutEditors onClose={function (): void {
setShowAbout(false);
}}/>}
{showMigration && <MigrationModal
onClose={function (): void { setShowMigration(false); }}
onSuccess={function (): void { setShowMigration(false); window.location.reload(); }}
/>}
</div>
);
}